public inbox for archer@sourceware.org
 help / color / mirror / Atom feed
* [python] Proposed fix for bz10633 (some strings not respecting options->print_max)
@ 2009-09-16 15:07 Phil Muldoon
  2009-09-16 16:50 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Phil Muldoon @ 2009-09-16 15:07 UTC (permalink / raw)
  To: Project Archer

[-- Attachment #1: Type: text/plain, Size: 730 bytes --]

http://sourceware.org/bugzilla/show_bug.cgi?id=10633

As shown in the bug, strings sourced from pretty printers are not 
respecting the current length of print_max. This is not a bug with the 
pretty printer code itself, but rather a missing check in c_printstr. 
This patch adds a check to the inner loop  while iterating over wchars 
to ensure that print_max is observed.

OK?

Regards

Phil

2009-09-16  Phil Muldoon <pmuldoon@redhat.com>

     * gdb.python/py-prettyprint.exp (gdb_py_test_silent_cmd): New
     Function.
     (run_lang_tests): Add print elements test.

2009-09-16  Phil Muldoon <pmuldoon@redhat.com>

     * c-lang.c (c_printstr): Do not loop past  options->print_max when
     iterating with wchar_iterate.


[-- Attachment #2: py_wchar_printmax.patch --]
[-- Type: text/plain, Size: 2053 bytes --]

diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 83a7382..515685a 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -459,7 +459,7 @@ c_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
 	 single character in isolation.  This makes the code simpler
 	 and probably does the sensible thing in the majority of
 	 cases.  */
-      while (num_chars == 1)
+      while (num_chars == 1 && things_printed < options->print_max)
 	{
 	  /* Count the number of repetitions.  */
 	  unsigned int reps = 0;
diff --git a/gdb/testsuite/gdb.python/py-prettyprint.exp b/gdb/testsuite/gdb.python/py-prettyprint.exp
index 287a5d3..4de1620 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint.exp
+++ b/gdb/testsuite/gdb.python/py-prettyprint.exp
@@ -32,6 +32,17 @@ if ![python_supported] then {
   return -1
 }
 
+# Run a command in GDB, and report a failure if a Python exception is thrown.
+# If report_pass is true, report a pass if no exception is thrown.
+proc gdb_py_test_silent_cmd {cmd name report_pass} {
+  global gdb_prompt
+
+  gdb_test_multiple $cmd $name {
+      -re "Traceback.*$gdb_prompt $"  { fail $name }
+      -re "$gdb_prompt $"	      { if $report_pass { pass $name } }
+  }
+}
+
 proc run_lang_tests {lang} {
     global srcdir subdir srcfile binfile testfile hex
     if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "debug $lang"] != "" } {
@@ -76,6 +87,11 @@ proc run_lang_tests {lang} {
 	gdb_test "print derived" \
 	    " = \{.*<Vbase1> = pp class name: Vbase1.*<Vbase2> = \{.*<VirtualTest> = pp value variable is: 1,.*members of Vbase2:.*_vptr.Vbase2 = $hex.*<Vbase3> = \{.*members of Vbase3.*members of Derived:.*value = 2.*"
 	gdb_test "print ns " "\"embedded\\\\000null\\\\000string\""
+	gdb_py_test_silent_cmd "set print elements 3" "" 1
+	gdb_test "print ns" "emb\.\.\.."
+	gdb_py_test_silent_cmd "set print elements 10" "" 1
+	gdb_test "print ns" "embedded\\\\000n\.\.\.."
+	gdb_py_test_silent_cmd "set print elements 200" "" 1
     }
 
     gdb_test "print x" " = $hex \"this is x\""

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [python] Proposed fix for bz10633 (some strings not respecting options->print_max)
  2009-09-16 15:07 [python] Proposed fix for bz10633 (some strings not respecting options->print_max) Phil Muldoon
@ 2009-09-16 16:50 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2009-09-16 16:50 UTC (permalink / raw)
  To: Phil Muldoon; +Cc: Project Archer

>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:

Phil> http://sourceware.org/bugzilla/show_bug.cgi?id=10633

Phil> 2009-09-16  Phil Muldoon <pmuldoon@redhat.com>
Phil>     * c-lang.c (c_printstr): Do not loop past  options->print_max when
Phil>     iterating with wchar_iterate.

Thanks, please check this in and submit upstream.

Note that when a patch fixes a PR, you should mention the PR in the
ChangeLog, like:

    PR python/10633:
    ...

(There are lots of examples to see in the existing ChangeLog, just
follow one of those.)

If you do this, then the commit will show up in bugzilla (because the
commit script extracts this info from the commit message, which should
just be the same as the ChangeLog entry...)

Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-09-16 16:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-16 15:07 [python] Proposed fix for bz10633 (some strings not respecting options->print_max) Phil Muldoon
2009-09-16 16:50 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).