From patchwork Wed Apr 24 18:45:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1090348 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ERL1fQ/N"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44q8x33vvvz9s4Y for ; Thu, 25 Apr 2019 05:08:39 +1000 (AEST) Received: from localhost ([127.0.0.1]:45889 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJNG1-0002He-DE for incoming@patchwork.ozlabs.org; Wed, 24 Apr 2019 15:08:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJN6K-0002Db-Ic for qemu-devel@nongnu.org; Wed, 24 Apr 2019 14:58:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hJMuM-0005Q2-M6 for qemu-devel@nongnu.org; Wed, 24 Apr 2019 14:46:15 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:40809) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hJMuM-0005O9-Fd for qemu-devel@nongnu.org; Wed, 24 Apr 2019 14:46:14 -0400 Received: by mail-wr1-x42c.google.com with SMTP id h4so26567572wre.7 for ; Wed, 24 Apr 2019 11:46:14 -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=UknJZKnJVERT3JA2rb2yBuVPhKJqbGKHtbXr3Dgn3pU=; b=ERL1fQ/NKJ+o+BYRChZgQbgez7ZNuBV7gOV+HbvM9CcUpCAgtlu/OT+T4C749zuW9v k59K+xveHzjolGFBJauYA7XwTjNpR7heUypzkWQr4CfmfUKHDeLVSKhOr47fg6Y/pkUu wi4UDVM2gIY7W2B9rAYs1TaVm/sYua8huwt73a4LuWD2aFKYuvXP0YuB3Fy+us6aEGfS AVOCx/dSTMQ1DlZgqtTZzzB9k1/GABga0MkgjjWsl/tRGTBXigKOFEh2hA4DDNPepKpU XG1BtYysdb6s/lG3s4bQr0sGllKDwFyAs24Wa+ozB5Q9nRehte7NN4d77j8gkuo/lgll BZdw== 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=UknJZKnJVERT3JA2rb2yBuVPhKJqbGKHtbXr3Dgn3pU=; b=CSGyR9LsoIxZSPglfi+lPUMti765hYsb+yd3WzNsibUfyRWJMOcJJR90a1vbdm/QuN ZpLyAEXoh91K+6xNKAfFY10EvlM1+37AlAO2SDXzLaGskVWqTXjmAfHJsF1xEybv4ucN nb8eJikLnSO1643eC9dCLvrmCHFjbuanEuqmo1SRF6x614SL3NUNnXH66cOwKa95bNok GNgWXlL2RuJhyprVPY1oPYttQxf7GkFyqreyCUNnBHU7oPRf6EFcQwobD7NR1GZOZi8S /mYA02eDXEOmkSuvNKFPBrzj0clnK7jaGz4NTJcsVIwyCebfab66xaG15vuHz61LpgXx 9oxQ== X-Gm-Message-State: APjAAAWgrXm2t1eGTYz+WDp04mq/H0T6np4QQEqLlwAD5iEf3fcLSNoC jTyiUTt+MChlL0elPwquDQzHhwk2 X-Google-Smtp-Source: APXvYqyPy6aMxqbpPzuicEhNKouTs/u+LTds1anWuLMd5b4EFFBhRp7A98DPUpO21kcF1g+KXp758w== X-Received: by 2002:adf:e703:: with SMTP id c3mr21179511wrm.98.1556131572844; Wed, 24 Apr 2019 11:46:12 -0700 (PDT) Received: from linux.local ([31.154.166.148]) by smtp.gmail.com with ESMTPSA id h9sm14720106wmb.5.2019.04.24.11.46.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2019 11:46:10 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Wed, 24 Apr 2019 21:45:42 +0300 Message-Id: <20190424184600.8445-2-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190424184600.8445-1-arilou@gmail.com> References: <20190424184600.8445-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42c Subject: [Qemu-devel] [PATCH v4 02/20] 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: Jon Doron Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-otff-by: Jon Doron --- gdbstub.c | 82 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 39 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 64680722fc..952a6d92ef 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1429,10 +1429,6 @@ static inline int startswith(const char *string, const char *pattern) return !strncmp(string, pattern, strlen(pattern)); } -__attribute__((unused)) static int process_string_cmd( - GDBState *s, void *user_ctx, const char *data, - GdbCmdParseEntry *cmds, int num_cmds); - static int process_string_cmd(GDBState *s, void *user_ctx, const char *data, GdbCmdParseEntry *cmds, int num_cmds) { @@ -1477,6 +1473,41 @@ static int process_string_cmd(GDBState *s, void *user_ctx, const char *data, return -1; } +static void handle_detach(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + GDBProcess *process; + GDBState *s = gdb_ctx->s; + uint32_t pid = 1; + + if (s->multiprocess) { + if (!gdb_ctx->num_params) { + put_packet(s, "E22"); + return; + } + + pid = gdb_ctx->params[0].val_ul; + } + + process = gdb_get_process(s, pid); + gdb_process_breakpoint_remove_all(s, process); + process->attached = false; + + if (pid == gdb_get_cpu_pid(s, s->c_cpu)) { + s->c_cpu = gdb_first_attached_cpu(s); + } + + if (pid == gdb_get_cpu_pid(s, s->g_cpu)) { + s->g_cpu = gdb_first_attached_cpu(s); + } + + if (!s->c_cpu) { + /* No more process attached */ + gdb_syscall_mode = GDB_SYS_DISABLED; + gdb_continue(s); + } + put_packet(s, "OK"); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1591,42 +1622,15 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) error_report("QEMU: Terminated via GDBstub"); exit(0); case 'D': - /* Detach packet */ - pid = 1; - - if (s->multiprocess) { - unsigned long lpid; - if (*p != ';') { - put_packet(s, "E22"); - break; - } - - if (qemu_strtoul(p + 1, &p, 16, &lpid)) { - put_packet(s, "E22"); - break; - } - - pid = lpid; - } - - process = gdb_get_process(s, pid); - gdb_process_breakpoint_remove_all(s, process); - process->attached = false; - - if (pid == gdb_get_cpu_pid(s, s->c_cpu)) { - s->c_cpu = gdb_first_attached_cpu(s); - } - - if (pid == gdb_get_cpu_pid(s, s->g_cpu)) { - s->g_cpu = gdb_first_attached_cpu(s); - } - - if (s->c_cpu == NULL) { - /* No more process attached */ - gdb_syscall_mode = GDB_SYS_DISABLED; - gdb_continue(s); + { + static GdbCmdParseEntry deatch_cmd_desc = { + .handler = handle_detach, + .cmd = "D", + .cmd_startswith = 1, + .schema = "?.l0" + }; + process_string_cmd(s, NULL, line_buf, &deatch_cmd_desc, 1); } - put_packet(s, "OK"); break; case 's': if (*p != '\0') {