@@ -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:
@@ -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 */
@@ -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. */
+ }
+ }
+}