* gdb.trace/actions.exp: Replace uses of send_gdb / gdb_expect.
* gdb.trace/backtrace.exp: Replace uses of send_gdb / gdb_expect.
* gdb.trace/collection.exp: Replace uses of send_gdb / gdb_expect.
* gdb.trace/deltrace.exp: Replace uses of send_gdb / gdb_expect.
* gdb.trace/infotrace.exp: Replace uses of send_gdb / gdb_expect.
* gdb.trace/limits.exp: Replace uses of send_gdb / gdb_expect.
* gdb.trace/report.exp: Replace uses of send_gdb / gdb_expect.
* gdb.trace/save-trace.exp: Replace uses of send_gdb / gdb_expect.
* gdb.trace/tfind.exp: Replace uses of send_gdb / gdb_expect.
* gdb.trace/tracecmd.exp: Replace uses of send_gdb / gdb_expect.
* gdb.trace/tsv.exp: Replace uses of send_gdb / gdb_expect.
# 5.1 actions of specified tracepoint
-send_gdb "info tracepoints\n"
-gdb_expect {
+gdb_test_multiple "info tracepoints" "5.1a: set three tracepoints, no actions" {
-re "Actions for tracepoint \[0-9\]+:.*$gdb_prompt $" {
fail "5.1a: testsuite failure (tracepoint already has action)!"
}
gdb_trace_setactions "5.5a: set empty actions for first tracepoint" \
"$trcpt1"
-send_gdb "info tracepoints\n"
-gdb_expect {
+gdb_test_multiple "info tracepoints" "5.5c: verify NO actions for first tracepoint" {
-re "No tracepoints.*$gdb_prompt $" {
fail "5.5c: verify NO actions for first tracepoint"
}
return;
}
-send_gdb "list $baseline, +12\n"
-gdb_expect {
+set return_me 0
+
+gdb_test_multiple "list $baseline, +12" "all tests in this module will fail" {
-re "\[\r\n\](\[0-9\]+).*gdbtestline 1 " {
set testline1 $expect_out(1,string)
exp_continue
-re ".*$gdb_prompt $" {
if { ($testline1 == 0) || ($testline2 == 0) || ($testline3 == 0) || ($testline4 == 0) || ($testline5 == 0) || ($testline6 == 0) } {
untested backtrace.exp
- return -1
+ set return_me 1
all tests in this module will fail."
}
}
default {
untested backtrace.exp
- return -1
+ set return_me 1
all tests in this module will fail."
- }
+ }
+}
+
+if { $return_me == 1 } then {
+ return -1;
}
#
# to be able to display the function's arguments or locals, and we
# do not expect to be able to identify the caller of this function.
- send_gdb "backtrace\n"
- gdb_expect {
- -re "#0\[\t \]+gdb_recursion_test.*depth=.*$gdb_prompt $" {
- pass "$msg"
- }
- -re ".*$gdb_prompt $" {
- fail "$msg"
- }
- timeout { fail "$msg (timeout)" }
- }
+ gdb_test "backtrace" \
+ "#0\[\t \]+gdb_recursion_test.*depth=.*" \
+ "$msg"
}
proc gdb_backtrace_tdp_2 { msg } {
# passed in registers (which isn't the case for m68k), and we
# don't expect to be able to identify the caller's stack frame.
- send_gdb "backtrace\n"
- gdb_expect {
- -re "#0\[\t \]+gdb_recursion_test.*depth=.*$gdb_prompt $" {
- pass "$msg"
- }
- -re ".*$gdb_prompt $" {
- fail "$msg"
- }
- timeout { fail "$msg (timeout)" }
- }
+ gdb_test "backtrace" \
+ "#0\[\t \]+gdb_recursion_test.*depth=.*" \
+ "$msg"
}
proc gdb_backtrace_tdp_3 { msg } {
# arguments and all locals. This means that the display of
# stack frame #0 should be complete (including argument values).
- send_gdb "backtrace\n"
- gdb_expect {
+ gdb_test_multiple "backtrace" "$msg" {
-re "#0\[\t \]+gdb_recursion_test.*depth=\[0-9\]+.*q1=\[0-9\]+.*q2=\[0-9\]+.*q3=\[0-9\]+.*q4=\[0-9\]+.*q5=\[0-9\]+.*q6=\[0-9\]+.*$gdb_prompt $" {
pass "$msg"
}
-re "#0\[\t \]+gdb_recursion_test.*depth=Cannot access.*$gdb_prompt $" {
fail "$msg (failed to collect arguments)"
}
- -re ".*$gdb_prompt $" {
- fail "$msg"
- }
- timeout { fail "$msg (timeout)" }
}
}
# assume that if we can't display at least "depth" levels (with
# args), it counts as an error.
- send_gdb "backtrace\n"
- gdb_expect {
+ gdb_test_multiple "backtrace" "$msg" {
-re "#$depth\[\t \].*gdb_recursion_test.*depth=\[0-9\]+.*q1=\[0-9\]+.*q2=\[0-9\]+.*q3=\[0-9\]+.*q4=\[0-9\]+.*q5=\[0-9\]+.*q6=\[0-9\]+.*$gdb_prompt $" {
pass "$msg"
}
-re "#\[0-9\]+\[\t \].*gdb_recursion_test.*depth=.*$gdb_prompt $" {
fail "$msg (fewer than $depth stack frames found)"
}
- -re ".*$gdb_prompt $" {
- fail "$msg"
- }
- timeout { fail "$msg (timeout)" }
}
}
# Find the comment-identified line for setting this tracepoint.
set testline 0
- send_gdb "list $func, +30\n"
- gdb_expect {
+ gdb_test_multiple "list $func, +30" "collect $msg: find tracepoint line" {
-re "\[\r\n\](\[0-9\]+)\[^\r\n\]+ Set_Tracepoint_Here .*$gdb_prompt" {
set testline $expect_out(1,string)
pass "collect $msg: find tracepoint line"
# Find the comment-identified line for setting this tracepoint.
set testline 0
- send_gdb "list $func, +30\n"
- gdb_expect {
+ gdb_test_multiple "list $func, +30" "collect $msg: find tracepoint line" {
-re "\[\r\n\](\[0-9\]+)\[^\r\n\]+ Set_Tracepoint_Here .*$gdb_prompt" {
set testline $expect_out(1,string)
pass "collect $msg: find tracepoint line"
# Find the comment-identified line for setting this tracepoint.
set testline 0
- send_gdb "list globals_test_func, +30\n"
- gdb_expect {
+ gdb_test_multiple "list globals_test_func, +30" "collect globals: find tracepoint line" {
-re "\[\r\n\](\[0-9\]+)\[^\r\n\]+ Set_Tracepoint_Here .*$gdb_prompt" {
set testline $expect_out(1,string)
pass "collect globals: find tracepoint line"
\[0-9\]+\[\t \]+tracepoint keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+" \
"3.1a: set three tracepoints"
-send_gdb "delete tracepoints\n"
-gdb_expect 30 {
- -re "Delete all tracepoints.*y or n.*$" {
- send_gdb "y\n"
- gdb_expect 30 {
- -re "$gdb_prompt $" {
- pass "3.1b: delete all tracepoints"
- }
- timeout { fail "3.1b: delete all tracepoints (timeout)" }
- }
- }
- -re "$gdb_prompt $" { # This should only happen if there are no tracepoints
- fail "3.1b: delete all tracepoints (no tracepoints?)"
- }
- timeout { fail "3.1b: delete all tracepoints (timeout)" }
-}
+gdb_test "delete tracepoints" \
+ "" \
+ "3.1b: delete all tracepoints" \
+ "Delete all tracepoints.*y or n.*$" \
+ "y"
+
# 3.2 delete tracepoint <n>
gdb_delete_tracepoints
"3.2a: set three tracepoints"
#gdb_test "delete tracepoint $trcpt1" "" ""
-send_gdb "delete tracepoint $trcpt1\n"
-gdb_expect {
+gdb_test_multiple "delete tracepoint $trcpt1" "3.2b: delete first tracepoint" {
-re "No tracepoint number.*$gdb_prompt $" {
fail "3.2b: delete first tracepoint"
}
-re "$gdb_prompt $" {
pass "3.2b: delete first tracepoint"
}
- timeout {
- fail "3.2b: delete first tracepoint (timeout)"
- }
}
gdb_test "info tracepoints" \
"3.2c: verify delete first tracepoint"
#gdb_test "delete tracepoint $trcpt2" "" ""
-send_gdb "delete tracepoint $trcpt2\n"
-gdb_expect {
+gdb_test_multiple "delete tracepoint $trcpt2" "3.2d: delete second tracepoint" {
-re "No tracepoint number.*$gdb_prompt $" {
fail "3.2d: delete second tracepoint"
}
-re "$gdb_prompt $" {
pass "3.2d: delete second tracepoint"
}
- timeout {
- fail "3.2d: delete second tracepoint (timeout)"
- }
}
gdb_test "info tracepoints" \
"3.2e: verify delete second tracepoint"
#gdb_test "delete tracepoint $trcpt3" "" ""
-send_gdb "delete tracepoint $trcpt3\n"
-gdb_expect {
+gdb_test_multiple "delete tracepoint $trcpt3" "3.2f: delete third tracepoint" {
-re "No tracepoint number.*$gdb_prompt $" {
fail "3.2f: delete third tracepoint"
}
-re "$gdb_prompt $" {
pass "3.2f: delete third tracepoint"
}
- timeout {
- fail "3.2f: delete third tracepoint (timeout)"
- }
}
# send_gdb "ARF! \\n\n"
"3.3a: set three tracepoints"
#gdb_test "delete tracepoint $trcpt1 $trcpt2 $trcpt3" "" ""
-send_gdb "delete tracepoint $trcpt1 $trcpt2 $trcpt3\n"
-gdb_expect {
- -re "No tracepoint number.*$gdb_prompt $" {
- fail "3.3b: delete three tracepoints"
- }
- -re ".*\[Ee\]rror.*$gdb_prompt $" {
- fail "3.3b: delete three tracepoints"
- }
- -re "$gdb_prompt $" {
- pass "3.3b: delete three tracepoints"
- }
- timeout {
- fail "3.3b: delete three tracepoint (timeout)"
+gdb_test_multiple "delete tracepoint $trcpt1 $trcpt2 $trcpt3" \
+ "3.3b: delete three tracepoints" {
+ -re "No tracepoint number.*$gdb_prompt $" {
+ fail "3.3b: delete three tracepoints"
+ }
+ -re ".*\[Ee\]rror.*$gdb_prompt $" {
+ fail "3.3b: delete three tracepoints"
+ }
+ -re "$gdb_prompt $" {
+ pass "3.3b: delete three tracepoints"
+ }
}
-}
gdb_test "info tracepoints" \
"No tracepoints." \
"2.3: info tracepoint (invalid tracepoint number)"
# 2.4 info tracepoints (list of numbers)
-send_gdb "info tracepoints $c_test_num $asm_test_num \n"
-gdb_expect {
- -re "Num Enb .*$gdb_prompt $" {
- fail "2.4: info trace rejects multiple tracepoint numbers"
+gdb_test_multiple "info tracepoints $c_test_num $asm_test_num " \
+ "2.4: info trace rejects multiple tracepoint numbers" {
+ -re "Num Enb .*$gdb_prompt $" {
+ fail "2.4: info trace rejects multiple tracepoint numbers"
+ }
+ -re ".*$gdb_prompt $" {
+ pass "2.4: info trace rejects multiple tracepoint numbers"
+ }
}
- -re ".*$gdb_prompt $" {
- pass "2.4: info trace rejects multiple tracepoint numbers"
- }
-}
# 2.5 help info trace
gdb_test "help info tracepoints" \
return;
}
-send_gdb "list $gdb_recursion_test_baseline, +12\n"
-gdb_expect {
+set return_me 0
+
+gdb_test_multiple "list $gdb_recursion_test_baseline, +12" "" {
-re "\[\r\n\](\[0-9\]+)\[^\r\n\]+gdbtestline 1 " {
set testline1 $expect_out(1,string)
exp_continue
-re ".*$gdb_prompt $" {
if { ($testline1 == 0) || ($testline2 == 0) || ($testline3 == 0) || ($testline4 == 0) || ($testline5 == 0) || ($testline6 == 0) } {
untested report.exp
- return -1
+ set return_me 1
all tests in this module will fail."
}
}
default {
untested report.exp
- return -1
+ set return_me 1
all tests in this module will fail."
}
}
+if { $return_me == 1 } then {
+ return -1;
+}
+
#
# Setup trace experiment. This will involve:
# 1) a tracepoint where nothing is collected
gdb_test "printf \"x %d x\\n\", \$trace_line" "x $testline1 x" \
"11.3: test \$trace_line"
-send_gdb "print \$trace_file\n"
-gdb_expect {
+gdb_test_multiple "print \$trace_file" "11.4: test \$trace_file" {
-re "\\$\[0-9\]+ = \"$srcfile\"\[\r\n\]+$gdb_prompt $" {
pass "11.4: test \$trace_file"
}
-re "\\$\[0-9\]+ = \"$srcdir/$subdir/$srcfile\"\[\r\n\]+$gdb_prompt $" {
pass "11.4: test \$trace_file"
}
- -re "$gdb_prompt $" {
- fail "11.4: test \$trace_file"
- }
- timeout {
- fail "11.4: test \$trace_file (timeout)"
- }
}
#gdb_test "print \$trace_file" "\"$srcdir/$subdir/$srcfile\"" \
# 12.x test report generation using arbitrary GDB commands, loops etc.
#
-send_gdb "while \$trace_frame != -1\n output \$trace_file\n printf \", line \%d \(tracepoint #\%d\)\\n\", \$trace_line, \$tracepoint\n tfind\n end\n"
-gdb_expect {
+gdb_test_multiple "while \$trace_frame != -1\n output \$trace_file\n printf \", line \%d \(tracepoint #\%d\)\\n\", \$trace_line, \$tracepoint\n tfind\n end" "12.1: trace report #1" {
-re " line $testline1 .tracepoint .$tdp1" {
set linecount1 [expr $linecount1 + 1]
exp_continue
pass "12.1: trace report #1"
}
}
- timeout {
- fail "12.1: trace report #1 (timeout)"
- }
}
gdb_tfind_test "12.2: tfind end, selects no frame" "end" "-1"
set linecount2 0
-send_gdb "while \$trace_frame != -1\n printf \"tracepoint #\%d, FP 0x\%08x, SP 0x\%08x, PC 0x%08x\\n\", \$tracepoint, \$fp, \$sp, \$pc\n tfind tracepoint\n end\n"
-gdb_expect {
+gdb_test_multiple "while \$trace_frame != -1\n printf \"tracepoint #\%d, FP 0x\%08x, SP 0x\%08x, PC 0x%08x\\n\", \$tracepoint, \$fp, \$sp, \$pc\n tfind tracepoint\n end" "12.2: trace report #2" {
-re "tracepoint #$tdp2, FP $hex, SP $hex, PC $hex" {
set linecount2 [expr $linecount2 + 1]
exp_continue
pass "12.2: trace report #2"
}
}
- timeout {
- fail "12.2: trace report #2 (timeout)"
- }
}
gdb_tfind_test "12.3: tfind end, selects no frame" "end" "-1"
set linecount3 0
-send_gdb "while \$trace_frame != -1\n printf \"TDP #\%d, frame \%d: depth = \%d, q1 = \%d\\n\", \$tracepoint, \$trace_frame, depth, q1\n tfind tracepoint\n end\n"
-gdb_expect {
+gdb_test_multiple "while \$trace_frame != -1\n printf \"TDP #\%d, frame \%d: depth = \%d, q1 = \%d\\n\", \$tracepoint, \$trace_frame, depth, q1\n tfind tracepoint\n end" "12.3: trace report #3" {
-re "TDP #$tdp3, frame $decimal: depth = $decimal, q1 = $decimal" {
set linecount3 [expr $linecount3 + 1]
exp_continue
pass "12.3: trace report #3"
}
}
- timeout {
- fail "12.3: trace report #3 (timeout)"
- }
}
gdb_tfind_test "12.4: tfind end, selects no frame" "end" "-1"
set linecount6 0
-send_gdb "while \$trace_frame != -1\n printf \"TDP #\%d, frame %d: char_test = \%d, long_test = \%d\\n\", \$tracepoint, \$trace_frame, gdb_char_test, gdb_long_test\n tfind tracepoint\n end\n"
-gdb_expect {
+gdb_test_multiple "while \$trace_frame != -1\n printf \"TDP #\%d, frame %d: char_test = \%d, long_test = \%d\\n\", \$tracepoint, \$trace_frame, gdb_char_test, gdb_long_test\n tfind tracepoint\n end" "12.4: trace report #4" {
-re "TDP #$tdp6, frame $decimal: char_test = $arg1, long_test = $arg3" {
set linecount6 [expr $linecount6 + 1]
exp_continue
pass "12.4: trace report #4"
}
}
- timeout {
- fail "12.4: trace report #4 (timeout)"
- }
}
# Finished!
set nl "\[\r\n\]+"
set ourstate 1;
set result "pass";
- send_gdb "info tracepoints\n";
- gdb_expect 10 {
+ gdb_test_multiple "info tracepoints" "$testname" {
-re "\[0-9\]+\[\t \]+tracepoint\[\t \]+keep y\[\t \]+0x\[0-9a-fA-F\]+ in gdb_recursion_test\[^\r\n\]+\r\n\[ \t]+trace only if \[0-9\] - 1 == \[0-9\] / 2" {
# if { $expect_out(1,string) != $ourstate } {
# set result "fail";
}
# 6.1 test tstart command
-send_gdb "tstart\n"
-gdb_expect {
+
+set return_me 1
+gdb_test_multiple "tstart" "6.1: tstart" {
-re "Trace can only be run on remote targets.*$gdb_prompt $" {
fail "6.1: tstart (not connected to remote?)"
- return;
}
-re "Target does not support this command.*$gdb_prompt $" {
fail "6.1: tstart (connected to wrong target?)"
- return;
}
-re "Target returns error code.*$gdb_prompt $" {
fail "6.1: tstart (connected to wrong target?)"
- return;
}
-re "$gdb_prompt $" {
pass "6.1: tstart"
- }
- default {
- fail "6.1: tstart (default)"
- return;
+ set return_me 0
}
}
+if { $return_me == 1 } then {
+ return -1;
+}
+
# test tstatus (when trace on)
gdb_test "tstatus" "\[Tt\]race is running.*" "test tstatus on"
"run trace experiment"
# 7.1 test tstop command
-send_gdb "tstop\n"
-gdb_expect {
+
+set return_me 1
+gdb_test_multiple "tstop" "7.1: tstop" {
-re "Trace can only be run on remote targets.*$gdb_prompt $" {
fail "7.1: tstop (not connected to remote?)"
- return;
}
-re "Target does not support this command.*$gdb_prompt $" {
fail "7.1: tstop (connected to wrong target?)"
- return;
}
-re "Target returns error code.*$gdb_prompt $" {
fail "7.1: tstop (connected to wrong target?)"
- return;
}
-re "$gdb_prompt $" {
pass "7.1: tstop"
+ set return_me 0
}
- default {
- fail "7.1: tstop (default)"
- return;
- }
+}
+
+if { $return_me == 1 } then {
+ return -1;
}
# 7.2 test help tstop
# 8.36 tfind and disassembly
gdb_tfind_test "8.36: tfind start" "start" "0"
set timeout 60
-send_gdb "disassemble gdb_c_test\n"
# look for disassembly of function label
-gdb_expect {
- -re "<(\.\[0-9\]+|)>:.*End of assembler dump.*$gdb_prompt $" { pass "8.36: trace disassembly" }
- -re ".*$gdb_prompt $" { fail "8.36: trace disassembly" }
- timeout { fail "8.36: trace disassembly (timeout)" }
-}
+gdb_test "disassemble gdb_c_test" \
+ "<(\.\[0-9\]+|)>:.*End of assembler dump.*" \
+ "8.36: trace disassembly"
gdb_test "tfind line 0" \
"out of range.*|failed to find.*" \
# 1.6 trace at a specific address
# Collect the address of "gdb_asm_test", and use that.
-send_gdb "print gdb_asm_test\n"
-gdb_expect {
+gdb_test_multiple "print gdb_asm_test" "" {
-re "\[$\]\[0-9\].*0x(\[0-9a-fA-F\]+).*$gdb_prompt $" {
set asm_test_addr $expect_out(1,string)
}
- timeout { }
}
gdb_delete_tracepoints
# 1.7 trace at function's exact address
# Collect the address of the function for comparison
-send_gdb "print gdb_recursion_test\n"
-gdb_expect {
+gdb_test_multiple "print gdb_recursion_test" "" {
-re "\[$\]\[0-9\].*0x(\[0-9a-fA-F\]+).*$gdb_prompt $" {
set c_test_addr $expect_out(1,string)
}
- timeout { }
}
gdb_delete_tracepoints
gdb_delete_tracepoints
-send_gdb "ftrace gdb_recursion_test\n"
# Acceptance vs rejection of a location are target-specific, so allow both.
-gdb_expect {
- -re "Fast tracepoint $decimal at $hex: file.*$srcfile, line $testline1.*$gdb_prompt $"
- { pass "Set a fast tracepoint" }
- -re ".*May not have a fast tracepoint at $hex.*$gdb_prompt $"
- { pass "Declined to set a fast tracepoint" }
- timeout { fail "Timeout while setting fast tracepoint" }
+gdb_test_multiple "ftrace gdb_recursion_test" "Set a fast tracepoint" {
+ -re "Fast tracepoint $decimal at $hex: file.*$srcfile, line $testline1.*$gdb_prompt $" {
+ pass "Set a fast tracepoint"
+ }
+ -re ".*May not have a fast tracepoint at $hex.*$gdb_prompt $" {
+ pass "Declined to set a fast tracepoint"
+ }
}
\\\$tvar3\[\t \]+1234567000000\[\t \]+.*<undefined>.*" \
"List tvariables after deletion"
-send_gdb "delete tvariable\n"
-gdb_expect 30 {
- -re "Delete all trace state variables.*y or n.*$" {
- send_gdb "y\n"
- gdb_expect 30 {
- -re "$gdb_prompt $" {
- pass "Delete all trace state variables"
- }
- timeout { fail "Delete all trace state variables (timeout)" }
- }
- }
- -re "$gdb_prompt $" { # This happens if there were no variables
- }
- timeout { perror "Delete all trace state variables (timeout)" ; return }
-}
+gdb_test "delete tvariable" \
+ "" \
+ "Delete all trace state variables" \
+ "Delete all trace state variables.*y or n.*$" \
+ "y"
gdb_test "info tvariables" \
"No trace state variables.*" \