aboutsummaryrefslogtreecommitdiff
path: root/replay
diff options
context:
space:
mode:
authorPavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>2020-10-03 20:13:49 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2020-10-06 08:34:49 +0200
commitcda382594b7ea50aff5f672f32767f9f9fef4c12 (patch)
tree9d33774ea1a44059a0a7d5e9895f5d7a3d530eba /replay
parentfda8458bd3a9cb3108ba2f09921b6e3eee0d1bf3 (diff)
gdbstub: add reverse continue support in replay mode
This patch adds support of the reverse continue operation for gdbstub. Reverse continue finds the last breakpoint that would happen in normal execution from the beginning to the current moment. Implementation of the reverse continue replays the execution twice: to find the breakpoints that were hit and to seek to the last breakpoint. Reverse continue loads the previous snapshot and tries to find the breakpoint since that moment. If there are no such breakpoints, it proceeds to the earlier snapshot, and so on. When no breakpoints or watchpoints were hit at all, execution stops at the beginning of the replay log. Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru> Message-Id: <160174522930.12451.6994758004725016836.stgit@pasha-ThinkPad-X280> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
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();
+}