aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2021-06-08 17:39:05 +0200
committerTom de Vries <tdevries@suse.de>2021-06-08 17:39:05 +0200
commitfdae5c22cedfb5948f2ccfbafc57ab53587129d5 (patch)
tree491342222ff749c4705f96a571e4658d6465d8f4
parent956ea65cd707707c0f725930214cbc781367a831 (diff)
downloadgdb-fdae5c22cedfb5948f2ccfbafc57ab53587129d5.zip
gdb-fdae5c22cedfb5948f2ccfbafc57ab53587129d5.tar.gz
gdb-fdae5c22cedfb5948f2ccfbafc57ab53587129d5.tar.bz2
[gdb/testsuite] Disallow single argument in multi_line
It's a common mistake of mine to do: ... set l [list "foo" "bar"] set re [multi_line $l] ... and to get "foo bar" while I was expecting "foo\r\nbar", which I get after doing instead: ... set re [multi_line {*}$l] ... Detect this type of mistake by erroring out in multi_line when only one argument is passed. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2021-06-08 Tom de Vries <tdevries@suse.de> * lib/gdb.exp (multi_line): Require more than one argument. * gdb.base/gdbinit-history.exp: Update multi_line call. * gdb.base/jit-reader.exp: Remove multi_line call. * gdb.fortran/dynamic-ptype-whatis.exp: Same.
-rw-r--r--gdb/testsuite/ChangeLog7
-rw-r--r--gdb/testsuite/gdb.base/gdbinit-history.exp6
-rw-r--r--gdb/testsuite/gdb.base/jit-reader.exp4
-rw-r--r--gdb/testsuite/gdb.fortran/dynamic-ptype-whatis.exp2
-rw-r--r--gdb/testsuite/lib/gdb.exp4
5 files changed, 18 insertions, 5 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index e2f1486..51abd0e 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,12 @@
2021-06-08 Tom de Vries <tdevries@suse.de>
+ * lib/gdb.exp (multi_line): Require more than one argument.
+ * gdb.base/gdbinit-history.exp: Update multi_line call.
+ * gdb.base/jit-reader.exp: Remove multi_line call.
+ * gdb.fortran/dynamic-ptype-whatis.exp: Same.
+
+2021-06-08 Tom de Vries <tdevries@suse.de>
+
* gdb.base/info-types.exp.tcl (match_line, gdb_test_lines): Move ...
* lib/gdb.exp: ... here.
* gdb.base/info-macros.exp: Use gdb_test_lines.
diff --git a/gdb/testsuite/gdb.base/gdbinit-history.exp b/gdb/testsuite/gdb.base/gdbinit-history.exp
index 8e3994e..36f4a11 100644
--- a/gdb/testsuite/gdb.base/gdbinit-history.exp
+++ b/gdb/testsuite/gdb.base/gdbinit-history.exp
@@ -144,7 +144,11 @@ proc check_history { hist } {
lappend hist_lines " $idx $h"
incr idx
}
- set pattern [eval multi_line $hist_lines]
+ if { [llength $hist_lines] == 1 } {
+ set pattern [lindex $hist_lines 0]
+ } else {
+ set pattern [eval multi_line $hist_lines]
+ }
# Check the history.
gdb_test "show commands" "$pattern.*"
diff --git a/gdb/testsuite/gdb.base/jit-reader.exp b/gdb/testsuite/gdb.base/jit-reader.exp
index 25d1100..83e4036 100644
--- a/gdb/testsuite/gdb.base/jit-reader.exp
+++ b/gdb/testsuite/gdb.base/jit-reader.exp
@@ -240,9 +240,7 @@ proc jit_reader_test {} {
# the built-in unwinder cannot backtrace through the mangled
# stack pointer.
gdb_test "bt" \
- [multi_line \
- "Backtrace stopped: Cannot access memory at address $sp_after_mangling" \
- ] \
+ "Backtrace stopped: Cannot access memory at address $sp_after_mangling" \
"bt shows error"
gdb_test "info frame" "Cannot access memory at address.*" \
diff --git a/gdb/testsuite/gdb.fortran/dynamic-ptype-whatis.exp b/gdb/testsuite/gdb.fortran/dynamic-ptype-whatis.exp
index d2ffd6d..5ea2aa4 100644
--- a/gdb/testsuite/gdb.fortran/dynamic-ptype-whatis.exp
+++ b/gdb/testsuite/gdb.fortran/dynamic-ptype-whatis.exp
@@ -73,7 +73,7 @@ gdb_test "whatis var4%t2_array" "type = Type type1, allocatable \\(3\\)"
gdb_test "whatis var5%t3_array" "type = Type type1 \\(3\\)"
gdb_test "whatis var6%t4_array" "type = Type type2, allocatable \\(3\\)"
gdb_test "whatis var7%t5_array" "type = Type type2 \\(4\\)"
-gdb_test "ptype var3%t1_i" [ multi_line "type = integer\\(kind=4\\)" ]
+gdb_test "ptype var3%t1_i" "type = integer\\(kind=4\\)"
gdb_test "ptype var4%t2_array" [ multi_line "type = Type type1" \
" integer\\(kind=4\\) :: spacer" \
" integer\\(kind=4\\) :: t1_i" \
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index f7ab219..8469ec9 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -7294,6 +7294,10 @@ proc capture_command_output { command prefix } {
# being.
proc multi_line { args } {
+ if { [llength $args] == 1 } {
+ set hint "forgot {*} before list argument?"
+ error "multi_line called with one argument ($hint)"
+ }
return [join $args "\r\n"]
}