This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
FYI: one more val_print_string fix
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 18 Oct 2010 13:13:07 -0600
- Subject: FYI: one more val_print_string fix
I'm checking this in.
In my earlier patch I neglected (sigh...) to change val_print_string to
actually use the new "encoding" argument.
This patch fixes the bug.
Built and regtested on x86-64 (compile farm).
I added a regression test for this.
Tom
2010-10-18 Tom Tromey <tromey@redhat.com>
* valprint.c (val_print_string): Pass 'encoding' to
LA_PRINT_STRING.
2010-10-18 Tom Tromey <tromey@redhat.com>
* gdb.python/py-prettyprint.exp (run_lang_tests): Test encoding
argument to lazy_string.
* gdb.python/py-prettyprint.py (pp_ls_encoding): New global.
(pp_ls.to_string): Use it.
* gdb.python/py-prettyprint.c (main): Move declarations to top.
Add "estring2" local.
Index: valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/valprint.c,v
retrieving revision 1.96
diff -u -r1.96 valprint.c
--- valprint.c 15 Oct 2010 18:54:12 -0000 1.96
+++ valprint.c 18 Oct 2010 19:12:48 -0000
@@ -1489,7 +1489,7 @@
fputs_filtered (" ", stream);
}
LA_PRINT_STRING (stream, elttype, buffer, bytes_read / width,
- NULL, force_ellipsis, options);
+ encoding, force_ellipsis, options);
}
if (errcode != 0)
Index: testsuite/gdb.python/py-prettyprint.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-prettyprint.c,v
retrieving revision 1.6
diff -u -r1.6 py-prettyprint.c
--- testsuite/gdb.python/py-prettyprint.c 14 Jul 2010 14:13:55 -0000 1.6
+++ testsuite/gdb.python/py-prettyprint.c 18 Oct 2010 19:12:50 -0000
@@ -213,6 +213,9 @@
/* Clearing by being `static' could invoke an other GDB C++ bug. */
struct nullstr nullstr;
nostring_type nstype;
+ struct ns ns;
+ struct lazystring estring, estring2;
+
nstype.elements = narray;
nstype.len = 0;
@@ -225,13 +228,14 @@
init_s (&arraystruct.x[0], 23);
init_s (&arraystruct.x[1], 24);
- struct ns ns;
ns.null_str = "embedded\0null\0string";
ns.length = 20;
- struct lazystring estring;
estring.lazy_str = "embedded x\201\202\203\204" ;
+ /* Incomplete UTF-8, but ok Latin-1. */
+ estring2.lazy_str = "embedded x\302";
+
#ifdef __cplusplus
S cps;
Index: testsuite/gdb.python/py-prettyprint.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-prettyprint.exp,v
retrieving revision 1.13
diff -u -r1.13 py-prettyprint.exp
--- testsuite/gdb.python/py-prettyprint.exp 1 Oct 2010 17:03:50 -0000 1.13
+++ testsuite/gdb.python/py-prettyprint.exp 18 Oct 2010 19:12:50 -0000
@@ -91,6 +91,10 @@
gdb_test "print cstring" " = \"const string\""
gdb_test "print estring" "\"embedded x\\\\201\\\\202\\\\203\\\\204\""
+
+ gdb_test_no_output "python pp_ls_encoding = 'UTF-8'"
+ gdb_test "print estring2" "\"embedded \", <incomplete sequence \\\\302>"
+
gdb_test "print c" " = container \"container\" with 2 elements = {$nl *.0. = 23,$nl *.1. = 72$nl}"
gdb_test "print nstype" " = {$nl *.0. = 7,$nl *.1. = 42$nl}"
Index: testsuite/gdb.python/py-prettyprint.py
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-prettyprint.py,v
retrieving revision 1.7
diff -u -r1.7 py-prettyprint.py
--- testsuite/gdb.python/py-prettyprint.py 4 Jun 2010 18:18:28 -0000 1.7
+++ testsuite/gdb.python/py-prettyprint.py 18 Oct 2010 19:12:50 -0000
@@ -139,6 +139,8 @@
def display_hint (self):
return 'string'
+pp_ls_encoding = None
+
class pp_ls:
"Print a std::basic_string of some kind"
@@ -146,7 +148,10 @@
self.val = val
def to_string(self):
- return self.val['lazy_str'].lazy_string()
+ if pp_ls_encoding is not None:
+ return self.val['lazy_str'].lazy_string(encoding = pp_ls_encoding)
+ else:
+ return self.val['lazy_str'].lazy_string()
def display_hint (self):
return 'string'