From nobody Tue Feb 10 20:14:13 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1511275126475252.4669698655722; Tue, 21 Nov 2017 06:38:46 -0800 (PST) Received: from localhost ([::1]:34792 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eH9hA-000136-Os for importer@patchew.org; Tue, 21 Nov 2017 09:38:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eH9G4-0002US-I8 for qemu-devel@nongnu.org; Tue, 21 Nov 2017 09:10:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eH9G0-0003Gs-Er for qemu-devel@nongnu.org; Tue, 21 Nov 2017 09:10:40 -0500 Received: from mail.ispras.ru ([83.149.199.45]:38532) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eH9G0-0003Gh-2F for qemu-devel@nongnu.org; Tue, 21 Nov 2017 09:10:36 -0500 Received: from Misha-PC.lan02.inno (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id 62A6E54006E; Tue, 21 Nov 2017 17:10:35 +0300 (MSK) From: Mihail Abakumov To: qemu-devel@nongnu.org Date: Tue, 21 Nov 2017 17:10:33 +0300 Message-ID: <151127343314.6888.13289325558071964830.stgit@Misha-PC.lan02.inno> In-Reply-To: <151127322955.6888.16198535123422076171.stgit@Misha-PC.lan02.inno> References: <151127322955.6888.16198535123422076171.stgit@Misha-PC.lan02.inno> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [PATCH v3 35/45] windbg: debug exception subscribing X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sw@weilnetz.de, lprosek@redhat.com, dovgaluk@ispras.ru, rkagan@virtuozzo.com, pbonzini@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Added handler registration of gdb debug exception. Its exception also can b= e used for windbg. Signed-off-by: Mihail Abakumov Signed-off-by: Pavel Dovgalyuk Signed-off-by: Dmitriy Koltunov --- cpus.c | 18 +++++++++++++++++- gdbstub.c | 4 ++++ include/sysemu/sysemu.h | 2 ++ windbgstub.c | 16 ++++++++++++---- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/cpus.c b/cpus.c index 9bed61eefc..212553b7e3 100644 --- a/cpus.c +++ b/cpus.c @@ -77,6 +77,8 @@ int64_t max_advance; static QEMUTimer *throttle_timer; static unsigned int throttle_percentage; =20 +static void (*excp_debug_handler)(CPUState *cpu); + #define CPU_THROTTLE_PCT_MIN 1 #define CPU_THROTTLE_PCT_MAX 99 #define CPU_THROTTLE_TIMESLICE_NS 10000000 @@ -960,9 +962,23 @@ static bool cpu_can_run(CPUState *cpu) return true; } =20 +bool register_excp_debug_handler(void (*handler)(CPUState *cpu)) +{ + if (excp_debug_handler =3D=3D NULL) { + excp_debug_handler =3D handler; + return true; + } else { + error_report("ERROR: Something debugger already using"); + return false; + } +} + static void cpu_handle_guest_debug(CPUState *cpu) { - gdb_set_stop_cpu(cpu); + if (excp_debug_handler !=3D NULL) { + excp_debug_handler(cpu); + } + qemu_system_debug_request(); cpu->stopped =3D true; } diff --git a/gdbstub.c b/gdbstub.c index 2a94030d3b..8c76f54117 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2006,6 +2006,10 @@ int gdbserver_start(const char *device) s->mon_chr =3D mon_chr; s->current_syscall_cb =3D NULL; =20 + if (!register_excp_debug_handler(gdb_set_stop_cpu)) { + exit(1); + } + return 0; } =20 diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index b21369672a..34588c99b4 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -193,6 +193,8 @@ QemuOpts *qemu_get_machine_opts(void); =20 bool defaults_enabled(void); =20 +bool register_excp_debug_handler(void (*handler)(CPUState *cpu)); + extern QemuOptsList qemu_legacy_drive_opts; extern QemuOptsList qemu_common_drive_opts; extern QemuOptsList qemu_drive_opts; diff --git a/windbgstub.c b/windbgstub.c index 489abe6d6c..b33f412659 100755 --- a/windbgstub.c +++ b/windbgstub.c @@ -115,16 +115,20 @@ static void windbg_send_control_packet(uint16_t type) windbg_state->ctrl_packet_id ^=3D 1; } =20 -static void windbg_vm_stop(void) +static void windbg_bp_handler(CPUState *cpu) { - CPUState *cpu =3D qemu_get_cpu(0); - vm_stop(RUN_STATE_PAUSED); - SizedBuf buf =3D kd_gen_exception_sc(cpu); windbg_send_data_packet(buf.data, buf.size, PACKET_TYPE_KD_STATE_CHANG= E64); SBUF_FREE(buf); } =20 +static void windbg_vm_stop(void) +{ + CPUState *cpu =3D qemu_get_cpu(0); + vm_stop(RUN_STATE_PAUSED); + windbg_bp_handler(cpu); +} + static void windbg_process_manipulate_packet(ParsingContext *ctx) { CPUState *cpu; @@ -432,6 +436,10 @@ int windbg_server_start(const char *device) =20 qemu_register_reset(windbg_handle_reset, NULL); =20 + if (!register_excp_debug_handler(windbg_bp_handler)) { + exit(1); + } + atexit(windbg_exit); return 0; }