All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Dovgalyuk <pavel.dovgalyuk@ispras.ru>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, wrampazz@redhat.com, pavel.dovgalyuk@ispras.ru,
	ehabkost@redhat.com, alex.bennee@linaro.org, mtosatti@redhat.com,
	armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com,
	crosa@redhat.com, pbonzini@redhat.com, philmd@redhat.com,
	zhiwei_liu@c-sky.com, rth@twiddle.net
Subject: [PATCH v7 13/14] replay: create temporary snapshot at debugger connection
Date: Sat, 03 Oct 2020 20:14:01 +0300	[thread overview]
Message-ID: <160174524096.12451.11651270339216758643.stgit@pasha-ThinkPad-X280> (raw)
In-Reply-To: <160174516520.12451.10785284392438702137.stgit@pasha-ThinkPad-X280>

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 <Pavel.Dovgalyuk@ispras.ru>

--

v6:
 - dropped unused error processing (suggested by Philippe Mathieu-Daudé)
---
 gdbstub.c                 |    1 +
 include/sysemu/replay.h   |    2 ++
 replay/replay-debugging.c |   14 ++++++++++++++
 3 files changed, 17 insertions(+)

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 b6cac175c4..2aa34b8919 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. */
+        }
+    }
+}



  parent reply	other threads:[~2020-10-03 17:26 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-03 17:12 [PATCH v7 00/14] Reverse debugging Pavel Dovgalyuk
2020-10-03 17:12 ` [PATCH v7 01/14] replay: don't record interrupt poll Pavel Dovgalyuk
2020-10-03 17:12 ` [PATCH v7 02/14] replay: provide an accessor for rr filename Pavel Dovgalyuk
2020-10-03 17:13 ` [PATCH v7 03/14] qcow2: introduce icount field for snapshots Pavel Dovgalyuk
2020-10-03 17:13 ` [PATCH v7 04/14] migration: " Pavel Dovgalyuk
2020-10-03 17:13 ` [PATCH v7 05/14] qapi: introduce replay.json for record/replay-related stuff Pavel Dovgalyuk
2020-10-03 17:13 ` [PATCH v7 06/14] replay: introduce info hmp/qmp command Pavel Dovgalyuk
2020-10-03 17:13 ` [PATCH v7 07/14] replay: introduce breakpoint at the specified step Pavel Dovgalyuk
2020-10-03 17:13 ` [PATCH v7 08/14] replay: implement replay-seek command Pavel Dovgalyuk
2020-10-03 17:13 ` [PATCH v7 09/14] replay: flush rr queue before loading the vmstate Pavel Dovgalyuk
2020-10-03 17:13 ` [PATCH v7 10/14] gdbstub: add reverse step support in replay mode Pavel Dovgalyuk
2020-10-03 17:13 ` [PATCH v7 11/14] gdbstub: add reverse continue " Pavel Dovgalyuk
2020-10-03 17:13 ` [PATCH v7 12/14] replay: describe reverse debugging in docs/replay.txt Pavel Dovgalyuk
2020-10-03 17:14 ` Pavel Dovgalyuk [this message]
2020-10-03 17:14 ` [PATCH v7 14/14] tests/acceptance: add reverse debugging test Pavel Dovgalyuk
2020-10-06 13:36   ` Cleber Rosa
2020-10-06 15:09     ` Pavel Dovgalyuk
2020-10-06 18:16       ` Cleber Rosa
2020-10-06 19:55   ` Philippe Mathieu-Daudé
2020-10-07  5:42     ` Philippe Mathieu-Daudé
2020-10-04  1:06 ` [PATCH v7 00/14] Reverse debugging no-reply
2020-10-05 12:27 ` Paolo Bonzini
2020-10-05 13:45   ` Pavel Dovgalyuk
2020-10-05 13:51     ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=160174524096.12451.11651270339216758643.stgit@pasha-ThinkPad-X280 \
    --to=pavel.dovgalyuk@ispras.ru \
    --cc=alex.bennee@linaro.org \
    --cc=armbru@redhat.com \
    --cc=crosa@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=stefanha@redhat.com \
    --cc=wrampazz@redhat.com \
    --cc=zhiwei_liu@c-sky.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.