From nobody Sun Feb 8 18:43:20 2026 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1556254708; cv=none; d=zoho.com; s=zohoarc; b=Ef8xQQOfv/o2umZGa613/k1T9Er+t33uvNW1Hy1KDk5u08crSMg9x+zeZw7PZnnP95+zaOYXo5dHyMzpfmlRIn24+Q+AkYhiWuOqVPKjGosYKvMtyv7M9EZgUShzPZFYJyBCJMUK4LiIq/4rvBHp30W5aWed4pr7TYZHVyJzmQM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556254708; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=o9g7yNsrGp0cm0nQks6oxRIXlO2CyhOpcYCjoRIegtQ=; b=eTBK5xh67/cY1UcDL/67RppwlqJG8XvKgEIh8pbYxYh7WDE1RxuQAeUAI0m69rpc2bVxiu6URHuuEHVLn7K22iTcfZnjYbxrXuHZVAEkGmEuzzvaHi6EXsfp3c/PyPn7SSdea0cna5Ht34nE6C09VhDEO58vDgWvlOt9pCa9lqI= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1556254707997486.70210712617643; Thu, 25 Apr 2019 21:58:27 -0700 (PDT) Received: from localhost ([127.0.0.1]:39255 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJswJ-0002hS-UV for importer@patchew.org; Fri, 26 Apr 2019 00:58:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJsmn-0000dE-Ur for qemu-devel@nongnu.org; Fri, 26 Apr 2019 00:48:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hJsar-0004Du-Ho for qemu-devel@nongnu.org; Fri, 26 Apr 2019 00:36:15 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:41405) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hJsap-0004CV-Vj for qemu-devel@nongnu.org; Fri, 26 Apr 2019 00:36:13 -0400 Received: by mail-wr1-x444.google.com with SMTP id c12so2424813wrt.8 for ; Thu, 25 Apr 2019 21:36:11 -0700 (PDT) Received: from localhost.localdomain (bzq-79-178-247-46.red.bezeqint.net. [79.178.247.46]) by smtp.gmail.com with ESMTPSA id h5sm3467088wmf.38.2019.04.25.21.36.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Apr 2019 21:36:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o9g7yNsrGp0cm0nQks6oxRIXlO2CyhOpcYCjoRIegtQ=; b=ed8ZoRcprNxGRyN50dgEXFK6upOUMA19AsUfWamwRpdE7qA+3SFCx/tZyNPPWC21wD 2FDvY6SCgxfTdAvehMjKZLR5X4Tuu9YLnrI4EzvCXMihKtV4Vv29sAq1iQasJoyQlouZ mBHfPYleRDND41NzPGs1O+M3QpSbIEl1ySnZoAVOhci+sqnWYUA7R91m6rf8GgQ/UtYo fA+I+ve3K3Y798TW3awfjETUU5FG3RMtT0WT56xzHlwREy3F5/UtNSkJl85MD3Fdj6+4 As1TDpjoXz+mqDqdAxgHzqbHEwCOf3aaiJtkVfgCqt/JiKxMbdYRiJmTHngtisuf5+ke EJsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o9g7yNsrGp0cm0nQks6oxRIXlO2CyhOpcYCjoRIegtQ=; b=Mg0b/6f1C8finEcAHw/jHqo97eN9BUdUGFQAMGM1Pk2OE/Ri+32/CSa77P3eaRM3HM XqX9LLA4JKj+cfwuq7WqP7Q+QmaTJ6V++PSBqI3cmUbmZj/3Bf3pzuBU2Js5ZwEDNp4s WYowfj0r4iChfajn1ciqveo3TdoP7S4YnTai/IKNYuvxa7YTJt4Ri6gtl8eQNeNf2ZFO PkuFZYF7QPYxzdy534Y00gtXPZ+e3EjGN3/qjsp4ZZ9PCJ/gD3eTUnVR8ySeQkY3ueVp geheKvty+Jwvvc3NO3bKHsX2fcQeD3MpDBsnoAdb6wkGKtXYBSw42rd0bKIuKWNDkxZA 0jTw== X-Gm-Message-State: APjAAAXO87GEaQw/yswAuPlNq9xK8d1loCek1Us1LLBA+7UE02fYBH2r GLV2SZaYiaBIwPQYJ8i3/iuYXgYa X-Google-Smtp-Source: APXvYqwc6/qPUoqs5jAyuzXvR9bumJDVCv9gma9ByBlM++ygXthng2BLyO9rKZP7VzpNidpvy/kxCA== X-Received: by 2002:adf:f64f:: with SMTP id x15mr8687595wrp.202.1556253370427; Thu, 25 Apr 2019 21:36:10 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Fri, 26 Apr 2019 07:35:39 +0300 Message-Id: <20190426043558.6888-3-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190426043558.6888-1-arilou@gmail.com> References: <20190426043558.6888-1-arilou@gmail.com> MIME-Version: 1.0 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::444 Subject: [Qemu-devel] [PATCH v7 02/21] gdbstub: Implement deatch (D pkt) with new infra 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: alex.bennee@linaro.org, Jon Doron Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jon Doron --- gdbstub.c | 90 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 50 insertions(+), 40 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index d5e0f3878a..621d689868 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1418,11 +1418,6 @@ static inline int startswith(const char *string, con= st char *pattern) return !strncmp(string, pattern, strlen(pattern)); } =20 -static int process_string_cmd( - GDBState *s, void *user_ctx, const char *data, - const GdbCmdParseEntry *cmds, int num_cmds) - __attribute__((unused)); - static int process_string_cmd(GDBState *s, void *user_ctx, const char *dat= a, const GdbCmdParseEntry *cmds, int num_cmds) { @@ -1468,6 +1463,41 @@ static int process_string_cmd(GDBState *s, void *use= r_ctx, const char *data, return -1; } =20 +static void handle_detach(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + GDBProcess *process; + GDBState *s =3D gdb_ctx->s; + uint32_t pid =3D 1; + + if (s->multiprocess) { + if (!gdb_ctx->num_params) { + put_packet(s, "E22"); + return; + } + + pid =3D gdb_ctx->params[0].val_ul; + } + + 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) { + /* No more process attached */ + gdb_syscall_mode =3D GDB_SYS_DISABLED; + gdb_continue(s); + } + put_packet(s, "OK"); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1482,6 +1512,7 @@ static int gdb_handle_packet(GDBState *s, const char = *line_buf) uint8_t *registers; target_ulong addr, len; GDBThreadIdKind thread_kind; + const GdbCmdParseEntry *cmd_parser =3D NULL; =20 trace_gdbstub_io_command(line_buf); =20 @@ -1582,42 +1613,15 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) error_report("QEMU: Terminated via GDBstub"); exit(0); case 'D': - /* Detach packet */ - 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); + { + static const GdbCmdParseEntry detach_cmd_desc =3D { + .handler =3D handle_detach, + .cmd =3D "D", + .cmd_startswith =3D 1, + .schema =3D "?.l0" + }; + cmd_parser =3D &detach_cmd_desc; } - put_packet(s, "OK"); break; case 's': if (*p !=3D '\0') { @@ -1990,6 +1994,12 @@ static int gdb_handle_packet(GDBState *s, const char= *line_buf) put_packet(s, buf); break; } + + if (cmd_parser && + process_string_cmd(s, NULL, line_buf, cmd_parser, 1)) { + put_packet(s, ""); + } + return RS_IDLE; } =20 --=20 2.20.1