From patchwork Tue Mar 12 17:31:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabien Chouteau X-Patchwork-Id: 227105 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 C9B132C0298 for ; Wed, 13 Mar 2013 06:21:15 +1100 (EST) Received: from localhost ([::1]:33230 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFUl7-0007sy-JI for incoming@patchwork.ozlabs.org; Tue, 12 Mar 2013 15:21:13 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47762) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFUjn-0007YV-Ht for qemu-devel@nongnu.org; Tue, 12 Mar 2013 15:20:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UFUg7-0000xy-DY for qemu-devel@nongnu.org; Tue, 12 Mar 2013 15:19:51 -0400 Received: from mel.act-europe.fr ([194.98.77.210]:36397) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFT33-0004EF-0y for qemu-devel@nongnu.org; Tue, 12 Mar 2013 13:31:37 -0400 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id D9C8729005F; Tue, 12 Mar 2013 18:31:35 +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 j2NW-eMulpBd; Tue, 12 Mar 2013 18:31:35 +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 B7630290041; Tue, 12 Mar 2013 18:31:35 +0100 (CET) From: Fabien Chouteau To: qemu-devel@nongnu.org Date: Tue, 12 Mar 2013 18:31:30 +0100 Message-Id: <1363109492-1901-2-git-send-email-chouteau@adacore.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1363109492-1901-1-git-send-email-chouteau@adacore.com> References: <1363109492-1901-1-git-send-email-chouteau@adacore.com> 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 V3 1/3] 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 QEMU handles qAttached request from gdb. When QEMU replies 1, GDB sends a "detach" command at the end of a debugging session otherwise GDB sends "kill". The default value for qAttached is 1 on system emulation and 0 on user emulation. 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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index e414ad9..70d54ce 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -42,6 +42,12 @@ #include "sysemu/kvm.h" #include "qemu/bitops.h" +#ifdef CONFIG_USER_ONLY +static bool gdb_attached; /* false */ +#else +static bool gdb_attached = true; +#endif + #ifndef TARGET_CPU_MEMORY_RW_DEBUG static inline int target_memory_rw_debug(CPUArchState *env, target_ulong addr, uint8_t *buf, int len, int is_write) @@ -2491,6 +2497,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;