public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
From: tromey@sourceware.org
To: archer-commits@sourceware.org
Subject: [SCM]  tromey/cleanup-checker: introduce scoped cleanups
Date: Tue, 14 May 2013 20:42:00 -0000	[thread overview]
Message-ID: <20130514204207.1776.qmail@sourceware.org> (raw)

The branch, tromey/cleanup-checker has been updated
  discards  212f7dae72349005357393d8c3b80e88c2e2c46b (commit)
       via  8a08c1b0d1feef7543005325d453a9efdcb4b7dc (commit)
      from  212f7dae72349005357393d8c3b80e88c2e2c46b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 8a08c1b0d1feef7543005325d453a9efdcb4b7dc
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu May 9 11:44:45 2013 -0600

    introduce scoped cleanups
    
    This adds scoped cleanups to gdb.  A scoped cleanup is a more
    efficient, and checkable, alternative to the common idiom:
    
        cleanup = make_cleanup (null_cleanup, NULL);
        ...
        do_cleanups (cleanup);
    
    ... where the cleanup is always run when exiting the scope.
    
    The efficiency comes from stack allocating the scoped cleanup.  This
    is probably minor.  However, I've noticed myself sometimes avoiding
    null cleanups on this basis, and it is nice to erase that bias.
    
    The checking comes from using a GCC extension when available.  This
    check ensures that the scoped cleanup was either run or discarded when
    the scope exits.

-----------------------------------------------------------------------

Summary of changes:
 gdb/cleanups.c |    6 ++++--
 gdb/cleanups.h |    4 ++--
 2 files changed, 6 insertions(+), 4 deletions(-)

First 500 lines of diff:
diff --git a/gdb/cleanups.c b/gdb/cleanups.c
index 76d28c4..6d6d78c 100644
--- a/gdb/cleanups.c
+++ b/gdb/cleanups.c
@@ -324,13 +324,15 @@ init_scoped_cleanup (struct scoped_cleanup *cl)
   return old_chain;
 }
 
+#ifdef SCOPED_CLEANUP_CHECKING
+
 /* Verify that a scoped cleanup was in fact handled.  */
 
 void
 cleanup_close_scope (struct scoped_cleanup *cl)
 {
-#ifdef SCOPED_CLEANUP_CHECKING
   if (!cl->base.cleaned_up)
     internal_warning (__FILE__, __LINE__, "scoped cleanup leaked");
-#endif /* SCOPED_CLEANUP_CHECKING */
 }
+
+#endif /* SCOPED_CLEANUP_CHECKING */
diff --git a/gdb/cleanups.h b/gdb/cleanups.h
index 9f8cbd4..e16a9fa 100644
--- a/gdb/cleanups.h
+++ b/gdb/cleanups.h
@@ -94,8 +94,6 @@ struct scoped_cleanup
 
 extern struct cleanup *init_scoped_cleanup (struct scoped_cleanup *);
 
-extern void cleanup_close_scope (struct scoped_cleanup *);
-
 #if defined (__GNUC__) && __GNUC__ >= 4
 
 /* Define this to consolidate #if checking with the
@@ -106,6 +104,8 @@ extern void cleanup_close_scope (struct scoped_cleanup *);
 #define SCOPED_CLEANUP_ATTRIBUTE \
   __attribute__ ((cleanup (cleanup_close_scope)))
 
+extern void cleanup_close_scope (struct scoped_cleanup *);
+
 #else
 
 #define SCOPED_CLEANUP_ATTRIBUTE


hooks/post-receive
--
Repository for Project Archer.


             reply	other threads:[~2013-05-14 20:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-14 20:42 tromey [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-05-13 17:45 tromey
2013-05-09 17:56 tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130514204207.1776.qmail@sourceware.org \
    --to=tromey@sourceware.org \
    --cc=archer-commits@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).