This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [RFC 5/6] Handle "set print sevenbit-strings on" in print_wchar



> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Keith Seitz
> Envoyé : mardi 1 octobre 2013 03:19
> À : Pierre Muller
> Cc : 'gdb-patches'
> Objet : Re: [RFC 5/6] Handle "set print sevenbit-strings on" in
print_wchar
> 
> On 09/26/2013 01:03 PM, Pierre Muller wrote:
> 
> > 2013-09-26  Pierre Muller  <muller@sourceware.org>
> >
> >   	valprint.c (print_wchar): Honor sevenbit_strings value.
> >
> 
> [Your ChangeLog entry got munged...] I would prefer that you ChangeLog
> entry be a little more explicit about what changed, e.g., "Print escaped
> characters if sevenbit-strings is set."
> 
> I think this patch is okay, but it definitely needs a test (and a
> maintainer to approve). It took me a non-trivial amount of time to
> actually get the patch to show any difference in the output.
> 
> The trick (on linux) was changing the charset to something where
> (char)0x80 and up are printable characters. I used CP1252, and then I
> could see what this patch actually did.
  Sorry, I should have mentioned that..
 
> Perhaps this can be used in a test that will run on more than just MinGW
> hosts.

What about the following:

Pierre

ChangeLog entry:

2013-10-01  Pierre Muller  <muller@sourceware.org>

	* valprint.c (print_wchar): Print all char above seven-bit
 	as octal or hexadecimal if SEVENBIT_STRINGS is non-zero.

testsuite ChangeLog:

2013-10-01  Pierre Muller  <muller@sourceware.org>
	gdb.base/charset.exp: Add test to print char \242 in charset CP1252
	with or without "set print sevenbit-strings on".

---
 gdb/testsuite/gdb.base/charset.exp |   13 +++++++++++++
 gdb/valprint.c                     |    7 ++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/gdb/testsuite/gdb.base/charset.exp
b/gdb/testsuite/gdb.base/charset.exp
index a5dbb28..01129e4 100644
--- a/gdb/testsuite/gdb.base/charset.exp
+++ b/gdb/testsuite/gdb.base/charset.exp
@@ -627,5 +627,18 @@ foreach name {short int long} {
 	"assign string to $name array"
 }
 
+# Set the target charset to CP1252.
+gdb_test_no_output "set charset CP1252"
+
+# \242 is a valid CP1252 character.
+gdb_test "print \"\\242\"" " = \".\"" \
+  "\\242 character in CP1252"
+
+gdb_test_no_output "set print sevenbit-strings on"
+
+# \242 is a valid CP1252 character, nut must now be printed in octal.
+gdb_test "print \"\\242\"" " = \"\\\\242\"" \
+  "\\242 character in CP1252, with seven-bit limitation"
+
 
 gdb_exit 
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 0f6d65e..912352c 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1926,9 +1926,10 @@ print_wchar (gdb_wint_t w, const gdb_byte *orig,
   int need_escape = *need_escapep;
 
   *need_escapep = 0;
-  if (gdb_iswprint (w) && (!need_escape || (!gdb_iswdigit (w)
-					    && w != LCST ('8')
-					    && w != LCST ('9'))))
+  if (gdb_iswprint (w)
+      && (!sevenbit_strings || (w > 0 && w < 0x7f))
+      && (!need_escape || (!gdb_iswdigit (w)
+			   && w != LCST ('8') && w != LCST ('9'))))
     {
       gdb_wchar_t wchar = w;
 
-- 
1.7.9


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]