public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [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.
@ 2009-02-06 15:23 pmuldoon
0 siblings, 0 replies; only message in thread
From: pmuldoon @ 2009-02-06 15:23 UTC (permalink / raw)
To: archer-commits
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.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-02-06 15:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-06 15:23 [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 pmuldoon
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).