+2020-12-21 Markus Metzger <markus.t.metzger@intel.com>
+
+ * gdb.btrace/data.exp: Make test names unique.
+ * gdb.btrace/delta.exp: Likewise.
+ * gdb.btrace/enable.exp: Likewise.
+ * gdb.btrace/function_call_history.exp: Likewise.
+ * gdb.btrace/nohist.exp: Likewise.
+ * gdb.btrace/non-stop.exp: Likewise.
+ * gdb.btrace/rn-dl-bind.exp: Likewise.
+ * gdb.btrace/step.exp: Likewise.
+ * gdb.btrace/stepi.exp: Likewise.
+ * gdb.btrace/tailcall.exp: Likewise.
+
2020-12-21 Markus Metzger <markus.t.metzger@intel.com>
* gdb.btrace/enable.exp: Update error message.
gdb_test "reverse-step" ".*test\.4.*"
# we can't read memory while we're replaying
-gdb_test "print glob" "unavailable\[^\\\r\\\n\]*"
-gdb_test "print loc" "unavailable\[^\\\r\\\n\]*"
+with_test_prefix "replay" {
+ with_test_prefix "default" {
+ gdb_test "print glob" "unavailable\[^\\\r\\\n\]*"
+ gdb_test "print loc" "unavailable\[^\\\r\\\n\]*"
+ }
-# we can read memory if we explicitly allow it.
-gdb_test_no_output "set record btrace replay-memory-access read-write"
-gdb_test "print glob" "1"
+ # we can read memory if we explicitly allow it.
+ with_test_prefix "read-write" {
+ gdb_test_no_output "set record btrace replay-memory-access read-write"
+ gdb_test "print glob" "1"
+ }
-# we can't if we don't explicitly allow it.
-gdb_test_no_output "set record btrace replay-memory-access read-only"
-gdb_test "print glob" "unavailable\[^\\\r\\\n\]*"
+ # we can't if we don't explicitly allow it.
+ with_test_prefix "read-only" {
+ gdb_test_no_output "set record btrace replay-memory-access read-only"
+ gdb_test "print glob" "unavailable\[^\\\r\\\n\]*"
+ }
+}
# stop replaying and try again
gdb_test "record goto end" ".*main\.3.*"
}
# check that we can reverse-stepi that instruction
-gdb_test "reverse-stepi"
-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\." \
- ] "reverse-stepi"
+with_test_prefix "reverse" {
+ gdb_test "reverse-stepi"
+ 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\." \
+ ]
+}
# and back
-gdb_test "stepi"
-gdb_test "info record" [multi_line \
- "Active record target: record-btrace" \
- "Recording format: .*" \
- "Recorded 1 instructions in 1 functions \\\(0 gaps\\\) for .*" \
- ] "and back"
+with_test_prefix "forward" {
+ gdb_test "stepi"
+ gdb_test "info record" [multi_line \
+ "Active record target: record-btrace" \
+ "Recording format: .*" \
+ "Recorded 1 instructions in 1 functions \\\(0 gaps\\\) for .*" \
+ ]
+}
untested "failed to run to main"
return -1
}
-gdb_test_no_output "record btrace"
+gdb_test_no_output "record btrace" "enable after restart"
if ![runto_main] {
untested "failed to run to main"
return -1
gdb_continue_to_breakpoint "cont to fib.4"
# start tracing
-gdb_test_no_output "record btrace"
+gdb_test_no_output "record btrace" "start recording after rerun"
# continue until line 30 above
delete_breakpoints
gdb_test_no_output "record btrace"
-check_not_replaying
+with_test_prefix "forward" {
+ check_not_replaying
+}
gdb_test "reverse-continue" "No more reverse-execution history\.\r\n.*"
-check_not_replaying
+with_test_prefix "backward" {
+ check_not_replaying
+}
# the prompt precedes any further output except some errors.
gdb_test_multiple "$full_cmd &" "$full_cmd: prompt" {
-re "$gdb_prompt " {
- pass "$full_cmd: prompt"
+ pass $gdb_test_name
}
}
# now check for the expected line - one per thread.
for {set i 0} {$i < $nthreads} {incr i} {
- set test "$full_cmd: thread $i"
-
- gdb_test_multiple "" $test {
+ gdb_test_multiple "" "$full_cmd: thread $i" {
-re "$line\[^\\\r\\\n\]*\r\n" {
- pass $test
+ pass $gdb_test_name
}
}
}
}
# trace the code between the two breakpoints
-gdb_cont_to_bp_line "$srcfile:$bp_1" all 2
-gdb_test_no_output "record btrace"
-gdb_cont_to_bp_line "$srcfile:$bp_2" all 2
+with_test_prefix "prepare" {
+ gdb_cont_to_bp_line "$srcfile:$bp_1" all 2
+}
+with_test_prefix "record" {
+ gdb_test_no_output "record btrace"
+ gdb_cont_to_bp_line "$srcfile:$bp_2" all 2
+}
# we don't need those breakpoints any longer.
# they will only disturb our stepping.
gdb_test "thread apply 1 record goto 2" "$loop_line"
gdb_test "thread apply 2 record goto 4" "$loop_line"
gdb_test "thread apply 1 info record" \
- ".*Replay in progress\. At instruction 2\."
+ ".*Replay in progress\. At instruction 2\." "thread 1 at insn 2"
gdb_test "thread apply 2 info record" \
- ".*Replay in progress\. At instruction 4\."
+ ".*Replay in progress\. At instruction 4\." "thread 2 at insn 4"
gdb_test "thread apply all record goto 5" "$loop_line"
gdb_test "thread apply 1 info record" \
- ".*Replay in progress\. At instruction 5\."
+ ".*Replay in progress\. At instruction 5\." "thread 1 at insn 5"
gdb_test "thread apply 2 info record" \
- ".*Replay in progress\. At instruction 5\."
+ ".*Replay in progress\. At instruction 5\." "thread 2 at insn 5"
}
with_test_prefix "step" {
with_test_prefix "continue" {
with_test_prefix "thread 1" {
- gdb_cont_to_no_history 1 "continue" 1
- gdb_test "thread apply 1 info record" \
- ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
- gdb_test "thread apply 2 info record" \
- ".*Replay in progress\. At instruction 5\."
-
- gdb_cont_to_no_history 1 "reverse-continue" 1
- gdb_test "thread apply 1 info record" \
- ".*Replay in progress\. At instruction 1\."
- gdb_test "thread apply 2 info record" \
- ".*Replay in progress\. At instruction 5\."
+ with_test_prefix "continue" {
+ gdb_cont_to_no_history 1 "continue" 1
+ gdb_test "thread apply 1 info record" \
+ ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
+ gdb_test "thread apply 2 info record" \
+ ".*Replay in progress\. At instruction 5\."
+ }
+ with_test_prefix "reverse-continue" {
+ gdb_cont_to_no_history 1 "reverse-continue" 1
+ gdb_test "thread apply 1 info record" \
+ ".*Replay in progress\. At instruction 1\."
+ gdb_test "thread apply 2 info record" \
+ ".*Replay in progress\. At instruction 5\."
+ }
}
with_test_prefix "thread 2" {
- gdb_cont_to_no_history 2 "continue" 1
- gdb_test "thread apply 1 info record" \
- ".*Replay in progress\. At instruction 1\."
- gdb_test "thread apply 2 info record" \
- ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
-
- gdb_cont_to_no_history 2 "reverse-continue" 1
- gdb_test "thread apply 1 info record" \
- ".*Replay in progress\. At instruction 1\."
- gdb_test "thread apply 2 info record" \
- ".*Replay in progress\. At instruction 1\."
+ with_test_prefix "continue" {
+ gdb_cont_to_no_history 2 "continue" 1
+ gdb_test "thread apply 1 info record" \
+ ".*Replay in progress\. At instruction 1\."
+ gdb_test "thread apply 2 info record" \
+ ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
+ }
+ with_test_prefix "reverse-continue" {
+ gdb_cont_to_no_history 2 "reverse-continue" 1
+ gdb_test "thread apply 1 info record" \
+ ".*Replay in progress\. At instruction 1\."
+ gdb_test "thread apply 2 info record" \
+ ".*Replay in progress\. At instruction 1\."
+ }
}
}
# trace the code for the call to test
gdb_test_no_output "record btrace"
-gdb_test "next" ".*main\.2.*"
+gdb_test "next" ".*main\.2.*" "next.1"
# just dump the function-call-history to help debugging
gdb_test_no_output "set record function-call-history-size 0"
gdb_test "record function-call-history /cli 1" ".*"
# check that we can reverse-next and next
-gdb_test "reverse-next" ".*main\.1.*"
-gdb_test "next" ".*main\.2.*"
+gdb_test "reverse-next" ".*main\.1.*" "reverse-next.1"
+gdb_test "next" ".*main\.2.*" "next.2"
# now go into test and try to reverse-next and next over the library call
-gdb_test "reverse-step" ".*test\.3.*"
-gdb_test "reverse-step" ".*test\.2.*"
-gdb_test "reverse-next" ".*test\.1.*"
-gdb_test "next" ".*test\.2.*"
+gdb_test "reverse-step" ".*test\.3.*" "reverse-step.1"
+gdb_test "reverse-step" ".*test\.2.*" "reverse-step.2"
+gdb_test "reverse-next" ".*test\.1.*" "reverse-next.2"
+gdb_test "next" ".*test\.2.*" "next.3"
}
# trace the call to the test function
-gdb_test_no_output "record btrace"
-gdb_test "next"
+with_test_prefix "record" {
+ gdb_test_no_output "record btrace"
+ gdb_test "next"
+}
# let's step around a bit
-gdb_test "reverse-next" ".*main\.2.*"
-gdb_test "step" ".*fun4\.2.*"
-gdb_test "next" ".*fun4\.3.*"
-gdb_test "step" ".*fun2\.2.*"
-gdb_test "finish" ".*fun4\.4.*"
-gdb_test "reverse-step" ".*fun2\.3.*"
-gdb_test "reverse-finish" ".*fun4\.3.*"
-gdb_test "reverse-next" ".*fun4\.2.*"
-gdb_test "reverse-finish" ".*main\.2.*"
+with_test_prefix "replay" {
+ gdb_test "reverse-next" ".*main\.2.*" "reverse-next.1"
+ gdb_test "step" ".*fun4\.2.*" "step.1"
+ gdb_test "next" ".*fun4\.3.*" "next.1"
+ gdb_test "step" ".*fun2\.2.*" "step.2"
+ gdb_test "finish" ".*fun4\.4.*" "finish.1"
+ gdb_test "reverse-step" ".*fun2\.3.*" "reverse-step.1"
+ gdb_test "reverse-finish" ".*fun4\.3.*" "reverse-finish.1"
+ gdb_test "reverse-next" ".*fun4\.2.*" "reverse-next.2"
+ gdb_test "reverse-finish" ".*main\.2.*" "reverse-finish.2"
+}
".*" \
"Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for .*" \
"Replay in progress\. At instruction $insn\." \
- ]
+ ] "check replay at $insn"
}
# trace the call to the test function
-gdb_test_no_output "record btrace"
-gdb_test "next"
+with_test_prefix "record" {
+ gdb_test_no_output "record btrace"
+ gdb_test "next" ".*" "next.1"
+}
# we start with stepping to make sure that the trace is fetched automatically
-gdb_test "reverse-stepi" ".*fun4\.5.*"
-gdb_test "reverse-stepi" ".*fun4\.5.*"
+with_test_prefix "fetch" {
+ gdb_test "reverse-stepi" ".*fun4\.5.*" "reverse-stepi.1"
+ gdb_test "reverse-stepi" ".*fun4\.5.*" "reverse-stepi.2"
-# let's check where we are in the trace
-with_test_prefix "reverse-stepi to 39" { check_replay_at 39 }
+ # let's check where we are in the trace
+ check_replay_at 39
+}
# let's step forward and check again
-gdb_test "stepi" ".*fun4\.5.*"
-with_test_prefix "stepi to 40" { check_replay_at 40 }
+with_test_prefix "stepi" {
+ gdb_test "stepi" ".*fun4\.5.*"
+ check_replay_at 40
+}
# with the next step, we stop replaying
-gdb_test "stepi" ".*main\.3.*"
-gdb_test "info record" [multi_line \
- "Active record target: record-btrace" \
- ".*" \
- "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \
- ] "stepi to live"
+with_test_prefix "end" {
+ gdb_test "stepi" ".*main\.3.*"
+ gdb_test "info record" [multi_line \
+ "Active record target: record-btrace" \
+ ".*" \
+ "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \
+ ]
+}
# let's try nexti
-gdb_test "reverse-nexti" ".*main\.2.*"
-with_test_prefix "reverse-nexti - 1" { check_replay_at 1 }
+with_test_prefix "reverse-nexti.1" {
+ gdb_test "reverse-nexti" ".*main\.2.*"
+ check_replay_at 1
+}
# we can't reverse-nexti any further
-gdb_test "reverse-nexti" "No more reverse-execution history\.\r\n.*main\.2.*"
-with_test_prefix "reverse-nexti - 1" { check_replay_at 1 }
+with_test_prefix "reverse-nexti.2" {
+ gdb_test "reverse-nexti" \
+ "No more reverse-execution history\.\r\n.*main\.2.*" \
+ "reverse-nexti.2"
+ check_replay_at 1
+}
# but we can step back again
-gdb_test "nexti" ".*main\.3.*" "next, 1.5"
-gdb_test "info record" [multi_line \
- "Active record target: record-btrace" \
- ".*" \
- "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \
- ] "nexti back"
+with_test_prefix "nexti" {
+ gdb_test "nexti" ".*main\.3.*"
+ gdb_test "info record" [multi_line \
+ "Active record target: record-btrace" \
+ ".*" \
+ "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \
+ ]
+}
# let's step from a goto position somewhere in the middle
-gdb_test "record goto 22" ".*fun3\.2.*"
-with_test_prefix "goto 22" { check_replay_at 22 }
+with_test_prefix "goto" {
+ gdb_test "record goto 22" ".*fun3\.2.*"
+ with_test_prefix "goto 22" { check_replay_at 22 }
-gdb_test "stepi" ".*fun1\.1.*"
-with_test_prefix "stepi to 23" { check_replay_at 23 }
+ gdb_test "stepi" ".*fun1\.1.*" "stepi.3"
+ with_test_prefix "stepi to 23" { check_replay_at 23 }
-gdb_test "reverse-stepi" ".*fun3\.2.*"
-with_test_prefix "reverse-stepi to 22" { check_replay_at 22 }
+ gdb_test "reverse-stepi" ".*fun3\.2.*" "reverse-stepi.3"
+ with_test_prefix "reverse-stepi to 22" { check_replay_at 22 }
-gdb_test "nexti" ".*fun3\.3.*"
-with_test_prefix "nexti to 27" { check_replay_at 27 }
+ gdb_test "nexti" ".*fun3\.3.*"
+ with_test_prefix "nexti to 27" { check_replay_at 27 }
-gdb_test "reverse-nexti" ".*fun3\.2.*"
-with_test_prefix "reverse-nexti to 22" { check_replay_at 22 }
+ gdb_test "reverse-nexti" ".*fun3\.2.*" "reverse-nexti.3"
+ with_test_prefix "reverse-nexti to 22" { check_replay_at 22 }
+}
# let's try to step off the left end
-gdb_test "record goto begin" ".*main\.2.*"
-with_test_prefix "goto begin" { check_replay_at 1 }
-
-gdb_test "reverse-stepi" "No more reverse-execution history\.\r\n.*main\.2.*"
-gdb_test "reverse-stepi" "No more reverse-execution history\.\r\n.*main\.2.*"
-with_test_prefix "reverse-stepi at begin" { check_replay_at 1 }
-
-gdb_test "reverse-nexti" "No more reverse-execution history\.\r\n.*main\.2.*"
-gdb_test "reverse-nexti" "No more reverse-execution history\.\r\n.*main\.2.*"
-with_test_prefix "reverse-nexti at begin" { check_replay_at 1 }
-
-# we can step forward, though
-gdb_test "stepi" ".*fun4\.1.*"
-with_test_prefix "stepi to 2" { check_replay_at 2 }
+with_test_prefix "goto begin" {
+ gdb_test "record goto begin" ".*main\.2.*"
+ check_replay_at 1
+
+ with_test_prefix "reverse-stepi" {
+ gdb_test "reverse-stepi" \
+ "No more reverse-execution history\.\r\n.*main\.2.*" \
+ "reverse-stepi.1"
+ gdb_test "reverse-stepi" \
+ "No more reverse-execution history\.\r\n.*main\.2.*" \
+ "reverse-stepi.2"
+ check_replay_at 1
+ }
+
+ with_test_prefix "reverse-nexti" {
+ gdb_test "reverse-nexti" \
+ "No more reverse-execution history\.\r\n.*main\.2.*" \
+ "reverse-nexti.1"
+ gdb_test "reverse-nexti" \
+ "No more reverse-execution history\.\r\n.*main\.2.*" \
+ "reverse-nexti.2"
+ check_replay_at 1
+ }
+
+ # we can step forward, though
+ with_test_prefix "stepi" {
+ gdb_test "stepi" ".*fun4\.1.*"
+ check_replay_at 2
+ }
+}
# let's try to step off the left end again
-gdb_test "reverse-stepi" ".*main\.2.*"
-gdb_test "reverse-stepi" "No more reverse-execution history\.\r\n.*main\.2.*"
-gdb_test "reverse-stepi" "No more reverse-execution history\.\r\n.*main\.2.*"
-with_test_prefix "reverse-stepi at begin" { check_replay_at 1 }
+with_test_prefix "reverse-stepi" {
+ gdb_test "reverse-stepi" ".*main\.2.*" "reverse-stepi.1"
+ gdb_test "reverse-stepi" \
+ "No more reverse-execution history\.\r\n.*main\.2.*" \
+ "reverse-stepi.2"
+ gdb_test "reverse-stepi" \
+ "No more reverse-execution history\.\r\n.*main\.2.*" \
+ "reverse-stepi.3"
+ check_replay_at 1
+}
gdb_test "down" "#1\[^\r\n\]*foo \\(\\) at tailcall.c:29\r\n.*" "down to foo"
# test stepping into and out of tailcalls.
-gdb_test "finish" "\[^\r\n\]*main \\(\\) at tailcall.c:38\r\n.*"
-gdb_test "reverse-step" "\[^\r\n\]*bar \\(\\) at tailcall.c:24\r\n.*"
-gdb_test "reverse-finish" "\[^\r\n\]*foo \\(\\) at tailcall.c:29\r\n.*"
-gdb_test "reverse-step" "\[^\r\n\]*main \\(\\) at tailcall.c:37\r\n.*"
-gdb_test "next" "\[^\r\n\]*38.*"
-gdb_test "reverse-next" "\[^\r\n\]*main \\(\\) at tailcall.c:37\r\n.*"
-gdb_test "step" "\[^\r\n\]*foo \\(\\) at tailcall.c:29\r\n.*"
-gdb_test "finish" "\[^\r\n\]*main \\(\\) at tailcall.c:38\r\n.*"
-gdb_test "reverse-step" "\[^\r\n\]*bar \\(\\) at tailcall.c:24\r\n.*"
-gdb_test "finish" "\[^\r\n\]*main \\(\\) at tailcall.c:38\r\n.*"
+gdb_test "finish" "\[^\r\n\]*main \\(\\) at tailcall.c:38\r\n.*" \
+ "finish.1"
+gdb_test "reverse-step" "\[^\r\n\]*bar \\(\\) at tailcall.c:24\r\n.*" \
+ "reverse-step.1"
+gdb_test "reverse-finish" "\[^\r\n\]*foo \\(\\) at tailcall.c:29\r\n.*" \
+ "reverse-finish.1"
+gdb_test "reverse-step" "\[^\r\n\]*main \\(\\) at tailcall.c:37\r\n.*" \
+ "reverse-step.2"
+gdb_test "next" "\[^\r\n\]*38.*" \
+ "next.1"
+gdb_test "reverse-next" "\[^\r\n\]*main \\(\\) at tailcall.c:37\r\n.*" \
+ "reverse-next.1"
+gdb_test "step" "\[^\r\n\]*foo \\(\\) at tailcall.c:29\r\n.*" \
+ "step.1"
+gdb_test "finish" "\[^\r\n\]*main \\(\\) at tailcall.c:38\r\n.*" \
+ "finish.2"
+gdb_test "reverse-step" "\[^\r\n\]*bar \\(\\) at tailcall.c:24\r\n.*" \
+ "reverse-step.3"
+gdb_test "finish" "\[^\r\n\]*main \\(\\) at tailcall.c:38\r\n.*" \
+ "finish.3"