summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.btrace
diff options
context:
space:
mode:
authorMarkus Metzger <markus.t.metzger@intel.com>2013-12-18 14:47:17 +0100
committerMarkus Metzger <markus.t.metzger@intel.com>2014-01-16 12:45:09 +0100
commit724c7dd8a4520d4020883b4ae3a3f2fa489acb1a (patch)
tree85624f783ecf58e38e565411a26cbd6106ad6cc0 /gdb/testsuite/gdb.btrace
parent6d78d93b8d3854dcab6c90307b19f43e1a93f592 (diff)
btrace, test: fix multi-line btrace tests
For testing multi-line test output, gdb.btrace tests used the following pattern: gdb_test "..." " ...\r ..." Change this to: gdb_test "..." [join [list \ "..." \ "..."] "\r\n"] Also extract repeated tests into a test function and shorten or remove test messages. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> testsuite/ * gdb.btrace/function_call_history.exp: Update * gdb.btrace/instruction_history.exp: Update.
Diffstat (limited to 'gdb/testsuite/gdb.btrace')
-rw-r--r--gdb/testsuite/gdb.btrace/function_call_history.exp247
-rw-r--r--gdb/testsuite/gdb.btrace/instruction_history.exp57
2 files changed, 145 insertions, 159 deletions
diff --git a/gdb/testsuite/gdb.btrace/function_call_history.exp b/gdb/testsuite/gdb.btrace/function_call_history.exp
index 5dd874a736..7ee4e66df6 100644
--- a/gdb/testsuite/gdb.btrace/function_call_history.exp
+++ b/gdb/testsuite/gdb.btrace/function_call_history.exp
@@ -37,167 +37,150 @@ set bp_location [gdb_get_line_number "bp.1" $testfile.c]
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 0" [join [list \
+ "0\tmain" \
+ "1\tinc" \
+ "2\tmain" \
+ "3\tinc" \
+ "4\tmain" \
+ "5\tinc" \
+ "6\tmain" \
+ "7\tinc" \
+ "8\tmain" \
+ "9\tinc" \
+ "10\tmain" \
+ "11\tinc" \
+ "12\tmain" \
+ "13\tinc" \
+ "14\tmain" \
+ "15\tinc" \
+ "16\tmain" \
+ "17\tinc" \
+ "18\tmain" \
+ "19\tinc" \
+ "20\tmain"] "\r\n"]
+}
+
# show function call history with unlimited size, we expect to see all 21 entries
gdb_test_no_output "set record function-call-history-size 0"
-gdb_test "record function-call-history" "
-0\tmain\r
-1\tinc\r
-2\tmain\r
-3\tinc\r
-4\tmain\r
-5\tinc\r
-6\tmain\r
-7\tinc\r
-8\tmain\r
-9\tinc\r
-10\tmain\r
-11\tinc\r
-12\tmain\r
-13\tinc\r
-14\tmain\r
-15\tinc\r
-16\tmain\r
-17\tinc\r
-18\tmain\r
-19\tinc\r
-20\tmain\r" "record function-call-history - with size unlimited"
+with_test_prefix "size unlimited" rec_fun_all
# show function call history with size of 21, we expect to see all 21 entries
gdb_test_no_output "set record function-call-history-size 21"
-# show function call history
-gdb_test "record function-call-history 0" "
-0\tmain\r
-1\tinc\r
-2\tmain\r
-3\tinc\r
-4\tmain\r
-5\tinc\r
-6\tmain\r
-7\tinc\r
-8\tmain\r
-9\tinc\r
-10\tmain\r
-11\tinc\r
-12\tmain\r
-13\tinc\r
-14\tmain\r
-15\tinc\r
-16\tmain\r
-17\tinc\r
-18\tmain\r
-19\tinc\r
-20\tmain\r" "record function-call-history - show all 21 entries"
+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 0" "
-0\tmain\r
-1\tinc\r
-2\tmain\r
-3\tinc\r
-4\tmain\r
-5\tinc\r
-6\tmain\r
-7\tinc\r
-8\tmain\r
-9\tinc\r
-10\tmain\r
-11\tinc\r
-12\tmain\r
-13\tinc\r
-14\tmain\r" "record function-call-history - show first 15 entries"
+gdb_test "record function-call-history 0" [join [list \
+ "0\tmain" \
+ "1\tinc" \
+ "2\tmain" \
+ "3\tinc" \
+ "4\tmain" \
+ "5\tinc" \
+ "6\tmain" \
+ "7\tinc" \
+ "8\tmain" \
+ "9\tinc" \
+ "10\tmain" \
+ "11\tinc" \
+ "12\tmain" \
+ "13\tinc" \
+ "14\tmain"] "\r\n"] "forward - 1"
# show last 6 entries
-gdb_test "record function-call-history +" "
-15\tinc\r
-16\tmain\r
-17\tinc\r
-18\tmain\r
-19\tinc\r
-20\tmain\r" "record function-call-history - show last 6 entries"
+gdb_test "record function-call-history +" [join [list \
+ "15\tinc" \
+ "16\tmain" \
+ "17\tinc" \
+ "18\tmain" \
+ "19\tinc" \
+ "20\tmain"] "\r\n"] "forward - 2"
# moving further should not work
-gdb_test "record function-call-history +" "At the end of the branch trace record\\." "record function-call-history - at the end (1)"
+gdb_test "record function-call-history +" "At the end of the branch trace record\\." "forward - 3"
# make sure we cannot move any further a second time
-gdb_test "record function-call-history +" "At the end of the branch trace record\\." "record function-call-history - at the end (2)"
+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 -" "
-6\tmain\r
-7\tinc\r
-8\tmain\r
-9\tinc\r
-10\tmain\r
-11\tinc\r
-12\tmain\r
-13\tinc\r
-14\tmain\r
-15\tinc\r
-16\tmain\r
-17\tinc\r
-18\tmain\r
-19\tinc\r
-20\tmain\r" "record function-call-history - show last 15 entries"
+gdb_test "record function-call-history -" [join [list \
+ "6\tmain" \
+ "7\tinc" \
+ "8\tmain" \
+ "9\tinc" \
+ "10\tmain" \
+ "11\tinc" \
+ "12\tmain" \
+ "13\tinc" \
+ "14\tmain" \
+ "15\tinc" \
+ "16\tmain" \
+ "17\tinc" \
+ "18\tmain" \
+ "19\tinc" \
+ "20\tmain"] "\r\n"] "backward - 1"
# moving further back shows the 6 first function calls
-gdb_test "record function-call-history -" "
-0\tmain\r
-1\tinc\r
-2\tmain\r
-3\tinc\r
-4\tmain\r
-5\tinc\r" "record function-call-history - show first 6 entries"
+gdb_test "record function-call-history -" [join [list \
+ "0\tmain" \
+ "1\tinc" \
+ "2\tmain" \
+ "3\tinc" \
+ "4\tmain" \
+ "5\tinc"] "\r\n"] "backward - 2"
# moving further back shouldn't work
-gdb_test "record function-call-history -" "At the start of the branch trace record\\." "record function-call-history - at the start (1)"
+gdb_test "record function-call-history -" "At the start of the branch trace record\\." "backward - 3"
# make sure we cannot move any further back
-gdb_test "record function-call-history -" "At the start of the branch trace record\\." "record function-call-history - at the start (2)"
+gdb_test "record function-call-history -" "At the start of the branch trace record\\." "backward - 4"
# 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 +" "
-.*$srcfile:40-41\tmain\r
-.*$srcfile:22-24\tinc\r
-.*$srcfile:40-41\tmain\r
-.*$srcfile:22-24\tinc\r
-.*$srcfile:40-41\tmain\r
-.*$srcfile:22-24\tinc\r
-.*$srcfile:40-41\tmain\r
-.*$srcfile:22-24\tinc\r
-.*$srcfile:40-41\tmain\r
-.*$srcfile:22-24\tinc\r
-.*$srcfile:40-41\tmain\r
-.*$srcfile:22-24\tinc\r
-.*$srcfile:40-41\tmain\r
-.*$srcfile:22-24\tinc\r
-.*$srcfile:40-41\tmain\r" "record function-call-history /l - show first 15 entries"
+gdb_test "record function-call-history /l +" [join [list \
+ ".*$srcfile:40-41\tmain" \
+ ".*$srcfile:22-24\tinc" \
+ ".*$srcfile:40-41\tmain" \
+ ".*$srcfile:22-24\tinc" \
+ ".*$srcfile:40-41\tmain" \
+ ".*$srcfile:22-24\tinc" \
+ ".*$srcfile:40-41\tmain" \
+ ".*$srcfile:22-24\tinc" \
+ ".*$srcfile:40-41\tmain" \
+ ".*$srcfile:22-24\tinc" \
+ ".*$srcfile:40-41\tmain" \
+ ".*$srcfile:22-24\tinc" \
+ ".*$srcfile:40-41\tmain" \
+ ".*$srcfile:22-24\tinc" \
+ ".*$srcfile:40-41\tmain"] "\r\n"] "forward /l - 1"
# moving forward and expect to see the latest 6 entries
-gdb_test "record function-call-history /l +" "
-.*$srcfile:22-24\tinc\r
-.*$srcfile:40-41\tmain\r
-.*$srcfile:22-24\tinc\r
-.*$srcfile:40-41\tmain\r
-.*$srcfile:22-24\tinc\r
-.*$srcfile:40-43\tmain\r" "record function-call-history /l - show last 6 entries"
+gdb_test "record function-call-history /l +" [join [list \
+ ".*$srcfile:22-24\tinc" \
+ ".*$srcfile:40-41\tmain" \
+ ".*$srcfile:22-24\tinc" \
+ ".*$srcfile:40-41\tmain" \
+ ".*$srcfile:22-24\tinc" \
+ ".*$srcfile:40-43\tmain"] "\r\n"] "forward /l - 2"
# moving further forward shouldn't work
-gdb_test "record function-call-history /l +" "At the end of the branch trace record\\." "record function-call-history /l - at the end (1)"
-gdb_test "record function-call-history /l" "At the end of the branch trace record\\." "record function-call-history /l - at the end (2)"
-
-set expected_range "3\tinc\r
-4\tmain\r
-5\tinc\r
-6\tmain\r
-7\tinc\r
-8\tmain\r
-9\tinc\r"
+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 \
+ "3\tinc" \
+ "4\tmain" \
+ "5\tinc" \
+ "6\tmain" \
+ "7\tinc" \
+ "8\tmain" \
+ "9\tinc"] "\r\n"]
# show functions in instruction range
-gdb_test "record function-call-history 3,10" $expected_range "absolute instruction range"
-gdb_test "record function-call-history 3,+7" $expected_range "relative positive instruction range"
-gdb_test "record function-call-history 10,-7" $expected_range "relative negative instruction range"
+gdb_test "record function-call-history 3,10" $expected_range
+gdb_test "record function-call-history 3,+7" $expected_range
+gdb_test "record function-call-history 10,-7" $expected_range
# set bp after fib recursion and continue
set bp_location [gdb_get_line_number "bp.2" $testfile.c]
@@ -207,7 +190,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 8 times,
# so we limit the output to only show the latest 10 function calls
gdb_test_no_output "set record function-call-history-size 10"
-set message "show recursive function call history"
+set message "recursive"
gdb_test_multiple "record function-call-history" $message {
-re "13\tmain\r\n14\tfib\r\n15\tfib\r\n16\tfib\r\n17\tfib\r\n18\tfib\r\n19\tfib\r\n20\tfib\r\n21\tfib\r\n22 main\r\n$gdb_prompt $" {
pass $message
diff --git a/gdb/testsuite/gdb.btrace/instruction_history.exp b/gdb/testsuite/gdb.btrace/instruction_history.exp
index 695c1a008d..6048ba1c9e 100644
--- a/gdb/testsuite/gdb.btrace/instruction_history.exp
+++ b/gdb/testsuite/gdb.btrace/instruction_history.exp
@@ -65,33 +65,36 @@ if { $traced != 7 } {
}
# test that we see the expected instructions
-gdb_test "record instruction-history 1,6" "
-1\t 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r
-2\t 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tdec %eax\r
-3\t 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tjmp 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r
-4\t 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tcmp \\\$0x0,%eax\r
-5\t 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r"
-
-gdb_test "record instruction-history /f 1,+5" "
-1\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r
-2\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec %eax\r
-3\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r
-4\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp \\\$0x0,%eax\r
-5\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r"
-
-gdb_test "record instruction-history /p 6,-5" "
-1\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r
-2\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tdec %eax\r
-3\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tjmp 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r
-4\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tcmp \\\$0x0,%eax\r
-5\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r"
-
-gdb_test "record instruction-history /pf 1,6" "
-1\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r
-2\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec %eax\r
-3\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r
-4\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp \\\$0x0,%eax\r
-5\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r"
+gdb_test "record instruction-history 1,6" [join [list \
+ "1\t 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+ "2\t 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tdec %eax" \
+ "3\t 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tjmp 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+ "4\t 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tcmp \\\$0x0,%eax" \
+ "5\t 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>"] "\r\n"]
+
+gdb_test "record instruction-history /f 1,+5" [join [list \
+ "1\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+ "2\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec %eax" \
+ "3\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+ "4\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp \\\$0x0,%eax" \
+ "5\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r" \
+] "\r\n"]
+
+gdb_test "record instruction-history /p 6,-5" [join [list \
+ "1\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+ "2\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tdec %eax" \
+ "3\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tjmp 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+ "4\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tcmp \\\$0x0,%eax" \
+ "5\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r" \
+] "\r\n"]
+
+gdb_test "record instruction-history /pf 1,6" [join [list \
+ "1\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+ "2\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec %eax" \
+ "3\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+ "4\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp \\\$0x0,%eax" \
+ "5\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r" \
+] "\r\n"]
# the following tests are checking the iterators
# to avoid lots of regexps, we just check the number of lines that