aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Metzger <markus.t.metzger@intel.com>2024-02-20 11:45:39 +0000
committerMarkus Metzger <markus.t.metzger@intel.com>2024-09-13 10:25:26 +0000
commit941a8f3df64a26055acbe83db29e256ed2ba7e8d (patch)
tree1a27adca28bf415801dfa2b1ae19ca3e32db8466
parent40422bbae1df369f4d013271bc7edeb6b30a3c44 (diff)
downloadgdb-941a8f3df64a26055acbe83db29e256ed2ba7e8d.zip
gdb-941a8f3df64a26055acbe83db29e256ed2ba7e8d.tar.gz
gdb-941a8f3df64a26055acbe83db29e256ed2ba7e8d.tar.bz2
gdb, btrace: fix pr19340
GDB fails with an assertion when stopping recording on a replaying thread and then resuming that thread. Stopping recording left the thread replaying but the record target is gone. Stop replaying all threads in the selected inferior before stopping recording. If the selected thread had been replaying, print the (potentially updated) location. I had to change the stepping test slightly to account for different compilers generating slightly different debug information, so when stepping the 'return 0' after 'record stop' I would end up in a different location depending on which compiler I used. The test still covers all stepping commands. Fixes PR gdb/19340.
-rw-r--r--gdb/record-btrace.c17
-rw-r--r--gdb/testsuite/gdb.btrace/step.exp22
2 files changed, 32 insertions, 7 deletions
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 997f442..1a5009c 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -415,11 +415,28 @@ record_btrace_target::stop_recording ()
{
DEBUG ("stop recording");
+ /* Remember the selected thread if it exists and is replaying. */
+ thread_info *curr = nullptr;
+ if (inferior_ptid.lwp_p ())
+ {
+ curr = inferior_thread ();
+ if (!btrace_is_replaying (curr))
+ curr = nullptr;
+ }
+
+ record_stop_replaying ();
record_btrace_auto_disable ();
for (thread_info *tp : current_inferior ()->non_exited_threads ())
if (tp->btrace.target != NULL)
btrace_disable (tp);
+
+ /* Print the updated location in case we had stopped a replaying thread. */
+ if (curr != nullptr)
+ {
+ curr->set_stop_pc (regcache_read_pc (get_thread_regcache (curr)));
+ print_stack_frame (get_selected_frame (), 1, SRC_AND_LOC, 1);
+ }
}
/* The disconnect method of target record-btrace. */
diff --git a/gdb/testsuite/gdb.btrace/step.exp b/gdb/testsuite/gdb.btrace/step.exp
index 0adc18b..ed6d214 100644
--- a/gdb/testsuite/gdb.btrace/step.exp
+++ b/gdb/testsuite/gdb.btrace/step.exp
@@ -31,18 +31,26 @@ if ![runto_main] {
# trace the call to the test function
with_test_prefix "record" {
gdb_test_no_output "record btrace"
- gdb_test "next"
+ gdb_test "step"
+ gdb_test "next 2"
}
# let's step around a bit
with_test_prefix "replay" {
- gdb_test "reverse-next" ".*main\.2.*" "reverse-next.1"
+ gdb_test "reverse-finish" ".*main\.2.*" "reverse-finish.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"
+ gdb_test "reverse-finish" ".*fun4\.3.*" "reverse-finish.2"
+ gdb_test "reverse-step" ".*fun1\.2.*" "reverse-step.1"
+ gdb_test "finish" ".*fun4\.3.*" "finish.1"
+ gdb_test "reverse-next" ".*fun4\.2.*" "reverse-next.1"
+ gdb_test "reverse-finish" ".*main\.2.*" "reverse-finish.3"
+}
+
+# stop recording and try to step live (pr19340)
+with_test_prefix "live" {
+ gdb_test "record stop" "fun4\.4.*Process record is stopped.*"
+ gdb_test "reverse-next" "Target .* does not support this command.*"
+ gdb_test "step" ".*fun3\.2.*"
}