Skip to content

Commit

Permalink
replay: create temporary snapshot at debugger connection
Browse files Browse the repository at this point in the history
When record/replay does not uses overlays for storing the snapshots,
user is not capable of issuing reverse debugging commands.
This patch adds creation of the VM snapshot on the temporary
overlay image, when the debugger connects to QEMU.
Therefore the execution can be rewind to the moment
of the debugger connection while debugging the virtual machine.

Signed-off-by: Pavel Dovgalyuk <[email protected]>

--

v6:
 - dropped unused error processing (suggested by Philippe Mathieu-Daudé)
Message-Id: <160174524096.12451.11651270339216758643.stgit@pasha-ThinkPad-X280>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
Dovgalyuk authored and bonzini committed Oct 6, 2020
1 parent 9a608af commit 56357d8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions gdbstub.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions include/sysemu/replay.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
14 changes: 14 additions & 0 deletions replay/replay-debugging.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
}
}
}

0 comments on commit 56357d8

Please sign in to comment.