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: use explicit returns to avoid checker confusion Date: Thu, 07 Mar 2013 16:38:00 -0000 [thread overview] Message-ID: <20130307163848.19927.qmail@sourceware.org> (raw) The branch, tromey/cleanup-checker has been updated via c365905452e9ec524dee52b06111a946831f79d7 (commit) via 054057285068c966a6e717678eaf646bf3a1a7b8 (commit) from a07800bcf88394a3b48aa8f6853a431220f706a7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit c365905452e9ec524dee52b06111a946831f79d7 Author: Tom Tromey <tromey@redhat.com> Date: Thu Mar 7 07:43:40 2013 -0700 use explicit returns to avoid checker confusion the checker does not understand the idiom if (except.reason < 0) { something; GDB_PY_HANDLE_EXCEPTION (except); } because it doesn't realize that the nested 'if' actually has the same condition commit 054057285068c966a6e717678eaf646bf3a1a7b8 Author: Tom Tromey <tromey@redhat.com> Date: Thu Mar 7 07:42:40 2013 -0700 minor cleanup in master cleanup representation ----------------------------------------------------------------------- Summary of changes: gdb/contrib/cleanup_check.py | 29 +++++++++++++++++++++-------- gdb/python/py-breakpoint.c | 2 +- gdb/python/py-frame.c | 2 +- gdb/python/python.c | 2 +- 4 files changed, 24 insertions(+), 11 deletions(-) First 500 lines of diff: diff --git a/gdb/contrib/cleanup_check.py b/gdb/contrib/cleanup_check.py index 542e658..17b81f6 100644 --- a/gdb/contrib/cleanup_check.py +++ b/gdb/contrib/cleanup_check.py @@ -61,7 +61,15 @@ def needs_special_treatment(decl): # Sometimes we need a new placeholder object that isn't the same as # anything else. class Dummy(object): - pass + def __init__(self, location): + self.location = location + +# A wrapper for a cleanup which has been assigned to a variable. +# This holds the variable and the location. +class Cleanup(object): + def __init__(self, var, location): + self.var = var + self.location = location # A class representing a master cleanup. This holds a stack of # cleanup objects and supports a merging operation. @@ -69,6 +77,9 @@ class MasterCleanup(object): # Create a new MasterCleanup object. OTHER, if given, is a # MasterCleanup object to copy. def __init__(self, other = None): + # 'cleanups' is a list of cleanups. Each element is either a + # Dummy, for an anonymous cleanup, or a Cleanup, for a cleanup + # which was assigned to a variable. if other is None: self.cleanups = [] else: @@ -132,17 +143,19 @@ class MasterCleanup(object): # meaning that this constructor's value wasn't used. def push(self, location, lhs): if lhs is None: - lhs = Dummy() - self.cleanups.append((location, lhs)) + obj = Dummy(location) + else: + obj = Cleanup(lhs, location) + self.cleanups.append(obj) # Pop constructors until we find one matching BACK_TO. # This is invoked when we see a do_cleanups call. def pop(self, location, back_to, bb_from): log('pop:', 4) for i in range(len(self.cleanups) - 1, -1, -1): - if isinstance(self.cleanups[i][1], Dummy): + if isinstance(self.cleanups[i], Dummy): continue - if self.compare_vars(location, self.cleanups[i][1], + if self.compare_vars(location, self.cleanups[i].var, back_to, bb_from): self.cleanups = self.cleanups[0:i] return @@ -152,8 +165,8 @@ class MasterCleanup(object): # all is well. def verify(self, location, arg, bb_from): return (len(self.cleanups) > 0 - and not isinstance(self.cleanups[0][1], Dummy) - and self.compare_vars(location, self.cleanups[0][1], + and not isinstance(self.cleanups[0], Dummy) + and self.compare_vars(location, self.cleanups[0].var, arg, bb_from)) # Check whether SELF is empty. @@ -164,7 +177,7 @@ class MasterCleanup(object): # Emit informational warnings about the cleanup stack. def inform(self): for item in reversed(self.cleanups): - gcc.inform(item[0], 'leaked cleanup') + gcc.inform(item.location, 'leaked cleanup') class CleanupChecker: def __init__(self, fun): diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index d099892..fd13811 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -492,7 +492,7 @@ bppy_get_commands (PyObject *self, void *closure) if (except.reason < 0) { do_cleanups (chain); - GDB_PY_HANDLE_EXCEPTION (except); + return gdbpy_convert_exception (except); } cmdstr = ui_file_xstrdup (string_file, &length); diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c index 33d0bd0..10a50ea 100644 --- a/gdb/python/py-frame.c +++ b/gdb/python/py-frame.c @@ -472,7 +472,7 @@ frapy_read_var (PyObject *self, PyObject *args) if (except.reason < 0) { do_cleanups (cleanup); - GDB_PY_HANDLE_EXCEPTION (except); + return gdbpy_convert_exception (except); } if (!var) diff --git a/gdb/python/python.c b/gdb/python/python.c index 24be906..db8f1c0 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -645,7 +645,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args) { do_cleanups (cleanups); /* We know this will always throw. */ - GDB_PY_HANDLE_EXCEPTION (except); + return gdbpy_convert_exception (except); } if (sals.nelts) hooks/post-receive -- Repository for Project Archer.
reply other threads:[~2013-03-07 16:38 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20130307163848.19927.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: linkBe 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).