From patchwork Thu Mar 14 19:51:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 227791 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 12F952C00A3 for ; Fri, 15 Mar 2013 06:51:52 +1100 (EST) Received: from localhost ([::1]:46735 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGEBq-000695-CY for incoming@patchwork.ozlabs.org; Thu, 14 Mar 2013 15:51:50 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGEBc-00068c-4b for qemu-devel@nongnu.org; Thu, 14 Mar 2013 15:51:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UGEBW-0003bv-QO for qemu-devel@nongnu.org; Thu, 14 Mar 2013 15:51:36 -0400 Received: from goliath.siemens.de ([192.35.17.28]:34350) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGEBW-0003bd-Gr for qemu-devel@nongnu.org; Thu, 14 Mar 2013 15:51:30 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by goliath.siemens.de (8.13.6/8.13.6) with ESMTP id r2EJpQcq008177; Thu, 14 Mar 2013 20:51:26 +0100 Received: from mchn199C.mchp.siemens.de ([139.25.109.49]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id r2EJpPdW002683; Thu, 14 Mar 2013 20:51:25 +0100 Message-ID: <51422A3D.7000308@siemens.com> Date: Thu, 14 Mar 2013 20:51:25 +0100 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Anthony Liguori References: <1363109492-1901-1-git-send-email-chouteau@adacore.com> <1363109492-1901-2-git-send-email-chouteau@adacore.com> In-Reply-To: <1363109492-1901-2-git-send-email-chouteau@adacore.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 192.35.17.28 Cc: "qemu-devel@nongnu.org" , Fabien Chouteau Subject: [Qemu-devel] [PATCH v4] 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. Based on original version by Fabien Chouteau. Signed-off-by: Jan Kiszka Reviewed-by: Jesse Larrew --- As Fabien dropped his attempt to make this configurable, let's preserve the value of exposing this feature to gdb statically. gdbstub.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index e414ad9..9daee86 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -42,6 +42,12 @@ #include "sysemu/kvm.h" #include "qemu/bitops.h" +#ifdef CONFIG_USER_ONLY +#define GDB_ATTACHED "0" +#else +#define GDB_ATTACHED "1" +#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); + break; + } /* Unrecognised 'q' command. */ goto unknown_command;