aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdbstub.c1
-rw-r--r--include/sysemu/replay.h2
-rw-r--r--replay/replay-debugging.c14
3 files changed, 17 insertions, 0 deletions
diff --git a/gdbstub.c b/gdbstub.c
index ac92273018..f19f98ab1a 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -3321,6 +3321,7 @@ static void gdb_chr_event(void *opaque, QEMUChrEvent event)
s->g_cpu = s->c_cpu;
vm_stop(RUN_STATE_PAUSED);
+ replay_gdb_attached();
gdb_has_xml = false;
break;
default:
diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h
index 172b20c60c..56c0c17c30 100644
--- a/include/sysemu/replay.h
+++ b/include/sysemu/replay.h
@@ -94,6 +94,8 @@ bool replay_reverse_continue(void);
bool replay_running_debug(void);
/* Called in reverse debugging mode to collect breakpoint information */
void replay_breakpoint(void);
+/* Called when gdb is attached to gdbstub */
+void replay_gdb_attached(void);
/* Processing the instructions */
diff --git a/replay/replay-debugging.c b/replay/replay-debugging.c
index 30ca38e5dd..ee9e86daa9 100644
--- a/replay/replay-debugging.c
+++ b/replay/replay-debugging.c
@@ -318,3 +318,17 @@ void replay_breakpoint(void)
assert(replay_mode == REPLAY_MODE_PLAY);
replay_last_breakpoint = replay_get_current_icount();
}
+
+void replay_gdb_attached(void)
+{
+ /*
+ * Create VM snapshot on temporary overlay to allow reverse
+ * debugging even if snapshots were not enabled.
+ */
+ if (replay_mode == REPLAY_MODE_PLAY
+ && !replay_snapshot) {
+ if (save_snapshot("start_debugging", NULL) != 0) {
+ /* Can't create the snapshot. Continue conventional debugging. */
+ }
+ }
+}