From 3c724c8ca91ee8304ba355f681ccd906f0e9725b Mon Sep 17 00:00:00 2001 From: Pierre-Marie de Rodat Date: Tue, 10 Mar 2015 09:51:27 +0100 Subject: [PATCH] Share the "multi_line" helper among all testcases gdb/testsuite/ChangeLog: * gdb.ada/complete.exp: Remove "multi_line". * gdb.ada/info_exc.exp: Remove "multi_line". * gdb.ada/packed_tagged.exp: Remove "multi_line". * gdb.ada/ptype_field.exp: Remove "multi_line". * gdb.ada/sym_print_name.exp: Remove "multi_line". * gdb.ada/tagged.exp: Remove "multi_line". * gdb.btrace/buffer-size.exp: Replace [join [list ...]] with [multi_line ...] * gdb.btrace/delta.exp: Likewise. * gdb.btrace/exception.exp: Likewise. * gdb.btrace/function_call_history.exp: Likewise. * gdb.btrace/instruction_history.exp: Likewise. * gdb.btrace/nohist.exp: Likewise. * gdb.btrace/record_goto.exp: Likewise. * gdb.btrace/segv.exp: Likewise. * gdb.btrace/stepi.exp: Likewise. * gdb.btrace/tailcall.exp: Likewise. * gdb.btrace/unknown_functions.exp: Likewise. * gdb.dwarf2/dw2-undefined-ret-addr.exp: Likewise. * lib/gdb.exp: Add the "multi_line" helper. --- gdb/testsuite/ChangeLog | 23 ++++++++ gdb/testsuite/gdb.ada/complete.exp | 10 ---- gdb/testsuite/gdb.ada/info_exc.exp | 11 ---- gdb/testsuite/gdb.ada/packed_tagged.exp | 11 ---- gdb/testsuite/gdb.ada/ptype_field.exp | 11 ---- gdb/testsuite/gdb.ada/sym_print_name.exp | 11 ---- gdb/testsuite/gdb.ada/tagged.exp | 11 ---- gdb/testsuite/gdb.btrace/buffer-size.exp | 8 +-- gdb/testsuite/gdb.btrace/delta.exp | 16 +++--- gdb/testsuite/gdb.btrace/exception.exp | 8 +-- .../gdb.btrace/function_call_history.exp | 44 +++++++-------- .../gdb.btrace/instruction_history.exp | 16 +++--- gdb/testsuite/gdb.btrace/nohist.exp | 4 +- gdb/testsuite/gdb.btrace/record_goto.exp | 56 +++++++++---------- gdb/testsuite/gdb.btrace/segv.exp | 4 +- gdb/testsuite/gdb.btrace/stepi.exp | 12 ++-- gdb/testsuite/gdb.btrace/tailcall.exp | 12 ++-- .../gdb.btrace/unknown_functions.exp | 8 +-- .../gdb.dwarf2/dw2-undefined-ret-addr.exp | 4 +- gdb/testsuite/lib/gdb.exp | 11 ++++ 20 files changed, 130 insertions(+), 161 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index d906a13dc81..11537330cf3 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,26 @@ +2015-04-01 Pierre-Marie de Rodat + + * gdb.ada/complete.exp: Remove "multi_line". + * gdb.ada/info_exc.exp: Remove "multi_line". + * gdb.ada/packed_tagged.exp: Remove "multi_line". + * gdb.ada/ptype_field.exp: Remove "multi_line". + * gdb.ada/sym_print_name.exp: Remove "multi_line". + * gdb.ada/tagged.exp: Remove "multi_line". + * gdb.btrace/buffer-size.exp: Replace [join [list ...]] with + [multi_line ...] + * gdb.btrace/delta.exp: Likewise. + * gdb.btrace/exception.exp: Likewise. + * gdb.btrace/function_call_history.exp: Likewise. + * gdb.btrace/instruction_history.exp: Likewise. + * gdb.btrace/nohist.exp: Likewise. + * gdb.btrace/record_goto.exp: Likewise. + * gdb.btrace/segv.exp: Likewise. + * gdb.btrace/stepi.exp: Likewise. + * gdb.btrace/tailcall.exp: Likewise. + * gdb.btrace/unknown_functions.exp: Likewise. + * gdb.dwarf2/dw2-undefined-ret-addr.exp: Likewise. + * lib/gdb.exp: Add the "multi_line" helper. + 2015-04-01 Pedro Alves * gdb.threads/tid-reuse.c: New file. diff --git a/gdb/testsuite/gdb.ada/complete.exp b/gdb/testsuite/gdb.ada/complete.exp index 1dc9cba489d..9919bdf9ef3 100644 --- a/gdb/testsuite/gdb.ada/complete.exp +++ b/gdb/testsuite/gdb.ada/complete.exp @@ -44,16 +44,6 @@ proc test_gdb_no_completion { expr } { gdb_test_no_output "complete p $expr" } -# A convenience function that joins all the arguments together, -# with a regexp that matches zero-or-more end of lines in between -# each argument. This function is ideal to write the expected output -# of a GDB command that generates more than a couple of lines, as -# this allows us to write each line as a separate string, which is -# easier to read by a human being. - -proc multi_line { args } { - return [join $args "\[\r\n\]*"] -} # Try a global variable, only one match should be found: test_gdb_complete "my_glob" \ diff --git a/gdb/testsuite/gdb.ada/info_exc.exp b/gdb/testsuite/gdb.ada/info_exc.exp index 3f21218264c..add83c5f933 100644 --- a/gdb/testsuite/gdb.ada/info_exc.exp +++ b/gdb/testsuite/gdb.ada/info_exc.exp @@ -21,17 +21,6 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } return -1 } -# A convenience function that joins all the arguments together, -# with a regexp that matches zero-or-more end of lines in between -# each argument. This function is ideal to write the expected output -# of a GDB command that generates more than a couple of lines, as -# this allows us to write each line as a separate string, which is -# easier to read by a human being. - -proc multi_line { args } { - return [join $args "\[\r\n\]*"] -} - clean_restart ${testfile} if ![runto_main] then { diff --git a/gdb/testsuite/gdb.ada/packed_tagged.exp b/gdb/testsuite/gdb.ada/packed_tagged.exp index 02e02eaddb7..4187702cbaa 100644 --- a/gdb/testsuite/gdb.ada/packed_tagged.exp +++ b/gdb/testsuite/gdb.ada/packed_tagged.exp @@ -21,17 +21,6 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } return -1 } -# A convenience function that joins all the arguments together, -# with a regexp that matches zero-or-more end of lines in between -# each argument. This function is ideal to write the expected output -# of a GDB command that generates more than a couple of lines, as -# this allows us to write each line as a separate string, which is -# easier to read by a human being. - -proc multi_line { args } { - return [join $args "\[\r\n\]*"] -} - clean_restart ${testfile} set bp_location [gdb_get_line_number "STOP" ${testdir}/comp_bug.adb] diff --git a/gdb/testsuite/gdb.ada/ptype_field.exp b/gdb/testsuite/gdb.ada/ptype_field.exp index caf99bad549..b4eb8f6553f 100644 --- a/gdb/testsuite/gdb.ada/ptype_field.exp +++ b/gdb/testsuite/gdb.ada/ptype_field.exp @@ -21,17 +21,6 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional return -1 } -# A convenience function that joins all the arguments together, -# with a regexp that matches zero-or-more end of lines in between -# each argument. This function is ideal to write the expected output -# of a GDB command that generates more than a couple of lines, as -# this allows us to write each line as a separate string, which is -# easier to read by a human being. - -proc multi_line { args } { - return [join $args "\[\r\n\]*"] -} - clean_restart ${testfile} set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb] diff --git a/gdb/testsuite/gdb.ada/sym_print_name.exp b/gdb/testsuite/gdb.ada/sym_print_name.exp index c78793e06e1..f942fdf68b0 100644 --- a/gdb/testsuite/gdb.ada/sym_print_name.exp +++ b/gdb/testsuite/gdb.ada/sym_print_name.exp @@ -21,17 +21,6 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } return -1 } -# A convenience function that joins all the arguments together, -# with a regexp that matches zero-or-more end of lines in between -# each argument. This function is ideal to write the expected output -# of a GDB command that generates more than a couple of lines, as -# this allows us to write each line as a separate string, which is -# easier to read by a human being. - -proc multi_line { args } { - return [join $args "\[\r\n\]*"] -} - clean_restart ${testfile} set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb] diff --git a/gdb/testsuite/gdb.ada/tagged.exp b/gdb/testsuite/gdb.ada/tagged.exp index 9f40a960b9f..f4281486912 100644 --- a/gdb/testsuite/gdb.ada/tagged.exp +++ b/gdb/testsuite/gdb.ada/tagged.exp @@ -21,17 +21,6 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } return -1 } -# A convenience function that joins all the arguments together, -# with a regexp that matches zero-or-more end of lines in between -# each argument. This function is ideal to write the expected output -# of a GDB command that generates more than a couple of lines, as -# this allows us to write each line as a separate string, which is -# easier to read by a human being. - -proc multi_line { args } { - return [join $args "\[\r\n\]*"] -} - clean_restart ${testfile} set bp_location [gdb_get_line_number "START" ${testdir}/foo.adb] diff --git a/gdb/testsuite/gdb.btrace/buffer-size.exp b/gdb/testsuite/gdb.btrace/buffer-size.exp index 1f10668bf6e..86d8270056b 100644 --- a/gdb/testsuite/gdb.btrace/buffer-size.exp +++ b/gdb/testsuite/gdb.btrace/buffer-size.exp @@ -35,12 +35,12 @@ gdb_test "show record btrace bts buffer-size" "The record/replay bts buffer size gdb_test_no_output "record btrace bts" gdb_test "show record btrace bts buffer-size" "The record/replay bts buffer size is 1\.\r" "bts buffer size while recording" -gdb_test "info record" [join [list \ +gdb_test "info record" [multi_line \ "Active record target: record-btrace" \ "Recording format: Branch Trace Store\." \ "Buffer size: 4kB\." \ "Recorded 0 instructions in 0 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \ - ] "\r\n"] "info record with small bts buffer" + ] "info record with small bts buffer" gdb_test "record stop" ".*" "stop recording with small bts buffer" gdb_test_no_output "set record btrace bts buffer-size 0" @@ -48,10 +48,10 @@ gdb_test "show record btrace bts buffer-size" "The record/replay bts buffer size gdb_test_no_output "record btrace bts" gdb_test "show record btrace bts buffer-size" "The record/replay bts buffer size is unlimited\.\r" "unlimited bts buffer size while recording" -gdb_test "info record" [join [list \ +gdb_test "info record" [multi_line \ "Active record target: record-btrace" \ "Recording format: Branch Trace Store\." \ "Buffer size: .*\." \ "Recorded 0 instructions in 0 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \ - ] "\r\n"] "info record with unlimited bts buffer" + ] "info record with unlimited bts buffer" gdb_test "record stop" ".*" "stop recording with unlimited bts buffer" diff --git a/gdb/testsuite/gdb.btrace/delta.exp b/gdb/testsuite/gdb.btrace/delta.exp index fed22f11e98..88f7ba52f7b 100644 --- a/gdb/testsuite/gdb.btrace/delta.exp +++ b/gdb/testsuite/gdb.btrace/delta.exp @@ -37,11 +37,11 @@ gdb_test_no_output "record btrace" # we start without trace with_test_prefix "no trace" { - gdb_test "info record" [join [list \ + gdb_test "info record" [multi_line \ "Active record target: record-btrace" \ "Recording format: .*" \ "Recorded 0 instructions in 0 functions \\\(0 gaps\\\) for .*" \ - ] "\r\n"] + ] gdb_test "record instruction-history" "No trace\." gdb_test "record function-call-history" "No trace\." } @@ -50,11 +50,11 @@ with_test_prefix "no trace" { gdb_test "stepi" proc check_trace {} { - gdb_test "info record" [join [list \ + gdb_test "info record" [multi_line \ "Active record target: record-btrace" \ "Recording format: .*" \ "Recorded 1 instructions in 1 functions \\\(0 gaps\\\) for .*" \ - ] "\r\n"] + ] gdb_test "record instruction-history /f 1" \ "1\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tmov *\\\$0x0,%eax\r" gdb_test "record function-call-history /c 1" "1\tmain" @@ -71,17 +71,17 @@ with_test_prefix "twice" { # check that we can reverse-stepi that instruction gdb_test "reverse-stepi" -gdb_test "info record" [join [list \ +gdb_test "info record" [multi_line \ "Active record target: record-btrace" \ "Recording format: .*" \ "Recorded 1 instructions in 1 functions \\\(0 gaps\\\) for .*" \ "Replay in progress\. At instruction 1\." \ - ] "\r\n"] "reverse-stepi" + ] "reverse-stepi" # and back gdb_test "stepi" -gdb_test "info record" [join [list \ +gdb_test "info record" [multi_line \ "Active record target: record-btrace" \ "Recording format: .*" \ "Recorded 1 instructions in 1 functions \\\(0 gaps\\\) for .*" \ - ] "\r\n"] "and back" + ] "and back" diff --git a/gdb/testsuite/gdb.btrace/exception.exp b/gdb/testsuite/gdb.btrace/exception.exp index 0c432736cac..075e6cf2581 100755 --- a/gdb/testsuite/gdb.btrace/exception.exp +++ b/gdb/testsuite/gdb.btrace/exception.exp @@ -48,25 +48,25 @@ gdb_continue_to_breakpoint "cont to bp.2" ".*$srcfile:$bp_2\r\n.*" # show the flat branch trace send_gdb "record function-call-history 1\n" gdb_expect_list "flat" "\r\n$gdb_prompt $" [list \ - [join [list \ + [multi_line \ "1\tmain\\(\\)" \ "2\ttest\\(\\)" \ "3\tfoo\\(\\)" \ "4\tbar\\(\\)" \ "5\tbad\\(\\)\r" \ - ] "\r\n"] \ + ] \ "" \ "\[0-9\]*\ttest\\(\\)"] # show the branch trace with calls indented send_gdb "record function-call-history /c 1\n" gdb_expect_list "indented" "\r\n$gdb_prompt $" [list \ - [join [list \ + [multi_line \ "1\tmain\\(\\)" \ "2\t test\\(\\)" \ "3\t foo\\(\\)" \ "4\t bar\\(\\)" \ "5\t bad\\(\\)\r" \ - ] "\r\n"] \ + ] \ "" \ "\[0-9\]*\t test\\(\\)"] diff --git a/gdb/testsuite/gdb.btrace/function_call_history.exp b/gdb/testsuite/gdb.btrace/function_call_history.exp index 2914bf27c1a..af4cae99aad 100644 --- a/gdb/testsuite/gdb.btrace/function_call_history.exp +++ b/gdb/testsuite/gdb.btrace/function_call_history.exp @@ -38,7 +38,7 @@ gdb_breakpoint $bp_location gdb_continue_to_breakpoint "cont to $bp_location" ".*$testfile.c:$bp_location.*" proc rec_fun_all {} { - gdb_test "record function-call-history 1" [join [list \ + gdb_test "record function-call-history 1" [multi_line \ "1\tmain" \ "2\tinc" \ "3\tmain" \ @@ -59,7 +59,7 @@ proc rec_fun_all {} { "18\tinc" \ "19\tmain" \ "20\tinc" \ - "21\tmain"] "\r\n"] + "21\tmain"] } # show function call history with unlimited size, we expect to see all 21 entries @@ -72,7 +72,7 @@ with_test_prefix "size 21" rec_fun_all # show first 15 entries gdb_test_no_output "set record function-call-history-size 15" -gdb_test "record function-call-history 1" [join [list \ +gdb_test "record function-call-history 1" [multi_line \ "1\tmain" \ "2\tinc" \ "3\tmain" \ @@ -87,16 +87,16 @@ gdb_test "record function-call-history 1" [join [list \ "12\tinc" \ "13\tmain" \ "14\tinc" \ - "15\tmain"] "\r\n"] "forward - 1" + "15\tmain"] "forward - 1" # show last 6 entries -gdb_test "record function-call-history +" [join [list \ +gdb_test "record function-call-history +" [multi_line \ "16\tinc" \ "17\tmain" \ "18\tinc" \ "19\tmain" \ "20\tinc" \ - "21\tmain"] "\r\n"] "forward - 2" + "21\tmain"] "forward - 2" # moving further should not work gdb_test "record function-call-history +" "At the end of the branch trace record\\." "forward - 3" @@ -105,7 +105,7 @@ gdb_test "record function-call-history +" "At the end of the branch trace record gdb_test "record function-call-history +" "At the end of the branch trace record\\." "forward - 4" # moving back showing the latest 15 function calls -gdb_test "record function-call-history -" [join [list \ +gdb_test "record function-call-history -" [multi_line \ "7\tmain" \ "8\tinc" \ "9\tmain" \ @@ -120,16 +120,16 @@ gdb_test "record function-call-history -" [join [list \ "18\tinc" \ "19\tmain" \ "20\tinc" \ - "21\tmain"] "\r\n"] "backward - 1" + "21\tmain"] "backward - 1" # moving further back shows the 6 first function calls -gdb_test "record function-call-history -" [join [list \ +gdb_test "record function-call-history -" [multi_line \ "1\tmain" \ "2\tinc" \ "3\tmain" \ "4\tinc" \ "5\tmain" \ - "6\tinc"] "\r\n"] "backward - 2" + "6\tinc"] "backward - 2" # moving further back shouldn't work gdb_test "record function-call-history -" "At the start of the branch trace record\\." "backward - 3" @@ -141,7 +141,7 @@ gdb_test "record function-call-history -" "At the start of the branch trace reco gdb_test_no_output "set filename-display basename" # moving forward again, but this time with file and line number, expected to see the first 15 entries -gdb_test "record function-call-history /l +" [join [list \ +gdb_test "record function-call-history /l +" [multi_line \ "\[0-9\]*\tmain\tat $srcfile:40,41" \ "\[0-9\]*\tinc\tat $srcfile:22,24" \ "\[0-9\]*\tmain\tat $srcfile:40,41" \ @@ -157,30 +157,30 @@ gdb_test "record function-call-history /l +" [join [list \ "\[0-9\]*\tmain\tat $srcfile:40,41" \ "\[0-9\]*\tinc\tat $srcfile:22,24" \ "\[0-9\]*\tmain\tat $srcfile:40,41" \ - ] "\r\n"] "forward /l - 1" + ] "forward /l - 1" # moving forward and expect to see the latest 6 entries -gdb_test "record function-call-history /l +" [join [list \ +gdb_test "record function-call-history /l +" [multi_line \ "\[0-9\]*\tinc\tat $srcfile:22,24" \ "\[0-9\]*\tmain\tat $srcfile:40,41" \ "\[0-9\]*\tinc\tat $srcfile:22,24" \ "\[0-9\]*\tmain\tat $srcfile:40,41" \ "\[0-9\]*\tinc\tat $srcfile:22,24" \ "\[0-9\]*\tmain\tat $srcfile:40,43" \ - ] "\r\n"] "forward /l - 2" + ] "forward /l - 2" # moving further forward shouldn't work gdb_test "record function-call-history /l +" "At the end of the branch trace record\\." "forward /l - 3" gdb_test "record function-call-history /l" "At the end of the branch trace record\\." "forward /l - 4" -set expected_range [join [list \ +set expected_range [multi_line \ "4\tinc" \ "5\tmain" \ "6\tinc" \ "7\tmain" \ "8\tinc" \ "9\tmain" \ - "10\tinc"] "\r\n"] + "10\tinc"] # show functions in instruction range gdb_test "record function-call-history 4,10" $expected_range @@ -196,7 +196,7 @@ gdb_continue_to_breakpoint "cont to $bp_location" ".*$testfile.c:$bp_location.*" # at this point we expect to have main, fib, ..., fib, main, where fib occurs 9 times, # so we limit the output to only show the latest 11 function calls gdb_test_no_output "set record function-call-history-size 11" -gdb_test "record function-call-history" [join [list \ +gdb_test "record function-call-history" [multi_line \ "21\tmain" \ "22\tfib" \ "23\tfib" \ @@ -207,10 +207,10 @@ gdb_test "record function-call-history" [join [list \ "28\tfib" \ "29\tfib" \ "30\tfib" \ - "31\tmain"] "\r\n"] "recursive" + "31\tmain"] "recursive" # show indented function call history for fib -gdb_test "record function-call-history /c 21, +11" [join [list \ +gdb_test "record function-call-history /c 21, +11" [multi_line \ "21\tmain" \ "22\t fib" \ "23\t fib" \ @@ -222,7 +222,7 @@ gdb_test "record function-call-history /c 21, +11" [join [list \ "29\t fib" \ "30\t fib" \ "31\tmain" \ - ] "\r\n"] "indented" + ] "indented" # make sure we can handle incomplete trace with respect to indentation if ![runto_main] { @@ -245,11 +245,11 @@ gdb_breakpoint $bp_location gdb_continue_to_breakpoint "cont to bp.2" ".*$testfile.c:$bp_location\r\n.*" # let's look at the trace. we expect to see the tail of the above listing. -gdb_test "record function-call-history /c" [join [list \ +gdb_test "record function-call-history /c" [multi_line \ "1\t fib" \ "2\t fib" \ "3\t fib" \ "4\t fib" \ "5\t fib" \ "6\tmain" \ - ] "\r\n"] "indented tail" + ] "indented tail" diff --git a/gdb/testsuite/gdb.btrace/instruction_history.exp b/gdb/testsuite/gdb.btrace/instruction_history.exp index a7b57e53f97..ba06647f9ab 100644 --- a/gdb/testsuite/gdb.btrace/instruction_history.exp +++ b/gdb/testsuite/gdb.btrace/instruction_history.exp @@ -65,37 +65,37 @@ if { $traced != 11 } { } # test that we see the expected instructions -gdb_test "record instruction-history 3,7" [join [list \ +gdb_test "record instruction-history 3,7" [multi_line \ "3\t 0x\[0-9a-f\]+ :\tje 0x\[0-9a-f\]+ " \ "4\t 0x\[0-9a-f\]+ :\tdec %eax" \ "5\t 0x\[0-9a-f\]+ :\tjmp 0x\[0-9a-f\]+ " \ "6\t 0x\[0-9a-f\]+ :\tcmp \\\$0x0,%eax" \ "7\t 0x\[0-9a-f\]+ :\tje 0x\[0-9a-f\]+ \r" \ - ] "\r\n"] + ] -gdb_test "record instruction-history /f 3,+5" [join [list \ +gdb_test "record instruction-history /f 3,+5" [multi_line \ "3\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ " \ "4\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec %eax" \ "5\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp 0x\[0-9a-f\]+ " \ "6\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp \\\$0x0,%eax" \ "7\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ \r" \ - ] "\r\n"] + ] -gdb_test "record instruction-history /p 7,-5" [join [list \ +gdb_test "record instruction-history /p 7,-5" [multi_line \ "3\t0x\[0-9a-f\]+ :\tje 0x\[0-9a-f\]+ " \ "4\t0x\[0-9a-f\]+ :\tdec %eax" \ "5\t0x\[0-9a-f\]+ :\tjmp 0x\[0-9a-f\]+ " \ "6\t0x\[0-9a-f\]+ :\tcmp \\\$0x0,%eax" \ "7\t0x\[0-9a-f\]+ :\tje 0x\[0-9a-f\]+ \r" \ - ] "\r\n"] + ] -gdb_test "record instruction-history /pf 3,7" [join [list \ +gdb_test "record instruction-history /pf 3,7" [multi_line \ "3\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ " \ "4\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec %eax" \ "5\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp 0x\[0-9a-f\]+ " \ "6\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp \\\$0x0,%eax" \ "7\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ \r" \ - ] "\r\n"] + ] gdb_test "record instruction-history 3,3" "3\t 0x\[0-9a-f\]+ :\tje 0x\[0-9a-f\]+ \r" diff --git a/gdb/testsuite/gdb.btrace/nohist.exp b/gdb/testsuite/gdb.btrace/nohist.exp index 0084f5a0582..f926ed044b2 100644 --- a/gdb/testsuite/gdb.btrace/nohist.exp +++ b/gdb/testsuite/gdb.btrace/nohist.exp @@ -31,11 +31,11 @@ if ![runto_main] { } proc check_not_replaying {} { - gdb_test "info record" [join [list \ + gdb_test "info record" [multi_line \ "Active record target: record-btrace" \ "Recording format: .*" \ "Recorded 0 instructions in 0 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \ - ] "\r\n"] + ] } gdb_test_no_output "record btrace" diff --git a/gdb/testsuite/gdb.btrace/record_goto.exp b/gdb/testsuite/gdb.btrace/record_goto.exp index 7485fc7908e..f4096e0f453 100644 --- a/gdb/testsuite/gdb.btrace/record_goto.exp +++ b/gdb/testsuite/gdb.btrace/record_goto.exp @@ -58,7 +58,7 @@ gdb_test_no_output "record btrace" gdb_test "next" # start by listing all functions -gdb_test "record function-call-history /ci 1, +20" [join [list \ +gdb_test "record function-call-history /ci 1, +20" [multi_line \ "1\tmain\tinst 1,1" \ "2\t fun4\tinst 2,4" \ "3\t fun1\tinst 5,8" \ @@ -75,118 +75,118 @@ gdb_test "record function-call-history /ci 1, +20" [join [list \ "14\t fun2\tinst 35,36" \ "15\t fun3\tinst 37,38" \ "16\t fun4\tinst 39,40" \ - ] "\r\n"] + ] # let's see if we can go back in history gdb_test "record goto 19" ".*fun4 \\(\\) at record_goto.c:43.*" # the function call history should start at the new location -gdb_test "record function-call-history /ci" [join [list \ +gdb_test "record function-call-history /ci" [multi_line \ "8\t fun4\tinst 19,19" \ "9\t fun3\tinst 20,22" \ "10\t fun1\tinst 23,26" \ - ] "\r\n"] "function-call-history from 19 forwards" + ] "function-call-history from 19 forwards" # the instruction history should start at the new location -gdb_test "record instruction-history" [join [list \ +gdb_test "record instruction-history" [multi_line \ "19.*" \ "20.*" \ "21.*" \ - ] "\r\n"] "instruction-history from 19 forwards" + ] "instruction-history from 19 forwards" # let's go to another place in the history gdb_test "record goto 27" ".*fun3 \\(\\) at record_goto.c:35.*" # check the back trace at that location -gdb_test "backtrace" [join [list \ +gdb_test "backtrace" [multi_line \ "#0.*fun3.*at record_goto.c:35.*" \ "#1.*fun4.*at record_goto.c:43.*" \ "#2.*main.*at record_goto.c:49.*" \ "Backtrace stopped: not enough registers or memory available to unwind further" \ - ] "\r\n"] + ] # walk the backtrace gdb_test "up" ".*fun4.*at record_goto.c:43.*" "up to fun4" gdb_test "up" ".*main.*at record_goto.c:49.*" "up to main" # the function call history should start at the new location -gdb_test "record function-call-history /ci -" [join [list \ +gdb_test "record function-call-history /ci -" [multi_line \ "9\t fun3\tinst 20,22" \ "10\t fun1\tinst 23,26" \ "11\t fun3\tinst 27,27" \ - ] "\r\n"] "function-call-history from 27 backwards" + ] "function-call-history from 27 backwards" # the instruction history should start at the new location -gdb_test "record instruction-history -" [join [list \ +gdb_test "record instruction-history -" [multi_line \ "25.*" \ "26.*" \ "27.*" \ - ] "\r\n"] "instruction-history from 27 backwards" + ] "instruction-history from 27 backwards" # test that we can go to the begin of the trace gdb_test "record goto begin" ".*main \\(\\) at record_goto.c:49.*" # check that we're filling up the context correctly -gdb_test "record function-call-history /ci -" [join [list \ +gdb_test "record function-call-history /ci -" [multi_line \ "1\tmain\tinst 1,1" \ "2\t fun4\tinst 2,4" \ "3\t fun1\tinst 5,8" \ - ] "\r\n"] "function-call-history from begin backwards" + ] "function-call-history from begin backwards" # check that we're filling up the context correctly -gdb_test "record instruction-history -" [join [list \ +gdb_test "record instruction-history -" [multi_line \ "1.*" \ "2.*" \ "3.*" \ - ] "\r\n"] "instruction-history from begin backwards" + ] "instruction-history from begin backwards" # we should get the exact same history from the first instruction gdb_test "record goto 2" ".*fun4 \\(\\) at record_goto.c:40.*" # check that we're filling up the context correctly -gdb_test "record function-call-history /ci -" [join [list \ +gdb_test "record function-call-history /ci -" [multi_line \ "1\tmain\tinst 1,1" \ "2\t fun4\tinst 2,4" \ "3\t fun1\tinst 5,8\r" \ - ] "\r\n"] "function-call-history from 2 backwards" + ] "function-call-history from 2 backwards" # check that we're filling up the context correctly -gdb_test "record instruction-history -" [join [list \ +gdb_test "record instruction-history -" [multi_line \ "1.*" \ "2.*" \ "3.*" \ - ] "\r\n"] "instruction-history from 2 backwards" + ] "instruction-history from 2 backwards" # check that we can go to the end of the trace gdb_test "record goto end" ".*main \\(\\) at record_goto.c:50.*" # check that we're filling up the context correctly -gdb_test "record function-call-history /ci" [join [list \ +gdb_test "record function-call-history /ci" [multi_line \ "14\t fun2\tinst 35,36" \ "15\t fun3\tinst 37,38" \ "16\t fun4\tinst 39,40" \ - ] "\r\n"] "function-call-history from end forwards" + ] "function-call-history from end forwards" # check that we're filling up the context correctly -gdb_test "record instruction-history" [join [list \ +gdb_test "record instruction-history" [multi_line \ "38.*" \ "39.*" \ "40.*\r" \ - ] "\r\n"] "instruction-history from end forwards" + ] "instruction-history from end forwards" # we should get the exact same history from the second to last instruction gdb_test "record goto 39" ".*fun4 \\(\\) at record_goto.c:44.*" # check that we're filling up the context correctly -gdb_test "record function-call-history /ci" [join [list \ +gdb_test "record function-call-history /ci" [multi_line \ "14\t fun2\tinst 35,36" \ "15\t fun3\tinst 37,38" \ "16\t fun4\tinst 39,40\r" \ - ] "\r\n"] "function-call-history from 39 forwards" + ] "function-call-history from 39 forwards" # check that we're filling up the context correctly -gdb_test "record instruction-history" [join [list \ +gdb_test "record instruction-history" [multi_line \ "38.*" \ "39.*" \ "40.*\r" \ - ] "\r\n"] "instruction-history from 39 forwards" + ] "instruction-history from 39 forwards" diff --git a/gdb/testsuite/gdb.btrace/segv.exp b/gdb/testsuite/gdb.btrace/segv.exp index cc7e0323594..71958cf2908 100644 --- a/gdb/testsuite/gdb.btrace/segv.exp +++ b/gdb/testsuite/gdb.btrace/segv.exp @@ -31,10 +31,10 @@ if ![runto_main] { # trace the test code gdb_test_no_output "record btrace" -gdb_test "continue" [join [list \ +gdb_test "continue" [multi_line \ "Program received signal SIGSEGV, Segmentation fault\." \ "0x0* in \\\?\\\? \\\(\\\)" \ - ] "\r\n"] "cont to segv" + ] "cont to segv" # we cannot do any high-level stepping gdb_test "reverse-finish" "Cannot find bounds of current function" diff --git a/gdb/testsuite/gdb.btrace/stepi.exp b/gdb/testsuite/gdb.btrace/stepi.exp index fd018acdf07..7e246284e3b 100644 --- a/gdb/testsuite/gdb.btrace/stepi.exp +++ b/gdb/testsuite/gdb.btrace/stepi.exp @@ -47,12 +47,12 @@ if ![runto_main] { } proc check_replay_at { insn } { - gdb_test "info record" [join [list \ + gdb_test "info record" [multi_line \ "Active record target: record-btrace" \ ".*" \ "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for .*" \ "Replay in progress\. At instruction $insn\." \ - ] "\r\n"] + ] } # trace the call to the test function @@ -72,11 +72,11 @@ with_test_prefix "stepi to 40" { check_replay_at 40 } # with the next step, we stop replaying gdb_test "stepi" ".*main\.3.*" -gdb_test "info record" [join [list \ +gdb_test "info record" [multi_line \ "Active record target: record-btrace" \ ".*" \ "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \ - ] "\r\n"] "stepi to live" + ] "stepi to live" # let's try nexti gdb_test "reverse-nexti" ".*main\.2.*" @@ -88,11 +88,11 @@ with_test_prefix "reverse-nexti - 1" { check_replay_at 1 } # but we can step back again gdb_test "nexti" ".*main\.3.*" "next, 1.5" -gdb_test "info record" [join [list \ +gdb_test "info record" [multi_line \ "Active record target: record-btrace" \ ".*" \ "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \ - ] "\r\n"] "nexti back" + ] "nexti back" # let's step from a goto position somewhere in the middle gdb_test "record goto 22" ".*fun3\.2.*" diff --git a/gdb/testsuite/gdb.btrace/tailcall.exp b/gdb/testsuite/gdb.btrace/tailcall.exp index b2ce415ca25..18b26cbfb94 100644 --- a/gdb/testsuite/gdb.btrace/tailcall.exp +++ b/gdb/testsuite/gdb.btrace/tailcall.exp @@ -56,31 +56,31 @@ gdb_test_no_output "record btrace" gdb_test "next 2" # show the flat branch trace -gdb_test "record function-call-history 1" [join [list \ +gdb_test "record function-call-history 1" [multi_line \ "1\tmain" \ "2\tfoo" \ "3\tbar" \ "4\tmain" \ - ] "\r\n"] "flat" + ] "flat" # show the branch trace with calls indented -gdb_test "record function-call-history /c 1" [join [list \ +gdb_test "record function-call-history /c 1" [multi_line \ "1\tmain" \ "2\t foo" \ "3\t bar" \ "4\tmain" \ - ] "\r\n"] "indented" + ] "indented" # go into bar gdb_test "record goto 4" ".*bar \\(\\) at .*tailcall.c:24\r\n.*" # check the backtrace -gdb_test "backtrace" [join [list \ +gdb_test "backtrace" [multi_line \ "#0.*bar \\(\\) at tailcall.c:24" \ "#1.*foo \\(\\) at tailcall.c:29" \ "#2.*main \\(\\) at tailcall.c:37" \ "Backtrace stopped: not enough registers or memory available to unwind further" \ - ] "\r\n"] + ] # walk the backtrace gdb_test "up" "#1\[^\r\n\]*foo \\(\\) at tailcall.c:29\r\n.*" "up to foo" diff --git a/gdb/testsuite/gdb.btrace/unknown_functions.exp b/gdb/testsuite/gdb.btrace/unknown_functions.exp index 12e35ffb842..dbeae696e9f 100644 --- a/gdb/testsuite/gdb.btrace/unknown_functions.exp +++ b/gdb/testsuite/gdb.btrace/unknown_functions.exp @@ -40,7 +40,7 @@ gdb_test_no_output "record btrace" gdb_continue_to_breakpoint "cont to test" ".*test.*" # show the flat branch trace -gdb_test "record function-call-history 1" [join [list \ +gdb_test "record function-call-history 1" [multi_line \ "1\ttest" \ "2\t\\\?\\\?" \ "3\t\\\?\\\?" \ @@ -48,10 +48,10 @@ gdb_test "record function-call-history 1" [join [list \ "5\ttest" \ "6\tmain" \ "7\ttest" \ - ] "\r\n"] "flat" + ] "flat" # show the branch trace with calls indented -gdb_test "record function-call-history /c 1" [join [list \ +gdb_test "record function-call-history /c 1" [multi_line \ "1\t test" \ "2\t \\\?\\\?" \ "3\t \\\?\\\?" \ @@ -59,4 +59,4 @@ gdb_test "record function-call-history /c 1" [join [list \ "5\t test" \ "6\tmain" \ "7\t test" \ - ] "\r\n"] "indented" + ] "indented" diff --git a/gdb/testsuite/gdb.dwarf2/dw2-undefined-ret-addr.exp b/gdb/testsuite/gdb.dwarf2/dw2-undefined-ret-addr.exp index 5fd77c0729d..94e66298a98 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-undefined-ret-addr.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-undefined-ret-addr.exp @@ -46,7 +46,7 @@ gdb_test "up" \ # "info frame" unwinds the PC for "saved ... = ". Make sure that # doesn't cause an error, and shows "". -gdb_test "info frame" [join [list \ +gdb_test "info frame" [multi_line \ "Stack level 0, frame at $hex\:" \ " rip = $hex in stop_frame \\(dw2-undefined-ret-addr\\.c:22\\); saved rip = " \ " Outermost frame: outermost" \ @@ -55,4 +55,4 @@ gdb_test "info frame" [join [list \ " Locals at $hex, Previous frame's sp is $hex" \ " Saved registers\:" \ " rbp at $hex.*" \ -] "\r\n"] +] diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 0041adf7a64..6b42997274a 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -5119,5 +5119,16 @@ proc capture_command_output { command prefix } { return $output_string } +# A convenience function that joins all the arguments together, with a +# regexp that matches exactly one end of line in between each argument. +# This function is ideal to write the expected output of a GDB command +# that generates more than a couple of lines, as this allows us to write +# each line as a separate string, which is easier to read by a human +# being. + +proc multi_line { args } { + return [join $args "\r\n"] +} + # Always load compatibility stuff. load_lib future.exp -- 2.30.2