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/testsuite | |
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/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-prettyprint.exp | 42 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-prettyprint.py | 5 |
3 files changed, 53 insertions, 1 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 45e4689..da283b8 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2010-06-04 Doug Evans <dje@google.com> + + * 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. + 2010-06-04 Tom Tromey <tromey@redhat.com> * gdb.python/py-value.exp (test_value_hash): Don't test equality diff --git a/gdb/testsuite/gdb.python/py-prettyprint.exp b/gdb/testsuite/gdb.python/py-prettyprint.exp index 1fbf0ca..a26c48b 100644 --- a/gdb/testsuite/gdb.python/py-prettyprint.exp +++ b/gdb/testsuite/gdb.python/py-prettyprint.exp @@ -57,7 +57,6 @@ proc run_lang_tests {lang} { gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} - if ![runto_main ] then { perror "couldn't run to breakpoint" return @@ -109,3 +108,44 @@ proc run_lang_tests {lang} { run_lang_tests "c" run_lang_tests "c++" + +# Run various other tests. + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "debug"] != "" } { + untested "Couldn't compile ${srcfile}" + return -1 +} + +# Start with a fresh gdb. +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main ] then { + perror "couldn't run to breakpoint" + return +} + +gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \ + ".*Breakpoint.*" +gdb_test "continue" ".*Breakpoint.*" + +set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py] + +gdb_test "python execfile ('${remote_python_file}')" "" + +gdb_test "print ss" " = a=< a=<1> b=<$hex>> b=< a=<2> b=<$hex>>" \ + "print ss enabled #1" + +gdb_test "python disable_lookup_function ()" "" + +gdb_test "print ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \ + "print ss disabled" + +gdb_test "python enable_lookup_function ()" "" + +gdb_test "print ss" " = a=< a=<1> b=<$hex>> b=< a=<2> b=<$hex>>" \ + "print ss enabled #2" + +remote_file host delete ${remote_python_file} diff --git a/gdb/testsuite/gdb.python/py-prettyprint.py b/gdb/testsuite/gdb.python/py-prettyprint.py index 44bfc49..23d8271 100644 --- a/gdb/testsuite/gdb.python/py-prettyprint.py +++ b/gdb/testsuite/gdb.python/py-prettyprint.py @@ -194,6 +194,11 @@ def lookup_function (val): return None +def disable_lookup_function (): + lookup_function.enabled = False + +def enable_lookup_function (): + lookup_function.enabled = True def register_pretty_printers (): pretty_printers_dict[re.compile ('^struct s$')] = pp_s |