From nobody Fri May 3 14:33:07 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=1559112243; cv=none; d=zoho.com; s=zohoarc; b=Cdfbju8YO9wK+0Zubz0mboifvTuuAMgFotVZiFnPSD6kQWQvNhCA4SSFPowSMw/Ns/QrdUdE9cTIDFzQSqjDCsa1lMl8ABilu4i+qmxJniaW0AetAZ5nwYDU4GzsriccqcQ8E7Eapb/4b3FTOPbn2KOEKWFLNEA5Sq45NHU28ao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559112243; h=Content-Type: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=7u1KXDRCT1QNSYdCXZwUYyZhwAFQkk64IoLiLE7FVbs=; b=cnaUtqH7N9cOkMUN8khdxxx5494GRMjljLd5sCRFrZ+t6PxHWquIKdwR5lfTAMGbCOiK0rM0a5V9WV8X8Xa51HIhEqnIvD4nd7ldK4GxOpKVaI/AdtB4H/aL2RQu4wzjUJlaeKZ365jOyfmTo6VLHkxdpnIGKljB1sLrUJ8nhMU= 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 1559112243939519.2008129986569; Tue, 28 May 2019 23:44:03 -0700 (PDT) Received: from localhost ([127.0.0.1]:48220 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsJV-00028N-Oz for importer@patchew.org; Wed, 29 May 2019 02:43:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsHl-0000xZ-Qf for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVsHk-0008W4-I6 for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:05 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:35283) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVsHk-0008LT-CA for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:04 -0400 Received: by mail-wm1-x341.google.com with SMTP id w9so695831wmi.0 for ; Tue, 28 May 2019 23:42:04 -0700 (PDT) Received: from linux.local ([31.154.166.148]) by smtp.gmail.com with ESMTPSA id f2sm6831168wme.12.2019.05.28.23.42.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 23:42:01 -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=7u1KXDRCT1QNSYdCXZwUYyZhwAFQkk64IoLiLE7FVbs=; b=CsNaQCuxNY48Eze7tJ5XsBUrguE0xOqRzWi9qVbQXODtcdNgkP2hZQim/a42F7g9Ia eTWZmSt6QIKI0gDaitu7mUunkPIgJ2y0NPYJg5qIgfg0GDK+JQx8mMUT4cmOJBjnemo/ mBJeehzN8OGNl3iZGiPpTagb16C7dfabzGxJd99eujCaFJaI9SdHzkchg11l1Kl59wtM iwlG5qNfO1vW5NvScrv5DEyImQ9PRC6egkplAqoV0bmFQQfIYj15Kncac0auRmtb2RgF iZbTFvvzXWsxPTTgzo//gNmj/hLc6nctApcRZTj8vv0NamfHmRqliN44BuF3UPkW78im bG1A== 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=7u1KXDRCT1QNSYdCXZwUYyZhwAFQkk64IoLiLE7FVbs=; b=dc9t+wnhVT09CaCrtN6GHfBrshaw7jluOCxZIFGPcuQOKzmd7LRl0wV4PGar/piOoI WAZvNE7Cs22jFrE5BU4Eb5Z7MJ6QZEx/dlsft5EgWus+sGbwjK+iDDMjYOXqkKue6oIb MaN3hNwHHOM2pIoUwpKEvAcx2C9ahSKgqZ3vhQv1lEBtd3HxZKqAAR8g+FTtGNBq7xDB AcOE9c8OIP2EHw/4xRTiE4n3WQCkUydXE1lpZfZaB15foMdwSec6CffVcnhDx75NTsF8 IuYAQQnG6ezn6y2Q/rUgQmReUBo6N8NXkdjrO+vRGXX9IxlRd7mDE96kSX5L6O+evv9U znZQ== X-Gm-Message-State: APjAAAWAM6uGhnT6ZB05c3rgbLvWPH4OiGLOuXFP3WrLEp1yoUQABIEW Ouj/AY8epB7VKn2TgAncCpd8SOXO X-Google-Smtp-Source: APXvYqyKasfXc4KBR8WPqp4raoJ7CbEmVyVvaIE0AbK1g46NU/cRzTIKVh0WoliDHMV+ctfjhKj6kg== X-Received: by 2002:a7b:c8c1:: with SMTP id f1mr5191504wml.159.1559112122356; Tue, 28 May 2019 23:42:02 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Wed, 29 May 2019 09:41:29 +0300 Message-Id: <20190529064148.19856-2-arilou@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190529064148.19856-1-arilou@gmail.com> References: <20190529064148.19856-1-arilou@gmail.com> 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::341 Subject: [Qemu-devel] [PATCH v12 01/20] gdbstub: Add infrastructure to parse cmd 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: 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) Signed-off-by: Jon Doron Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e --- gdbstub.c | 195 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index d54abd17cc..e6d895177b 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1268,6 +1268,201 @@ out: return res; } =20 +typedef union GdbCmdVariant { + const char *data; + uint8_t opcode; + unsigned long val_ul; + unsigned long long val_ull; + struct { + GDBThreadIdKind kind; + uint32_t pid; + uint32_t tid; + } thread_id; +} GdbCmdVariant; + +static const char *cmd_next_param(const char *param, const char delimiter) +{ + static const char all_delimiters[] =3D ",;:=3D"; + char curr_delimiters[2] =3D {0}; + const char *delimiters; + + if (delimiter =3D=3D '?') { + delimiters =3D all_delimiters; + } else if (delimiter =3D=3D '0') { + return strchr(param, '\0'); + } else if (delimiter =3D=3D '.' && *param) { + return param + 1; + } else { + curr_delimiters[0] =3D delimiter; + delimiters =3D curr_delimiters; + } + + param +=3D strcspn(param, delimiters); + if (*param) { + param++; + } + return param; +} + +static int cmd_parse_params(const char *data, const char *schema, + GdbCmdVariant *params, int *num_params) +{ + int curr_param; + const char *curr_schema, *curr_data; + + *num_params =3D 0; + + if (!schema) { + return 0; + } + + curr_schema =3D schema; + curr_param =3D 0; + curr_data =3D data; + while (curr_schema[0] && curr_schema[1] && *curr_data) { + switch (curr_schema[0]) { + case 'l': + if (qemu_strtoul(curr_data, &curr_data, 16, + ¶ms[curr_param].val_ul)) { + return -EINVAL; + } + curr_param++; + curr_data =3D cmd_next_param(curr_data, curr_schema[1]); + break; + case 'L': + if (qemu_strtou64(curr_data, &curr_data, 16, + (uint64_t *)¶ms[curr_param].val_ull)) { + return -EINVAL; + } + curr_param++; + curr_data =3D cmd_next_param(curr_data, curr_schema[1]); + break; + case 's': + params[curr_param].data =3D curr_data; + curr_param++; + curr_data =3D cmd_next_param(curr_data, curr_schema[1]); + break; + case 'o': + params[curr_param].opcode =3D *(uint8_t *)curr_data; + curr_param++; + curr_data =3D cmd_next_param(curr_data, curr_schema[1]); + break; + case 't': + params[curr_param].thread_id.kind =3D + read_thread_id(curr_data, &curr_data, + ¶ms[curr_param].thread_id.pid, + ¶ms[curr_param].thread_id.tid); + curr_param++; + curr_data =3D cmd_next_param(curr_data, curr_schema[1]); + break; + case '?': + curr_data =3D cmd_next_param(curr_data, curr_schema[1]); + break; + default: + return -EINVAL; + } + curr_schema +=3D 2; + } + + *num_params =3D curr_param; + return 0; +} + +typedef struct GdbCmdContext { + GDBState *s; + GdbCmdVariant *params; + int num_params; + uint8_t mem_buf[MAX_PACKET_LENGTH]; + char str_buf[MAX_PACKET_LENGTH + 1]; +} GdbCmdContext; + +typedef void (*GdbCmdHandler)(GdbCmdContext *gdb_ctx, void *user_ctx); + +/* + * cmd_startswith -> cmd is compared using startswith + * + * + * schema definitions: + * Each schema parameter entry consists of 2 chars, + * the first char represents the parameter type handling + * the second char represents the delimiter for the next parameter + * + * Currently supported schema types: + * 'l' -> unsigned long (stored in .val_ul) + * 'L' -> unsigned long long (stored in .val_ull) + * 's' -> string (stored in .data) + * 'o' -> single char (stored in .opcode) + * 't' -> thread id (stored in .thread_id) + * '?' -> skip according to delimiter + * + * Currently supported delimiters: + * '?' -> Stop at any delimiter (",;:=3D\0") + * '0' -> Stop at "\0" + * '.' -> Skip 1 char unless reached "\0" + * Any other value is treated as the delimiter value itself + */ +typedef struct GdbCmdParseEntry { + GdbCmdHandler handler; + const char *cmd; + bool cmd_startswith; + const char *schema; +} GdbCmdParseEntry; + +static inline int startswith(const char *string, const char *pattern) +{ + return !strncmp(string, pattern, strlen(pattern)); +} + +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) +{ + int i, schema_len, max_num_params =3D 0; + GdbCmdContext gdb_ctx; + + if (!cmds) { + return -1; + } + + for (i =3D 0; i < num_cmds; i++) { + const GdbCmdParseEntry *cmd =3D &cmds[i]; + g_assert(cmd->handler && cmd->cmd); + + if ((cmd->cmd_startswith && !startswith(data, cmd->cmd)) || + (!cmd->cmd_startswith && strcmp(cmd->cmd, data))) { + continue; + } + + if (cmd->schema) { + schema_len =3D strlen(cmd->schema); + if (schema_len % 2) { + return -2; + } + + max_num_params =3D schema_len / 2; + } + + gdb_ctx.params =3D + (GdbCmdVariant *)alloca(sizeof(*gdb_ctx.params) * max_num_para= ms); + memset(gdb_ctx.params, 0, sizeof(*gdb_ctx.params) * max_num_params= ); + + if (cmd_parse_params(&data[strlen(cmd->cmd)], cmd->schema, + gdb_ctx.params, &gdb_ctx.num_params)) { + return -1; + } + + gdb_ctx.s =3D s; + cmd->handler(&gdb_ctx, user_ctx); + return 0; + } + + return -1; +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; --=20 2.21.0 From nobody Fri May 3 14:33:07 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=1559112593; cv=none; d=zoho.com; s=zohoarc; b=TGBwa2VMOgvHrJ85gESs8w/nwU0SCYG4QMiDQVL/vX3+YxY8Wy/mr62SHCsx6PfukQ/+jWRDsweo9G+oXj02afYs7hwzit7QUl7d5p1YkQJkTtBu4Wg9RyllnuFkIRAUJVmhejhStjcpmMJRM0n+c74sTjbeWEDs1HOLlakKEg0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559112593; 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=2qe4jUb7Wrs/Gksk3zL4XfYnM/CEolczq1katmanDvA=; b=dEhpoI6NkIRUXiTpFWrRDErBYHTpxyRDCBxb38o8Ckxnp7rpAgcdCUtn/szC7rawkK1nZxyGs4fXRahKWV5H6Uf7fU0wjb+uTkcd8q57W8TstKrtdQq9ScAQBYNRDtf1oXuWb8Mic578Tsr51MWPWf+0ZjsrNWRNMR9WUAnD92g= 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 1559112593501827.6757035494115; Tue, 28 May 2019 23:49:53 -0700 (PDT) Received: from localhost ([127.0.0.1]:48300 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsPC-00074Q-DO for importer@patchew.org; Wed, 29 May 2019 02:49:46 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsHm-0000y2-MJ for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVsHl-0000FV-H7 for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:06 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:36798) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVsHl-00005B-BE for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:05 -0400 Received: by mail-wm1-x342.google.com with SMTP id v22so691296wml.1 for ; Tue, 28 May 2019 23:42:05 -0700 (PDT) Received: from linux.local ([31.154.166.148]) by smtp.gmail.com with ESMTPSA id f2sm6831168wme.12.2019.05.28.23.42.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 23:42:02 -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=2qe4jUb7Wrs/Gksk3zL4XfYnM/CEolczq1katmanDvA=; b=IbuIiXq2eGf7/gxLLkUDe10z821pzSAcDu1CEZMfWjjLQE4SFkxOqxI9+037vcCPvH 1cb6T/nmMimbcgUfiOaUaP9vpylZPxormXi5eNJp00Acr16Zmgc9xZaLto3U2zFkcwKW E1XQjuRpJSown8lo7pu9CBH/XjpWX6FCnTR+jrqWwdH40002kbsN+B4vmQm2F0sqRBES aspne1YVDqZpqh0ZAdXRzf8b5jDUOwg0fwKgN1/B03RCJzeazt5nPntjPmVrPrdVukoT 8Cu/T36+hoXN5g/ABxHIi+yGm05ep9WhXIImmC3N1PZZQnGWV5n+GMg6Qivi9ZHUGls1 oDng== 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=2qe4jUb7Wrs/Gksk3zL4XfYnM/CEolczq1katmanDvA=; b=ZL2n5yv5lexvRCYyvD09yGuwrfL+CBRy18FBwISZ5EnEiyvoWbIUiGKCqioamqVfPS zqyFIMY1JowZjCcRqA7hLG/YGW1ZFZ0aARkBk3bALACRwkI4oqW5aw4qBj/EcDDgCzQD ZYDkjf5VM6G61qUh9+PgylcNS0jJ6/PEZc52k7mhUTVzH8kvmghmZIIoEUj25jiBbrI+ oO1XwkC4RgsRg6Lf+u1hJRtkYdc6fQSb+1aVkqeCMgmKqgz9d0I4w/P7q05qfl3Vh6/u qYkyogsMLKFmnWGiWDSnpK1PoenPqE3kkrqWbEmGEC4gSTtb750XAFiUBo3Ywvab/sxS 2NsQ== X-Gm-Message-State: APjAAAVk3ISD/ZkgvF0aopZVgMf2L2d8Ok5Bq9IX5JORasfq4tjMN1IT 6zeYjlaXAOPcnnk2JfF1+ANpedKs X-Google-Smtp-Source: APXvYqyh3wiRwJ0kmjhLQ13B3rQHLIvHA1TII+rNXSTV8+b7SGRmqO8AJLgPLxcYF6krchdDjW2GYA== X-Received: by 2002:a1c:411:: with SMTP id 17mr5161634wme.74.1559112123367; Tue, 28 May 2019 23:42:03 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Wed, 29 May 2019 09:41:30 +0300 Message-Id: <20190529064148.19856-3-arilou@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190529064148.19856-1-arilou@gmail.com> References: <20190529064148.19856-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::342 Subject: [Qemu-devel] [PATCH v12 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: 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 Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e --- gdbstub.c | 101 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 61 insertions(+), 40 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index e6d895177b..1db322c15a 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1413,11 +1413,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) { @@ -1463,6 +1458,55 @@ static int process_string_cmd(GDBState *s, void *use= r_ctx, const char *data, return -1; } =20 +static void run_cmd_parser(GDBState *s, const char *data, + const GdbCmdParseEntry *cmd) +{ + if (!data) { + return; + } + + /* In case there was an error during the command parsing we must + * send a NULL packet to indicate the command is not supported */ + if (process_string_cmd(s, NULL, data, cmd, 1)) { + put_packet(s, ""); + } +} + +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; @@ -1477,6 +1521,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 @@ -1577,42 +1622,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') { @@ -1985,6 +2003,9 @@ static int gdb_handle_packet(GDBState *s, const char = *line_buf) put_packet(s, buf); break; } + + run_cmd_parser(s, line_buf, cmd_parser); + return RS_IDLE; } =20 --=20 2.21.0 From nobody Fri May 3 14:33:07 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=1559112446; cv=none; d=zoho.com; s=zohoarc; b=SyHHAxTDlfW+UV43SF3/9udaNjkimYY8kbQpjuYwzU4N5bPq+nxWZLSCoJ1A46HeYY2EYEdqU/ZNRphIMZ+Q/oW7/sDPeAInlLeV7/UtrrarCrBIraYiC/iHXpimU7ZGz9J2fED3tXbvYVFQneK8NWqT2BrPqoKPOC+4L/r0woU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559112446; h=Content-Type: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=Q93fkAMrEvzu0zyZkj4+7iBrZF/eUh2AH5ITql2fAuw=; b=kWlRlGFXLWBesZex5g7ezEuj15o0ugVjoq+UC6yp3gT4EoBN8NxEWkctDaK2O9kOXxDC6NgQDgC+Tk/ElE6H58LQZ2GfsjmUqs5K48KpxMhUV/hnCnF+4AdoqpqlSqpniE/d04wQM2ntOfFjrxs4lNbScwfkl5mF83RnczRwOLc= 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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 15591124464041018.5703337840024; Tue, 28 May 2019 23:47:26 -0700 (PDT) Received: from localhost ([127.0.0.1]:48276 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsMH-0004YL-4V for importer@patchew.org; Wed, 29 May 2019 02:46:45 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsHm-0000y6-NZ for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVsHl-0000HO-Kq for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:06 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:53158) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVsHl-000065-DI for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:05 -0400 Received: by mail-wm1-x343.google.com with SMTP id y3so723688wmm.2 for ; Tue, 28 May 2019 23:42:05 -0700 (PDT) Received: from linux.local ([31.154.166.148]) by smtp.gmail.com with ESMTPSA id f2sm6831168wme.12.2019.05.28.23.42.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 23:42:03 -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=Q93fkAMrEvzu0zyZkj4+7iBrZF/eUh2AH5ITql2fAuw=; b=llp7jX5jrtS228xwaO7CXpp8dgXz3frK0rn/LRAoYrnuVUsosdvEFU8vHf6DFbL8lB lEXUjyHt5u6J+5dw662Au04mJLshd2gNfulzSiZlBWJT5TLScvwO0iOEAOs40DZeSXGM q5LhY9meWm4P2lQPxCvpOVODgn46AwwMtoVaHn6WxqIzYPmyXWb0+5c4lyCGB3Nb/+z8 mnhxTtfyufB4GKuZsqldDm9dvsblZZRlY0Ne5RwCoXx6pZTj4KudYJb1hDkx+nGdTA7t ojKGZ7JO9qM3VIYq0Riy+PreIFdDrMZsFuA+2dzEScEEm7eo+HYGtve3jJhwxAa8pZdB c3ZQ== 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=Q93fkAMrEvzu0zyZkj4+7iBrZF/eUh2AH5ITql2fAuw=; b=RQ2JN6MSFUyywcJbTeU7U8VoNynNUiXOA0nxYCt4TerLAJA5ePm8hJ8BIhQptrl7NY PVWmWPEzFBJkbbqE+M/vS8qIZF6aCOGtIq+etDS1cAgLms1pAMZrXFNsG7JetRCH8F+G 7VOvDAUvoRelBkGMAZ9Rlu0l/Xqo9YKI7VWEONVUVIFWYNwcTSYpg4/cN6wY7k3rENXG mKdTKxxS6G3edMtAMdqgLZ3hPBK8d32AuzC3fMfM8aXzJb4jVrH5OMeIUwB6vP8t13pp pGzPcWjMmG85xcdeRSfmzT/ZrXhYFmRx3TNsGxTNX3Tbkdvb6jP9D2q/Vyc/KC/pai6t QHPw== X-Gm-Message-State: APjAAAXzTftRcMyqhUouXnQdojA9GVcA2pyuEY+583cQQ2cuPPRN8zB5 J6/FsM79X7bYVxLUCQ3rKlmairuI X-Google-Smtp-Source: APXvYqyD7lHuGhAPQV8e/oWvtZp59igvCuLeewguQCECWrSZdQIC5OGPCL6bAzUbEIKOsZd2FelBJw== X-Received: by 2002:a7b:cb84:: with SMTP id m4mr6043579wmi.50.1559112124271; Tue, 28 May 2019 23:42:04 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Wed, 29 May 2019 09:41:31 +0300 Message-Id: <20190529064148.19856-4-arilou@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190529064148.19856-1-arilou@gmail.com> References: <20190529064148.19856-1-arilou@gmail.com> 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::343 Subject: [Qemu-devel] [PATCH v12 03/20] gdbstub: Implement thread_alive (T 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) Signed-off-by: Jon Doron Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e --- gdbstub.c | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 1db322c15a..7801f2f260 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1507,6 +1507,30 @@ static void handle_detach(GdbCmdContext *gdb_ctx, vo= id *user_ctx) put_packet(s, "OK"); } =20 +static void handle_thread_alive(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + CPUState *cpu; + + if (!gdb_ctx->num_params) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + if (gdb_ctx->params[0].thread_id.kind =3D=3D GDB_READ_THREAD_ERR) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + cpu =3D gdb_get_cpu(gdb_ctx->s, gdb_ctx->params[0].thread_id.pid, + gdb_ctx->params[0].thread_id.tid); + if (!cpu) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + put_packet(gdb_ctx->s, "OK"); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1807,17 +1831,14 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) } break; case 'T': - thread_kind =3D read_thread_id(p, &p, &pid, &tid); - if (thread_kind =3D=3D GDB_READ_THREAD_ERR) { - put_packet(s, "E22"); - break; - } - cpu =3D gdb_get_cpu(s, pid, tid); - - if (cpu !=3D NULL) { - put_packet(s, "OK"); - } else { - put_packet(s, "E22"); + { + static const GdbCmdParseEntry thread_alive_cmd_desc =3D { + .handler =3D handle_thread_alive, + .cmd =3D "T", + .cmd_startswith =3D 1, + .schema =3D "t0" + }; + cmd_parser =3D &thread_alive_cmd_desc; } break; case 'q': --=20 2.21.0 From nobody Fri May 3 14:33:07 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=1559112434; cv=none; d=zoho.com; s=zohoarc; b=hCe6FlSXIwOgydB9r4IObO92JjI1bIYClh0pQjFUKMYPs0+wNVPgSTCFACOY/NDQPBYEDiDoSSnoVqcj35SxefE08NnnUrA9Aeh9UD7BOMzu1nRre9fNdobquDCz034fXKt8X8plzchtgk9iYhxl2dfoul6ZP51vw8mY0OmY6eY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559112434; h=Content-Type: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=c/H4UbLodN8W8KnJQVGCVD1bmZpUHc1MnaG+rfAIN+E=; b=S3y2D7o3jqDCdWbdk+DKexTtGLXqXv3RkgBEHc2/q3wU0RPESA1b4JkqAxwNEQXtaySCrGMou2Vpg53khT5VKc6y9+bAsu+dTQCv/JmQpwvxAJ1w90MY7reTYfiqoLuf0+Kh40zKfLbtQOgtkXccBrzkP4N9iEuRhD7clie9WRE= 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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559112434317601.3659188374473; Tue, 28 May 2019 23:47:14 -0700 (PDT) Received: from localhost ([127.0.0.1]:48278 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsMI-0004aD-28 for importer@patchew.org; Wed, 29 May 2019 02:46:46 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45104) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsHn-0000yU-Bu for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVsHm-0000PU-B9 for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:07 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:55393) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVsHm-0000HM-5c for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:06 -0400 Received: by mail-wm1-x343.google.com with SMTP id u78so714592wmu.5 for ; Tue, 28 May 2019 23:42:06 -0700 (PDT) Received: from linux.local ([31.154.166.148]) by smtp.gmail.com with ESMTPSA id f2sm6831168wme.12.2019.05.28.23.42.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 23:42:04 -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=c/H4UbLodN8W8KnJQVGCVD1bmZpUHc1MnaG+rfAIN+E=; b=SIEISxmMolQDrhG1dnDnbWNdtxnblqb897StG2V6efQL0AC/aXaHq1SmaisjN0OIWP M1boQisYwgGkWJ4471I6tLlfX/MFWcdCB+2oKEwTZSK2BpO+mUNC8AfzDFRom0DmYr6b QJjilEreYg4WoPOAC7UZ8NVOGaHl95M6GE+A0hgcQe9quCwlBGgJHSR7M9AotwB6lu/F MDYcob4hT9p7rR0mg3CoSZfYL/ATDLHBSgChDdofI07x8IYGYQGF4/8eYk3A9jVaviUS UEqi/kD0DKJItUXmF4voX7LtUs70zPrNsU3C0EDqGsXJ6vwZVHbE1seze8eyugHhO0zZ jzZg== 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=c/H4UbLodN8W8KnJQVGCVD1bmZpUHc1MnaG+rfAIN+E=; b=oK8IcdiLfs77NbN9Iwkdyt9lYspymjlDy1FrmIoaKLJTGmIn9k0B4Xz6w+ibTavPZt ptKK+8vCe+Nq31vJi0osztFLl8Ite4pS0URJu7FGpRJA42i2JbOsFz7XNi8PqZfCZ6Iz qnljbEf21mFOE51YRMDyhVEox5HT7gjB1hngKxcDre5LBKY4gd6mDgyga7N67cC//Zg1 SEChDSKJnitCVR8//hys9PLQbdPji93YsZCyTI46bDR+Rd2L3C+OId+VqCORlVE42LeI W5ftl/PC/v5jnvtzaLuR3vMApyQho6MUzzK83jXqTKWFcSrCe0IfmYP43L39VXWdzlp1 jNCg== X-Gm-Message-State: APjAAAU70TDIcAO/BYHB3IDFVT9fwgnCnLIR5RyHlAWX0xuUjNH380Vo P7sUJ5EPrrAz3Sfx95BCTSfDV3gD X-Google-Smtp-Source: APXvYqwoZd+xvoQjhyhn02a8H49TIhWf+B3CFeARO7asJgRwRid7PH8XHXx2ifMV8gOGzxdO0JEXEg== X-Received: by 2002:a7b:c846:: with SMTP id c6mr5939617wml.0.1559112125157; Tue, 28 May 2019 23:42:05 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Wed, 29 May 2019 09:41:32 +0300 Message-Id: <20190529064148.19856-5-arilou@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190529064148.19856-1-arilou@gmail.com> References: <20190529064148.19856-1-arilou@gmail.com> 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::343 Subject: [Qemu-devel] [PATCH v12 04/20] gdbstub: Implement continue (c 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) Signed-off-by: Jon Doron Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e --- gdbstub.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 7801f2f260..99b78aa426 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1531,6 +1531,16 @@ static void handle_thread_alive(GdbCmdContext *gdb_c= tx, void *user_ctx) put_packet(gdb_ctx->s, "OK"); } =20 +static void handle_continue(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (gdb_ctx->num_params) { + gdb_set_cpu_pc(gdb_ctx->s, gdb_ctx->params[0].val_ull); + } + + gdb_ctx->s->signal =3D 0; + gdb_continue(gdb_ctx->s); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1567,13 +1577,16 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) gdb_breakpoint_remove_all(); break; case 'c': - if (*p !=3D '\0') { - addr =3D strtoull(p, (char **)&p, 16); - gdb_set_cpu_pc(s, addr); + { + static const GdbCmdParseEntry continue_cmd_desc =3D { + .handler =3D handle_continue, + .cmd =3D "c", + .cmd_startswith =3D 1, + .schema =3D "L0" + }; + cmd_parser =3D &continue_cmd_desc; } - s->signal =3D 0; - gdb_continue(s); - return RS_IDLE; + break; case 'C': s->signal =3D gdb_signal_to_target (strtoul(p, (char **)&p, 16)); if (s->signal =3D=3D -1) --=20 2.21.0 From nobody Fri May 3 14:33:07 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=1559112780; cv=none; d=zoho.com; s=zohoarc; b=EGGrsf5ESBvkZseULGebzTflEFqLuuRNVuEZVLgkIv6WJ09eLS1qpeVitH3xYMEapmQKfvAqXK8MDYkceNtApBGEcE+Fr/A5UF4w2/TUIc9BZLXyknzkR78VdOkfJXPKVZtCl0Tg+6Zul26yYhTxgMRGyI2BxGIBjk6/eQ5Ba3s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559112780; h=Content-Type: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=EtefPPv82bU3jmtDczAi1mprca6DMOXKZgFlCzVJYC0=; b=LhqcACW3Yqp1HOxteiK8LKa26OulLAahI/GTKJTExMq8vOHnCbEFK2Cv+aNW6enz7jAaYpBnssMHAuMKQAFliLwnV/o7s2URA9vFAPc0TYU9yzlyy1BNMxfS4BdIEGzbMtyP3QglyLKk4C1ozX0lX/7QFj55CKhDkDjkMKVPR1g= 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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559112780693977.7551608155497; Tue, 28 May 2019 23:53:00 -0700 (PDT) Received: from localhost ([127.0.0.1]:48369 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsS6-0001b9-PN for importer@patchew.org; Wed, 29 May 2019 02:52:46 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45122) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsHo-0000zE-CA for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVsHn-0000dD-DO for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:08 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:37980) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVsHn-0000SZ-8F for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:07 -0400 Received: by mail-wr1-x442.google.com with SMTP id d18so793423wrs.5 for ; Tue, 28 May 2019 23:42:07 -0700 (PDT) Received: from linux.local ([31.154.166.148]) by smtp.gmail.com with ESMTPSA id f2sm6831168wme.12.2019.05.28.23.42.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 23:42:05 -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=EtefPPv82bU3jmtDczAi1mprca6DMOXKZgFlCzVJYC0=; b=gr65Q4xWrYS0PmeTHl1MUkM9MIQrReCnacTl4elZ1nJ/i+pHfhXHD6OccW9N+6odXC x72mso3hHOGT+42wifm7t7OGzVFhMVETscXZb6JO76n2aCPA2MZVk5ZWk919xyDz0l8V yzDrP3Q5YlU6QGkvJ3APaU3ibnCS7ihRes7iovTNpwBTiu6iG9BDvWygYtLZIlFQ1Q0z xQziafGxG7OLMbH3xTx2rl018+SQUb7rAUlL3bcuHau5O7U3XdPsjKfwbmAGAhbezV4N gFWvw5GroiHZEOxrPc0USAQ7dlYKx3X5rArp0vVO7xRS+wrTFoTRrqEnTvMN9Mw52Mdr XTew== 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=EtefPPv82bU3jmtDczAi1mprca6DMOXKZgFlCzVJYC0=; b=X+bI7iOxkp6bSsPbBRZLfzM3CtJlMOmNT5e+KTCgn7ppd3MTb4YdmTixGVHlmqfYC9 88kZBDoFoe4c4RFXTYU32zOWBUW8mcw3rhSTHfOCa6/0W+0egtjhqH9jl/GY2+XZgJZc kasJZx1x8ko34AmXGCKIR25Cvc+A6TmWn3QfPty9F3WhbvnDGncGNOS/O7k3dzUpJ6Mr fNF8NVVv8byPY35xRmdxMz0oYGzrWiZT78NIghd9hDfbHsdvAmnw9/qefNOXWEzcM4YL +KmVDXMMVKlcFAQ1/d1dKEDD4LhnnTVa3r+/Q9gfV3uXlckTE6gz5W+b5nMLcbehTqp9 IpAw== X-Gm-Message-State: APjAAAVaUEJlfcZ7kUCYTGnSMl/qTgiVdFNoIXMEDJb/rwQl83XIL2DL YL6vLpbeCaa9hqst5N8D/yWkqFTO X-Google-Smtp-Source: APXvYqxXgmnOfmy0GSeJqUwNUTCcgJBLZceH/e1m87naR5B7qFVmYXipakFMeZ+vk/OwpBL978Fc9Q== X-Received: by 2002:a5d:4692:: with SMTP id u18mr1550268wrq.285.1559112126045; Tue, 28 May 2019 23:42:06 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Wed, 29 May 2019 09:41:33 +0300 Message-Id: <20190529064148.19856-6-arilou@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190529064148.19856-1-arilou@gmail.com> References: <20190529064148.19856-1-arilou@gmail.com> 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::442 Subject: [Qemu-devel] [PATCH v12 05/20] gdbstub: Implement continue with signal (C 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) Signed-off-by: Jon Doron Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e --- gdbstub.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 99b78aa426..5df4d58427 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1541,6 +1541,25 @@ static void handle_continue(GdbCmdContext *gdb_ctx, = void *user_ctx) gdb_continue(gdb_ctx->s); } =20 +static void handle_cont_with_sig(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + unsigned long signal =3D 0; + + /* + * Note: C sig;[addr] is currently unsupported and we simply + * omit the addr parameter + */ + if (gdb_ctx->num_params) { + signal =3D gdb_ctx->params[0].val_ul; + } + + gdb_ctx->s->signal =3D gdb_signal_to_target(signal); + if (gdb_ctx->s->signal =3D=3D -1) { + gdb_ctx->s->signal =3D 0; + } + gdb_continue(gdb_ctx->s); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1588,11 +1607,16 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) } break; case 'C': - s->signal =3D gdb_signal_to_target (strtoul(p, (char **)&p, 16)); - if (s->signal =3D=3D -1) - s->signal =3D 0; - gdb_continue(s); - return RS_IDLE; + { + static const GdbCmdParseEntry cont_with_sig_cmd_desc =3D { + .handler =3D handle_cont_with_sig, + .cmd =3D "C", + .cmd_startswith =3D 1, + .schema =3D "l0" + }; + cmd_parser =3D &cont_with_sig_cmd_desc; + } + break; case 'v': if (strncmp(p, "Cont", 4) =3D=3D 0) { p +=3D 4; --=20 2.21.0 From nobody Fri May 3 14:33:07 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=1559112944; cv=none; d=zoho.com; s=zohoarc; b=N9GlPLDLmyuOR/YvCx3guiqzF0bdc+1gII2cwtQVWJfjchjvTU2WQ4xJPv1T8EX0vFLBaKgjVP1/U9i+WhiBNJ+618sNVngBdCHJFLGse+p4W5aDXXDbivmxBK8MPvtv1nGLxpxw70MYm0/gB3cgI1Y9XAfoTaqc1zURcWLH0EU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559112944; h=Content-Type: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=Xz2AchwCFuUocRvSAx5FgReaJdMORDzlKxZ7VV9ScE8=; b=Zbr3o4sameKvJCmv91log3EgY1iyg4nQ9GXmt/q8nVESFzcrnFPtdDR+ihL71uGzeiQKIVGp8bceTMt/hFX+M0xf85x/61cB7BBfkF/kLZB79tUChSOtFuodgInLDLtcGxhHjPNWB2CxSSg+krluXqCoQj8HN2jqYQwQdGZNetA= 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 1559112944228837.5900124374476; Tue, 28 May 2019 23:55:44 -0700 (PDT) Received: from localhost ([127.0.0.1]:48398 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsUr-0003tv-5T for importer@patchew.org; Wed, 29 May 2019 02:55:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45133) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsHp-00010F-Br for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVsHo-0000q5-AN for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:09 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:46893) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVsHo-0000dL-3y for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:08 -0400 Received: by mail-wr1-x444.google.com with SMTP id r7so757221wrr.13 for ; Tue, 28 May 2019 23:42:08 -0700 (PDT) Received: from linux.local ([31.154.166.148]) by smtp.gmail.com with ESMTPSA id f2sm6831168wme.12.2019.05.28.23.42.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 23:42:06 -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=Xz2AchwCFuUocRvSAx5FgReaJdMORDzlKxZ7VV9ScE8=; b=Q8Qo9BHDhNTZqPNeYeoa6CpmeUr9aYHvxmnaWJE/iLqUSj0k54YcSJouX3wLnYlMhk 7iD/XGAHe2gDH4liy7u97hKeR37BYJrxv84zBzv728uArYJdY5mOhUhWH/yOWlRB8ssE 8P9WQW0tTWXy+Y3GUxYXHzGlFOYDSyRchsdiPAOCm1G8l4IyVXJCWH4ymfCgWVPK2x7p e5HdnlyzdQj0UlGJyz9gVPXLIATLFAJvKA5HwDuRsT0g4b74kgkS8n8XvCcokp5kv68X gyC8uy1baojna7wRxlQl+/+SqjETR9ybpeYWs6D8MZ218SlnwI70blZblld1EBZqbVSk 5FMQ== 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=Xz2AchwCFuUocRvSAx5FgReaJdMORDzlKxZ7VV9ScE8=; b=euBBf1aHtbU1j6897+QZlgdn8LTMP1bHwDcqFADU3gPmZ453rNp+FAmeJcGN9cosNf FInpXYw6ugNlJ6u88OTuEvJLYMyMBtaCb7CP5dAASe91NzkSSVaNzIrrXWNhQFDNptrl ZKBOkQZXnlqh/bVkT77PwdD/zHLCQIz7DstWbulD3o8YfuLDz36uPIlhODXMP+mhVH7e UjtS3fEKIDZXk0m7bpBOiSqqFUS/eJJGIlrg/cMM5IKvR6VNGOpHTf0F7GAjDv3omKuL i6mEyFy73IaWk6lerr8xyrtW6BL4wI20YcTDzecuAaiFbm3sZ3guTEtFZnbn/viZgB1W d0Yg== X-Gm-Message-State: APjAAAXDr0/5CyMoKdpz1IQzvfLJQvi4cX49GJFaFPPgL8+1HNMhCZ5A TdAA0zEOPggcPRZU+RM4FyScZ3zG X-Google-Smtp-Source: APXvYqy8WKsjHQYg9+mUOqoz94x/AcLSsWPyOPsha/nr4QqnghK/bE9I+5NbF9rWaMeSEfj/nf3s5w== X-Received: by 2002:adf:ebc6:: with SMTP id v6mr8443845wrn.258.1559112126947; Tue, 28 May 2019 23:42:06 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Wed, 29 May 2019 09:41:34 +0300 Message-Id: <20190529064148.19856-7-arilou@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190529064148.19856-1-arilou@gmail.com> References: <20190529064148.19856-1-arilou@gmail.com> 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::444 Subject: [Qemu-devel] [PATCH v12 06/20] gdbstub: Implement set_thread (H 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) Signed-off-by: Jon Doron Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e --- gdbstub.c | 83 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 30 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 5df4d58427..db213cf173 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1560,6 +1560,51 @@ static void handle_cont_with_sig(GdbCmdContext *gdb_= ctx, void *user_ctx) gdb_continue(gdb_ctx->s); } =20 +static void handle_set_thread(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + CPUState *cpu; + + if (gdb_ctx->num_params !=3D 2) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + if (gdb_ctx->params[1].thread_id.kind =3D=3D GDB_READ_THREAD_ERR) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + if (gdb_ctx->params[1].thread_id.kind !=3D GDB_ONE_THREAD) { + put_packet(gdb_ctx->s, "OK"); + return; + } + + cpu =3D gdb_get_cpu(gdb_ctx->s, gdb_ctx->params[1].thread_id.pid, + gdb_ctx->params[1].thread_id.tid); + if (!cpu) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + /* + * Note: This command is deprecated and modern gdb's will be using the + * vCont command instead. + */ + switch (gdb_ctx->params[0].opcode) { + case 'c': + gdb_ctx->s->c_cpu =3D cpu; + put_packet(gdb_ctx->s, "OK"); + break; + case 'g': + gdb_ctx->s->g_cpu =3D cpu; + put_packet(gdb_ctx->s, "OK"); + break; + default: + put_packet(gdb_ctx->s, "E22"); + break; + } +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1573,7 +1618,6 @@ static int gdb_handle_packet(GDBState *s, const char = *line_buf) char thread_id[16]; uint8_t *registers; target_ulong addr, len; - GDBThreadIdKind thread_kind; const GdbCmdParseEntry *cmd_parser =3D NULL; =20 trace_gdbstub_io_command(line_buf); @@ -1836,35 +1880,14 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) put_packet(s, "E22"); break; case 'H': - type =3D *p++; - - thread_kind =3D read_thread_id(p, &p, &pid, &tid); - if (thread_kind =3D=3D GDB_READ_THREAD_ERR) { - put_packet(s, "E22"); - break; - } - - if (thread_kind !=3D GDB_ONE_THREAD) { - put_packet(s, "OK"); - break; - } - cpu =3D gdb_get_cpu(s, pid, tid); - if (cpu =3D=3D NULL) { - put_packet(s, "E22"); - break; - } - switch (type) { - case 'c': - s->c_cpu =3D cpu; - put_packet(s, "OK"); - break; - case 'g': - s->g_cpu =3D cpu; - put_packet(s, "OK"); - break; - default: - put_packet(s, "E22"); - break; + { + static const GdbCmdParseEntry set_thread_cmd_desc =3D { + .handler =3D handle_set_thread, + .cmd =3D "H", + .cmd_startswith =3D 1, + .schema =3D "o.t0" + }; + cmd_parser =3D &set_thread_cmd_desc; } break; case 'T': --=20 2.21.0 From nobody Fri May 3 14:33:07 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=1559112317; cv=none; d=zoho.com; s=zohoarc; b=I/NA5Wl1alqkrRz9sIgXAsj3SfPVNt8m7JqgKUJHP8nBQEf283pTAZ2S8OH0b+JtjBfhhQUMf5U5FsRXj9yb2OyM9fTUB4fytJP4A14n+b+VQ7KBAy26GmFCA/Ye+bh1r2eF9VN0qLgAZlcqgqZr4xR6YfNcZB7Rs3wNzahgQnc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559112317; 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=ULsli7t5tLBpSKOtDy0rVTDXfDiFz7yOCX2I2aNFHAE=; b=EfcyjD4InVidB56WrnYRar4w9NMSo2ub7bCjJ/xNKungYj3pGfJSZHPkqwgwM5yK2mqIPHVrrRrmTjoqSnVs/VcH+i74BQioOeQwhxbGw58BK0YO4o172cMHxyYg8EjlocxrKnlBmRL0gov0IYMftRcVdM9hCVwkNse9iEr5pk0= 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 155911231748726.848990254300247; Tue, 28 May 2019 23:45:17 -0700 (PDT) Received: from localhost ([127.0.0.1]:48234 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsKn-0003L7-DS for importer@patchew.org; Wed, 29 May 2019 02:45:13 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45146) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsHq-00010w-5t for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVsHp-0000wv-0A for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:10 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:36800) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVsHo-0000pu-Qq for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:08 -0400 Received: by mail-wm1-x344.google.com with SMTP id v22so691403wml.1 for ; Tue, 28 May 2019 23:42:08 -0700 (PDT) Received: from linux.local ([31.154.166.148]) by smtp.gmail.com with ESMTPSA id f2sm6831168wme.12.2019.05.28.23.42.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 23:42:07 -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=ULsli7t5tLBpSKOtDy0rVTDXfDiFz7yOCX2I2aNFHAE=; b=CK384sZtj6L/QtOGzs7I5gHCZED7s6Sz3Dvqq4yeiZN8WhMcsq5SyYDJGBKAyYkgP9 X2WGQbyEDTABP2iS4lnrE/FlO3xQf1a+uICFuUVQ7zcR50mYU/EIMUAthtuiDeE13d2b 0O6wjiPS4KUi6cukSRD2bofk/Q+zYItST1fkEbo9yip1ZzaXWPsIM7a8vSyENQojRhRO KkpfTpwPjmsD5aBB9O1OxPbC1DU3DIy575/Ojum0motv0dCylbVI1BUQpbeeEj6/ebLU AbO643tsN7H5ymFLEcnfKPRT0FGboOyNgcb0LUNhwKzjOAPqiKjFsdiHYKxuXrg3YAf6 XVYQ== 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=ULsli7t5tLBpSKOtDy0rVTDXfDiFz7yOCX2I2aNFHAE=; b=eZU1F8TbLyvu8G5dWSqECmMY9Nh0KPxClSb9CEBpi2IMrHo5HKZlqu1J5pjJ8+5kLt /fwUIb8bmxogAblMIlFzAwuwwKjQ2ZEOx57fwi0baWVyf5lD6udn1tq78TTQW/Ref+Ny 3TGnoG8cic58UQx9CynWAhUfZqU5sEezN5OqSAhY2t+a0H1VCdPNPvB/eXXWr1iCnCMN qoLvtZAj6B1V34Ac1NBqYD6UDGghvO/2VqSc8quZplN18m78UIVse//BgruF5k7cZRd+ 7j5dSD8C51rTe4WkdBi7vpqaP5Y1koINh2Co4XhEz8et1QtZ60s2InLkf2Tcq4BUb00k Exuw== X-Gm-Message-State: APjAAAUKzY0zG0IRntys2nmUcc5mitI1KtPbebSXM8PvI49HnsjmPbiB O5X/xuj0zeHBfAd6uwoEy5B+oWFF X-Google-Smtp-Source: APXvYqxwfelihn/niAltW+mz7cdxfPpUdgKQQZNM8b1d0txMnehQpXUxp7PAGCXM4sGb+5QOPxqXmg== X-Received: by 2002:a1c:f610:: with SMTP id w16mr5336644wmc.37.1559112127827; Tue, 28 May 2019 23:42:07 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Wed, 29 May 2019 09:41:35 +0300 Message-Id: <20190529064148.19856-8-arilou@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190529064148.19856-1-arilou@gmail.com> References: <20190529064148.19856-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::344 Subject: [Qemu-devel] [PATCH v12 07/20] gdbstub: Implement breakpoint commands (Z/z 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 Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e --- gdbstub.c | 86 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 67 insertions(+), 19 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index db213cf173..572222bfa4 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -950,7 +950,7 @@ static inline int xlat_gdb_type(CPUState *cpu, int gdbt= ype) } #endif =20 -static int gdb_breakpoint_insert(target_ulong addr, target_ulong len, int = type) +static int gdb_breakpoint_insert(int type, target_ulong addr, target_ulong= len) { CPUState *cpu; int err =3D 0; @@ -987,7 +987,7 @@ static int gdb_breakpoint_insert(target_ulong addr, tar= get_ulong len, int type) } } =20 -static int gdb_breakpoint_remove(target_ulong addr, target_ulong len, int = type) +static int gdb_breakpoint_remove(int type, target_ulong addr, target_ulong= len) { CPUState *cpu; int err =3D 0; @@ -1605,6 +1605,52 @@ static void handle_set_thread(GdbCmdContext *gdb_ctx= , void *user_ctx) } } =20 +static void handle_insert_bp(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + int res; + + if (gdb_ctx->num_params !=3D 3) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + res =3D gdb_breakpoint_insert(gdb_ctx->params[0].val_ul, + gdb_ctx->params[1].val_ull, + gdb_ctx->params[2].val_ull); + if (res >=3D 0) { + put_packet(gdb_ctx->s, "OK"); + return; + } else if (res =3D=3D -ENOSYS) { + put_packet(gdb_ctx->s, ""); + return; + } + + put_packet(gdb_ctx->s, "E22"); +} + +static void handle_remove_bp(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + int res; + + if (gdb_ctx->num_params !=3D 3) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + res =3D gdb_breakpoint_remove(gdb_ctx->params[0].val_ul, + gdb_ctx->params[1].val_ull, + gdb_ctx->params[2].val_ull); + if (res >=3D 0) { + put_packet(gdb_ctx->s, "OK"); + return; + } else if (res =3D=3D -ENOSYS) { + put_packet(gdb_ctx->s, ""); + return; + } + + put_packet(gdb_ctx->s, "E22"); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1860,24 +1906,26 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) put_packet(s, "OK"); break; case 'Z': + { + static const GdbCmdParseEntry insert_bp_cmd_desc =3D { + .handler =3D handle_insert_bp, + .cmd =3D "Z", + .cmd_startswith =3D 1, + .schema =3D "l?L?L0" + }; + cmd_parser =3D &insert_bp_cmd_desc; + } + break; case 'z': - type =3D strtoul(p, (char **)&p, 16); - if (*p =3D=3D ',') - p++; - addr =3D strtoull(p, (char **)&p, 16); - if (*p =3D=3D ',') - p++; - len =3D strtoull(p, (char **)&p, 16); - if (ch =3D=3D 'Z') - res =3D gdb_breakpoint_insert(addr, len, type); - else - res =3D gdb_breakpoint_remove(addr, len, type); - if (res >=3D 0) - put_packet(s, "OK"); - else if (res =3D=3D -ENOSYS) - put_packet(s, ""); - else - put_packet(s, "E22"); + { + static const GdbCmdParseEntry remove_bp_cmd_desc =3D { + .handler =3D handle_remove_bp, + .cmd =3D "z", + .cmd_startswith =3D 1, + .schema =3D "l?L?L0" + }; + cmd_parser =3D &remove_bp_cmd_desc; + } break; case 'H': { --=20 2.21.0 From nobody Fri May 3 14:33:07 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=1559113134; cv=none; d=zoho.com; s=zohoarc; b=W6CXLDlBwQDdAdWMOJmtJuqv0ByFLpfqeR9Mwm/T4+WAlKOSIoZFkgU/kYRM/oLgeOI2zQNIxjYDxGGuo3NgjDijRma0P/yyGtuaQBKDvEiQmMQBnbhiLUu8Z7ZObsqRAmtMuThcO0DFn3jEE/2asF/sYX9CwRlUMlaHgXDHo8Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559113134; 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=6BpSj4VncrNQLULTrP7ZGJ4fogVHX3e/cU14TJAFSE4=; b=VxgYaBqzZ0rxXinQ/mf6kgrMbLpe5G+q/C2TJ0dvBnE9ugP6KZMG1dp28KtKzN0PYAOCtktd44VAm83s5080TbB2N34c9/kOewhBw5WLpHGbQo0z9A6OQoKEuFSQdhUFqJYNR8L/wpuOUmc4BVKv3ScPRat40mHS5g7YAXt4uks= 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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 155911313451987.64620097091392; Tue, 28 May 2019 23:58:54 -0700 (PDT) Received: from localhost ([127.0.0.1]:48457 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsXT-0006Ui-UP for importer@patchew.org; Wed, 29 May 2019 02:58:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45155) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsHq-00011p-Ri for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVsHp-00016r-T1 for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:10 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:35107) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVsHp-0000zc-NF for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:09 -0400 Received: by mail-wr1-x444.google.com with SMTP id m3so810809wrv.2 for ; Tue, 28 May 2019 23:42:09 -0700 (PDT) Received: from linux.local ([31.154.166.148]) by smtp.gmail.com with ESMTPSA id f2sm6831168wme.12.2019.05.28.23.42.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 23:42:08 -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=6BpSj4VncrNQLULTrP7ZGJ4fogVHX3e/cU14TJAFSE4=; b=c7g0XgVF7T8Uz5xGPd9s9zd+evaxonHXiJ7gZGCnXlMeqOvciRdITgydXIlxjxnEMH 0hqcgejs3WlnAoUA566B4zYdwsIcc4TuilnBDMJu9hmlVzDeDx6ImFNGatBeT9JZg4J4 9XebHEmzOj2ZM5LKJwyKLLh8ZOnFbeF1XwIEwkRobbkqJHKw6aYbXkcnKOgQsZFugRyB +IU+U4vYfNKZdSwlzTIJYrhs5/w66ZDzQ3l+nv2CejoAYfqoN6l2l6tka5SxPjGLbO9H N2oSTcM/v0lQ4d2sUuJWWpXlt/X/fbkxf0jw6LH8sP+jpefCkGx87KJ7+g5j9r+c6QAp l4oA== 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=6BpSj4VncrNQLULTrP7ZGJ4fogVHX3e/cU14TJAFSE4=; b=oQFd2zrV85bIpe6wkHrJqpeLT5qHLaf620mK25B3nN3LcRo0DMubDIEmnjBFbOWaf5 tjX6XuvAtpP+1WTyHQ6rw+RGFXU3OIsiz9ep0bs30wNosD8QNwHHn70lrEUvq7TyWz2c r6tX1qqElUJY25H3sr+ivcjye9WMAS2i9CTQQDEqp/9ygHMjk+lU9n8b9sVpfYNJbeTm QN0nkGQF+sVzyMzyPutYsKbvICLTvnmIfPitJabDKfceOs+bu10xgK0aXoG47wH2UGPr 0X6MRcBrNAR/vKf/Yc0+SjILYpOAqSMUFdc+VMSKF1BVTzGt4Q4RDfg7VYJVdObx8ApY /Fuw== X-Gm-Message-State: APjAAAWirEUHEuXVBI6qmRelaCZhdfCubvVTPUnnkMjHKPUppgoJFAb8 RKkDORLkLtv84YODmVE1sy7aHBaA X-Google-Smtp-Source: APXvYqzHvmi3Rdjp+2e69VaVHMji2I/ThMvnV5qppVrkQQVz4MtRoTMCbgWAXxSystkZ3vZD80eAUQ== X-Received: by 2002:a5d:6709:: with SMTP id o9mr13310735wru.301.1559112128686; Tue, 28 May 2019 23:42:08 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Wed, 29 May 2019 09:41:36 +0300 Message-Id: <20190529064148.19856-9-arilou@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190529064148.19856-1-arilou@gmail.com> References: <20190529064148.19856-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 v12 08/20] gdbstub: Implement set register (P 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 Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e --- gdbstub.c | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 572222bfa4..fc9526b3f5 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1651,6 +1651,27 @@ static void handle_remove_bp(GdbCmdContext *gdb_ctx,= void *user_ctx) put_packet(gdb_ctx->s, "E22"); } =20 +static void handle_set_reg(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + int reg_size; + + if (!gdb_has_xml) { + put_packet(gdb_ctx->s, "E00"); + return; + } + + if (gdb_ctx->num_params !=3D 2) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + reg_size =3D strlen(gdb_ctx->params[1].data) / 2; + hextomem(gdb_ctx->mem_buf, gdb_ctx->params[1].data, reg_size); + gdb_write_register(gdb_ctx->s->g_cpu, gdb_ctx->mem_buf, + gdb_ctx->params[0].val_ull); + put_packet(gdb_ctx->s, "OK"); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1895,15 +1916,15 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) } break; case 'P': - if (!gdb_has_xml) - goto unknown_command; - addr =3D strtoull(p, (char **)&p, 16); - if (*p =3D=3D '=3D') - p++; - reg_size =3D strlen(p) / 2; - hextomem(mem_buf, p, reg_size); - gdb_write_register(s->g_cpu, mem_buf, addr); - put_packet(s, "OK"); + { + static const GdbCmdParseEntry set_reg_cmd_desc =3D { + .handler =3D handle_set_reg, + .cmd =3D "P", + .cmd_startswith =3D 1, + .schema =3D "L?s0" + }; + cmd_parser =3D &set_reg_cmd_desc; + } break; case 'Z': { --=20 2.21.0 From nobody Fri May 3 14:33:07 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=1559112250; cv=none; d=zoho.com; s=zohoarc; b=jifV0D7rom8sX9VK4W+2JgeGyeHbqIhcTPGVQNlrwYtRfcRqoX8UJ4na6rY5+L0GTFy+GC8YUIhQ86sR42oW1BGBzvyDB656OuiVccVfyHGJuxxLvAQiELyDywpBD89BG6p7cV53baj/aAfrFU3/LhNIFsnuQmpBqPJpTzV0YbM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559112250; 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=e2K4Chkj3TNfvRg6bH2FBwRgCjBJSljoXPJlT5yCRqs=; b=CEpitk/32FmIrT6urzPFCXxPSooaZmLdnXfOZxpwOv1gLX3Hdyms87+I+UBcL+Ryh7yaH0MgW/Hh4ANZtNM1li0yBOmhw2ZS+ZBK3YyZaFrT+NXGzAltzW+88fi4vTc3S8m47QcOp2hhKec3ps7C0f3fY60bAMu1iK6p2aNaEDQ= 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 1559112250497723.7951300061908; Tue, 28 May 2019 23:44:10 -0700 (PDT) Received: from localhost ([127.0.0.1]:48226 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsJc-0002DQ-FQ for importer@patchew.org; Wed, 29 May 2019 02:44:00 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsHr-00012V-Nl for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVsHq-0001JF-PS for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:11 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:34543) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVsHq-000190-Jv for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:10 -0400 Received: by mail-wm1-x343.google.com with SMTP id e19so3627106wme.1 for ; Tue, 28 May 2019 23:42:10 -0700 (PDT) Received: from linux.local ([31.154.166.148]) by smtp.gmail.com with ESMTPSA id f2sm6831168wme.12.2019.05.28.23.42.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 23:42: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=e2K4Chkj3TNfvRg6bH2FBwRgCjBJSljoXPJlT5yCRqs=; b=gFbCnDCGgE/+VIQf5Saw5AM5qnVCzEIUd1yKQQ49dZe643HqfdBAWpkDfZtamJyGNB z6irEoF21j4w0vuqvnPA2CaeKvDFD1GLet7X9YbMW1HkPH7Kpkhy1cKNYW8sjVKpLr4F SMCJik6g8K97wbMC/Mx5EYh2gv4LMFHtwN0yZnCPl8zDyEL02onKxuVH8HXwKYo/OxSy w++S7M1DBGLqj81aT0iZrxFZC/XAs6VYFd2Wkc8X9mjSws68U05dHv8QEkj84FmgY+Vd LEoGTLBN8lPzHVBpX0b4+5VyHUZiStZ/og//gC/5o34Ls7NE5Yx/PvoHqkA03VK5bHyp QlEA== 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=e2K4Chkj3TNfvRg6bH2FBwRgCjBJSljoXPJlT5yCRqs=; b=NRK5h62ZJRB3BwlodnMIwL3Df5XWxhxlKvUZLkvG4VpaUE5PkOyFvAa+fmisa9jrzS +tHXmU+0Wpv219ViletRHxpHoXeJP2pBP8CFdP8FW1AGwOopmEorxUt8uljPu535mKRt CODHL5AvA5VN7aswgD7S5nqY3WtRnkEjcKe16XI1SkpSYJk4a0d1Sp1U6z0NAbHx0DOd /JO+9iN7Q9tRHp0itNbDg0iNo30zIjDUS0tVqG0gsQMalUwfQK63F1K9yA3/gXikSlBE xLsXpXskY+hhf20pNA/npHDIdm/RyolP36JVjxX6wdQz8X0ZZji26EnjOOMH7XGCRto6 0E8A== X-Gm-Message-State: APjAAAVop3+XvpD61x5ytBmL1tweYPfAfrpLJAZQqPRqRwIswzIEdHhP uhVvWQ/ll7ZOgBh3ly319N7eYa+n X-Google-Smtp-Source: APXvYqy0SJUqRoVgTkHZUYOdZjdGos+nyVyWClU4q7m38iUgdLzp9b3sd74gPOghQizOFczep20H6Q== X-Received: by 2002:a1c:7001:: with SMTP id l1mr5904440wmc.40.1559112129585; Tue, 28 May 2019 23:42:09 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Wed, 29 May 2019 09:41:37 +0300 Message-Id: <20190529064148.19856-10-arilou@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190529064148.19856-1-arilou@gmail.com> References: <20190529064148.19856-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::343 Subject: [Qemu-devel] [PATCH v12 09/20] gdbstub: Implement get register (p 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 Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e --- gdbstub.c | 50 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index fc9526b3f5..07740ec0af 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1672,6 +1672,36 @@ static void handle_set_reg(GdbCmdContext *gdb_ctx, v= oid *user_ctx) put_packet(gdb_ctx->s, "OK"); } =20 +static void handle_get_reg(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + int reg_size; + + /* + * Older gdb are really dumb, and don't use 'g' if 'p' is avaialable. + * This works, but can be very slow. Anything new enough to + * understand XML also knows how to use this properly. + */ + if (!gdb_has_xml) { + put_packet(gdb_ctx->s, ""); + return; + } + + if (!gdb_ctx->num_params) { + put_packet(gdb_ctx->s, "E14"); + return; + } + + reg_size =3D gdb_read_register(gdb_ctx->s->g_cpu, gdb_ctx->mem_buf, + gdb_ctx->params[0].val_ull); + if (!reg_size) { + put_packet(gdb_ctx->s, "E14"); + return; + } + + memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, reg_size); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1901,18 +1931,14 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) } break; case 'p': - /* Older gdb are really dumb, and don't use 'g' if 'p' is avaialab= le. - This works, but can be very slow. Anything new enough to - understand XML also knows how to use this properly. */ - if (!gdb_has_xml) - goto unknown_command; - addr =3D strtoull(p, (char **)&p, 16); - reg_size =3D gdb_read_register(s->g_cpu, mem_buf, addr); - if (reg_size) { - memtohex(buf, mem_buf, reg_size); - put_packet(s, buf); - } else { - put_packet(s, "E14"); + { + static const GdbCmdParseEntry get_reg_cmd_desc =3D { + .handler =3D handle_get_reg, + .cmd =3D "p", + .cmd_startswith =3D 1, + .schema =3D "L0" + }; + cmd_parser =3D &get_reg_cmd_desc; } break; case 'P': --=20 2.21.0 From nobody Fri May 3 14:33:07 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=1559112434; cv=none; d=zoho.com; s=zohoarc; b=fv1W5dZbNIe+09AEyFra1dTbvb68rGKXStclJJ7GNgbirCMm4k1T8tQZnM2vK6sOike1e61B1wNJkh6V+5nJ2AVbwzxxHZTQD+ztfWpb/nmP70uxy5w9MhVgC/y/zkuOOyUE9GObmAn1rXZjzuPw1Q/eWzqaiv9e5kOjuWalPPE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559112434; h=Content-Type: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=zYpwIgeZFIPxtX2pfuZMsiFOK3Cy3BKlk2l3IGPOWQs=; b=Sqce2h2mX+En4tYKWl2eRJ/SJPWLEkQdK0ZyJdwF3jJjxqgjm8+awCTWIDMFUlbcqQVCSct59lSDrh+/w5JTbgsl1NVfoT2te06uN/ZRAoMeMPQLaWdvUVHUSMWZWyGpOV60zMFpLNYJ6ZFgycvHsupyQdLowFGcJ6OdE1S7Oy0= 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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559112434286853.5657294364664; Tue, 28 May 2019 23:47:14 -0700 (PDT) Received: from localhost ([127.0.0.1]:48282 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsMK-0004dg-Tr for importer@patchew.org; Wed, 29 May 2019 02:46:48 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45184) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsHs-00013J-Oe for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVsHr-0001Td-OC for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:12 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:34481) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVsHr-0001KJ-Hi for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:11 -0400 Received: by mail-wr1-x443.google.com with SMTP id f8so820916wrt.1 for ; Tue, 28 May 2019 23:42:11 -0700 (PDT) Received: from linux.local ([31.154.166.148]) by smtp.gmail.com with ESMTPSA id f2sm6831168wme.12.2019.05.28.23.42.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 23:42:10 -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=zYpwIgeZFIPxtX2pfuZMsiFOK3Cy3BKlk2l3IGPOWQs=; b=oU1d6x5qNPlRW/5uyByXp+jFygpKPXrdw4cIhTd6YzQou9ZHhgPXmPMUgksaQjsCZN SSzytTsNjez3Nk1XqgsxFFzl9kqUwinoYIvuwbY1Vo+oqBvjCbDgxmoeqFrvLJ+zehf9 pP8xDgdjFvYEGRlTC92mEPdv3RLeUoeOuzAXAW6HSZ8uq4AUMbgXwwuyhBnbVLspE5P9 0xkCy/i+nxnOkJ30IcIKglBakFF9XnJa0EjgdKniYrdIu2ycTkIjTcWAQ+1Hg3bq0az9 ILzNw5SGyReBRpLs9O3+mvlmEy+sLfUmY9Zg4zyvebMHwJi1fJv24Mcre/b18kTZPtjQ WRgQ== 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=zYpwIgeZFIPxtX2pfuZMsiFOK3Cy3BKlk2l3IGPOWQs=; b=iUOmOXPsoe0PrZE7FpEhDYGp0/R/N85hQ2GHSvXDQjw8kE/qolp1Md8eCrXIbPGm6c Zgz6+lnDgkopwbLrWjprkj96fS8zCGHbcVmRMV9rE4ei91w1fXAQvGhK4E/H/k8wTYo2 GgWKP/QjlyhNRPz4wC86N1DS4yEbm4l+ozADPBf4g2tIB8D7DiZmRztjnMr/gD17xbAl eeEVdmWznPEcWdcrY7Sk7gHXj7GXYcitwYV7qSdLDDKczkdrwU2rTeTdonTg8GklG01Y NNNB8odgzQ4V45oySItiKpRenPRdj8A6DM+aMRTgQynhCELyAORStXhvL9lnGKD5xAzm aGcw== X-Gm-Message-State: APjAAAXsBhwzBaTjnijG68+k1bvMdUqqjeNG8/U9DlVzSTqA33E/PHJJ HCryVlu9+eOlldastADVzG8U8EM7 X-Google-Smtp-Source: APXvYqzQ5HTbTOjWP9jWEJJKJubxInmKqfZHqz0NPYSSA0ns/oEe1jTz2BDDrNRkPXD/M/LHjR+nHQ== X-Received: by 2002:a5d:5342:: with SMTP id t2mr17123074wrv.71.1559112130464; Tue, 28 May 2019 23:42:10 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Wed, 29 May 2019 09:41:38 +0300 Message-Id: <20190529064148.19856-11-arilou@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190529064148.19856-1-arilou@gmail.com> References: <20190529064148.19856-1-arilou@gmail.com> 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::443 Subject: [Qemu-devel] [PATCH v12 10/20] gdbstub: Implement write memory (M 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) Signed-off-by: Jon Doron Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e --- gdbstub.c | 51 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 07740ec0af..f2ea5bdd5c 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1702,6 +1702,31 @@ static void handle_get_reg(GdbCmdContext *gdb_ctx, v= oid *user_ctx) put_packet(gdb_ctx->s, gdb_ctx->str_buf); } =20 +static void handle_write_mem(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (gdb_ctx->num_params !=3D 3) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + /* hextomem() reads 2*len bytes */ + if (gdb_ctx->params[1].val_ull > strlen(gdb_ctx->params[2].data) / 2) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + hextomem(gdb_ctx->mem_buf, gdb_ctx->params[2].data, + gdb_ctx->params[1].val_ull); + if (target_memory_rw_debug(gdb_ctx->s->g_cpu, gdb_ctx->params[0].val_u= ll, + gdb_ctx->mem_buf, + gdb_ctx->params[1].val_ull, true)) { + put_packet(gdb_ctx->s, "E14"); + return; + } + + put_packet(gdb_ctx->s, "OK"); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1910,24 +1935,14 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) } break; case 'M': - addr =3D strtoull(p, (char **)&p, 16); - if (*p =3D=3D ',') - p++; - len =3D strtoull(p, (char **)&p, 16); - if (*p =3D=3D ':') - p++; - - /* hextomem() reads 2*len bytes */ - if (len > strlen(p) / 2) { - put_packet (s, "E22"); - break; - } - hextomem(mem_buf, p, len); - if (target_memory_rw_debug(s->g_cpu, addr, mem_buf, len, - true) !=3D 0) { - put_packet(s, "E14"); - } else { - put_packet(s, "OK"); + { + static const GdbCmdParseEntry write_mem_cmd_desc =3D { + .handler =3D handle_write_mem, + .cmd =3D "M", + .cmd_startswith =3D 1, + .schema =3D "L,L:s0" + }; + cmd_parser =3D &write_mem_cmd_desc; } break; case 'p': --=20 2.21.0 From nobody Fri May 3 14:33:07 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=1559113287; cv=none; d=zoho.com; s=zohoarc; b=Xhs5BEJOd51G0ORVNFhacsiydxXEIx0MyNNr3o4xvcUo5JBwMVVxaOkOOz258oPDIb4nByaDuENClYKubYR6F+w+3S9nsM0ria4ZaEtGKKUYMF3vQpMubsLHzwcM+nBPE+rvvJjEaaDtgCASgUT62Ypj2SGvWHXtSwDg3hsoGf8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559113287; h=Content-Type: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=8ICssjH6IZyanWlXmi8fQqHEPU1P+hXRIPq59SDpKSI=; b=CerI8GCPxg94NERoQ3sIZx+OHPCALv/uZ0cqU2zN3p/pmRWD7z38OebRD0/SXRQqMEVIPNAV9GTTGVH0ncHpZpDLUZqFYqiPeyk+cY2uaY9WCldntE1MOkJ9mqjjKDFpbSGFkhZj99p0Py9xh6PLSnbRXUmpC2n52BtaChkdTOA= 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 155911328785675.2753654819436; Wed, 29 May 2019 00:01:27 -0700 (PDT) Received: from localhost ([127.0.0.1]:48519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsaL-0000S5-NT for importer@patchew.org; Wed, 29 May 2019 03:01:17 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsHt-00014T-PF for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVsHs-0001gS-Nu for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:13 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:40440) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVsHs-0001VX-HB for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:12 -0400 Received: by mail-wr1-x441.google.com with SMTP id t4so785334wrx.7 for ; Tue, 28 May 2019 23:42:12 -0700 (PDT) Received: from linux.local ([31.154.166.148]) by smtp.gmail.com with ESMTPSA id f2sm6831168wme.12.2019.05.28.23.42.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 23:42:10 -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=8ICssjH6IZyanWlXmi8fQqHEPU1P+hXRIPq59SDpKSI=; b=UB2/o5Yi7r6ntVxzzE+03McbIm48XlBPtVIhl1h8MBpwGLgDDiNY2aYr9Kr4UR3Efm K61LncmU2ckf5BrleGFQjVs3Vzd36zRluVhOhQFOrXTBhKtbhkS0ofq9+R6lRy0zmZyg kR666K6vc5nWklAEfHMCseAP1Ehi/fVoOQfnTa00BkQ6s42y6m+PP4WpA71Za4aZbvF6 FBxMVNIJxVCVJu0pEAn0XQB3deoPYa5jEe1myehLwzYHUR0sGWRoFI+K7joRfOivtqWh Q5ULJ8ClzXZJk2QL42HH6vod7ppcshIDNjZLPTY7vm4E5BP+Ikh+wCAQRuX8yOk/o96x 63iA== 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=8ICssjH6IZyanWlXmi8fQqHEPU1P+hXRIPq59SDpKSI=; b=CbvD93T/bxr5wyUWSQLtSdaGnlEU3Tky2lBIZ90APv1aGUaE2EyC58dGtYv8p1HVw7 zM2OGn/+U6iLdKTPdvjdZooizWoGsk2CexCa70H2ETK6D+NPdWygCDZspX0N17ZKsbiB 13q5ZdpfpUdsQDVirAuaa0FomSdPDGXV+i/JZ8XbjOzuZwqCIk9iqGbEVmGgn1QrkLVg N5vJoY8om1dgry+bgqlQoVI3exhArVsfuC5MRp6E9LQI47Lp2rTxq74oQp7b84pFYACN uJJ4yyBk/l8qO27gNaaNUVS59TT6/Ifhsj5tUGX2FaA8I57mpL3UyrHw1bzt1gDyV8sx 97kA== X-Gm-Message-State: APjAAAWLsLRzLPkQdf9OMgVGbKNtX63MoFTM9TIWgKYuXEKncK7hcg9L LREe16Mi++Otvf36CqppI0D/RT+d X-Google-Smtp-Source: APXvYqx62EDUHnSY2+Zb9cODZrCyQu0tdHHBGqtc7E/6bRROICPIBVC3Y5fi/+3qgi2ZR3AwowDjDA== X-Received: by 2002:adf:8307:: with SMTP id 7mr69120734wrd.86.1559112131346; Tue, 28 May 2019 23:42:11 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Wed, 29 May 2019 09:41:39 +0300 Message-Id: <20190529064148.19856-12-arilou@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190529064148.19856-1-arilou@gmail.com> References: <20190529064148.19856-1-arilou@gmail.com> 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::441 Subject: [Qemu-devel] [PATCH v12 11/20] gdbstub: Implement read memory (m 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) Signed-off-by: Jon Doron Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e --- gdbstub.c | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index f2ea5bdd5c..3d8c2f8f42 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1727,6 +1727,30 @@ static void handle_write_mem(GdbCmdContext *gdb_ctx,= void *user_ctx) put_packet(gdb_ctx->s, "OK"); } =20 +static void handle_read_mem(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (gdb_ctx->num_params !=3D 2) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + /* memtohex() doubles the required space */ + if (gdb_ctx->params[1].val_ull > MAX_PACKET_LENGTH / 2) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + if (target_memory_rw_debug(gdb_ctx->s->g_cpu, gdb_ctx->params[0].val_u= ll, + gdb_ctx->mem_buf, + gdb_ctx->params[1].val_ull, false)) { + put_packet(gdb_ctx->s, "E14"); + return; + } + + memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, gdb_ctx->params[1].val_ul= l); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1916,22 +1940,14 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) put_packet(s, "OK"); break; case 'm': - addr =3D strtoull(p, (char **)&p, 16); - if (*p =3D=3D ',') - p++; - len =3D strtoull(p, NULL, 16); - - /* memtohex() doubles the required space */ - if (len > MAX_PACKET_LENGTH / 2) { - put_packet (s, "E22"); - break; - } - - if (target_memory_rw_debug(s->g_cpu, addr, mem_buf, len, false) != =3D 0) { - put_packet (s, "E14"); - } else { - memtohex(buf, mem_buf, len); - put_packet(s, buf); + { + static const GdbCmdParseEntry read_mem_cmd_desc =3D { + .handler =3D handle_read_mem, + .cmd =3D "m", + .cmd_startswith =3D 1, + .schema =3D "L,L0" + }; + cmd_parser =3D &read_mem_cmd_desc; } break; case 'M': --=20 2.21.0 From nobody Fri May 3 14:33:07 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=1559112593; cv=none; d=zoho.com; s=zohoarc; b=CkIxs4TdpT+hPLbDoe5P1sUJEYu+kwCowpADyuqnPasTQt2hTkZSVEwWejCL1UeZ5MbHN+twZJbhGIPE8Mp7LzLUSfcXauM+Bv9hSiz1RhxwhcWuDrzNj6TxoedWyQ41XdIhCOpEVe9V/l15BfH3MwgAkHyWji2t74yntSoTDXM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559112593; h=Content-Type: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=fmBgz+KC4/5bEya28Z0ZS6wch0W9g6YQKvTnKrR7Gq0=; b=npDzcLblffILoVF1vJ9UhHkhIuhlqNWkN4AEkc2xsEdSTe4E5LnPdSQIBvyyYxxg9YP+FBvzU1XQGbZ5OMV3At/tVfd0jYtgfdMMoWC+LyFUjdUxf7SREItg4Aa2w6Hp8z8+IAo95pqnxJqDMjKIoAuMH5w8GFTYtJdNDGWeTuo= 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 15591125934361005.3137061695483; Tue, 28 May 2019 23:49:53 -0700 (PDT) Received: from localhost ([127.0.0.1]:48302 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsPC-00074u-HS for importer@patchew.org; Wed, 29 May 2019 02:49:46 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45208) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsHu-00015D-Ka for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVsHt-0001qd-GW for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:14 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:40169) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVsHt-0001h3-9b for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:13 -0400 Received: by mail-wm1-x344.google.com with SMTP id 15so680867wmg.5 for ; Tue, 28 May 2019 23:42:13 -0700 (PDT) Received: from linux.local ([31.154.166.148]) by smtp.gmail.com with ESMTPSA id f2sm6831168wme.12.2019.05.28.23.42.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 23:42:11 -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=fmBgz+KC4/5bEya28Z0ZS6wch0W9g6YQKvTnKrR7Gq0=; b=ozt1N/ASHQlONUmPN1vjIH4Rk4z0A3QWI55MvOpOzFYoSFUBkgsAOZJRxhqMrm4BRM miosJMHcnrLnd6XlMdPeWpbZ8Rjr+xMAok2owOTdthjmj93plPWpRsWsFjFLequPnSRi bIGYpwaas/hYs+LbSH7uR7dryX7F2wN84SRzQv1vD55fVTTRP/eBOQligk647Sgl94Un qc73SnllnY9lLxm7Gsh/ImpZ4kvYqUx7psw82XfHKTjZmV18yTacfV3nXczWlKUYeAol Ekqz6PNJTQcQU18QIsL3vro/6gePqwVOIJ00cEULvq+3Hfx/aqmImiKWk5wzKnir88BQ J05A== 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=fmBgz+KC4/5bEya28Z0ZS6wch0W9g6YQKvTnKrR7Gq0=; b=UzIls8XFG5jFJifuBpeRAT4joNFixQqUThWi7FfdvxFRQ6FtzyLKq5IXJCIAHr0jjB fKzmxUH46UJM+gOVKVQVKJDvPHbfKI9OGpb0siLE9vXtB5nbLMrqZpbYNEf+wEfNwdpw zGY/BMCScBnTJumKGSlbNCIpt5UIFnhWPy6XP6w1+HVfrPj386WK2bmtMVPBQOh2gLkQ 6aGMG+2fN9tQcEjlJFUM3cL7J43JSRGWVO5c0TBO8yC3SuGkTrZ6mJmDhirDGB1JP8bk Za7wVbqQ4llBQMHvUDjpAEo+Pkvaqhq/Y0hZ8QHlNvdZvTGBFKVfQmZ4hfraR82SDYT0 QoSg== X-Gm-Message-State: APjAAAXTh/T7rlXmeffxPlmJoZWeyY5bocEbE8cPfzbO18UZf5549noO vdfp9Efm5T55TNiz8F3iWk5Hn154 X-Google-Smtp-Source: APXvYqxHHLKIMEIcVJ9XxYtnAgv7UrEs0QFWWK836Rz3od+KhQVxsB3Lflcd1hbBq7QwDLqOAUootQ== X-Received: by 2002:a7b:c939:: with SMTP id h25mr5769956wml.7.1559112132287; Tue, 28 May 2019 23:42:12 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Wed, 29 May 2019 09:41:40 +0300 Message-Id: <20190529064148.19856-13-arilou@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190529064148.19856-1-arilou@gmail.com> References: <20190529064148.19856-1-arilou@gmail.com> 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::344 Subject: [Qemu-devel] [PATCH v12 12/20] gdbstub: Implement write all registers (G 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) Signed-off-by: Jon Doron Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e --- gdbstub.c | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 3d8c2f8f42..a487e549d1 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1751,6 +1751,29 @@ static void handle_read_mem(GdbCmdContext *gdb_ctx, = void *user_ctx) put_packet(gdb_ctx->s, gdb_ctx->str_buf); } =20 +static void handle_write_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + target_ulong addr, len; + uint8_t *registers; + int reg_size; + + if (!gdb_ctx->num_params) { + return; + } + + cpu_synchronize_state(gdb_ctx->s->g_cpu); + registers =3D gdb_ctx->mem_buf; + len =3D strlen(gdb_ctx->params[0].data) / 2; + hextomem(registers, gdb_ctx->params[0].data, len); + for (addr =3D 0; addr < gdb_ctx->s->g_cpu->gdb_num_g_regs && len > 0; + addr++) { + reg_size =3D gdb_write_register(gdb_ctx->s->g_cpu, registers, addr= ); + len -=3D reg_size; + registers +=3D reg_size; + } + put_packet(gdb_ctx->s, "OK"); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1762,7 +1785,6 @@ static int gdb_handle_packet(GDBState *s, const char = *line_buf) uint8_t mem_buf[MAX_PACKET_LENGTH]; char buf[sizeof(mem_buf) + 1 /* trailing NUL */]; char thread_id[16]; - uint8_t *registers; target_ulong addr, len; const GdbCmdParseEntry *cmd_parser =3D NULL; =20 @@ -1928,16 +1950,15 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) put_packet(s, buf); break; case 'G': - cpu_synchronize_state(s->g_cpu); - registers =3D mem_buf; - len =3D strlen(p) / 2; - hextomem((uint8_t *)registers, p, len); - for (addr =3D 0; addr < s->g_cpu->gdb_num_g_regs && len > 0; addr+= +) { - reg_size =3D gdb_write_register(s->g_cpu, registers, addr); - len -=3D reg_size; - registers +=3D reg_size; + { + static const GdbCmdParseEntry write_all_regs_cmd_desc =3D { + .handler =3D handle_write_all_regs, + .cmd =3D "G", + .cmd_startswith =3D 1, + .schema =3D "s0" + }; + cmd_parser =3D &write_all_regs_cmd_desc; } - put_packet(s, "OK"); break; case 'm': { --=20 2.21.0 From nobody Fri May 3 14:33:07 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=1559113490; cv=none; d=zoho.com; s=zohoarc; b=lBOU/L62OMfjpdrQGIVsVLQ7AgW92xs9ZeqLr66zTYt/2gK7aAG38enSe1N/HA/0C/c0cBPcO3EVAL9KDxCwU/ok3HXtLdlzrtFESNSgHJzvzHAwZkDBrkqP7xeo2BaZmAaH9VQ3X19yYzn92MamGu771UWeAi4m7tkv1HDvrAg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559113490; h=Content-Type: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=znSiOGTnV63Iw4NoeCVkFq+8TJBRoFVxm4iUWeh4XxE=; b=RMvOEfe5L3TNjW7fCnpHqRyWzfIHE23HMNEpKEEQyoRD6MjXjS0MVmLzanANwuDqept0EZ04OG2vsUGl1mQCVspfv3QkVnOtgU0EcdLKp8i6miJ4dWId4KpUYfoao6JMlC0mttA1zORJwA/CVBaX8u8njqo3lLTaXqWTHgHj+Xg= 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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559113490110666.6907257911066; Wed, 29 May 2019 00:04:50 -0700 (PDT) Received: from localhost ([127.0.0.1]:48551 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsdc-000350-MK for importer@patchew.org; Wed, 29 May 2019 03:04:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsHv-00016L-Fv for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVsHu-000224-GU for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:15 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:37981) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVsHu-0001uT-Af for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:14 -0400 Received: by mail-wr1-x443.google.com with SMTP id d18so793679wrs.5 for ; Tue, 28 May 2019 23:42:14 -0700 (PDT) Received: from linux.local ([31.154.166.148]) by smtp.gmail.com with ESMTPSA id f2sm6831168wme.12.2019.05.28.23.42.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 23:42:12 -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=znSiOGTnV63Iw4NoeCVkFq+8TJBRoFVxm4iUWeh4XxE=; b=W8DVy6X34OB183ztL9J5Uorl/nmQURkpqPMerzieAUEpyAIxzBwalKwG29Iwtvl3h8 vh4ItqgaKPfgYOyahzoHLNhyXg5vzM8Bae2NEoyqXoyeK48GBZbw9Tczl8jAUcsf2KBO vDdFnu/cUHpQCGlc318qTTTyzX9GAOojWfZ3djD8XNxirmnATRMQSWnf7vDbw3WLDAhZ 4kH2zB1nLOE/HBinDU+FML5VRNwWJJ0bAHTw4uyuVdC0/oRgQaaAztvFPp1R+FKvabJH rx8J55SWlH639Xw6NlUAfnHychKphrHr55ntcvWnWtFdkXqawpWj622wVEtDLTsYNgbE JAhw== 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=znSiOGTnV63Iw4NoeCVkFq+8TJBRoFVxm4iUWeh4XxE=; b=fL6c1XRr0Sh3ofxKi/MZgeJaMjnb8CiHOk8Qld/UjR4njJG2KnYedy0dpQUl7iSVZQ igiXPLJmN2B9FC+Z8bwPiRXjUqEC9ckuufw+5wbdnnZ+2T+FYbgMpNNth0rZyIF5Ls3Z S81g7GsVuSw4XMWz35s3B9lQF7ffCHp/2/2UzPVhyZwHaapGEWNLXNfZD+H0sFA/nn++ ueU+4ViUPe2KG6rjNHn4USX0KcZ/w6JKKoRVSYKO9UmPSzHJsfiPqxfY/j5yT3OaZotr woIp4/ssAJjK9y/IAK8g82JyXzI7YXnhM9Gb4bPZCcJqM7sTDWWHmULNQt4/fbXlyQcP YU3g== X-Gm-Message-State: APjAAAWQXFUaRsCBWHFRWAsCJJeEGRv4WCTP3A/G7iPIxxuiVUK/DIto aA97D9Cla7mjQj+SBGRkA+E8xQ0A X-Google-Smtp-Source: APXvYqxmIeA/W36rmi9TZKfKoRqq6hFsEZysWbqlu7eHpXQ3JJg1yamkcvf11V9ffVVQqjGcTsxanA== X-Received: by 2002:a5d:6189:: with SMTP id j9mr16791438wru.151.1559112133229; Tue, 28 May 2019 23:42:13 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Wed, 29 May 2019 09:41:41 +0300 Message-Id: <20190529064148.19856-14-arilou@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190529064148.19856-1-arilou@gmail.com> References: <20190529064148.19856-1-arilou@gmail.com> 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::443 Subject: [Qemu-devel] [PATCH v12 13/20] gdbstub: Implement read all registers (g 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) Signed-off-by: Jon Doron Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e --- gdbstub.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index a487e549d1..8a401e6527 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1774,6 +1774,21 @@ static void handle_write_all_regs(GdbCmdContext *gdb= _ctx, void *user_ctx) put_packet(gdb_ctx->s, "OK"); } =20 +static void handle_read_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + target_ulong addr, len; + + cpu_synchronize_state(gdb_ctx->s->g_cpu); + len =3D 0; + for (addr =3D 0; addr < gdb_ctx->s->g_cpu->gdb_num_g_regs; addr++) { + len +=3D gdb_read_register(gdb_ctx->s->g_cpu, gdb_ctx->mem_buf + l= en, + addr); + } + + memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, len); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1781,7 +1796,7 @@ static int gdb_handle_packet(GDBState *s, const char = *line_buf) CPUClass *cc; const char *p; uint32_t pid, tid; - int ch, reg_size, type, res; + int ch, type, res; uint8_t mem_buf[MAX_PACKET_LENGTH]; char buf[sizeof(mem_buf) + 1 /* trailing NUL */]; char thread_id[16]; @@ -1940,14 +1955,14 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) } break; case 'g': - cpu_synchronize_state(s->g_cpu); - len =3D 0; - for (addr =3D 0; addr < s->g_cpu->gdb_num_g_regs; addr++) { - reg_size =3D gdb_read_register(s->g_cpu, mem_buf + len, addr); - len +=3D reg_size; + { + static const GdbCmdParseEntry read_all_regs_cmd_desc =3D { + .handler =3D handle_read_all_regs, + .cmd =3D "g", + .cmd_startswith =3D 1 + }; + cmd_parser =3D &read_all_regs_cmd_desc; } - memtohex(buf, mem_buf, len); - put_packet(s, buf); break; case 'G': { --=20 2.21.0 From nobody Fri May 3 14:33:07 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=1559113670; cv=none; d=zoho.com; s=zohoarc; b=KRh/4vO1UGgfEfDIAaoUk1Fx7VREmBR1DbGXrgNeKc4gcHt2ETx27W8p9ivTHqhGLy1hx3ADICAX/onHSnEdkCc7RA4fDww+3OJ+rmFQTUM0s9VthLg5vwwZXIMVlPBYt9Df0Dfc0JfM6CiKvaP4LY5eg1EcztFPMRvXIGrB8K4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559113670; 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=nfvTF304j4FxQ92xKihWDltBNWAJ9aSBkHnyPnGx2bw=; b=Qks/ZL+1oN9+kY4/3yaF1KkL2xUSTwl97Tc9mQuXDKC3a2fPYOEH9s06LD8FWAA20SnaVdXSNz+MBpspsk/b+wYtFUIY/0JfwypRFF2k8jkw3XOpb0mMAUQlMCydhwvVvznh/mWEn2FmeqdWyHCShn8er5dC/kPNssK+4IjLKxc= 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 1559113670479840.475199778313; Wed, 29 May 2019 00:07:50 -0700 (PDT) Received: from localhost ([127.0.0.1]:48607 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsgZ-0005gT-Sm for importer@patchew.org; Wed, 29 May 2019 03:07:43 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsHw-00017U-HB for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVsHv-00029Z-Dy for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:16 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:51340) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVsHv-000248-7i for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:15 -0400 Received: by mail-wm1-x343.google.com with SMTP id f10so727835wmb.1 for ; Tue, 28 May 2019 23:42:15 -0700 (PDT) Received: from linux.local ([31.154.166.148]) by smtp.gmail.com with ESMTPSA id f2sm6831168wme.12.2019.05.28.23.42.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 23:42:13 -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=nfvTF304j4FxQ92xKihWDltBNWAJ9aSBkHnyPnGx2bw=; b=Oj+pdJphteXnj3D+MI3kpRepureN0Ee/gdJI+Uz27t+Z4Wl3ARqJamy0ZMgj6i2M5V Y4xSBxqvu3094RHoz9dPjMWsnaaZNQAUQ35M7kH46y+UdgcJKNG3nmGDOPtd/7Q2pJTK NXU5O1X3FfFPGyFfGZzVIao42rWKCFE8QA+fW253BPYvxCKFXCYjJq/EVUyQk0m1089D R+m6YniFeRVWqngcLH8d//zl5dKqax6ryvubTSbtY/TmWkw+wnMgvarGjCUjvV80e6eV eSy3/Wi2pGcDht9GxTvOt/uiePKKURB7KUxceSZBkCmZqdvJRj7DLg7RZn5CoXh3beQ5 b6gQ== 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=nfvTF304j4FxQ92xKihWDltBNWAJ9aSBkHnyPnGx2bw=; b=XryzrUL7Cv4GfgRNec96r/XBNP1aLtFTywbJzA+y6rliSPp8HB/I7CHa+pWMG2Dzwa tN1k8/pZUJVCEKOkuyk30mFhhK422Nys/DK4xcQfdWjirlA8wlleJ7B5b5pacT1V4Ia7 tS3A4Us91q1Bkn9IFZncwyFmFoM2M4z5r/s2HWR+40UIw0gipX/er+YFJa0X1EN8MjAi K533ZNQpzFPePhpRz7P7m6k3opeFzhYM7kxB5fcPENwS4CPVB4u/OsGa5LdxDF53371b PAhqD0nG9M7/CHFGK6MmRzJrQbnUGIFxPOEhoyAX4G1s09gu/kqntITqQZiB/tG30Zqf P/rA== X-Gm-Message-State: APjAAAVmIbWhIKJN0/3PZ+ZdRZDrIPYEIb7oGpVUFchs4jCBQ4oKsFKL GsH1ig1IWUm8siqmtCoHR5IuQVUy X-Google-Smtp-Source: APXvYqzJo5qyD3pJI/OpgECmuXJzvC+R8pnsSB/va1VBFoxF0lJQVXgWkAxhPuvJvPDcWQTBlpAPdA== X-Received: by 2002:a7b:c846:: with SMTP id c6mr5940068wml.0.1559112134236; Tue, 28 May 2019 23:42:14 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Wed, 29 May 2019 09:41:42 +0300 Message-Id: <20190529064148.19856-15-arilou@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190529064148.19856-1-arilou@gmail.com> References: <20190529064148.19856-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::343 Subject: [Qemu-devel] [PATCH v12 14/20] gdbstub: Implement file io (F 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 Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e --- gdbstub.c | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 8a401e6527..ea85966b27 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1789,6 +1789,25 @@ static void handle_read_all_regs(GdbCmdContext *gdb_= ctx, void *user_ctx) put_packet(gdb_ctx->s, gdb_ctx->str_buf); } =20 +static void handle_file_io(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (gdb_ctx->num_params >=3D 2 && gdb_ctx->s->current_syscall_cb) { + target_ulong ret, err; + + ret =3D (target_ulong)gdb_ctx->params[0].val_ull; + err =3D (target_ulong)gdb_ctx->params[1].val_ull; + gdb_ctx->s->current_syscall_cb(gdb_ctx->s->c_cpu, ret, err); + gdb_ctx->s->current_syscall_cb =3D NULL; + } + + if (gdb_ctx->num_params >=3D 3 && gdb_ctx->params[2].opcode =3D=3D (ui= nt8_t)'C') { + put_packet(gdb_ctx->s, "T02"); + return; + } + + gdb_continue(gdb_ctx->s); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1930,28 +1949,13 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) return RS_IDLE; case 'F': { - target_ulong ret; - target_ulong err; - - ret =3D strtoull(p, (char **)&p, 16); - if (*p =3D=3D ',') { - p++; - err =3D strtoull(p, (char **)&p, 16); - } else { - err =3D 0; - } - if (*p =3D=3D ',') - p++; - type =3D *p; - if (s->current_syscall_cb) { - s->current_syscall_cb(s->c_cpu, ret, err); - s->current_syscall_cb =3D NULL; - } - if (type =3D=3D 'C') { - put_packet(s, "T02"); - } else { - gdb_continue(s); - } + static const GdbCmdParseEntry file_io_cmd_desc =3D { + .handler =3D handle_file_io, + .cmd =3D "F", + .cmd_startswith =3D 1, + .schema =3D "L,L,o0" + }; + cmd_parser =3D &file_io_cmd_desc; } break; case 'g': --=20 2.21.0 From nobody Fri May 3 14:33:07 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=1559112790; cv=none; d=zoho.com; s=zohoarc; b=MwFpEn0uMzfvF0aNfj8irMglQ6JmdJw2yVUpzRHOEpTjqQvXhrQ9doIj26zj0KaTt6HVIpb0CXX+bAG/S5tyyrZWf+PTGp8nH2UI51yfQaxatiq+ZiGc+7S6PLsun0L9HL2m8l8UUfrJYP1SwhrgGYDm1BJ8zxbAsZ1IETjNeeE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559112790; h=Content-Type: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=HQvIxbBUXHhlW/4mbYuy+l0vzsqWjiYKQE0W+h99nC0=; b=XVSlO2kzpD7QI3kd5V+4Y5kjHKLA5WL83f7ojycLZvW/9ms16owiAGfwY6P138g2sZnu9Ifg1g9p9d8YZ5IMzprrPeq5Hg1FxgLIDZD7KXx2e5+E91ayZi34hh94qcdbpiVtJ1Q4MoLyvpiHSmnCUn5RN4X2GSmhkNRFoMWPdOc= 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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559112790294198.9231326664933; Tue, 28 May 2019 23:53:10 -0700 (PDT) Received: from localhost ([127.0.0.1]:48375 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsSI-0001hN-7N for importer@patchew.org; Wed, 29 May 2019 02:52:58 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45326) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsI2-0001Eg-U9 for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVsI1-0003Ag-Sx for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:22 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:40169) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVsI1-00034Z-NM for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:21 -0400 Received: by mail-wm1-x342.google.com with SMTP id 15so681108wmg.5 for ; Tue, 28 May 2019 23:42:21 -0700 (PDT) Received: from linux.local ([31.154.166.148]) by smtp.gmail.com with ESMTPSA id f2sm6831168wme.12.2019.05.28.23.42.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 23:42: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=HQvIxbBUXHhlW/4mbYuy+l0vzsqWjiYKQE0W+h99nC0=; b=qK0hhyXUh+SDMxhjiIw9CmYJsi+W7Xu1t46UMcqIbtiRzgfEAIqrgjgbEEHFQEoglD 8X7+NPOjLm6/v2Bz+eB+NlMZYCMyS231MmmOTpW+5Owq6HPN/+jAjdN1IBemKn+c5S8h MZbOjiLcfK7WPPP/O6/bocnazgDWMtLi5q9EX2Gdo2U6K7U+UHx+TXMdx9xphEGaccxT jkR+rgb8crjTc2d64YVzCLk9XAhaq77HzBSw4TExRP3gtBgjl8HmCVAWXuceKov5WHfN xoeTxFTpdW891BCFbFFmb7pkTRsqHdIHsUaqOq1t6VXr7NGjcM7YPC/4xcPoQcSXN49K DAtg== 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=HQvIxbBUXHhlW/4mbYuy+l0vzsqWjiYKQE0W+h99nC0=; b=A4eeYgoeEJKpNbOvAJE94hubVMwg65UaU6uXmYewsROX07rkq2Hjm18x7N/zuagITn K9v2hWncF3EvrG8Xl+XYIgbPjoj6wbibCcw8SgTlM7JVE91vHf3iNYkNbpYkvN8N3eVZ beHfc7GxGr29Q6u5hEWId1eT7S86uxbRVvZPWLBj2qtJ6K8nxHTCCKqZVutL2Er0XE/P CwtfJ/k1dGQ4jmTYYgS5AiV7l8VLo7OSqe03oH2rNay69fcEdrZVmCCJevxHdZBF9Ncv XR2z+xVeK5jkFG9x9tkN9KHkTJwjyqB6UewuHDHnQCtB4BhDnu2DBI6hLQBS1cBdWBbP lyhw== X-Gm-Message-State: APjAAAWVv1qmBoczMvssg1MzV8ftzLgpuLIxd12ya6xNGu8hvIyBRfnp +y+Hoff/57/2L0Au3W+RPsCgPsNc X-Google-Smtp-Source: APXvYqxo3R3BXFr+2CDcXkv834nIz+OL9qYDPevKsJTHB2bDRRbqa0BZ0DQ1gNOQMEPpu1dfPLlNaA== X-Received: by 2002:a1c:9ac2:: with SMTP id c185mr5400301wme.72.1559112135202; Tue, 28 May 2019 23:42:15 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Wed, 29 May 2019 09:41:43 +0300 Message-Id: <20190529064148.19856-16-arilou@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190529064148.19856-1-arilou@gmail.com> References: <20190529064148.19856-1-arilou@gmail.com> 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::342 Subject: [Qemu-devel] [PATCH v12 15/20] gdbstub: Implement step (s 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) Signed-off-by: Jon Doron Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e --- gdbstub.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index ea85966b27..3fd1a1cddb 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1808,6 +1808,16 @@ static void handle_file_io(GdbCmdContext *gdb_ctx, v= oid *user_ctx) gdb_continue(gdb_ctx->s); } =20 +static void handle_step(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (gdb_ctx->num_params) { + gdb_set_cpu_pc(gdb_ctx->s, (target_ulong)gdb_ctx->params[0].val_ul= l); + } + + cpu_single_step(gdb_ctx->s->c_cpu, sstep_flags); + gdb_continue(gdb_ctx->s); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1940,13 +1950,16 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) } break; case 's': - if (*p !=3D '\0') { - addr =3D strtoull(p, (char **)&p, 16); - gdb_set_cpu_pc(s, addr); + { + static const GdbCmdParseEntry step_cmd_desc =3D { + .handler =3D handle_step, + .cmd =3D "s", + .cmd_startswith =3D 1, + .schema =3D "L0" + }; + cmd_parser =3D &step_cmd_desc; } - cpu_single_step(s->c_cpu, sstep_flags); - gdb_continue(s); - return RS_IDLE; + break; case 'F': { static const GdbCmdParseEntry file_io_cmd_desc =3D { --=20 2.21.0 From nobody Fri May 3 14:33:07 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=1559113842; cv=none; d=zoho.com; s=zohoarc; b=K/ZuWc9mUwpFyo7xTJcn5PDii/lbpw3JXoOGRW6NrFEKcRmAuhNetYqE7Ki0tgjCA1PbIl6eDg49rXDJcwTqLCvJAFbtrrmLKuTLw0Neeuthk4dFmh8ERLkYzNfnJmeAq8gzcPmHsadsn/zPfFI9bJa7NJeOxN0UwGAaSZ9o5JA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559113842; 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=WJhaKk0Bv9gRHhRS5uztzL7FE5AQMtFAVizIuMhmaP4=; b=cH56CCNlFA/KT7yJcg7CjDyO2spTBGLfdbwbjWRCk2vGTS1MwtJ0P9CS76MokqQM1gsyqZbhzF4vinmiZAH9HZOfQqCYEXzSQlgi4mzp+DfwWgkPbbdwN/mUt0967aUrjpu5s/NCGuC38086gJMXKr9FXF++FdlZMcWA0jxI8e4= 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 1559113842368782.4657072613604; Wed, 29 May 2019 00:10:42 -0700 (PDT) Received: from localhost ([127.0.0.1]:48638 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsjJ-0007zD-Ov for importer@patchew.org; Wed, 29 May 2019 03:10:33 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45256) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsHy-00019y-LO for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVsHx-0002T5-9j for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:18 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:55393) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVsHx-0002Jq-48 for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:17 -0400 Received: by mail-wm1-x341.google.com with SMTP id u78so714973wmu.5 for ; Tue, 28 May 2019 23:42:17 -0700 (PDT) Received: from linux.local ([31.154.166.148]) by smtp.gmail.com with ESMTPSA id f2sm6831168wme.12.2019.05.28.23.42.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 23:42:15 -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=WJhaKk0Bv9gRHhRS5uztzL7FE5AQMtFAVizIuMhmaP4=; b=px0LcRNrPB7184dsi9bPUkbTrp6T1HnCkcUH8cYGUDYK3SrU+Q66JPUV/nd9p8oEi+ CIQ7/aTXxJOwIAiwQOAzrlGCFcaxfmD4M79OA/YYn0E8sxclLc1KwpFj/ENrbIs50tdQ 3LrtGh4INJTfYeP4cKDwHxM7w+92cwQ85fr51s0xuYEKkwvetA4Mp0j7fYYa2dznIat4 jGrKT1X2UmjRnMscksfhVt9clxHQGPixVJrZMCA0LstyzQIv92UqbjPzO3sTGzsDJnfX P5qHRug+DDQsYvv5rnDKYLuT42VLsAk7YZrYAgxJiOmVA93Kqq67xCeqMEM8g9Yx7Yiw pHrg== 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=WJhaKk0Bv9gRHhRS5uztzL7FE5AQMtFAVizIuMhmaP4=; b=RKUgUUDQ/qt3qT/aKEPh6Z06hxwAvHuMtT9qL+7g2jnu3knTE1hPkC3d/feF4sr/D/ ofAbh9wvjBGlbPVOa6fsnXKBViDRrTlUbNfT0hiRknZfFFjIPuAWnaFkSTmpI9jKEExh wunI4NciOGRHKLH9VYWqlD06j5mzTzFysRxUVCHVk2M4v8Z8yYxu4jpkWpQVfvCJsD4l JBeruyAb8i9uqlDDoFy5hnmKB/aEe9/kBvRoaDk38WbOkkhsXlD2A51FpUcpD0WL+yD0 YeOqT3HsaokB4glPqvEvGq3n/CcfYyncVrZw1OpnJ+dRK6R6G7eWC83dz7EIcfXnNMal 1IfA== X-Gm-Message-State: APjAAAUVaK0l9ypVOC+x5accB2F9orRgdZ4S3cFec8yLVlGc8LF22Bx1 4vSsJNqUHHD8StLavYBRmU+HeBfF X-Google-Smtp-Source: APXvYqzyh65MPSvEbgK/SqHKtBapmD5ltw/UATkC6ZwWpHAq+VoBxjfVjJvSBN21WJhixZcn5TO06w== X-Received: by 2002:a1c:f610:: with SMTP id w16mr5337031wmc.37.1559112136097; Tue, 28 May 2019 23:42:16 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Wed, 29 May 2019 09:41:44 +0300 Message-Id: <20190529064148.19856-17-arilou@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190529064148.19856-1-arilou@gmail.com> References: <20190529064148.19856-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::341 Subject: [Qemu-devel] [PATCH v12 16/20] gdbstub: Implement v commands 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 Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e --- gdbstub.c | 170 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 110 insertions(+), 60 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 3fd1a1cddb..648191a3b0 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1818,6 +1818,106 @@ static void handle_step(GdbCmdContext *gdb_ctx, voi= d *user_ctx) gdb_continue(gdb_ctx->s); } =20 +static void handle_v_cont_query(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + put_packet(gdb_ctx->s, "vCont;c;C;s;S"); +} + +static void handle_v_cont(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + int res; + + if (!gdb_ctx->num_params) { + return; + } + + res =3D gdb_handle_vcont(gdb_ctx->s, gdb_ctx->params[0].data); + if ((res =3D=3D -EINVAL) || (res =3D=3D -ERANGE)) { + put_packet(gdb_ctx->s, "E22"); + } else if (res) { + put_packet(gdb_ctx->s, ""); + } +} + +static void handle_v_attach(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + GDBProcess *process; + CPUState *cpu; + char thread_id[16]; + + pstrcpy(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "E22"); + if (!gdb_ctx->num_params) { + goto cleanup; + } + + process =3D gdb_get_process(gdb_ctx->s, gdb_ctx->params[0].val_ul); + if (!process) { + goto cleanup; + } + + cpu =3D get_first_cpu_in_process(gdb_ctx->s, process); + if (!cpu) { + goto cleanup; + } + + process->attached =3D true; + gdb_ctx->s->g_cpu =3D cpu; + gdb_ctx->s->c_cpu =3D cpu; + + gdb_fmt_thread_id(gdb_ctx->s, cpu, thread_id, sizeof(thread_id)); + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "T%02xthread:%s;", + GDB_SIGNAL_TRAP, thread_id); +cleanup: + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + +static void handle_v_kill(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + /* Kill the target */ + put_packet(gdb_ctx->s, "OK"); + error_report("QEMU: Terminated via GDBstub"); + exit(0); +} + +static GdbCmdParseEntry gdb_v_commands_table[] =3D { + /* Order is important if has same prefix */ + { + .handler =3D handle_v_cont_query, + .cmd =3D "Cont?", + .cmd_startswith =3D 1 + }, + { + .handler =3D handle_v_cont, + .cmd =3D "Cont", + .cmd_startswith =3D 1, + .schema =3D "s0" + }, + { + .handler =3D handle_v_attach, + .cmd =3D "Attach;", + .cmd_startswith =3D 1, + .schema =3D "l0" + }, + { + .handler =3D handle_v_kill, + .cmd =3D "Kill;", + .cmd_startswith =3D 1 + }, +}; + +static void handle_v_commands(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (!gdb_ctx->num_params) { + return; + } + + if (process_string_cmd(gdb_ctx->s, NULL, gdb_ctx->params[0].data, + gdb_v_commands_table, + ARRAY_SIZE(gdb_v_commands_table))) { + put_packet(gdb_ctx->s, ""); + } +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1825,7 +1925,7 @@ static int gdb_handle_packet(GDBState *s, const char = *line_buf) CPUClass *cc; const char *p; uint32_t pid, tid; - int ch, type, res; + int ch, type; uint8_t mem_buf[MAX_PACKET_LENGTH]; char buf[sizeof(mem_buf) + 1 /* trailing NUL */]; char thread_id[16]; @@ -1874,66 +1974,16 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) } break; case 'v': - if (strncmp(p, "Cont", 4) =3D=3D 0) { - p +=3D 4; - if (*p =3D=3D '?') { - put_packet(s, "vCont;c;C;s;S"); - break; - } - - res =3D gdb_handle_vcont(s, p); - - if (res) { - if ((res =3D=3D -EINVAL) || (res =3D=3D -ERANGE)) { - put_packet(s, "E22"); - break; - } - goto unknown_command; - } - break; - } else if (strncmp(p, "Attach;", 7) =3D=3D 0) { - unsigned long pid; - - p +=3D 7; - - if (qemu_strtoul(p, &p, 16, &pid)) { - put_packet(s, "E22"); - break; - } - - process =3D gdb_get_process(s, pid); - - if (process =3D=3D NULL) { - put_packet(s, "E22"); - break; - } - - cpu =3D get_first_cpu_in_process(s, process); - - if (cpu =3D=3D NULL) { - /* Refuse to attach an empty process */ - put_packet(s, "E22"); - break; - } - - process->attached =3D true; - - s->g_cpu =3D cpu; - s->c_cpu =3D cpu; - - snprintf(buf, sizeof(buf), "T%02xthread:%s;", GDB_SIGNAL_TRAP, - gdb_fmt_thread_id(s, cpu, thread_id, sizeof(thread_id= ))); - - put_packet(s, buf); - break; - } else if (strncmp(p, "Kill;", 5) =3D=3D 0) { - /* Kill the target */ - put_packet(s, "OK"); - error_report("QEMU: Terminated via GDBstub"); - exit(0); - } else { - goto unknown_command; + { + static const GdbCmdParseEntry v_cmd_desc =3D { + .handler =3D handle_v_commands, + .cmd =3D "v", + .cmd_startswith =3D 1, + .schema =3D "s0" + }; + cmd_parser =3D &v_cmd_desc; } + break; case 'k': /* Kill the target */ error_report("QEMU: Terminated via GDBstub"); --=20 2.21.0 From nobody Fri May 3 14:33:07 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=1559114012; cv=none; d=zoho.com; s=zohoarc; b=QfbrUs/+lVtCWm1BXgS2XzOW8ei6UzIP1oqH5DT6PFmZ+q7MG3YBdH/QtuprvG3llEYYe3A694TY36B9zn9NmruWkixu2fm18D8Vsvd/9FEeGw4QZlKTV4O/wj97+NAHvaYKlROmpGWKCy+pOHf2C5t0MOherm4Jn+CokoroKIw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559114012; 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=zjVkQKD6OtkrgDxr3akS1/Hh3DJg3dXdiMQd6x4QPKo=; b=VT4QxSJT1bY3F/fCRGMwT6fh/eyoVgFj3q7iuIX8aYxZxsoRmx/Dwra5c/LTtrJ5N1K8EbDcl7l1Ra2T0JU5gWo3Rh9QlJnRIbVX7uhSRAIXydkebH3eWqmdTCuGtSEh2VeMP9fLK+5qGJEik0MLoOs12LdRjIAgGtX7csHtQG8= 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 1559114012287463.1758871491704; Wed, 29 May 2019 00:13:32 -0700 (PDT) Received: from localhost ([127.0.0.1]:48701 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsm6-0002G3-Ig for importer@patchew.org; Wed, 29 May 2019 03:13:26 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsI0-0001CP-Tb for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVsHy-0002gA-LO for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:20 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:39792) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVsHy-0002WR-Aw for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:18 -0400 Received: by mail-wm1-x341.google.com with SMTP id z23so682445wma.4 for ; Tue, 28 May 2019 23:42:18 -0700 (PDT) Received: from linux.local ([31.154.166.148]) by smtp.gmail.com with ESMTPSA id f2sm6831168wme.12.2019.05.28.23.42.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 23:42:16 -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=zjVkQKD6OtkrgDxr3akS1/Hh3DJg3dXdiMQd6x4QPKo=; b=QRIXz/ZYPOWv4GKEedHEQrTZ/z+d4o8fP/0I98FCjw1Xx/ecPMhRR6Cs8GJAJ8ESvM tg9m6Az4al/97DNzux3z3ayFpOeL6gkL8XRN5kISCa2RNA3YZUzbOMjgJXKwrNswTRDe nmMoYiK4/uFuFM02MNHugY5WmjDPokfin0SYyiBgGOjN+tVpq3DQCwEQxQBGYYnXC8jy 1OAZAgIL6ydE6IsnOoZLqMsIo3MQEB0aL2CtZfBHtATBHA02qe5UWMWnNAu9gos2u/Zf Uarl1BDhjMrVDzQzYIAfE5S1YrDyoX7BSbrD97LQrZSyb2fhq1gY97mKrnKOPkKK4OTd RRgg== 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=zjVkQKD6OtkrgDxr3akS1/Hh3DJg3dXdiMQd6x4QPKo=; b=NRH3ootuSEuiUDEkn5H68CD27f6+nxQwHazqrZGUWifWNpifpY08GdiCA/sy6W/MJ6 /N1gnIyBZM1p19qVeV48kt72M+426kplbuXoOKzjd8lM14hKHwkRl3v7kiMTh6apm829 +Vr/l7dUeapwg73bhV85kTOcLyaZ/pf2jEo4jqofSek4DC/NJw4++Box0LFBe5EK+R3E aZ1XJJpEooSanlC43YLYbelK7+BqZEQC3MZ3RHFwJokDlaS0Y8JtD5+kASQLd2FCQQrx mTbC6CR9qh8qSyIz+muH+a7kk9jf3gnKUY172l+9f4M9q30nhskQ0QaZxYdxToD7o4x6 ZOnA== X-Gm-Message-State: APjAAAXs731WItzfq/RJH79YWrpfBy4Ke0rh7dwp4L9P8bsClAzIKjsP 9cO+cu5rhfJumAac6ZmIvtIq7+9J X-Google-Smtp-Source: APXvYqy7La4D+rfo9ziZGZO60ayITXZyUbNZzEISvNPB+s71luQ+PVXpIWXpbJ3SHEtj1BGSiUguKA== X-Received: by 2002:a1c:f205:: with SMTP id s5mr1517507wmc.14.1559112137080; Tue, 28 May 2019 23:42:17 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Wed, 29 May 2019 09:41:45 +0300 Message-Id: <20190529064148.19856-18-arilou@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190529064148.19856-1-arilou@gmail.com> References: <20190529064148.19856-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::341 Subject: [Qemu-devel] [PATCH v12 17/20] gdbstub: Implement generic set/query (Q/q 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" The generic set/query packets contains implementation for varioius sub-commands which are required for GDB and also additional commands which are QEMU specific. To see which QEMU specific commands are available use the command gdb> maintenance packet qqemu.Supported Currently the only implemented QEMU specific command is the command that sets the single step behavior. gdb> maintenance packet qqemu.sstepbits Will display the MASK bits used to control the single stepping. gdb> maintenance packet qqemu.sstep Will display the current value of the mask used when single stepping. gdb> maintenance packet Qqemu.sstep:HEX_VALUE Will change the single step mask. Signed-off-by: Jon Doron Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e --- gdbstub.c | 559 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 373 insertions(+), 186 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 648191a3b0..80fe5b2d0c 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1130,14 +1130,6 @@ static GDBThreadIdKind read_thread_id(const char *bu= f, const char **end_buf, return GDB_ONE_THREAD; } =20 -static int is_query_packet(const char *p, const char *query, char separato= r) -{ - unsigned int query_len =3D strlen(query); - - return strncmp(p, query, query_len) =3D=3D 0 && - (p[query_len] =3D=3D '\0' || p[query_len] =3D=3D separator); -} - /** * gdb_handle_vcont - Parses and handles a vCont packet. * returns -ENOTSUP if a command is unsupported, -EINVAL or -ERANGE if the= re is @@ -1918,18 +1910,368 @@ static void handle_v_commands(GdbCmdContext *gdb_c= tx, void *user_ctx) } } =20 -static int gdb_handle_packet(GDBState *s, const char *line_buf) +static void handle_query_qemu_sstepbits(GdbCmdContext *gdb_ctx, void *user= _ctx) +{ + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), + "ENABLE=3D%x,NOIRQ=3D%x,NOTIMER=3D%x", SSTEP_ENABLE, + SSTEP_NOIRQ, SSTEP_NOTIMER); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + +static void handle_set_qemu_sstep(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (!gdb_ctx->num_params) { + return; + } + + sstep_flags =3D gdb_ctx->params[0].val_ul; + put_packet(gdb_ctx->s, "OK"); +} + +static void handle_query_qemu_sstep(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "0x%x", sstep_fla= gs); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + +static void handle_query_curr_tid(GdbCmdContext *gdb_ctx, void *user_ctx) { CPUState *cpu; GDBProcess *process; + char thread_id[16]; + + /* + * "Current thread" remains vague in the spec, so always return + * the first thread of the current process (gdb returns the + * first thread). + */ + process =3D gdb_get_cpu_process(gdb_ctx->s, gdb_ctx->s->g_cpu); + cpu =3D get_first_cpu_in_process(gdb_ctx->s, process); + gdb_fmt_thread_id(gdb_ctx->s, cpu, thread_id, sizeof(thread_id)); + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "QC%s", thread_id= ); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + +static void handle_query_threads(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + char thread_id[16]; + + if (!gdb_ctx->s->query_cpu) { + put_packet(gdb_ctx->s, "l"); + return; + } + + gdb_fmt_thread_id(gdb_ctx->s, gdb_ctx->s->query_cpu, thread_id, + sizeof(thread_id)); + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "m%s", thread_id); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); + gdb_ctx->s->query_cpu =3D + gdb_next_attached_cpu(gdb_ctx->s, gdb_ctx->s->query_cpu); +} + +static void handle_query_first_threads(GdbCmdContext *gdb_ctx, void *user_= ctx) +{ + gdb_ctx->s->query_cpu =3D gdb_first_attached_cpu(gdb_ctx->s); + handle_query_threads(gdb_ctx, user_ctx); +} + +static void handle_query_thread_extra(GdbCmdContext *gdb_ctx, void *user_c= tx) +{ + CPUState *cpu; + int len; + + if (!gdb_ctx->num_params || + gdb_ctx->params[0].thread_id.kind =3D=3D GDB_READ_THREAD_ERR) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + cpu =3D gdb_get_cpu(gdb_ctx->s, gdb_ctx->params[0].thread_id.pid, + gdb_ctx->params[0].thread_id.tid); + if (!cpu) { + return; + } + + cpu_synchronize_state(cpu); + + if (gdb_ctx->s->multiprocess && (gdb_ctx->s->process_num > 1)) { + /* Print the CPU model and name in multiprocess mode */ + ObjectClass *oc =3D object_get_class(OBJECT(cpu)); + const char *cpu_model =3D object_class_get_name(oc); + char *cpu_name =3D object_get_canonical_path_component(OBJECT(cpu)= ); + len =3D snprintf((char *)gdb_ctx->mem_buf, sizeof(gdb_ctx->str_buf= ) / 2, + "%s %s [%s]", cpu_model, cpu_name, + cpu->halted ? "halted " : "running"); + g_free(cpu_name); + } else { + /* memtohex() doubles the required space */ + len =3D snprintf((char *)gdb_ctx->mem_buf, sizeof(gdb_ctx->str_buf= ) / 2, + "CPU#%d [%s]", cpu->cpu_index, + cpu->halted ? "halted " : "running"); + } + trace_gdbstub_op_extra_info((char *)gdb_ctx->mem_buf); + memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, len); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + +#ifdef CONFIG_USER_ONLY +static void handle_query_offsets(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + TaskState *ts; + + ts =3D gdb_ctx->s->c_cpu->opaque; + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), + "Text=3D" TARGET_ABI_FMT_lx ";Data=3D" TARGET_ABI_FMT_lx + ";Bss=3D" TARGET_ABI_FMT_lx, + ts->info->code_offset, + ts->info->data_offset, + ts->info->data_offset); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} +#else +static void handle_query_rcmd(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + int len; + + if (!gdb_ctx->num_params) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + len =3D strlen(gdb_ctx->params[0].data); + if (len % 2) { + put_packet(gdb_ctx->s, "E01"); + return; + } + + len =3D len / 2; + hextomem(gdb_ctx->mem_buf, gdb_ctx->params[0].data, len); + gdb_ctx->mem_buf[len++] =3D 0; + qemu_chr_be_write(gdb_ctx->s->mon_chr, gdb_ctx->mem_buf, len); + put_packet(gdb_ctx->s, "OK"); + +} +#endif + +static void handle_query_supported(GdbCmdContext *gdb_ctx, void *user_ctx) +{ CPUClass *cc; + + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "PacketSize=3D%x", + MAX_PACKET_LENGTH); + cc =3D CPU_GET_CLASS(first_cpu); + if (cc->gdb_core_xml_file) { + pstrcat(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), + ";qXfer:features:read+"); + } + + if (gdb_ctx->num_params && + strstr(gdb_ctx->params[0].data, "multiprocess+")) { + gdb_ctx->s->multiprocess =3D true; + } + + pstrcat(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), ";multiprocess+"); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + +static void handle_query_xfer_features(GdbCmdContext *gdb_ctx, void *user_= ctx) +{ + GDBProcess *process; + CPUClass *cc; + unsigned long len, total_len, addr; + const char *xml; const char *p; - uint32_t pid, tid; - int ch, type; + + if (gdb_ctx->num_params < 3) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + process =3D gdb_get_cpu_process(gdb_ctx->s, gdb_ctx->s->g_cpu); + cc =3D CPU_GET_CLASS(gdb_ctx->s->g_cpu); + if (!cc->gdb_core_xml_file) { + put_packet(gdb_ctx->s, ""); + return; + } + + gdb_has_xml =3D true; + p =3D gdb_ctx->params[0].data; + xml =3D get_feature_xml(gdb_ctx->s, p, &p, process); + if (!xml) { + put_packet(gdb_ctx->s, "E00"); + return; + } + + addr =3D gdb_ctx->params[1].val_ul; + len =3D gdb_ctx->params[2].val_ul; + total_len =3D strlen(xml); + if (addr > total_len) { + put_packet(gdb_ctx->s, "E00"); + return; + } + + if (len > (MAX_PACKET_LENGTH - 5) / 2) { + len =3D (MAX_PACKET_LENGTH - 5) / 2; + } + + if (len < total_len - addr) { + gdb_ctx->str_buf[0] =3D 'm'; + len =3D memtox(gdb_ctx->str_buf + 1, xml + addr, len); + } else { + gdb_ctx->str_buf[0] =3D 'l'; + len =3D memtox(gdb_ctx->str_buf + 1, xml + addr, total_len - addr); + } + + put_packet_binary(gdb_ctx->s, gdb_ctx->str_buf, len + 1, true); +} + +static void handle_query_attached(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + put_packet(gdb_ctx->s, GDB_ATTACHED); +} + +static void handle_query_qemu_supported(GdbCmdContext *gdb_ctx, void *user= _ctx) +{ + put_packet(gdb_ctx->s, "sstepbits;sstep"); +} + +static GdbCmdParseEntry gdb_gen_query_set_common_table[] =3D { + /* Order is important if has same prefix */ + { + .handler =3D handle_query_qemu_sstepbits, + .cmd =3D "qemu.sstepbits", + }, + { + .handler =3D handle_query_qemu_sstep, + .cmd =3D "qemu.sstep", + }, + { + .handler =3D handle_set_qemu_sstep, + .cmd =3D "qemu.sstep=3D", + .cmd_startswith =3D 1, + .schema =3D "l0" + }, +}; + +static GdbCmdParseEntry gdb_gen_query_table[] =3D { + { + .handler =3D handle_query_curr_tid, + .cmd =3D "C", + }, + { + .handler =3D handle_query_threads, + .cmd =3D "sThreadInfo", + }, + { + .handler =3D handle_query_first_threads, + .cmd =3D "fThreadInfo", + }, + { + .handler =3D handle_query_thread_extra, + .cmd =3D "ThreadExtraInfo,", + .cmd_startswith =3D 1, + .schema =3D "t0" + }, +#ifdef CONFIG_USER_ONLY + { + .handler =3D handle_query_offsets, + .cmd =3D "Offsets", + }, +#else + { + .handler =3D handle_query_rcmd, + .cmd =3D "Rcmd,", + .cmd_startswith =3D 1, + .schema =3D "s0" + }, +#endif + { + .handler =3D handle_query_supported, + .cmd =3D "Supported:", + .cmd_startswith =3D 1, + .schema =3D "s0" + }, + { + .handler =3D handle_query_supported, + .cmd =3D "Supported", + .schema =3D "s0" + }, + { + .handler =3D handle_query_xfer_features, + .cmd =3D "Xfer:features:read:", + .cmd_startswith =3D 1, + .schema =3D "s:l,l0" + }, + { + .handler =3D handle_query_attached, + .cmd =3D "Attached:", + .cmd_startswith =3D 1 + }, + { + .handler =3D handle_query_attached, + .cmd =3D "Attached", + }, + { + .handler =3D handle_query_qemu_supported, + .cmd =3D "qemu.Supported", + }, +}; + +static GdbCmdParseEntry gdb_gen_set_table[] =3D { + /* Order is important if has same prefix */ + { + .handler =3D handle_set_qemu_sstep, + .cmd =3D "qemu.sstep:", + .cmd_startswith =3D 1, + .schema =3D "l0" + }, +}; + +static void handle_gen_query(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (!gdb_ctx->num_params) { + return; + } + + if (!process_string_cmd(gdb_ctx->s, NULL, gdb_ctx->params[0].data, + gdb_gen_query_set_common_table, + ARRAY_SIZE(gdb_gen_query_set_common_table))) { + return; + } + + if (process_string_cmd(gdb_ctx->s, NULL, gdb_ctx->params[0].data, + gdb_gen_query_table, + ARRAY_SIZE(gdb_gen_query_table))) { + put_packet(gdb_ctx->s, ""); + } +} + +static void handle_gen_set(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (!gdb_ctx->num_params) { + return; + } + + if (!process_string_cmd(gdb_ctx->s, NULL, gdb_ctx->params[0].data, + gdb_gen_query_set_common_table, + ARRAY_SIZE(gdb_gen_query_set_common_table))) { + return; + } + + if (process_string_cmd(gdb_ctx->s, NULL, gdb_ctx->params[0].data, + gdb_gen_set_table, + ARRAY_SIZE(gdb_gen_set_table))) { + put_packet(gdb_ctx->s, ""); + } +} + +static int gdb_handle_packet(GDBState *s, const char *line_buf) +{ + const char *p; + int ch; uint8_t mem_buf[MAX_PACKET_LENGTH]; char buf[sizeof(mem_buf) + 1 /* trailing NUL */]; char thread_id[16]; - target_ulong addr, len; const GdbCmdParseEntry *cmd_parser =3D NULL; =20 trace_gdbstub_io_command(line_buf); @@ -2131,183 +2473,28 @@ static int gdb_handle_packet(GDBState *s, const ch= ar *line_buf) } break; case 'q': - case 'Q': - /* parse any 'q' packets here */ - if (!strcmp(p,"qemu.sstepbits")) { - /* Query Breakpoint bit definitions */ - snprintf(buf, sizeof(buf), "ENABLE=3D%x,NOIRQ=3D%x,NOTIMER=3D%= x", - SSTEP_ENABLE, - SSTEP_NOIRQ, - SSTEP_NOTIMER); - put_packet(s, buf); - break; - } else if (is_query_packet(p, "qemu.sstep", '=3D')) { - /* Display or change the sstep_flags */ - p +=3D 10; - if (*p !=3D '=3D') { - /* Display current setting */ - snprintf(buf, sizeof(buf), "0x%x", sstep_flags); - put_packet(s, buf); - break; - } - p++; - type =3D strtoul(p, (char **)&p, 16); - sstep_flags =3D type; - put_packet(s, "OK"); - break; - } else if (strcmp(p,"C") =3D=3D 0) { - /* - * "Current thread" remains vague in the spec, so always return - * the first thread of the current process (gdb returns the - * first thread). - */ - cpu =3D get_first_cpu_in_process(s, gdb_get_cpu_process(s, s->= g_cpu)); - snprintf(buf, sizeof(buf), "QC%s", - gdb_fmt_thread_id(s, cpu, thread_id, sizeof(thread_id= ))); - put_packet(s, buf); - break; - } else if (strcmp(p,"fThreadInfo") =3D=3D 0) { - s->query_cpu =3D gdb_first_attached_cpu(s); - goto report_cpuinfo; - } else if (strcmp(p,"sThreadInfo") =3D=3D 0) { - report_cpuinfo: - if (s->query_cpu) { - snprintf(buf, sizeof(buf), "m%s", - gdb_fmt_thread_id(s, s->query_cpu, - thread_id, sizeof(thread_id))); - put_packet(s, buf); - s->query_cpu =3D gdb_next_attached_cpu(s, s->query_cpu); - } else - put_packet(s, "l"); - break; - } else if (strncmp(p,"ThreadExtraInfo,", 16) =3D=3D 0) { - if (read_thread_id(p + 16, &p, &pid, &tid) =3D=3D GDB_READ_THR= EAD_ERR) { - put_packet(s, "E22"); - break; - } - cpu =3D gdb_get_cpu(s, pid, tid); - if (cpu !=3D NULL) { - cpu_synchronize_state(cpu); - - if (s->multiprocess && (s->process_num > 1)) { - /* Print the CPU model and name in multiprocess mode */ - ObjectClass *oc =3D object_get_class(OBJECT(cpu)); - const char *cpu_model =3D object_class_get_name(oc); - char *cpu_name =3D - object_get_canonical_path_component(OBJECT(cpu)); - len =3D snprintf((char *)mem_buf, sizeof(buf) / 2, - "%s %s [%s]", cpu_model, cpu_name, - cpu->halted ? "halted " : "running"); - g_free(cpu_name); - } else { - /* memtohex() doubles the required space */ - len =3D snprintf((char *)mem_buf, sizeof(buf) / 2, - "CPU#%d [%s]", cpu->cpu_index, - cpu->halted ? "halted " : "running"); - } - trace_gdbstub_op_extra_info((char *)mem_buf); - memtohex(buf, mem_buf, len); - put_packet(s, buf); - } - break; - } -#ifdef CONFIG_USER_ONLY - else if (strcmp(p, "Offsets") =3D=3D 0) { - TaskState *ts =3D s->c_cpu->opaque; - - snprintf(buf, sizeof(buf), - "Text=3D" TARGET_ABI_FMT_lx ";Data=3D" TARGET_ABI_FMT= _lx - ";Bss=3D" TARGET_ABI_FMT_lx, - ts->info->code_offset, - ts->info->data_offset, - ts->info->data_offset); - put_packet(s, buf); - break; - } -#else /* !CONFIG_USER_ONLY */ - else if (strncmp(p, "Rcmd,", 5) =3D=3D 0) { - int len =3D strlen(p + 5); - - if ((len % 2) !=3D 0) { - put_packet(s, "E01"); - break; - } - len =3D len / 2; - hextomem(mem_buf, p + 5, len); - mem_buf[len++] =3D 0; - qemu_chr_be_write(s->mon_chr, mem_buf, len); - put_packet(s, "OK"); - break; - } -#endif /* !CONFIG_USER_ONLY */ - if (is_query_packet(p, "Supported", ':')) { - snprintf(buf, sizeof(buf), "PacketSize=3D%x", MAX_PACKET_LENGT= H); - cc =3D CPU_GET_CLASS(first_cpu); - if (cc->gdb_core_xml_file !=3D NULL) { - pstrcat(buf, sizeof(buf), ";qXfer:features:read+"); - } - - if (strstr(p, "multiprocess+")) { - s->multiprocess =3D true; - } - pstrcat(buf, sizeof(buf), ";multiprocess+"); - - put_packet(s, buf); - break; - } - if (strncmp(p, "Xfer:features:read:", 19) =3D=3D 0) { - const char *xml; - target_ulong total_len; - - process =3D gdb_get_cpu_process(s, s->g_cpu); - cc =3D CPU_GET_CLASS(s->g_cpu); - if (cc->gdb_core_xml_file =3D=3D NULL) { - goto unknown_command; - } - - gdb_has_xml =3D true; - p +=3D 19; - xml =3D get_feature_xml(s, p, &p, process); - if (!xml) { - snprintf(buf, sizeof(buf), "E00"); - put_packet(s, buf); - break; - } - - if (*p =3D=3D ':') - p++; - addr =3D strtoul(p, (char **)&p, 16); - if (*p =3D=3D ',') - p++; - len =3D strtoul(p, (char **)&p, 16); - - total_len =3D strlen(xml); - if (addr > total_len) { - snprintf(buf, sizeof(buf), "E00"); - put_packet(s, buf); - break; - } - if (len > (MAX_PACKET_LENGTH - 5) / 2) - len =3D (MAX_PACKET_LENGTH - 5) / 2; - if (len < total_len - addr) { - buf[0] =3D 'm'; - len =3D memtox(buf + 1, xml + addr, len); - } else { - buf[0] =3D 'l'; - len =3D memtox(buf + 1, xml + addr, total_len - addr); - } - put_packet_binary(s, buf, len + 1, true); - break; + { + static const GdbCmdParseEntry gen_query_cmd_desc =3D { + .handler =3D handle_gen_query, + .cmd =3D "q", + .cmd_startswith =3D 1, + .schema =3D "s0" + }; + cmd_parser =3D &gen_query_cmd_desc; } - if (is_query_packet(p, "Attached", ':')) { - put_packet(s, GDB_ATTACHED); - break; + break; + case 'Q': + { + static const GdbCmdParseEntry gen_set_cmd_desc =3D { + .handler =3D handle_gen_set, + .cmd =3D "Q", + .cmd_startswith =3D 1, + .schema =3D "s0" + }; + cmd_parser =3D &gen_set_cmd_desc; } - /* Unrecognised 'q' command. */ - goto unknown_command; - + break; default: - unknown_command: /* put empty packet */ buf[0] =3D '\0'; put_packet(s, buf); --=20 2.21.0 From nobody Fri May 3 14:33:07 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=1559112595; cv=none; d=zoho.com; s=zohoarc; b=iEsktv5OESAG47WnUsOiBypYqN18vi4Ju5U1QgJDYs5S3laXS2aS4yh1jxbcFkp2+s7b0XccIsc8U8Z9pUccmijGQZ+ilNY5xsgsJJHr+PgMa4pz3hGHLcMXK9hUn/5FvsOcp++pyeDX6vR69RVTv4z8/bXoV62OmzaU092qnoU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559112595; 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=sRCF1yk5BK3cTo+Mv+zzOIGiiu+VhlStwtESYiCGuI0=; b=ZlXs7wHu0k8GUlFqepcDb19Y6rxA44Yttgtz4iRO8NsczyDQnWxLZZ9QnvP9BlctRa3MmKHrAKtK6Z517RMQxfvnLA7+bZBBSxztip3FX29wH0FNP6Jqi3gCQTC84edfYc2u3vP69T8gm13M4LNKAAGtolryQvtaePO4lHSBhS4= 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 1559112595922735.1072504669265; Tue, 28 May 2019 23:49:55 -0700 (PDT) Received: from localhost ([127.0.0.1]:48308 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsPH-00079c-TS for importer@patchew.org; Wed, 29 May 2019 02:49:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsI0-0001Bg-8Q for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVsHz-0002nF-9P for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:20 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:38282) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVsHz-0002eT-2l for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:19 -0400 Received: by mail-wm1-x342.google.com with SMTP id t5so685582wmh.3 for ; Tue, 28 May 2019 23:42:19 -0700 (PDT) Received: from linux.local ([31.154.166.148]) by smtp.gmail.com with ESMTPSA id f2sm6831168wme.12.2019.05.28.23.42.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 23:42:17 -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=sRCF1yk5BK3cTo+Mv+zzOIGiiu+VhlStwtESYiCGuI0=; b=Q2NLtgtbV243T4I3RiSws3kw7L4AKA8hpmhJdDT8r6IxnDY+C6zTCNTq14Rq4qyObn pQ43d1qYPWKlqQ+GOw6r3XOzsGoWyuw0h1hQoXNE+Hp6hWBYEzeEzbKEQ2tcrYs4jG/j zUwsjEf1PsV7s34bNwS7px3EqDY6JzqNseqlwFFlAjr5kZIUAwtuzHTCaQILAaSCRWXA kyisifk6FoAggw+3B6RGGlVoMUhZFID3nnKoWInUl23qOiN036lq5DNEyfK1E47dMI/J CyfxWEs2Krw2H/7WO5L0vjeT60kYe4pvyN2F/hAz+H5qLfN5ZsWjA/g5dlY0233v+T2k a9dQ== 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=sRCF1yk5BK3cTo+Mv+zzOIGiiu+VhlStwtESYiCGuI0=; b=SpdOewVLxjzXRxO5Z+X2oLCzzxPDUa4WVCsacfbjgCXyPG1WGXW8NFIzWw96qD7TTP GI1ZL3V3c3r874vhxXOdGNnR2giC3eBkA3tfyXdsrDCE5q/3TxoLvNGIQR8GKg0LQmVM 1KmsASnG0IZYpyObt9koVSOucy0Q9RoDFUHtjJz2dlahbJk9kcVGXYVd3yFSI4pdSDrV y1TNTgZpPSb/LYe3AjidXCWX4QJu1fuI5nJ5dvxc6Wrwlh8YOWXXLB3ZnFuHlTKA0jaM /dcY1bR7lRxI5K8lQBzS/5PHL97ax3vWj5KyQivdbZKgOjaTwrqNl0G5hSbVD0PLdVYS GhsA== X-Gm-Message-State: APjAAAWi1e2osu7rajonS2G8mYZybOTmPVhVBNT1zkRSG/y0dCUrp2pA ZiuLIXzIzUSP7HG5R/37QR+YyNFE X-Google-Smtp-Source: APXvYqzTzNaNkNr5phj6Qs7JHzDMWEHak1V1APAXUy6OzREOIb1Wzlz3yNaW9lZv+vZQnNCZ3QR3AQ== X-Received: by 2002:a1c:4102:: with SMTP id o2mr5555053wma.91.1559112138047; Tue, 28 May 2019 23:42:18 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Wed, 29 May 2019 09:41:46 +0300 Message-Id: <20190529064148.19856-19-arilou@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190529064148.19856-1-arilou@gmail.com> References: <20190529064148.19856-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::342 Subject: [Qemu-devel] [PATCH v12 18/20] gdbstub: Implement target halted (? 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" Note: The user-mode thread-id has been correctly reported since bd88c780e6 Signed-off-by: Jon Doron Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e --- gdbstub.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 80fe5b2d0c..a474f2c755 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2265,13 +2265,29 @@ static void handle_gen_set(GdbCmdContext *gdb_ctx, = void *user_ctx) } } =20 +static void handle_target_halt(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + char thread_id[16]; + + gdb_fmt_thread_id(gdb_ctx->s, gdb_ctx->s->c_cpu, thread_id, + sizeof(thread_id)); + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "T%02xthread:%s;", + GDB_SIGNAL_TRAP, thread_id); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); + /* + * Remove all the breakpoints when this query is issued, + * because gdb is doing an initial connect and the state + * should be cleaned up. + */ + gdb_breakpoint_remove_all(); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { const char *p; int ch; uint8_t mem_buf[MAX_PACKET_LENGTH]; char buf[sizeof(mem_buf) + 1 /* trailing NUL */]; - char thread_id[16]; const GdbCmdParseEntry *cmd_parser =3D NULL; =20 trace_gdbstub_io_command(line_buf); @@ -2283,15 +2299,14 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) put_packet(s, "OK"); break; case '?': - /* TODO: Make this return the correct value for user-mode. */ - snprintf(buf, sizeof(buf), "T%02xthread:%s;", GDB_SIGNAL_TRAP, - gdb_fmt_thread_id(s, s->c_cpu, thread_id, sizeof(thread_i= d))); - put_packet(s, buf); - /* Remove all the breakpoints when this query is issued, - * because gdb is doing and initial connect and the state - * should be cleaned up. - */ - gdb_breakpoint_remove_all(); + { + static const GdbCmdParseEntry target_halted_cmd_desc =3D { + .handler =3D handle_target_halt, + .cmd =3D "?", + .cmd_startswith =3D 1 + }; + cmd_parser =3D &target_halted_cmd_desc; + } break; case 'c': { --=20 2.21.0 From nobody Fri May 3 14:33:07 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=1559112503; cv=none; d=zoho.com; s=zohoarc; b=IpvPKVKc3U6yXpmR2/D+9swU8dCyV9LiL6fQmVTcv/3G2BwLLH6CuHHOvWkOiFKtdyv/Uge+uo2zKDNJ8PCHr/jKyaitL62DwiM0EP2ixQ6zAKMseANRsQCMPqcYrBXsJrUteHJFGB7/wNzShEOWRsZenECJDe8hWvOz7Biw51o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559112503; h=Content-Type: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=GBKnE31GL9OCTYapbjGnGJ705BbyWe9rrqLVzVNFM+0=; b=PjeqvCi4GHwuEcUAM+nwChDapRxxhjCOqfB4AkULyXkzM5CULTAEXeuvOedKdepLgq4J/SgVdSLPuPxWx7GwxYFCa4WTw0SVbRDW7R2kbrbOm3IcKSnQclMjQwGOeylW7PneQ3Q5LUQs9Og5C0rOrP/dJNzoZ0P6mgjftQHy07g= 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 15591125033981017.3624373251306; Tue, 28 May 2019 23:48:23 -0700 (PDT) Received: from localhost ([127.0.0.1]:48288 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsNk-0005wJ-BO for importer@patchew.org; Wed, 29 May 2019 02:48:16 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45298) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsI1-0001Cr-8F for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVsI0-0002wo-CA for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:21 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:34481) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVsI0-0002qw-6M for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:20 -0400 Received: by mail-wr1-x442.google.com with SMTP id f8so821167wrt.1 for ; Tue, 28 May 2019 23:42:20 -0700 (PDT) Received: from linux.local ([31.154.166.148]) by smtp.gmail.com with ESMTPSA id f2sm6831168wme.12.2019.05.28.23.42.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 23:42:18 -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=GBKnE31GL9OCTYapbjGnGJ705BbyWe9rrqLVzVNFM+0=; b=GuOpxM6xf0dSzZQQV2+bQ8b3KXdOP6CkWQlX3l+ru5CZZwhW4i7i95KBkfrgFNpbCr 6uYiV7nAnlY+VSqkkso9OFTeQh/E0GLAtwo0qUoNk7tp9af1R75kxgcWXNSlajVsb6DL s664wS6hIVNgiMxZezp6WfSteubYnssbnLJgBKimiSn2eud1ngMh/JQsvyW1EpEHKj1I swUqcNChO0BnmvqwieOPEKXEVHMc4InJQARQvE///RhmzxLzLtI2ZoV8ePwbIyfQadmq 4Kc5chIXy9KL0iHoEy8KKj0kknyFOhL8due9u97NKrgVMLAl9cxYiCW301DZcZGrAeFF LZcw== 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=GBKnE31GL9OCTYapbjGnGJ705BbyWe9rrqLVzVNFM+0=; b=qokgp0k3w/W0RrVipfdotyef7h0Zh9zFGvcZvfx6V5L5vEYocNAm3f2g1+QDTt7xWl zBquL5dO2ZMmEkrybD8VYXkqg4duDGQFTgvrvum6TbPcfgoqpX3elnF8zF30EpLO12rH KgW3HjC8xMONjLIzww1jW04pec0Ov03DSroJwEb9hIjlAS+aOeHGl44dgcfhu+eje8ia yk9sAcOoHqESZ7Erb3lrpG/dWNr3m/TGjfrwGUZ0/0KzoTu4OudQoeCNvK4YGXObNwIT nUydlp+yYnPpjgI2weENoyVRnMIjDmbGxzG5UTHmOD0pcf58BmopjXONuVwJyzFmej1c HzvA== X-Gm-Message-State: APjAAAVducaZeVLmPw8dRA7CQfLypte5hFYMCFxsmrE6AsVovsphmgkx txAKJt9WqDNpDTrAh0nUXC53Jiwu X-Google-Smtp-Source: APXvYqzqCXN0PNUZrCwnAMu0/pDS7IsKeSOwfZNGI+BrxPjUaTzas29VPMrRbs8eWcp7rXuMnBEpyA== X-Received: by 2002:a5d:4581:: with SMTP id p1mr9538934wrq.228.1559112138991; Tue, 28 May 2019 23:42:18 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Wed, 29 May 2019 09:41:47 +0300 Message-Id: <20190529064148.19856-20-arilou@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190529064148.19856-1-arilou@gmail.com> References: <20190529064148.19856-1-arilou@gmail.com> 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::442 Subject: [Qemu-devel] [PATCH v12 19/20] gdbstub: Clear unused variables in gdb_handle_packet 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) Signed-off-by: Jon Doron Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e --- gdbstub.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index a474f2c755..a0ff0017f6 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2284,17 +2284,11 @@ static void handle_target_halt(GdbCmdContext *gdb_c= tx, void *user_ctx) =20 static int gdb_handle_packet(GDBState *s, const char *line_buf) { - const char *p; - int ch; - uint8_t mem_buf[MAX_PACKET_LENGTH]; - char buf[sizeof(mem_buf) + 1 /* trailing NUL */]; const GdbCmdParseEntry *cmd_parser =3D NULL; =20 trace_gdbstub_io_command(line_buf); =20 - p =3D line_buf; - ch =3D *p++; - switch(ch) { + switch (line_buf[0]) { case '!': put_packet(s, "OK"); break; @@ -2511,8 +2505,7 @@ static int gdb_handle_packet(GDBState *s, const char = *line_buf) break; default: /* put empty packet */ - buf[0] =3D '\0'; - put_packet(s, buf); + put_packet(s, ""); break; } =20 --=20 2.21.0 From nobody Fri May 3 14:33:07 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=1559114196; cv=none; d=zoho.com; s=zohoarc; b=jOSXJ3SOIlsXUM6Uh8yXdn9i8atRWWBV6dfGMvjLcQx/38ckm9+FD7fweQRTV5kMtQzuC50j4vXgcBOb39Yy2EWC2tCwYsHfFyfvSlbFwShWoGyZHs2/O70/9vu8oB8InFOA0HnTMq9y93l8GlhYiN/GINzqaXHPh7Nc0fhbdfk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559114196; 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=KoGMDinYQHodOIbKXwJ/At0fSWyzS9xNAHk1qWOol/Y=; b=Jjimr2S1/3ce/hQ1vB6GH7Mx5Aa1dohspWEjE6hIUEBpG3Be/BJB8HvF1ZKXxpFuwJRY/kgs81O3fF8b8CL3w0QOg30kntHXJScAMEc2rArNk3lmpVZIrnpWEzbQQV7UmW1wFSe3Gsrqcb4TQ7L6zSNhjEy1dEiF8drOElwkGtY= 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 1559114196514999.778744017012; Wed, 29 May 2019 00:16:36 -0700 (PDT) Received: from localhost ([127.0.0.1]:48763 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsp0-0004iM-A6 for importer@patchew.org; Wed, 29 May 2019 03:16:26 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45320) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsI2-0001EL-J3 for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVsI1-00037l-GJ for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:22 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:39793) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVsI1-0002zc-9H for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:21 -0400 Received: by mail-wm1-x342.google.com with SMTP id z23so682539wma.4 for ; Tue, 28 May 2019 23:42:21 -0700 (PDT) Received: from linux.local ([31.154.166.148]) by smtp.gmail.com with ESMTPSA id f2sm6831168wme.12.2019.05.28.23.42.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 23:42:19 -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=KoGMDinYQHodOIbKXwJ/At0fSWyzS9xNAHk1qWOol/Y=; b=Xm04gVdb6d47qroLNMeVkNI3fzQAhUYv3GAleOVr//GuhCF7RwVNwpfHzJtLo7+9op iNbqp+bdOLyinH/twZOq1A8Alv951lX0B2ROv0tWwKQ7I8Lsg5uK4e+X+1eZJC879Hi6 SWrSvEmuZN31YAlA4PiLKT4M3AGZWxsxeg5PsYxjMhpZ05HMQDbUNl35RBCAwUPihmad MGpGsdwds1EwXVMECwIs8v9rG0wXbFxDA9AXvX8dHT6zIHQTP4c/c7WdXCewlV3ASqnq IEN097XZK3usrdDgBCLFWMzx7HXPfJJpS+PJh2WjKuiwh0Byclk6EZ7b2YIEFewJCyhi rO0g== 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=KoGMDinYQHodOIbKXwJ/At0fSWyzS9xNAHk1qWOol/Y=; b=cIdeL68JLbGoAt3VTgALe+nXlzPcbuObAlPfBdX2CODGwovlR1nqNDsCUF00KjRy0u bsMxW9YQb+NNlwlm0Nwcf2kOnfqf307ojwZwZ34yziAmIaQDafT7Fx1DbJQh1Pp1XxiZ xSLJ2Xhx189WN0R7/OECz8fZl64sdhIShCy2aDQdsk5BctuHVq3QVeDoy3hyQgx3Ogom w5wrt74Ele32KTfe+0TrQqOOjIctbU6QcVNjBLmLOAWCo4IY3qKHOM96at+UmdwVp7qW fo8tbkg6QCuOBeCjNPkXHSESF8aDRxsv581pbf64C6PfsDXlBUGOqeRV/irLkzeCDk5o xvJw== X-Gm-Message-State: APjAAAXupC4DvyeGuYOst3k5tPf7b7BTD/gOybsB88xKdG/zPQmY/awb PFHT7ySGQoiBaJU+gFrM87+CJG5P X-Google-Smtp-Source: APXvYqwZvV0+sTiIKaaghXnlHiQ4iINiV5otlgQKdKCj6+lrmCvyeiJps+nRnEPSifXSBVCgmYJPPw== X-Received: by 2002:a1c:4484:: with SMTP id r126mr5794829wma.27.1559112140264; Tue, 28 May 2019 23:42:20 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Wed, 29 May 2019 09:41:48 +0300 Message-Id: <20190529064148.19856-21-arilou@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190529064148.19856-1-arilou@gmail.com> References: <20190529064148.19856-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::342 Subject: [Qemu-devel] [PATCH v12 20/20] gdbstub: Implement qemu physical memory mode 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" Add a new query/set which changes the memory GDB sees to physical memory only. gdb> maint packet qqemu.PhyMemMode will reply the current phy_mem_mode state (1 for enabled, 0 for disabled) gdb> maint packet Qqemu.PhyMemMode:1 Will make GDB read/write only to physical memory, set to 0 to disable Signed-off-by: Jon Doron Tested-by: Alex Benn=C3=A9e --- gdbstub.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index a0ff0017f6..d46e21bf70 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -46,11 +46,27 @@ #define GDB_ATTACHED "1" #endif =20 +#ifndef CONFIG_USER_ONLY +static int phy_memory_mode; +#endif + static inline int target_memory_rw_debug(CPUState *cpu, target_ulong addr, uint8_t *buf, int len, bool is_wr= ite) { - CPUClass *cc =3D CPU_GET_CLASS(cpu); + CPUClass *cc; =20 +#ifndef CONFIG_USER_ONLY + if (phy_memory_mode) { + if (is_write) { + cpu_physical_memory_write(addr, buf, len); + } else { + cpu_physical_memory_read(addr, buf, len); + } + return 0; + } +#endif + + cc =3D CPU_GET_CLASS(cpu); if (cc->memory_rw_debug) { return cc->memory_rw_debug(cpu, addr, buf, len, is_write); } @@ -2132,8 +2148,36 @@ static void handle_query_attached(GdbCmdContext *gdb= _ctx, void *user_ctx) =20 static void handle_query_qemu_supported(GdbCmdContext *gdb_ctx, void *user= _ctx) { - put_packet(gdb_ctx->s, "sstepbits;sstep"); + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "sstepbits;sstep"= ); +#ifndef CONFIG_USER_ONLY + pstrcat(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), ";PhyMemMode"); +#endif + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + +#ifndef CONFIG_USER_ONLY +static void handle_query_qemu_phy_mem_mode(GdbCmdContext *gdb_ctx, + void *user_ctx) +{ + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "%d", phy_memory_= mode); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + +static void handle_set_qemu_phy_mem_mode(GdbCmdContext *gdb_ctx, void *use= r_ctx) +{ + if (!gdb_ctx->num_params) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + if (!gdb_ctx->params[0].val_ul) { + phy_memory_mode =3D 0; + } else { + phy_memory_mode =3D 1; + } + put_packet(gdb_ctx->s, "OK"); } +#endif =20 static GdbCmdParseEntry gdb_gen_query_set_common_table[] =3D { /* Order is important if has same prefix */ @@ -2215,6 +2259,12 @@ static GdbCmdParseEntry gdb_gen_query_table[] =3D { .handler =3D handle_query_qemu_supported, .cmd =3D "qemu.Supported", }, +#ifndef CONFIG_USER_ONLY + { + .handler =3D handle_query_qemu_phy_mem_mode, + .cmd =3D "qemu.PhyMemMode", + }, +#endif }; =20 static GdbCmdParseEntry gdb_gen_set_table[] =3D { @@ -2225,6 +2275,14 @@ static GdbCmdParseEntry gdb_gen_set_table[] =3D { .cmd_startswith =3D 1, .schema =3D "l0" }, +#ifndef CONFIG_USER_ONLY + { + .handler =3D handle_set_qemu_phy_mem_mode, + .cmd =3D "qemu.PhyMemMode:", + .cmd_startswith =3D 1, + .schema =3D "l0" + }, +#endif }; =20 static void handle_gen_query(GdbCmdContext *gdb_ctx, void *user_ctx) --=20 2.21.0