aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python/python-prettyprint.py
diff options
context:
space:
mode:
authorPhil Muldoon <pmuldoon@redhat.com>2009-07-10 10:35:17 +0000
committerPhil Muldoon <pmuldoon@redhat.com>2009-07-10 10:35:17 +0000
commitfbb8f2990ccfa180274ab4a578818fe247823540 (patch)
tree3cadb912a530bab6a1332d62cdc8deafa7375bde /gdb/testsuite/gdb.python/python-prettyprint.py
parent041de40dc8e221039d7a983d489c6dcacd446e36 (diff)
downloadbinutils-fbb8f2990ccfa180274ab4a578818fe247823540.zip
binutils-fbb8f2990ccfa180274ab4a578818fe247823540.tar.gz
binutils-fbb8f2990ccfa180274ab4a578818fe247823540.tar.bz2
2009-07-10 Phil Muldoon <pmuldoon@redhat.com>
* python/python-internal.h (apply_varobj_pretty_printer): Update definition. (python_string_to_target_python_string): Add definition. * python/python-utils.c (unicode_to_encoded_python_string) (unicode_to_target_python_string) (python_string_to_target_python_string): New Functions. * python/python-prettyprint.c (pretty_print_one_value): Likewise. (print_string_repr): Refactor to logic to account for PyObject returned strings. (apply_varobj_pretty_printer): Likewise. * python/python-value.c (valpy_string): Parse length keyword. Use length keyword in LA_GET_STRING. * varobj.c (value_get_print_value): Refactor logic to account for PyObject returned strings. * c-lang.c (c_get_string): If the length parameter is specified, use that. Return value in characters. Update comments. * language.h: Update c_get_string prototype comments. 2009-07-10 Phil Muldoon <pmuldoon@redhat.com> * gdb.texinfo (Values From Inferior): Add length parameter description. 2009-07-10 Phil Muldoon <pmuldoon@redhat.com> * gdb.python/python-prettyprint.c: Add counted null string structure. * gdb.python/python-prettyprint.exp: Print null string. Test for embedded nulls. * gdb.python/python-prettyprint.py (pp_ns): New Function. * gdb.python/python-value.exp (test_value_in_inferior): Add variable length string fetch tests. * gdb.python/python-value.c (main): Add strings for string fetch tests.
Diffstat (limited to 'gdb/testsuite/gdb.python/python-prettyprint.py')
-rw-r--r--gdb/testsuite/gdb.python/python-prettyprint.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/python-prettyprint.py b/gdb/testsuite/gdb.python/python-prettyprint.py
index 493cf29..bf009a1 100644
--- a/gdb/testsuite/gdb.python/python-prettyprint.py
+++ b/gdb/testsuite/gdb.python/python-prettyprint.py
@@ -92,6 +92,19 @@ class pp_vbase1:
def to_string (self):
return "pp class name: " + self.val.type.tag
+class pp_ns:
+ "Print a std::basic_string of some kind"
+
+ def __init__(self, val):
+ self.val = val
+
+ def to_string(self):
+ len = self.val['length']
+ return self.val['null_str'].string (gdb.parameter ('target-charset'), length = len)
+
+ def display_hint (self):
+ return 'string'
+
def lookup_function (val):
"Look-up and return a pretty-printer that can print val."
@@ -145,6 +158,8 @@ def register_pretty_printers ():
pretty_printers_dict[re.compile ('^string_repr$')] = string_print
pretty_printers_dict[re.compile ('^container$')] = ContainerPrinter
+ pretty_printers_dict[re.compile ('^struct ns$')] = pp_ns
+ pretty_printers_dict[re.compile ('^ns$')] = pp_ns
pretty_printers_dict = {}
register_pretty_printers ()