From patchwork Tue Mar 5 16:03:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabien Chouteau X-Patchwork-Id: 225068 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 13FF52C032C for ; Wed, 6 Mar 2013 03:04:06 +1100 (EST) Received: from localhost ([::1]:51841 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCuLU-0004qC-8x for incoming@patchwork.ozlabs.org; Tue, 05 Mar 2013 11:04:04 -0500 Received: from eggs.gnu.org ([208.118.235.92]:38421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCuKz-0004il-CO for qemu-devel@nongnu.org; Tue, 05 Mar 2013 11:03:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UCuKx-0002sj-NC for qemu-devel@nongnu.org; Tue, 05 Mar 2013 11:03:33 -0500 Received: from mel.act-europe.fr ([194.98.77.210]:35687) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCuKx-0002sV-BP for qemu-devel@nongnu.org; Tue, 05 Mar 2013 11:03:31 -0500 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 8763729007D; Tue, 5 Mar 2013 17:03:30 +0100 (CET) X-Virus-Scanned: amavisd-new at eu.adacore.com Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZOPHfKS+2AoQ; Tue, 5 Mar 2013 17:03:30 +0100 (CET) Received: from PomPomGalli.act-europe.fr (pompomgalli.act-europe.fr [10.10.1.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 42422290079; Tue, 5 Mar 2013 17:03:30 +0100 (CET) From: Fabien Chouteau To: qemu-devel@nongnu.org Date: Tue, 5 Mar 2013 17:03:18 +0100 Message-Id: <1362499399-19475-1-git-send-email-chouteau@adacore.com> X-Mailer: git-send-email 1.7.9.5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 194.98.77.210 Cc: jan.kiszka@siemens.com Subject: [Qemu-devel] [PATCH 1/2] Add GDB qAttached support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org With this patch GDB will issue a "detach" command at the end of a debugging session instead of a "kill". This behavior can be inverted with the new option -gdb-not-attached. This patch implements the requirement described in Jan Kiszka's patch: "gdbstub: Do not kill target in system emulation mode". The patch can therefore be reverted. Signed-off-by: Fabien Chouteau --- gdbstub.c | 13 ++++++++++++- include/exec/gdbstub.h | 2 ++ qemu-options.hx | 7 +++++++ vl.c | 3 +++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/gdbstub.c b/gdbstub.c index e414ad9..c0686a9 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -32,7 +32,6 @@ #include "monitor/monitor.h" #include "char/char.h" #include "sysemu/sysemu.h" -#include "exec/gdbstub.h" #endif #define MAX_PACKET_LENGTH 4096 @@ -41,6 +40,9 @@ #include "qemu/sockets.h" #include "sysemu/kvm.h" #include "qemu/bitops.h" +#include "exec/gdbstub.h" + +static bool gdb_attached = true; #ifndef TARGET_CPU_MEMORY_RW_DEBUG static inline int target_memory_rw_debug(CPUArchState *env, target_ulong addr, @@ -2491,6 +2493,10 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) break; } #endif + if (strncmp(p, "Attached", 8) == 0) { + put_packet(s, gdb_attached ? "1" : "0"); + break; + } /* Unrecognised 'q' command. */ goto unknown_command; @@ -3055,3 +3061,8 @@ int gdbserver_start(const char *device) return 0; } #endif + +void gdb_set_attached(bool attached) +{ + gdb_attached = attached; +} diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index ba20afa..b2d3b13 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -50,4 +50,6 @@ int gdbserver_start(const char *port); /* in gdbstub-xml.c, generated by scripts/feature_to_c.sh */ extern const char *const xml_builtin[][2]; +void gdb_set_attached(bool attached); + #endif diff --git a/qemu-options.hx b/qemu-options.hx index 6f9334a..026d3eb 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2988,6 +2988,13 @@ property must be set. These objects are placed in the '/objects' path. ETEXI +DEF("gdb-not-attached", 0, QEMU_OPTION_gdb_not_attached, + "-gdb-not-attached\n" + " Do not set Gdb remote server in attached mode.\n" + " When exiting debugging session, Gdb will send a 'kill'\n" + " command instead of a 'detach'.\n", + QEMU_ARCH_ALL) + HXCOMM This is the last statement. Insert new options before this line! STEXI @end table diff --git a/vl.c b/vl.c index c03edf1..ccd7405 100644 --- a/vl.c +++ b/vl.c @@ -3815,6 +3815,9 @@ int main(int argc, char **argv, char **envp) exit(1); } break; + case QEMU_OPTION_gdb_not_attached: + gdb_set_attached(false); + break; default: os_parse_cmd_args(popt->index, optarg); }