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" \ " = \{.* = pp class name: Vbase1.* = \{.* = pp value variable is: 1,.*members of Vbase2:.*_vptr.Vbase2 = $hex.* = \{.*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\""