diff options
author | Doug Evans <dje@google.com> | 2010-06-04 18:18:28 +0000 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2010-06-04 18:18:28 +0000 |
commit | 967cf47793f3a66dd3f8637279fe6d891dd2de9f (patch) | |
tree | 2b4a8257ec0d430b6cbdec547f6ef52ca97e7ca0 /gdb/python | |
parent | 2dec564e9127282478f922bc9946248745c5b140 (diff) | |
download | gdb-967cf47793f3a66dd3f8637279fe6d891dd2de9f.zip gdb-967cf47793f3a66dd3f8637279fe6d891dd2de9f.tar.gz gdb-967cf47793f3a66dd3f8637279fe6d891dd2de9f.tar.bz2 |
Add support for enabling/disabling individual pretty-printers.
* python/py-prettyprint.c (search_pp_list): Skip disabled printers.
* python/python-internal.h (gdbpy_enabled_cst): Declare.
* python/python.c (gdbpy_enabled_cst): Define.
(_initialize_python): Initialize gdbpy_enabled_cst.
* NEWS: Add entry.
doc/
* gdb.texinfo (Python API): New node `Disabling Pretty-Printers'.
testsuite/
* gdb.python/py-prettyprint.exp: Add new test for enabled and
disabled printers.
* gdb.python/py-prettyprint.py (disable_lookup_function): New function.
(enable_lookup_function): New function.
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/py-prettyprint.c | 5 | ||||
-rw-r--r-- | gdb/python/python-internal.h | 1 | ||||
-rw-r--r-- | gdb/python/python.c | 2 |
3 files changed, 8 insertions, 0 deletions
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index e678898..4d60c96 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -48,6 +48,11 @@ search_pp_list (PyObject *list, PyObject *value) if (! function) return NULL; + /* Skip if disabled. */ + if (PyObject_HasAttr (function, gdbpy_enabled_cst) + && ! PyObject_IsTrue (PyObject_GetAttr (function, gdbpy_enabled_cst))) + continue; + printer = PyObject_CallFunctionObjArgs (function, value, NULL); if (! printer) return NULL; diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index bc07b5d..5bd2a4b 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -200,6 +200,7 @@ extern PyObject *gdbpy_doc_cst; extern PyObject *gdbpy_children_cst; extern PyObject *gdbpy_to_string_cst; extern PyObject *gdbpy_display_hint_cst; +extern PyObject *gdbpy_enabled_cst; extern PyObject *gdbpy_gdberror_exc; diff --git a/gdb/python/python.c b/gdb/python/python.c index 0b7b7ba..31880c1 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -56,6 +56,7 @@ PyObject *gdbpy_to_string_cst; PyObject *gdbpy_children_cst; PyObject *gdbpy_display_hint_cst; PyObject *gdbpy_doc_cst; +PyObject *gdbpy_enabled_cst; /* The GdbError exception. */ PyObject *gdbpy_gdberror_exc; @@ -693,6 +694,7 @@ Enables or disables printing of Python stack traces."), gdbpy_children_cst = PyString_FromString ("children"); gdbpy_display_hint_cst = PyString_FromString ("display_hint"); gdbpy_doc_cst = PyString_FromString ("__doc__"); + gdbpy_enabled_cst = PyString_FromString ("enabled"); /* Create a couple objects which are used for Python's stdout and stderr. */ |