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.
This commit is contained in:
parent
e89702a8bd
commit
00bd41d6bc
6 changed files with 71 additions and 9 deletions
|
@ -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" \
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue