Index: gdb/testsuite/gdb.base/printcmds.exp |
diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp |
index 993162e350542a96e26055cbbe548915e67515b8..6d65107be1df8a8537489fa4f41dde7052125514 100644 |
--- a/gdb/testsuite/gdb.base/printcmds.exp |
+++ b/gdb/testsuite/gdb.base/printcmds.exp |
@@ -1,7 +1,6 @@ |
# This testcase is part of GDB, the GNU debugger. |
-# Copyright 1992, 1994-1997, 1999-2000, 2002-2004, 2007-2012 Free |
-# Software Foundation, Inc. |
+# Copyright 1992-2013 Free Software Foundation, Inc. |
# This program is free software; you can redistribute it and/or modify |
# it under the terms of the GNU General Public License as published by |
@@ -21,9 +20,8 @@ |
# This file was written by Fred Fish. (fnf@cygnus.com) |
-set testfile "printcmds" |
-set srcfile ${testfile}.c |
-set binfile ${objdir}/${subdir}/${testfile} |
+standard_testfile .c |
+ |
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { |
untested printcmds.exp |
return -1 |
@@ -424,48 +422,48 @@ proc test_print_all_chars {} { |
proc test_print_repeats_10 {} { |
global gdb_prompt decimal |
- for { set x 1; } { $x <= 16 } { incr x; } { |
+ for { set x 1 } { $x <= 16 } { incr x } { |
gdb_test_no_output "set print elements $x" |
- for { set e 1; } { $e <= 16 } {incr e; } { |
- set v [expr $e - 1]; |
+ for { set e 1 } { $e <= 16 } {incr e } { |
+ set v [expr $e - 1] |
set command "p &ctable2\[${v}*16\]" |
if { $x < $e } { |
- set aval $x; |
+ set aval $x |
} else { |
- set aval $e; |
+ set aval $e |
} |
- set xval [expr $x - $e]; |
+ set xval [expr $x - $e] |
if { $xval < 0 } { |
- set xval 0; |
+ set xval 0 |
} |
if { $aval > 10 } { |
- set a "'a' <repeats $aval times>"; |
+ set a "'a' <repeats $aval times>" |
if { $xval > 0 } { |
- set a "${a}, \\\""; |
+ set a "${a}, \\\"" |
} |
} else { |
- set a "\\\"[string range "aaaaaaaaaaaaaaaa" 1 $aval]"; |
+ set a "\\\"[string range "aaaaaaaaaaaaaaaa" 1 $aval]" |
if { $xval > 10 } { |
- set a "$a\\\", "; |
+ set a "$a\\\", " |
} |
} |
- set xstr ""; |
+ set xstr "" |
if { $xval > 10 } { |
- set xstr "'X' <repeats $xval times>"; |
+ set xstr "'X' <repeats $xval times>" |
} else { |
if { $xval > 0 } { |
- set xstr "[string range "XXXXXXXXXXXXXXXX" 1 $xval]\\\""; |
+ set xstr "[string range "XXXXXXXXXXXXXXXX" 1 $xval]\\\"" |
} else { |
if { $aval <= 10 } { |
- set xstr "\\\""; |
+ set xstr "\\\"" |
} |
} |
} |
if { $aval < 16 } { |
set xstr "${xstr}\[.\]\[.\]\[.\]" |
} |
- set string " = \[(\]unsigned char \[*\]\[)\] <ctable2(\\+$decimal)?> ${a}${xstr}"; |
- gdb_test "$command" "$string" "$command with print elements set to $x"; |
+ set string " = \[(\]unsigned char \[*\]\[)\] <ctable2(\\+$decimal)?> ${a}${xstr}" |
+ gdb_test "$command" "$string" "$command with print elements set to $x" |
} |
} |
} |
@@ -589,6 +587,16 @@ proc test_print_int_arrays {} { |
" = {{{0, 1}, {2, 3}, {4, 5}}, {{6, 7}, {8, 9}, {10, 11}}}" |
gdb_test_escape_braces "p int4dim" \ |
" = {{{{0, 1}, {2, 3}, {4, 5}}, {{6, 7}, {8, 9}, {10, 11}}}}" |
+ |
+ # Some checks for various output formats. |
+ gdb_test_escape_braces "p/x int4dim" \ |
+ " = {{{{0x0, 0x1}, {0x2, 0x3}, {0x4, 0x5}}, {{0x6, 0x7}, {0x8, 0x9}, {0xa, 0xb}}}}" |
+ gdb_test_escape_braces "p/z int4dim" \ |
+ " = {{{{0x0+0, 0x0+1}, {0x0+2, 0x0+3}, {0x0+4, 0x0+5}}, {{0x0+6, 0x0+7}, {0x0+8, 0x0+9}, {0x0+a, 0x0+b}}}}" |
+ gdb_test_escape_braces "p/o int4dim" \ |
+ " = {{{{0, 01}, {02, 03}, {04, 05}}, {{06, 07}, {010, 011}, {012, 013}}}}" |
+ gdb_test_escape_braces "p/t int4dim" \ |
+ " = {{{{0, 1}, {10, 11}, {100, 101}}, {{110, 111}, {1000, 1001}, {1010, 1011}}}}" |
} |
proc test_print_typedef_arrays {} { |
@@ -660,7 +668,7 @@ proc test_print_string_constants {} { |
# We need to up this because this can be really slow on some boards. |
# (Test may involve inferior malloc() calls). |
- set timeout 60; |
+ set timeout 60 |
gdb_test "p \"a string\"" " = \"a string\"" |
gdb_test "p \"embedded \\000 null\"" " = \"embedded \\\\000 null\"" |
@@ -684,7 +692,7 @@ proc test_print_array_constants {} { |
# We need to up this because this can be really slow on some boards. |
# (Test may involve inferior malloc() calls). |
- set timeout 60; |
+ set timeout 60 |
gdb_test "print {'a','b','c'}" " = \"abc\"" |
gdb_test_escape_braces "print {0,1,2}" " = {0, 1, 2}" |
@@ -720,6 +728,24 @@ proc test_printf {} { |
# Regression test for "%% at end of format string. |
# See http://sourceware.org/bugzilla/show_bug.cgi?id=11345 |
gdb_test "printf \"%%%d%%\\n\", 5" "%5%" |
+ |
+ # Some tests for missing format specifier after '%'. |
+ gdb_test "printf \"%\", 0" "Incomplete format specifier at end of format string" |
+ gdb_test "printf \"%.234\", 0" "Incomplete format specifier at end of format string" |
+ gdb_test "printf \"%-\", 0" "Incomplete format specifier at end of format string" |
+ gdb_test "printf \"%-23\", 0" "Incomplete format specifier at end of format string" |
+ |
+ # Test for invalid printf flags on pointer types. |
+ gdb_test "printf \"%#p\", 0" "Inappropriate modifiers to format specifier 'p' in printf" |
+ gdb_test "printf \"% p\", 0" "Inappropriate modifiers to format specifier 'p' in printf" |
+ gdb_test "printf \"%0p\", 0" "Inappropriate modifiers to format specifier 'p' in printf" |
+ gdb_test "printf \"%+p\", 0" "Inappropriate modifiers to format specifier 'p' in printf" |
+ |
+ |
+ gdb_test "define hibob\nprintf \"hi bob \"\nshell echo zzz\nprintf \"y\\n\"\nend" \ |
+ "" \ |
+ "create hibob command" |
+ gdb_test "hibob" "hi bob zzz.*y" "run hibob command" |
} |
#Test printing DFP values with printf |
@@ -771,6 +797,9 @@ proc test_printf_with_dfp {} { |
# The largest exponent for 128-bit dfp value is 6144. |
gdb_test "printf \"%DDf\\n\",1.2E6144dl" "1.200000000000000000000000000000000E\\+6144" |
+ |
+ # GDB used to get this wrong. |
+ gdb_test "printf \"%Hf %Hf\\n\",1.2df,1.3df" "1.2 1.3" |
} |
proc test_print_symbol {} { |
@@ -792,6 +821,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 +950,4 @@ test_print_enums |
test_printf |
test_printf_with_dfp |
test_print_symbol |
+test_repeat_bytes |