aboutsummaryrefslogtreecommitdiff
path: root/replay
diff options
context:
space:
mode:
Diffstat (limited to 'replay')
-rw-r--r--replay/replay-debugging.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/replay/replay-debugging.c b/replay/replay-debugging.c
index 1e1dec0295..30ca38e5dd 100644
--- a/replay/replay-debugging.c
+++ b/replay/replay-debugging.c
@@ -23,6 +23,8 @@
#include "migration/snapshot.h"
static bool replay_is_debugging;
+static int64_t replay_last_breakpoint;
+static int64_t replay_last_snapshot;
bool replay_running_debug(void)
{
@@ -246,3 +248,73 @@ bool replay_reverse_step(void)
return false;
}
+
+static void replay_continue_end(void)
+{
+ replay_is_debugging = false;
+ vm_stop(RUN_STATE_DEBUG);
+ replay_delete_break();
+}
+
+static void replay_continue_stop(void *opaque)
+{
+ Error *err = NULL;
+ if (replay_last_breakpoint != -1LL) {
+ replay_seek(replay_last_breakpoint, replay_stop_vm_debug, &err);
+ if (err) {
+ error_free(err);
+ replay_continue_end();
+ }
+ return;
+ }
+ /*
+ * No breakpoints since the last snapshot.
+ * Find previous snapshot and try again.
+ */
+ if (replay_last_snapshot != 0) {
+ replay_seek(replay_last_snapshot - 1, replay_continue_stop, &err);
+ if (err) {
+ error_free(err);
+ replay_continue_end();
+ }
+ replay_last_snapshot = replay_get_current_icount();
+ return;
+ } else {
+ /* Seek to the very first step */
+ replay_seek(0, replay_stop_vm_debug, &err);
+ if (err) {
+ error_free(err);
+ replay_continue_end();
+ }
+ return;
+ }
+ replay_continue_end();
+}
+
+bool replay_reverse_continue(void)
+{
+ Error *err = NULL;
+
+ assert(replay_mode == REPLAY_MODE_PLAY);
+
+ if (replay_get_current_icount() != 0) {
+ replay_seek(replay_get_current_icount() - 1,
+ replay_continue_stop, &err);
+ if (err) {
+ error_free(err);
+ return false;
+ }
+ replay_last_breakpoint = -1LL;
+ replay_is_debugging = true;
+ replay_last_snapshot = replay_get_current_icount();
+ return true;
+ }
+
+ return false;
+}
+
+void replay_breakpoint(void)
+{
+ assert(replay_mode == REPLAY_MODE_PLAY);
+ replay_last_breakpoint = replay_get_current_icount();
+}