From nobody Tue Apr 15 14:46:40 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1546879215603651.6982922210168; Mon, 7 Jan 2019 08:40:15 -0800 (PST) Received: from localhost ([127.0.0.1]:44367 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggXwk-0002w3-FX for importer@patchew.org; Mon, 07 Jan 2019 11:40:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46373) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggXoa-00050f-P5 for qemu-devel@nongnu.org; Mon, 07 Jan 2019 11:31:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggXoY-00025Y-FR for qemu-devel@nongnu.org; Mon, 07 Jan 2019 11:31:48 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:37102) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ggXoY-0001rP-5r for qemu-devel@nongnu.org; Mon, 07 Jan 2019 11:31:46 -0500 Received: by mail-wr1-x430.google.com with SMTP id s12so1079270wrt.4 for ; Mon, 07 Jan 2019 08:31:37 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id j14sm46039759wrv.96.2019.01.07.08.31.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Jan 2019 08:31:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=1s/FyqcakpdikFoKdyxVjsd1dTTqxskhDVsUDUlN9cs=; b=XTFDdOfY8jNy+vmLzqcuzQcwwWQ8PyKPV+YzF2GK2NGmBLzTvp3ql12ei9XQcK8Dzr yVQrIDxp4vfeHoHwZz+j44UDz3YvQ+BfyU6xL3Jgs9phnGqQSVXS4pliPdYZtIxIHkds xCRpHX1ltMieKvWLcc9T6XIaY2ZJlXyAInNC8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1s/FyqcakpdikFoKdyxVjsd1dTTqxskhDVsUDUlN9cs=; b=cPuJ8yTaqdakWsEEyNWPL3QnAknmVNxuEKlXq2/UORG2fz5i1O8hhMRbvQAFaoeDml iEceWmMj+WtPW6tH93R+HnNdHF9K/Z2GqH2TlyFMjicee9MPywdIHlKRMeST+vA6AsyO RvPCdg5zs9T1llFDF1LIYvqoPGhsjTe/BmCV4P68zu49sTNiJT1E1GDPMaX9qc5so+wI E5Tk4uscEhY8ghtWhblzA4rdaRi3/vkhnwAAuGRKKFdjyshfVKwvbCA0WOvJg87L9HSr i7kbNXM8a35YXuF37AJEH1nCdhTN8fJN6EQ8JTclrvTkftdzyRCv7kCvB3bOw7HyMGv4 iirw== X-Gm-Message-State: AJcUukelO5DmEoiwiu4d2WkHv0pumGSRibxwRCQOpZg7ZVptTfA4dTpx alaYpDKtNM2KIewo1ghrld1t4+HnLiWlVQ== X-Google-Smtp-Source: ALg8bN5kn5su05T0KD99Z99ibUBsbmb4KU9O0H6EIJpOTPBWkaMG/qL77xE2ia9yf6vw9yAensXnPg== X-Received: by 2002:a5d:444a:: with SMTP id x10mr54560311wrr.162.1546878695723; Mon, 07 Jan 2019 08:31:35 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 7 Jan 2019 16:30:52 +0000 Message-Id: <20190107163117.16269-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190107163117.16269-1-peter.maydell@linaro.org> References: <20190107163117.16269-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::430 Subject: [Qemu-devel] [PULL 12/37] gdbstub: add multiprocess support to 'D' 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Luc Michel 'D' packets are used by GDB to detach from a process. In multiprocess mode, the PID to detach from is sent in the request. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Edgar E. Iglesias Acked-by: Alistair Francis Message-id: 20181207090135.7651-11-luc.michel@greensocs.com Signed-off-by: Peter Maydell --- gdbstub.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index edee38b6136..2c7032f53ab 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1047,6 +1047,24 @@ static int gdb_breakpoint_remove(target_ulong addr, = target_ulong len, int type) } } =20 +static inline void gdb_cpu_breakpoint_remove_all(CPUState *cpu) +{ + cpu_breakpoint_remove_all(cpu, BP_GDB); +#ifndef CONFIG_USER_ONLY + cpu_watchpoint_remove_all(cpu, BP_GDB); +#endif +} + +static void gdb_process_breakpoint_remove_all(const GDBState *s, GDBProces= s *p) +{ + CPUState *cpu =3D get_first_cpu_in_process(s, p); + + while (cpu) { + gdb_cpu_breakpoint_remove_all(cpu); + cpu =3D gdb_next_cpu_in_process(s, cpu); + } +} + static void gdb_breakpoint_remove_all(void) { CPUState *cpu; @@ -1057,10 +1075,7 @@ static void gdb_breakpoint_remove_all(void) } =20 CPU_FOREACH(cpu) { - cpu_breakpoint_remove_all(cpu, BP_GDB); -#ifndef CONFIG_USER_ONLY - cpu_watchpoint_remove_all(cpu, BP_GDB); -#endif + gdb_cpu_breakpoint_remove_all(cpu); } } =20 @@ -1339,9 +1354,40 @@ static int gdb_handle_packet(GDBState *s, const char= *line_buf) exit(0); case 'D': /* Detach packet */ - gdb_breakpoint_remove_all(); - gdb_syscall_mode =3D GDB_SYS_DISABLED; - gdb_continue(s); + pid =3D 1; + + if (s->multiprocess) { + unsigned long lpid; + if (*p !=3D ';') { + put_packet(s, "E22"); + break; + } + + if (qemu_strtoul(p + 1, &p, 16, &lpid)) { + put_packet(s, "E22"); + break; + } + + pid =3D lpid; + } + + process =3D gdb_get_process(s, pid); + gdb_process_breakpoint_remove_all(s, process); + process->attached =3D false; + + if (pid =3D=3D gdb_get_cpu_pid(s, s->c_cpu)) { + s->c_cpu =3D gdb_first_attached_cpu(s); + } + + if (pid =3D=3D gdb_get_cpu_pid(s, s->g_cpu)) { + s->g_cpu =3D gdb_first_attached_cpu(s); + } + + if (s->c_cpu =3D=3D NULL) { + /* No more process attached */ + gdb_syscall_mode =3D GDB_SYS_DISABLED; + gdb_continue(s); + } put_packet(s, "OK"); break; case 's': --=20 2.19.2