From nobody Tue Feb 10 12:13:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542965306760214.11707896943597; Fri, 23 Nov 2018 01:28:26 -0800 (PST) Received: from localhost ([::1]:51207 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gQ7l4-0000W0-HS for importer@patchew.org; Fri, 23 Nov 2018 04:28:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gQ7bQ-0008MB-4G for qemu-devel@nongnu.org; Fri, 23 Nov 2018 04:18:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gQ7bP-0001rJ-6s for qemu-devel@nongnu.org; Fri, 23 Nov 2018 04:18:20 -0500 Received: from greensocs.com ([193.104.36.180]:47084) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gQ7bE-0000Y7-Av; Fri, 23 Nov 2018 04:18:08 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 4CA875E7083; Fri, 23 Nov 2018 10:17:38 +0100 (CET) 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 7Pu_KYu25Axg; Fri, 23 Nov 2018 10:17:37 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 4D9B15C026E; Fri, 23 Nov 2018 10:17:36 +0100 (CET) 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 E2D285BD1BB; Fri, 23 Nov 2018 10:17:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542964658; bh=Z00BqOOzxwxQiFvqeJqBI3QzAKx10rAgWiZpdnSVwVs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=e7DaYj1WrjjQbPcr5c25MhjcKG7EP7lGKR4prndD91mW1KOIAGbAq3vPjnEU1JQQJ KqICnLA9/V21FixDFyPTUG4ZpiUkq8Or+7a7y1CXYW31hMCPUzMPorBHwyEI6WxgWJ feYCZ0MuEHezllBPOKbX1rTylUMGjBaRAKvE2N/E= 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=kTT4IyNW; dkim=pass (1024-bit key) header.d=greensocs.com header.b=kTT4IyNW DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542964656; bh=Z00BqOOzxwxQiFvqeJqBI3QzAKx10rAgWiZpdnSVwVs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kTT4IyNWHQH5ZawXbni4GnvBEcpHW5KqFT3/kulj2ugtQ2m9EGQUm6FqZp52yOrv7 OP81OEWwS4NG3fHzotXoLCoC5ubacGZvXqvU7jTdfz9qhAoancLFpPI9RWFPAPiejS kqS59mW3ImfZQK1Tjvy+Nm0I0cWA61rZmXGjYbv0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542964656; bh=Z00BqOOzxwxQiFvqeJqBI3QzAKx10rAgWiZpdnSVwVs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kTT4IyNWHQH5ZawXbni4GnvBEcpHW5KqFT3/kulj2ugtQ2m9EGQUm6FqZp52yOrv7 OP81OEWwS4NG3fHzotXoLCoC5ubacGZvXqvU7jTdfz9qhAoancLFpPI9RWFPAPiejS kqS59mW3ImfZQK1Tjvy+Nm0I0cWA61rZmXGjYbv0= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 23 Nov 2018 10:17:23 +0100 Message-Id: <20181123091729.29921-11-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181123091729.29921-1-luc.michel@greensocs.com> References: <20181123091729.29921-1-luc.michel@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v7 10/16] 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: , Cc: Peter Maydell , Eduardo Habkost , alistair@alistair23.me, mark.burton@greensocs.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) Content-Type: text/plain; charset="utf-8" '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 --- gdbstub.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 4c4f519dd9..0cccce1f38 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1041,24 +1041,39 @@ static int gdb_breakpoint_remove(target_ulong addr,= target_ulong len, int type) default: return -ENOSYS; } } =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; =20 if (kvm_enabled()) { kvm_remove_all_breakpoints(gdbserver_state->c_cpu); return; } =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 static void gdb_set_cpu_pc(GDBState *s, target_ulong pc) { @@ -1333,13 +1348,44 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) /* Kill the target */ error_report("QEMU: Terminated via GDBstub"); 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': if (*p !=3D '\0') { addr =3D strtoull(p, (char **)&p, 16); --=20 2.19.1