aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base/printcmds.exp
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2012-11-10 20:19:01 +0000
committerKeith Seitz <keiths@redhat.com>2012-11-10 20:19:01 +0000
commit0d63ecdad04d410698c905283d095505680ba907 (patch)
tree3f894b47be2cfef2d36d71ffb1cb4d33717bd9b7 /gdb/testsuite/gdb.base/printcmds.exp
parent9b8d6827200e1b04d3ca860ce52472655e84248c (diff)
downloadgdb-0d63ecdad04d410698c905283d095505680ba907.zip
gdb-0d63ecdad04d410698c905283d095505680ba907.tar.gz
gdb-0d63ecdad04d410698c905283d095505680ba907.tar.bz2
PR gdb/14288
* c-valprint.c (c_val_print): For character arrays with "print null" option on, print ellipses if the output is truncated and the next character is not \000. * valprint.c (MAX_WCHARS): Define. (WCHAR_BUFLEN): Likewise. (WCHAR_BUFLEN_MAX): Likewise. (struct converted_character): New structure. (count_next_character): New function. (print_converted_chars_to_obstack): New function. (generic_printstr): Rewrite using count_next_character and print_converted_chars_to_obstack. * gdb.base/printcmds.c: Add invalid_XXX globals for repeated byte tests. * gdb.base/printcmds.exp (test_repeat_bytes): New procedure. * gdb.base/wchar.c (main): Add and construct a wchar_t array with repeated characters. * gdb.base/wchar.exp: Add repeated character tests.
Diffstat (limited to 'gdb/testsuite/gdb.base/printcmds.exp')
-rw-r--r--gdb/testsuite/gdb.base/printcmds.exp71
1 files changed, 71 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp
index 4f76cec..4dfe90f 100644
--- a/gdb/testsuite/gdb.base/printcmds.exp
+++ b/gdb/testsuite/gdb.base/printcmds.exp
@@ -792,6 +792,76 @@ proc gdb_test_escape_braces { args } {
gdb_test [lindex $args 0] $esc_pattern [lindex $args 2]
}
+proc test_repeat_bytes {} {
+ set start(E) {}
+ set start(S) {a}
+ set start(L) {abaabbaaabbb}
+ set start(R) {'a' <repeats 20 times>}
+ set end(E) {}
+ set end(S) {c}
+ set end(L) {cdccddcccddd}
+ set end(R) {'c' <repeats 20 times>}
+ set invalid(S) {\\240}
+ set invalid(L) {\\240\\240\\240\\240}
+ set invalid(R) {'\\240' <repeats 20 times>}
+
+ set fmt(SSS) "\"%s%s%s\""
+ set fmt(SSR) "\"%s%s\", %s"
+ set fmt(SRS) "\"%s\", %s, \"%s\""
+ set fmt(RSS) "%s, \"%s%s\""
+ set fmt(RSR) "%s, \"%s\", %s"
+ set fmt(SRR) "\"%s\", %s, %s"
+ set fmt(RRS) "%s, %s, \"%s\""
+ set fmt(RRR) "%s, %s, %s"
+
+ set fmt(RS) "%s, \"%s\""
+ set fmt(RR) "%s, %s"
+ set fmt(SR) "\"%s\", %s"
+ set fmt(SS) "\"%s%s\""
+
+ # Test the various permutations of invalid characters
+ foreach i [array names invalid] {
+ set I $i
+
+ if {$i == "L"} {
+ set i "S"
+ }
+
+ foreach s [array names start] {
+ set S $s
+
+ if {$s == "L"} {
+ set s "S"
+ }
+
+
+ foreach e [array names end] {
+ set E $e
+
+ if {$e == "L"} {
+ set e "S"
+ }
+
+ # Skip E*E.
+ if {$s == "E" && $e == "E"} { continue }
+
+ # Special cases...
+ if {$s == "E"} {
+ set result [format $fmt($i$e) $invalid($I) $end($E)]
+ } elseif {$e == "E"} {
+ set result [format $fmt($s$i) $start($S) $invalid($I)]
+ } else {
+ set result [format $fmt($s$i$e) \
+ $start($S) $invalid($I) $end($E)]
+ }
+
+ send_log "expecting: = $result\n"
+ gdb_test "print invalid_$S$I$E" "= $result"
+ }
+ }
+ }
+}
+
# Start with a fresh gdb.
gdb_exit
@@ -851,3 +921,4 @@ test_print_enums
test_printf
test_printf_with_dfp
test_print_symbol
+test_repeat_bytes