From nobody Mon Sep 15 18:08:18 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=ispras.ru ARC-Seal: i=1; a=rsa-sha256; t=1601377742; cv=none; d=zohomail.com; s=zohoarc; b=e8cLbg0D9U631hf3Cjkyc4y3ZZThOy7OFVJ1nO2kSSehjbXnjFO0guS+8SV1ejK3cwM2MpuuB9UF/FGIVLUndv6LNCb0mptv1euFkB+/dbBjysEZoU5TiYCKEHN3YzHsJmCJNgDIPoAj/WhyAzqwZJmkPFrOzVvjtYQyHp+3/Rc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601377742; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Gy7QnmrIpInXfCxQAqxEID7LjzNsOYAdeeF9Xi7a2cM=; b=GTkkvh6CAqG9AmNQzlL/xqJ/ZToUDF3io0P0I7/jPI3DOUSAHvbGr4SV0M/9rq7E7NX+JBcpUdSskI+PmnVt4ZoiZghdvMvnyRiu+J8jPUpHLHZ1MTVqI7mTbbSVGOU8c6D1cwl/sxxTy94teHplA1i+D+hRbt9oh2SUp7p4D3Y= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1601377742472845.1510997913797; Tue, 29 Sep 2020 04:09:02 -0700 (PDT) Received: from localhost ([::1]:56602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kNDVF-00038j-9c for importer@patchew.org; Tue, 29 Sep 2020 07:09:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kNDOr-0003fJ-DE for qemu-devel@nongnu.org; Tue, 29 Sep 2020 07:02:25 -0400 Received: from mail.ispras.ru ([83.149.199.84]:35304) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kNDOp-0002i1-Dm for qemu-devel@nongnu.org; Tue, 29 Sep 2020 07:02:24 -0400 Received: from [127.0.1.1] (unknown [62.118.151.149]) by mail.ispras.ru (Postfix) with ESMTPSA id 4ED2E413C33E; Tue, 29 Sep 2020 11:02:20 +0000 (UTC) Subject: [PATCH v6 13/14] replay: create temporary snapshot at debugger connection From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Tue, 29 Sep 2020 14:02:20 +0300 Message-ID: <160137734000.31007.4668841178583344264.stgit@pasha-ThinkPad-X280> In-Reply-To: <160137726426.31007.12061315974029139983.stgit@pasha-ThinkPad-X280> References: <160137726426.31007.12061315974029139983.stgit@pasha-ThinkPad-X280> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=83.149.199.84; envelope-from=pavel.dovgalyuk@ispras.ru; helo=mail.ispras.ru X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/29 07:01:05 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" 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 -- v6: - dropped unused error processing (suggested by Philippe Mathieu-Daud=C3= =A9) --- 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 =3D s->c_cpu; =20 vm_stop(RUN_STATE_PAUSED); + replay_gdb_attached(); gdb_has_xml =3D 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); =20 /* Processing the instructions */ =20 diff --git a/replay/replay-debugging.c b/replay/replay-debugging.c index d02d4e0766..a55715ba0a 100644 --- a/replay/replay-debugging.c +++ b/replay/replay-debugging.c @@ -316,3 +316,17 @@ void replay_breakpoint(void) assert(replay_mode =3D=3D REPLAY_MODE_PLAY); replay_last_breakpoint =3D 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 =3D=3D REPLAY_MODE_PLAY + && !replay_snapshot) { + if (save_snapshot("start_debugging", NULL) !=3D 0) { + /* Can't create the snapshot. Continue conventional debugging.= */ + } + } +}