public inbox for archer-commits@sourceware.org help / color / mirror / Atom feed
From: pmuldoon@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-pmuldoon-pretty-printers-lookup: Add debug statement to python. Flush any exceptions to GDB console on PyObject_CallFunction. Return and check for Py_None. Date: Fri, 06 Feb 2009 15:23:00 -0000 [thread overview] Message-ID: <20090206152324.18234.qmail@sourceware.org> (raw) The branch, archer-pmuldoon-pretty-printers-lookup has been updated via ba800ef72f86ecad23eaf1cd1bf0d56189d45559 (commit) from 925bbf82b021f5191a44fae9baa41fea9d60d377 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit ba800ef72f86ecad23eaf1cd1bf0d56189d45559 Author: Phil Muldoon <pmuldoon@redhat.com> Date: Fri Feb 6 15:22:09 2009 +0000 Add debug statement to python. Flush any exceptions to GDB console on PyObject_CallFunction. Return and check for Py_None. ----------------------------------------------------------------------- Summary of changes: gdb/python/lib/gdb/libstdcxx/v6/printers.py | 17 ++++++++++++--- gdb/python/python.c | 29 ++++++++++++++------------ 2 files changed, 29 insertions(+), 17 deletions(-) First 500 lines of diff: diff --git a/gdb/python/lib/gdb/libstdcxx/v6/printers.py b/gdb/python/lib/gdb/libstdcxx/v6/printers.py index 88bf086..22d1a12 100644 --- a/gdb/python/lib/gdb/libstdcxx/v6/printers.py +++ b/gdb/python/lib/gdb/libstdcxx/v6/printers.py @@ -18,6 +18,7 @@ import gdb import itertools import re +import sys pretty_printers_dict = {} @@ -558,12 +559,20 @@ def register_libstdcxx_printers(obj): obj.pretty_printers.append(lookup_function) def lookup_function(value): - lookup_type = value.type () + lookup_type = value.type().tag() + if (lookup_type == None): + return None; + print "" + print "*Python Says*: Finding a printer matching this type: ", lookup_type + sys.stdout.flush() for printer in pretty_printers_dict: - if (lookup_type.tag() != None): - if printer.search(lookup_type.tag()): - return pretty_printers_dict[printer](value) + if printer.search(lookup_type): + print "*Python Says*: Found this pattern matches type: ", printer.pattern + print "*Python Says*: Instantiate this function: ", pretty_printers_dict[printer] + sys.stdout.flush() + return pretty_printers_dict[printer](value) + return None def build_libstdcxx_dictionary(): # libstdc++ objects requiring pretty-printing. diff --git a/gdb/python/python.c b/gdb/python/python.c index a3248da..e6e261a 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -854,11 +854,11 @@ search_pp_list (PyObject *list, struct value *value) { function = PyList_GetItem (list,i); printer = gdbpy_instantiate_printer (function, value); - if (printer) - return printer; + if (printer != Py_None) + return printer; } - return NULL; + return Py_None; } /* Find the pretty-printing constructor function for TYPE. If no @@ -883,7 +883,7 @@ find_pretty_printer (struct value *value) list = objfpy_get_printers (objf, NULL); function = search_pp_list (list, value); - if (function) + if (function != Py_None) goto done; Py_DECREF (list); @@ -902,7 +902,7 @@ find_pretty_printer (struct value *value) function = search_pp_list (list, value); done: - if (function) + if (function != Py_None) Py_INCREF (function); Py_XDECREF (list); @@ -966,6 +966,10 @@ gdbpy_instantiate_printer (PyObject *cons, struct value *value) GDB_PY_HANDLE_EXCEPTION (except); result = PyObject_CallFunctionObjArgs (cons, val_obj, NULL); + /* Phil: DEBUG CODE, Remove Later */ + if (PyErr_Occurred()) + gdbpy_print_stack (); + /* End of DEBUG CODE */ Py_DECREF (val_obj); return result; } @@ -1291,23 +1295,22 @@ apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr, /* Find the constructor. */ func = find_pretty_printer (value); - if (!func) + if (func == Py_None) goto done; /* If we are printing a map, we want some special formatting. */ hint = gdbpy_get_display_hint (func); make_cleanup (free_current_contents, &hint); - make_cleanup_py_decref (func); - if (func != Py_None) - { - print_string_repr (func, hint, stream, recurse, options, language); - print_children (func, hint, stream, recurse, options, language); + /* Print the section */ + print_string_repr (func, hint, stream, recurse, options, language); + print_children (func, hint, stream, recurse, options, language); + make_cleanup_py_decref (func); + result = 1; - result = 1; - } done: + Py_DECREF(func); do_cleanups (cleanups); return result; } hooks/post-receive -- Repository for Project Archer.
reply other threads:[~2009-02-06 15:23 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=20090206152324.18234.qmail@sourceware.org \ --to=pmuldoon@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).