From patchwork Mon Oct 1 11:57:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10621921 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E50F71515 for ; Mon, 1 Oct 2018 12:07:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D280828FB9 for ; Mon, 1 Oct 2018 12:07:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C69AA29106; Mon, 1 Oct 2018 12:07:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7666428FB9 for ; Mon, 1 Oct 2018 12:07:30 +0000 (UTC) Received: from localhost ([::1]:37901 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wz3-00048X-P5 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 01 Oct 2018 08:07:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpn-0002jq-4Y for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6wpm-00061X-Du for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:55 -0400 Received: from greensocs.com ([193.104.36.180]:40136) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpg-0005iY-St; Mon, 01 Oct 2018 07:57:49 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id C91C8511C71; Mon, 1 Oct 2018 13:57:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395034; bh=9C/gIEA3NZLS7VnTV3RQTiDgLuN+c06HAC6nEZRMMAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SZaFWYkiOsu4oPrvC2yB8M2R6Ass2w2aWnQC4b4DqjE11Mi+L1scaeMfy55CgFJ0a VXDFj6gXRbNRWpkVKqkNUHyrUvlIRgR+aNw7yne3zBd4O4Vf3Uqm8nyFav/JSVofXJ gu+SWaausqmnN/p3mLcViOT+TQYx4h34TRNsL7KE= 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=W7Yx0Td2; dkim=pass (1024-bit key) header.d=greensocs.com header.b=W7Yx0Td2 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 XwQY7GnSPX3z; Mon, 1 Oct 2018 13:57:14 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 5501E511C59; Mon, 1 Oct 2018 13:57:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395031; bh=9C/gIEA3NZLS7VnTV3RQTiDgLuN+c06HAC6nEZRMMAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=W7Yx0Td2RjuHMYcaYWI7RdT9g+qcHZ4n6JYYDOeQB8vUvAsGtsTCkClj+l05/8VyA X8JXwSx9MWMdcqq1NzFyt8OVi5ze4jBeY6sNgE9LY9Mq2Mwp54BG+ct4Gy11INZjm/ 6cWV9C5JQIlGyfJDE1u0Mk9HP/+5QCRXeO2nNIBg= 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 E7EDB511C6F; Mon, 1 Oct 2018 13:57:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395031; bh=9C/gIEA3NZLS7VnTV3RQTiDgLuN+c06HAC6nEZRMMAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=W7Yx0Td2RjuHMYcaYWI7RdT9g+qcHZ4n6JYYDOeQB8vUvAsGtsTCkClj+l05/8VyA X8JXwSx9MWMdcqq1NzFyt8OVi5ze4jBeY6sNgE9LY9Mq2Mwp54BG+ct4Gy11INZjm/ 6cWV9C5JQIlGyfJDE1u0Mk9HP/+5QCRXeO2nNIBg= From: Luc Michel To: qemu-devel@nongnu.org Date: Mon, 1 Oct 2018 13:57:00 +0200 Message-Id: <20181001115704.701-12-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181001115704.701-1-luc.michel@greensocs.com> References: <20181001115704.701-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 v2 11/15] 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 , 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add support for the vAttach packets. In multiprocess mode, GDB sends them to attach to additional processes. Signed-off-by: Luc Michel --- gdbstub.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index d372972dd3..b6de821025 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1326,10 +1326,42 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) break; } goto unknown_command; } break; + } else if (strncmp(p, "Attach", 6) == 0) { + unsigned long pid; + + p += 7; + + qemu_strtoul(p, &p, 16, &pid); + + 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 */