From patchwork Fri Oct 26 08:16:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 989497 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=greensocs.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=greensocs.com header.i=@greensocs.com header.b="orY2G34F"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=greensocs.com header.i=@greensocs.com header.b="EfzeOY0j"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=greensocs.com header.i=@greensocs.com header.b="EfzeOY0j"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42hHQR75Xcz9s3C for ; Fri, 26 Oct 2018 19:36:15 +1100 (AEDT) Received: from localhost ([::1]:58838 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFxbJ-0000Xh-81 for incoming@patchwork.ozlabs.org; Fri, 26 Oct 2018 04:36:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFxUD-0000gN-6b for qemu-devel@nongnu.org; Fri, 26 Oct 2018 04:28:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gFxJY-0004y8-GF for qemu-devel@nongnu.org; Fri, 26 Oct 2018 04:17:53 -0400 Received: from greensocs.com ([193.104.36.180]:45406) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFxJT-0004la-Ny; Fri, 26 Oct 2018 04:17:48 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 9CFAA441B48; Fri, 26 Oct 2018 10:17:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1540541840; bh=L3lheXRjjCXYHVz6bZsvvaoBb9o5ZwPf2un7Fgcf6EM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=orY2G34F/yzysqdJR2OBUhO5bCBaSxZ6O823QP52IH/JktBgzNJQ9nWHv/MrjuJ6w NKpFwhOJugo1deeG5NZEbKjIhwSumLeof6Ywf7RNOsTVDarGs6HwMpr2AIRRrOanYy VXW6CLioO2C8BGYffKKnccLYWj1YCBu98QpzCQR8= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=EfzeOY0j; dkim=pass (1024-bit key) header.d=greensocs.com header.b=EfzeOY0j Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nZG5xloL_VVl; Fri, 26 Oct 2018 10:17:19 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id E05A0441B49; Fri, 26 Oct 2018 10:17:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1540541837; bh=L3lheXRjjCXYHVz6bZsvvaoBb9o5ZwPf2un7Fgcf6EM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=EfzeOY0jnDc07yxeRB0FJlZFSWDTFUU2zA2br+5zfiToyPlrxUeXheuZNeBXLFuRw j8itz+yTJ4sKgqnhCLjqAp8sh6kIeNyTOJzEcWIrGVNThecTDsrcYctnoqXVnSLSx4 dZ2I6hUNuzPShILzxz8yTRnJxQuxmyeSh283OtDA= Received: from michell-laptop.home.lmichel.fr (lfbn-1-8165-82.w90-112.abo.wanadoo.fr [90.112.74.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 7C081441B47; Fri, 26 Oct 2018 10:17:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1540541837; bh=L3lheXRjjCXYHVz6bZsvvaoBb9o5ZwPf2un7Fgcf6EM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=EfzeOY0jnDc07yxeRB0FJlZFSWDTFUU2zA2br+5zfiToyPlrxUeXheuZNeBXLFuRw j8itz+yTJ4sKgqnhCLjqAp8sh6kIeNyTOJzEcWIrGVNThecTDsrcYctnoqXVnSLSx4 dZ2I6hUNuzPShILzxz8yTRnJxQuxmyeSh283OtDA= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 26 Oct 2018 10:16:49 +0200 Message-Id: <20181026081653.24602-13-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181026081653.24602-1-luc.michel@greensocs.com> References: <20181026081653.24602-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v3 12/16] gdbstub: add support for vAttach packets 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: Peter Maydell , Eduardo Habkost , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Add support for the vAttach packets. In multiprocess mode, GDB sends them to attach to additional processes. Signed-off-by: Luc Michel --- gdbstub.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index 9c239c1760..e5eddd8e2b 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1337,10 +1337,45 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) break; } goto unknown_command; } break; + } else if (strncmp(p, "Attach;", 7) == 0) { + unsigned long pid; + + p += 7; + + if (qemu_strtoul(p, &p, 16, &pid)) { + put_packet(s, "E22"); + break; + } + + process = gdb_get_process(s, pid); + + if (process == NULL) { + put_packet(s, "E22"); + break; + } + + cpu = get_first_cpu_in_process(s, process); + + if (cpu == NULL) { + /* Refuse to attach an empty process */ + put_packet(s, "E22"); + break; + } + + process->attached = true; + + s->g_cpu = cpu; + s->c_cpu = cpu; + + snprintf(buf, sizeof(buf), "T%02xthread:%s;", GDB_SIGNAL_TRAP, + gdb_fmt_thread_id(s, cpu, thread_id, sizeof(thread_id))); + + put_packet(s, buf); + break; } else { goto unknown_command; } case 'k': /* Kill the target */