From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12372 invoked by alias); 5 Sep 2012 15:56:57 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 12340 invoked by uid 9514); 5 Sep 2012 15:56:56 -0000 Date: Wed, 05 Sep 2012 15:56:00 -0000 Message-ID: <20120905155656.12325.qmail@sourceware.org> From: pmuldoon@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-pmuldoon-python-backtrace: Account for set print frame-arguments none. Fix several bugs relating to printing frame variables. X-Git-Refname: refs/heads/archer-pmuldoon-python-backtrace X-Git-Reftype: branch X-Git-Oldrev: a55f52d41be94f4da9b701175aa4d14e1175be21 X-Git-Newrev: 4682515b26543db5b2319e75b64a0c404a054629 X-SW-Source: 2012-q3/txt/msg00038.txt.bz2 List-Id: The branch, archer-pmuldoon-python-backtrace has been updated via 4682515b26543db5b2319e75b64a0c404a054629 (commit) from a55f52d41be94f4da9b701175aa4d14e1175be21 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 4682515b26543db5b2319e75b64a0c404a054629 Author: Phil Muldoon Date: Wed Sep 5 16:56:12 2012 +0100 Account for set print frame-arguments none. Fix several bugs relating to printing frame variables. ----------------------------------------------------------------------- Summary of changes: gdb/python/lib/gdb/BaseFrameWrapper.py | 75 +++++++++++++++++++++++++------ gdb/python/py-framefilter.c | 77 +++++++++++++++++++++++++++---- 2 files changed, 128 insertions(+), 24 deletions(-) First 500 lines of diff: diff --git a/gdb/python/lib/gdb/BaseFrameWrapper.py b/gdb/python/lib/gdb/BaseFrameWrapper.py index aa49ad1..0ddeb55 100644 --- a/gdb/python/lib/gdb/BaseFrameWrapper.py +++ b/gdb/python/lib/gdb/BaseFrameWrapper.py @@ -27,6 +27,20 @@ class BaseFrameWrapper (FrameWrapper): super(BaseFrameWrapper, self).__init__(base) self.base = base + # Determine if this a library or limited frame + frame = self.inferior_frame() + + def is_limited_frame (self, frame): + sal = frame.find_sal() + + if (not sal.symtab or not sal.symtab.filename + or frame == gdb.DUMMY_FRAME + or frame == gdb.SIGTRAMP_FRAME): + + return True + + return False + def elided (self): if hasattr(self.base, "elided"): return self.base.elided() @@ -34,14 +48,32 @@ class BaseFrameWrapper (FrameWrapper): return None def function (self): - if hasattr(self.base, "function"): - return str(self.base.function()) - - fname = str (self.base.function()) - if (fname == ""): - return None + # As this is the base wrapper, "base" can either be a gdb.Frame, + # or a another frame wrapper object (another filter may extend + # this object, but not implement "function". So in this case + # we must instance check what "base" is, as later there is + # some work to be done on solib names. + if isinstance(self.base, gdb.Frame): + name = self.base.name() else: - return fname + if hasattr(self.base, "function"): + return str(self.base.function()) + + frame = self.inferior_frame() + + if frame == gdb.DUMMY_FRAME: + return "" + elif frame == gdb.SIGTRAMP_FRAME: + return "" + + sal = frame.find_sal () + pc = frame.pc () + + if not name and not sal.symtab: + unknown = format (" 0x%08x in" % pc) + return unknown + + return name def address (self): if hasattr(self.base, "address"): @@ -54,15 +86,19 @@ class BaseFrameWrapper (FrameWrapper): return self.base.filename() sal = self.base.find_sal() - if (sal): - return sal.symtab.filename + if (not sal.symtab or not sal.symtab.filename): + pc = self.inferior_frame().pc() + return gdb.solib_name (pc) else: - return None + return sal.symtab.filename def frame_args (self): if hasattr(self.base, "frame_args"): return self.base.frame_args() + if self.is_limited_frame (self.base): + return None + args = FrameVars (self.base) return args.fetch_frame_args() @@ -70,6 +106,9 @@ class BaseFrameWrapper (FrameWrapper): if hasattr(self.base, "frame_locals"): return self.base.frame_locals() + if self.is_limited_frame (self.base): + return None + args = FrameVars (self.base) return args.fetch_frame_locals() @@ -77,6 +116,9 @@ class BaseFrameWrapper (FrameWrapper): if hasattr(self.base, "line"): return self.base.line() + if self.is_limited_frame (self.base): + return None + sal = self.base.find_sal() if (sal): return sal.line @@ -127,7 +169,10 @@ class FrameVars (): def fetch_frame_locals (self): lvars = [] - block = self.frame.block() + try: + block = self.frame.block() + except: + return None for sym in block: if sym.is_argument: @@ -142,13 +187,15 @@ class FrameVars (): def fetch_frame_args (self): args = [] - block = self.frame.block() + try: + block = self.frame.block() + except: + return None for sym in block: if not sym.is_argument: continue; - if self.fetch_b (sym): - args.append(BaseSymValueWrapper(sym,None)) + args.append(BaseSymValueWrapper(sym,None)) if len(args) == 0: return None diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c index 65bb62b..31384f8 100644 --- a/gdb/python/py-framefilter.c +++ b/gdb/python/py-framefilter.c @@ -153,6 +153,42 @@ extract_value (PyObject *obj, struct value **value) return 1; } +static int +mi_should_print (struct symbol *sym, const char *type) +{ + int print_me = 0; + + switch (SYMBOL_CLASS (sym)) + { + default: + case LOC_UNDEF: /* catches errors */ + case LOC_CONST: /* constant */ + case LOC_TYPEDEF: /* local typedef */ + case LOC_LABEL: /* local label */ + case LOC_BLOCK: /* local function */ + case LOC_CONST_BYTES: /* loc. byte seq. */ + case LOC_UNRESOLVED: /* unresolved static */ + case LOC_OPTIMIZED_OUT: /* optimized out */ + print_me = 0; + break; + + case LOC_ARG: /* argument */ + case LOC_REF_ARG: /* reference arg */ + case LOC_REGPARM_ADDR: /* indirect register arg */ + case LOC_LOCAL: /* stack local */ + case LOC_STATIC: /* static */ + case LOC_REGISTER: /* register */ + case LOC_COMPUTED: /* computed location */ + if (strcmp (type, "all")) + print_me = 1; + else if (strcmp (type, "locals")) + print_me = !SYMBOL_IS_ARGUMENT (sym); + else + print_me = SYMBOL_IS_ARGUMENT (sym); + } + return print_me; +} + /* Helper function which outputs a type name to a "type" field in a stream. OUT is the ui-out structure the type name will be output too, and VAL is the value that the type will be extracted from. @@ -315,6 +351,7 @@ py_print_single_arg (struct ui_out *out, struct value_print_options opts, int mi_print_type, int print_mi_args_flag, + const char *cli_print_frame_args_type, const struct language_defn *language) { struct value *val; @@ -389,15 +426,26 @@ py_print_single_arg (struct ui_out *out, annotate_arg_value (value_type (val)); - /* If CLI, always print values. For MI do not print values if the - enumerator is PRINT_NO_VALUES. */ + /* If the output is to the CLI, and the user option set print + frame-arguments is set to none, just output "...". */ if (! ui_out_is_mi_like_p (out) - || (ui_out_is_mi_like_p (out) - && mi_print_type != PRINT_NO_VALUES)) - { + && ! strcmp (cli_print_frame_args_type, "none")) - if (! py_print_value (out, val, opts, mi_print_type, language)) - goto error; + { + ui_out_field_string (out, "value", "..."); + } + else + { + /* If CLI, and the first if condition above not true always + print values. For MI do not print values if the enumerator + is PRINT_NO_VALUES. */ + if (! ui_out_is_mi_like_p (out) + || (ui_out_is_mi_like_p (out) + && mi_print_type != PRINT_NO_VALUES)) + { + if (! py_print_value (out, val, opts, mi_print_type, language)) + goto error; + } } do_cleanups (inner_cleanup); @@ -481,6 +529,9 @@ enumerate_args (PyObject *iter, Py_DECREF (item); item = NULL; + if (sym && ui_out_is_mi_like_p (out) && ! mi_should_print (sym, "args")) + continue; + /* If the object did not provide a value, read it using read_frame_args and account for entry values, if any. */ if (! val) @@ -516,7 +567,8 @@ enumerate_args (PyObject *iter, if (arg.entry_kind != print_entry_values_only) py_print_single_arg (out, NULL, &arg, NULL, opts, mi_print_type, - print_mi_args_flag, NULL); + print_mi_args_flag, + cli_print_frame_args_type, NULL); if (entryarg.entry_kind != print_entry_values_no) { @@ -528,7 +580,8 @@ enumerate_args (PyObject *iter, py_print_single_arg (out, NULL, &entryarg, NULL, opts, mi_print_type, - print_mi_args_flag, NULL); + print_mi_args_flag, + cli_print_frame_args_type, NULL); } xfree (arg.error); @@ -540,7 +593,9 @@ enumerate_args (PyObject *iter, if (val) py_print_single_arg (out, sym_name, NULL, val, opts, mi_print_type, - print_mi_args_flag, language); + print_mi_args_flag, + cli_print_frame_args_type, + language); } xfree (sym_name); @@ -617,6 +672,8 @@ enumerate_locals (PyObject *iter, Py_DECREF (item); + if (sym && ui_out_is_mi_like_p (out) && ! mi_should_print (sym, "locals")) + continue; /* If the object did not provide a value, read it. */ if (! val) hooks/post-receive -- Repository for Project Archer.