From nobody Sat Sep 28 22:06:48 2024 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=1556782387; cv=none; d=zoho.com; s=zohoarc; b=hzd8Owe5/Dkb/lj1qkL7Spq81u5Uk7iUUtIZXL7H2wy2YdyKZ8wDsyMS+5aShJSJ1qYQw3cVcsouZyIxib1JxITWKEo21QFnHJb14Z42ds7LMAaI8SvtiJtYKEREj7dEToxoWLmxkJTygvKFOcacSJt6YD8Eek9jZppjt0bgiC0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556782387; 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=OBsE/O9i0JQnSPvrdvrKAn6KenY15j34Su6RmDm9g2/TYLwGTHmD0Cdptrb77aQvemRIELen5Lj2J6pp4lopZGUl4ng84oXTaP1vMhVJoyC5j7ErCdFAY/quBIscinBkhoPj2E1XrApXnedfkggtTvvbQJeRWQcLZnauuGsEylw= 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 1556782387061597.169784332447; Thu, 2 May 2019 00:33:07 -0700 (PDT) Received: from localhost ([127.0.0.1]:46562 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6DE-0007QX-V2 for importer@patchew.org; Thu, 02 May 2019 03:33:00 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM68k-0003lo-9d for qemu-devel@nongnu.org; Thu, 02 May 2019 03:28:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM68e-0001bC-Pt for qemu-devel@nongnu.org; Thu, 02 May 2019 03:28:19 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:44036) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM68U-0008UO-3g for qemu-devel@nongnu.org; Thu, 02 May 2019 03:28:12 -0400 Received: by mail-wr1-x443.google.com with SMTP id c5so1771055wrs.11 for ; Thu, 02 May 2019 00:26:57 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id z5sm8769289wre.70.2019.05.02.00.26.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 00:26:55 -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=Xq5yqmXHrrveNmR//VLjr3VV0PDxJG2xHSnnRLPvBgcaB2v2kpzwOM2tyWOeWLxxSf k97HWW2Le3oiKVdvggdIyXae1oBy8hTlM1mig6MeP3F/Al4OQHqNvWdNi2Ng+twdv0mL aq7tdNEhlWlTGAS+IZFcKtH1Yxpvf3hfU2gjQcKXCp9kCrWaUGlFNauCyB74ZLG0PRBQ VQxgjAGC+9Mox028q/2LFUsO1edqrhN3JjrodrCi9xwTl2Cj+dQo8W+8hQTOW4eMhtSf 1ENAImKkouDDgx1vRkdopkGVbKz11Rgvi/4mTy0AKbTbO0zu0IvRZ1HsygTLLn+GUHUI bQ+g== 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=PFACW+TGC1ySqBseuVp5eKptaiXISvaKREk3seYETB2e5fjOp+FdDQBlBpDfC1hCsO 7QhHLjRC+JJkXASOFIt5X1mWa5WMVGfxHqd+16H14tZzZzrIPBoL/IB/brYMr1FOLpXq LVplXFTuW1pOTXbgCUP51sAt/oP63aCp8Jo2qf1cEfF4hzocaHSebcMdr4wclOh8hDuo UOqA3/P2JaVlnqr2lPKL4dJcijY3HubB91BzL/ObXb767Fs0jsdf8zO7UFV7NwXOZkXR Tmt0AGfeUAE735tLuet2qOdXbFLPpy7+dG8Q0Dt2+CUpF+Tw8gDY8KzvpFLj0ZxvEYpl q7hQ== X-Gm-Message-State: APjAAAXvigJDQY3h4ay/kvGk8Lbz5APJ+Qi2Fk6MfvboMF7OKTCvuCkL 6ovgK20NZ6+6hjpgo7ZyJftH8RnV X-Google-Smtp-Source: APXvYqw3E9CZjysTL5okERvl3rsGBi6U5h314iwer6HAZRbqQ7DA7hQasiLCxnjpYkGyRNXWP8sfBw== X-Received: by 2002:adf:d847:: with SMTP id k7mr1444834wrl.90.1556782015927; Thu, 02 May 2019 00:26:55 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 10:26:16 +0300 Message-Id: <20190502072641.4667-3-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502072641.4667-1-arilou@gmail.com> References: <20190502072641.4667-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::443 Subject: [Qemu-devel] [PATCH v8 02/27] 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: liran.alon@oracle.com, 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