diff options
author | Phil Muldoon <pmuldoon@redhat.com> | 2011-07-28 10:36:40 +0000 |
---|---|---|
committer | Phil Muldoon <pmuldoon@redhat.com> | 2011-07-28 10:36:40 +0000 |
commit | 00bd41d6bc7fc83d8fa5d739722f9d3bc3f62da1 (patch) | |
tree | 6ea7137fdf0a61a30a046a34fc8e549d3d6e2aa5 /gdb/testsuite/gdb.python | |
parent | e89702a8bdadd66330aaa605cfe571ed50f50a70 (diff) | |
download | gdb-00bd41d6bc7fc83d8fa5d739722f9d3bc3f62da1.zip gdb-00bd41d6bc7fc83d8fa5d739722f9d3bc3f62da1.tar.gz gdb-00bd41d6bc7fc83d8fa5d739722f9d3bc3f62da1.tar.bz2 |
2011-07-28 Phil Muldoon <pmuldoon@redhat.com>
* varobj.c (value_get_print_value): Move hint check later into the
function. Comment function. Free thevalue before reusing it.
2011-07-28 Phil Muldoon <pmuldoon@redhat.com>
* gdb.python/py-mi.exp: Test printers returning string hint, and
also not returning a value.
* gdb.python/py-prettyprint.c: Add testcase for above.
* gdb.python/py-prettyprint.py: Add test printer for above.
Diffstat (limited to 'gdb/testsuite/gdb.python')
-rw-r--r-- | gdb/testsuite/gdb.python/py-mi.exp | 7 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-prettyprint.c | 8 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-prettyprint.py | 15 |
3 files changed, 30 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/py-mi.exp b/gdb/testsuite/gdb.python/py-mi.exp index b232fc3..0ad4310 100644 --- a/gdb/testsuite/gdb.python/py-mi.exp +++ b/gdb/testsuite/gdb.python/py-mi.exp @@ -284,6 +284,13 @@ mi_list_varobj_children nstype2 { { {nstype2.<error at 0>} {<error at 0>} 6 {char \[6\]} } } "list children after setting exception flag" +mi_create_varobj me me \ + "create me varobj" + +mi_gdb_test "-var-evaluate-expression me" \ + "\\^done,value=\"<error reading variable: Cannot access memory.>.*\"" \ + "evaluate me varobj" + # C++ MI tests gdb_exit if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}-cxx" \ diff --git a/gdb/testsuite/gdb.python/py-prettyprint.c b/gdb/testsuite/gdb.python/py-prettyprint.c index b65a84f..30f649c 100644 --- a/gdb/testsuite/gdb.python/py-prettyprint.c +++ b/gdb/testsuite/gdb.python/py-prettyprint.c @@ -149,6 +149,11 @@ struct justchildren typedef struct justchildren nostring_type; +struct memory_error +{ + const char *s; +}; + struct container { string name; @@ -227,6 +232,7 @@ main () /* Clearing by being `static' could invoke an other GDB C++ bug. */ struct nullstr nullstr; nostring_type nstype, nstype2; + struct memory_error me; struct ns ns, ns2; struct lazystring estring, estring2; struct hint_error hint_error; @@ -234,6 +240,8 @@ main () nstype.elements = narray; nstype.len = 0; + me.s = "blah"; + init_ss(&ss, 1, 2); init_ss(ssa+0, 3, 4); init_ss(ssa+1, 5, 6); diff --git a/gdb/testsuite/gdb.python/py-prettyprint.py b/gdb/testsuite/gdb.python/py-prettyprint.py index 92280e0..8bff3c0 100644 --- a/gdb/testsuite/gdb.python/py-prettyprint.py +++ b/gdb/testsuite/gdb.python/py-prettyprint.py @@ -17,6 +17,7 @@ # printers. import re +import gdb # Test returning a Value from a printer. class string_print: @@ -186,6 +187,18 @@ class pp_outer: yield 's', self.val['s'] yield 'x', self.val['x'] +class MemoryErrorString: + "Raise an error" + + def __init__(self, val): + self.val = val + + def to_string(self): + raise gdb.MemoryError ("Cannot access memory."); + + def display_hint (self): + return 'string' + def lookup_function (val): "Look-up and return a pretty-printer that can print val." @@ -261,6 +274,8 @@ def register_pretty_printers (): pretty_printers_dict[re.compile ('^struct hint_error$')] = pp_hint_error pretty_printers_dict[re.compile ('^hint_error$')] = pp_hint_error + pretty_printers_dict[re.compile ('^memory_error$')] = MemoryErrorString + pretty_printers_dict = {} register_pretty_printers () |