From patchwork Fri Dec 7 09:01:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 1009246 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="Pi5DYeNa"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=greensocs.com header.i=@greensocs.com header.b="nZyw/Xah"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=greensocs.com header.i=@greensocs.com header.b="nZyw/Xah"; 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 43B6FL0XT8z9s3q for ; Fri, 7 Dec 2018 20:12:51 +1100 (AEDT) Received: from localhost ([::1]:44897 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVCBj-0000kI-Nh for incoming@patchwork.ozlabs.org; Fri, 07 Dec 2018 04:12:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57458) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1O-00081q-A2 for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVC1H-0005Wz-DJ for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:05 -0500 Received: from greensocs.com ([193.104.36.180]:52247) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1B-0005Rt-Ax; Fri, 07 Dec 2018 04:01:53 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 10E7B511C5F; Fri, 7 Dec 2018 10:01:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173312; bh=1YfOa6KOFz7+7vzadhdXswLweJ5s+84SUWufA2FeAHI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Pi5DYeNaSgvXp87NaMdAhQ2JpNkSboV6FiIEOXJ5JAfEDuRSMcVYathp/HIIU23ur LLES74ZBZDKmh0p+1jSsxjdCGZTz2N/jj4Knto7YXWUarNY9jEoySHsqQY/tceL3Oh HGs5IJQq4eZRN5XShyFhpzONVyNfzbo6cgOQ/LSo= 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=nZyw/Xah; dkim=pass (1024-bit key) header.d=greensocs.com header.b=nZyw/Xah 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 YOZfpkmDVJnh; Fri, 7 Dec 2018 10:01:51 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 4DD4A48003A; Fri, 7 Dec 2018 10:01:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173306; bh=1YfOa6KOFz7+7vzadhdXswLweJ5s+84SUWufA2FeAHI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nZyw/XahwVzHrG7ZGAbNtnnd7P1onfGeibw1RiutgNeRpff4WRvFiwRp/I28HUobo gEo8/BVCTqL5Q4liXjfuPr7qinzMm9TFr4r4AP2WSnCb+ffvYqEyjl6sYj7CwOUEQ8 ZUXlT/kmBIuqIrLAzKh0yx8bVEjrkby29iRL5kmQ= 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 D31C4480037; Fri, 7 Dec 2018 10:01:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173306; bh=1YfOa6KOFz7+7vzadhdXswLweJ5s+84SUWufA2FeAHI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nZyw/XahwVzHrG7ZGAbNtnnd7P1onfGeibw1RiutgNeRpff4WRvFiwRp/I28HUobo gEo8/BVCTqL5Q4liXjfuPr7qinzMm9TFr4r4AP2WSnCb+ffvYqEyjl6sYj7CwOUEQ8 ZUXlT/kmBIuqIrLAzKh0yx8bVEjrkby29iRL5kmQ= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 10:01:30 +0100 Message-Id: <20181207090135.7651-13-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181207090135.7651-1-luc.michel@greensocs.com> References: <20181207090135.7651-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v8 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 Reviewed-by: Edgar E. Iglesias Acked-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daudé --- gdbstub.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index 1cf1bea428..8601be533b 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1347,10 +1347,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 */