From patchwork Thu May 2 08:15:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094049 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="PS9HWP/M"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vp5g6W7Jz9s4V for ; Thu, 2 May 2019 18:17:11 +1000 (AEST) Received: from localhost ([127.0.0.1]:47179 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6tv-000358-Kg for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:17:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42461) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6t1-000351-CM for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6sz-0007Eo-Le for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:11 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:42034) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6sz-00079X-FL for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:09 -0400 Received: by mail-wr1-x442.google.com with SMTP id l2so1983812wrb.9 for ; Thu, 02 May 2019 01:16: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=9gs1pjZcHlRiuvyF89Xf0dDUFOI/nZh6LcrIM/HDQRg=; b=PS9HWP/MIAjLGJXkZy0nraGanI83qmx++phe56i5PKbGKQ/Np2Cvscj+g3cJuoRKB4 N9w4nHBoTdBKsMBnv9XmYTDlpOGSyztKcvwd0a1l4QAGVImZ2okgwNV2BgUtQ3IvEceg fiXEWUQGf1ni1vw82FXNIo/RXNfX+Y1fYpNnDanolb6xqnlHWmHqYfnrVnfXr+G1jhWv fTsGKSqUdPVvjMQHnts9z7Uguh5jYGEV9r+6tulIm+Pq26XFCeEUwJff5ShoumfSCI5f jDrgt0Kf+f+mXiANGSJOTBpxeSyXdRRg2BsfdOQiMG7OgOco43eDbUMXqkzViFwcg0rp 5Ocg== 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=9gs1pjZcHlRiuvyF89Xf0dDUFOI/nZh6LcrIM/HDQRg=; b=e70Wsg7I1/CvDnsUk0Jc2CqA+c79VsqpKVgLPzYmzeRJMgjVhUjzJYcIpZL2w6QCBs lMn66dAFZClpw1A1nroK/4bPKuk42hEneOfAEVJr8EURfa8c08vGuPfqsLgaHgAjBI8Y YGbHdpMLaGQios1bfAkru6AZZDq8wEfancS3izlccQG1bq5ouKLoNrXJq1ahLToOrsRf IaeEYj5zlmf7WdQlVLbMLP4+JrKBSpkOkVJpQqXEm8Pu0RxOPRKKncu3qzMySpNr4QSH 4gLBlu/xf9uL+mkSGNH/ZERhBflmgvV1IgS356oi+FPnfFCZnT3VGeWS56fJ78ZOsLF/ bbyA== X-Gm-Message-State: APjAAAUf03bXnmS8OnVDsLeBZdv/EVjTAQLSD9tjFoKXPoxKuhNgc7NL T1g6KTraQRqAqha/e2w9HRB8ARoG X-Google-Smtp-Source: APXvYqyMliQOexKRZ0Rcdic0GRF1LnwZl8zGkbeAaF30CrIt8BHJtFqA19XrawNPEJrTAWXptTOGfQ== X-Received: by 2002:adf:eec8:: with SMTP id a8mr1733251wrp.64.1556784967273; Thu, 02 May 2019 01:16:07 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:06 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:28 +0300 Message-Id: <20190502081554.5521-2-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PATCH v9 01/27] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Jon Doron Reviewed-by: Alex Bennée --- gdbstub.c | 200 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index d54abd17cc..d5e0f3878a 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1268,6 +1268,206 @@ out: return res; } +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[] = ",;:="; + char curr_delimiters[2] = {0}; + const char *delimiters; + + if (delimiter == '?') { + delimiters = all_delimiters; + } else if (delimiter == '0') { + return strchr(param, '\0'); + } else if (delimiter == '.' && *param) { + return param + 1; + } else { + curr_delimiters[0] = delimiter; + delimiters = curr_delimiters; + } + + param += 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 = 0; + + if (!schema) { + return 0; + } + + curr_schema = schema; + curr_param = 0; + curr_data = 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 = 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 = cmd_next_param(curr_data, curr_schema[1]); + break; + case 's': + params[curr_param].data = curr_data; + curr_param++; + curr_data = cmd_next_param(curr_data, curr_schema[1]); + break; + case 'o': + params[curr_param].opcode = *(uint8_t *)curr_data; + curr_param++; + curr_data = cmd_next_param(curr_data, curr_schema[1]); + break; + case 't': + params[curr_param].thread_id.kind = + read_thread_id(curr_data, &curr_data, + ¶ms[curr_param].thread_id.pid, + ¶ms[curr_param].thread_id.tid); + curr_param++; + curr_data = cmd_next_param(curr_data, curr_schema[1]); + break; + case '?': + curr_data = cmd_next_param(curr_data, curr_schema[1]); + break; + default: + return -EINVAL; + } + curr_schema += 2; + } + + *num_params = 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 (",;:=\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; + union { + int flags; + struct { + int cmd_startswith:1; + }; + }; + 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 *data, + const GdbCmdParseEntry *cmds, int num_cmds) +{ + int i, schema_len, max_num_params = 0; + GdbCmdContext gdb_ctx; + + if (!cmds) { + return -1; + } + + for (i = 0; i < num_cmds; i++) { + const GdbCmdParseEntry *cmd = &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 = strlen(cmd->schema); + if (schema_len % 2) { + return -2; + } + + max_num_params = schema_len / 2; + } + + gdb_ctx.params = + (GdbCmdVariant *)alloca(sizeof(*gdb_ctx.params) * max_num_params); + 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 = s; + cmd->handler(&gdb_ctx, user_ctx); + return 0; + } + + return -1; +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; From patchwork Thu May 2 08:15:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094051 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="TPDSUDsx"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vp5n4J1Nz9s4V for ; Thu, 2 May 2019 18:17:17 +1000 (AEST) Received: from localhost ([127.0.0.1]:47183 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6u3-00036p-GA for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:17:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6t3-000357-BH for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6t1-0007GI-Ge for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:13 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:35254) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6t1-0007Ea-Aj for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:11 -0400 Received: by mail-wr1-x444.google.com with SMTP id f7so2031951wrs.2 for ; Thu, 02 May 2019 01:16: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=o9g7yNsrGp0cm0nQks6oxRIXlO2CyhOpcYCjoRIegtQ=; b=TPDSUDsx1b4/+tuFMGwcj6Si+1Z6tZT+ncA3pFeq1vN/C1foc1FPpS2YqSvY5Xpwlp /Vj+/wcn2JjxQQJFyDWCsUky21s5Yv+d1yuCovGj8SUlZJPZyYMzDkYE16qRnkqT5v49 fI8Y4eBMxXJtFpJuPBQhwrKeE7caF/h8sIcF34gZHb9QUUhp0HPQl4hyVdrrIkjbhhqs eZypk0BpoHpCanCwE2DgEuWaocZ3SbfxZ8acKAf2F/f7B41cV2gWNx5Mdio6GwZxE/MD OnzNytekIBC8SOasfglXVH9QUZjVLoYxeTBJYji2Kl0EIfcGccXY1MSBnr2qY95Hwmw4 kQEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o9g7yNsrGp0cm0nQks6oxRIXlO2CyhOpcYCjoRIegtQ=; b=JMpcPmmG72kUlCK5xSFSoGj1XvoMFsYLPXT/srME/2kyGV/hWQFtO0U1pkD8RbS+Wk Hl919DJlaHXJk/9RKNsWfNIh7GDZYnSMpcH4+NrXmaDJarKgYtyy18g+j+WBSZ7HZ2w7 V5Bk8KPuZORK0/18SCJdX3DGJU2u9XK8Dmm9+oCtx36T0Nl3Tso9YWoWpOm+4UQlYGpo q6m4Wh/oIJUIlCZXDrTes5qjhv6l84iJ2GjNYMeNyzFBrnoNg+eFj0v1A0q5POkiF9kG EO5lhypdH03jeydTPRm5jdA8mni+6OdMmDxkrVdr5VOzRl438K8MrFjyY8D5A7ff022k x5Qg== X-Gm-Message-State: APjAAAWZZwVRCltBM7IX5GDkKMhGBgEMfBIveFVeOgSFo5s/GjeCeM8M aVxrnwQ3iQfIfp5FH04kwnfFaI7H X-Google-Smtp-Source: APXvYqxLj4B/HnnAt92t56MYBnCCBwZTx5uItuGBIn/x8Xb/LT5W1EFFfFu/O7nJkZ8+1VV59Yynzg== X-Received: by 2002:adf:eb03:: with SMTP id s3mr876801wrn.170.1556784968761; Thu, 02 May 2019 01:16:08 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:08 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:29 +0300 Message-Id: <20190502081554.5521-3-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PATCH v9 02/27] gdbstub: Implement deatch (D pkt) with new infra X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, Jon Doron Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Jon Doron --- gdbstub.c | 90 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 50 insertions(+), 40 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index d5e0f3878a..621d689868 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1418,11 +1418,6 @@ static inline int startswith(const char *string, 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 *data, const GdbCmdParseEntry *cmds, int num_cmds) { @@ -1468,6 +1463,41 @@ static int process_string_cmd(GDBState *s, void *user_ctx, const char *data, return -1; } +static void handle_detach(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + GDBProcess *process; + GDBState *s = gdb_ctx->s; + uint32_t pid = 1; + + if (s->multiprocess) { + if (!gdb_ctx->num_params) { + put_packet(s, "E22"); + return; + } + + pid = gdb_ctx->params[0].val_ul; + } + + process = gdb_get_process(s, pid); + gdb_process_breakpoint_remove_all(s, process); + process->attached = false; + + if (pid == gdb_get_cpu_pid(s, s->c_cpu)) { + s->c_cpu = gdb_first_attached_cpu(s); + } + + if (pid == gdb_get_cpu_pid(s, s->g_cpu)) { + s->g_cpu = gdb_first_attached_cpu(s); + } + + if (!s->c_cpu) { + /* No more process attached */ + gdb_syscall_mode = GDB_SYS_DISABLED; + gdb_continue(s); + } + put_packet(s, "OK"); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1482,6 +1512,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) uint8_t *registers; target_ulong addr, len; GDBThreadIdKind thread_kind; + const GdbCmdParseEntry *cmd_parser = NULL; trace_gdbstub_io_command(line_buf); @@ -1582,42 +1613,15 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) error_report("QEMU: Terminated via GDBstub"); exit(0); case 'D': - /* Detach packet */ - pid = 1; - - if (s->multiprocess) { - unsigned long lpid; - if (*p != ';') { - put_packet(s, "E22"); - break; - } - - if (qemu_strtoul(p + 1, &p, 16, &lpid)) { - put_packet(s, "E22"); - break; - } - - pid = lpid; - } - - process = gdb_get_process(s, pid); - gdb_process_breakpoint_remove_all(s, process); - process->attached = false; - - if (pid == gdb_get_cpu_pid(s, s->c_cpu)) { - s->c_cpu = gdb_first_attached_cpu(s); - } - - if (pid == gdb_get_cpu_pid(s, s->g_cpu)) { - s->g_cpu = gdb_first_attached_cpu(s); - } - - if (s->c_cpu == NULL) { - /* No more process attached */ - gdb_syscall_mode = GDB_SYS_DISABLED; - gdb_continue(s); + { + static const GdbCmdParseEntry detach_cmd_desc = { + .handler = handle_detach, + .cmd = "D", + .cmd_startswith = 1, + .schema = "?.l0" + }; + cmd_parser = &detach_cmd_desc; } - put_packet(s, "OK"); break; case 's': if (*p != '\0') { @@ -1990,6 +1994,12 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) put_packet(s, buf); break; } + + if (cmd_parser && + process_string_cmd(s, NULL, line_buf, cmd_parser, 1)) { + put_packet(s, ""); + } + return RS_IDLE; } From patchwork Thu May 2 08:15:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094052 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="fgrUIQ2j"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vp5w4KG5z9s4V for ; Thu, 2 May 2019 18:17:24 +1000 (AEST) Received: from localhost ([127.0.0.1]:47185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6uA-0003BB-Gz for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:17:22 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42513) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6t9-00039D-PZ for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6t3-0007Id-Sg for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:17 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:33065) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6t3-0007GP-IR for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:13 -0400 Received: by mail-wr1-x442.google.com with SMTP id e28so2043589wra.0 for ; Thu, 02 May 2019 01:16: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=lYm7IhGBrxn52sVAeIC90HrrQ0q55SD5y2VdGObDHgY=; b=fgrUIQ2jOXqt4FTBaAvZCMwg+DNK+T8ejvDceyXZd0+G1n7AgUJfeWmcTYaACpkNny KIW7B6Kuk7meD7/QbdRrzc0KzKe/bllc/s8O60ZVA4D740MnYUrikWQAU99KYm6fDzCd XmaQm+KaFYi/3KR8S0F5op7czSND0Ge2ic1ZmHBq5lnnP1QNEYpGLATyQ0tfm/XWrzf3 ERUm2FYb8JUPiYEFljYDO/zH/bVo8mXg6WhuLL9CDreU6X0c5J5gXAUE8dDLd2Hmbw8R HBErZgrzm7ppCMvulGsDC5EdJXMNKsil6y09AqM/LkJWR6xPw/aGunfQPxSpJlryWLJ3 8+Xg== 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=lYm7IhGBrxn52sVAeIC90HrrQ0q55SD5y2VdGObDHgY=; b=IuHICTPES2KicIaaKAS0QfpSkKTNTOLDzTnU6EYZiG7E9FbrX51UfiHp1E6IFC53W5 gWEXVek+0e1EgeSdSqquovCHMH4hM7iP/RGydXWHen7uPFuuvPUKIj9LQLNamtvhF0Mw 5PbWgRV5Ri9o/hzDyllZwtgB8Uo5WjHyWN81tLCHM5HehazzUhaLKWvnLSed9C8hHt1Q cgQMvEQMye+ApSHEqLjzJoahldI1HYShtLAGttfxwgzY6NXIaFORT0N/NhkNJG14gLg6 Ioge3n9nirzNfkHrtT4W+DRdYLTTNcrG6qhYlkdn75MG1B9wyu0PPOANAyAfaujAYUcU NXxg== X-Gm-Message-State: APjAAAXyhLGz3lByL7U4j18zDUdsuB4c3l/4sJKLbm0W7ngSD7qxkiK+ iUdc1YimKy34hYRlE+TFRCtvMqzj X-Google-Smtp-Source: APXvYqzxHxKTutINtIGOIIj8ytrOEUi/C04Ck1pjkVEtm5U8xlENACvdYP7LnSMuqytVTBy1k2OzpA== X-Received: by 2002:a5d:4acc:: with SMTP id y12mr1754378wrs.234.1556784970894; Thu, 02 May 2019 01:16:10 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:10 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:30 +0300 Message-Id: <20190502081554.5521-4-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PATCH v9 03/27] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Jon Doron Reviewed-by: Alex Bennée Reviewed-by: Alex Bennée --- gdbstub.c | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 621d689868..c47ef7dd9c 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1498,6 +1498,30 @@ static void handle_detach(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(s, "OK"); } +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 == GDB_READ_THREAD_ERR) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + cpu = 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; @@ -1798,17 +1822,14 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } break; case 'T': - thread_kind = read_thread_id(p, &p, &pid, &tid); - if (thread_kind == GDB_READ_THREAD_ERR) { - put_packet(s, "E22"); - break; - } - cpu = gdb_get_cpu(s, pid, tid); - - if (cpu != NULL) { - put_packet(s, "OK"); - } else { - put_packet(s, "E22"); + { + static const GdbCmdParseEntry thread_alive_cmd_desc = { + .handler = handle_thread_alive, + .cmd = "T", + .cmd_startswith = 1, + .schema = "t0" + }; + cmd_parser = &thread_alive_cmd_desc; } break; case 'q': From patchwork Thu May 2 08:15:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094055 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="uUAX/zF+"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vp9N2W6Bz9sBr for ; Thu, 2 May 2019 18:20:24 +1000 (AEST) Received: from localhost ([127.0.0.1]:47204 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6x2-0005XV-5W for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:20:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42553) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6tJ-0003Cv-3Y for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6tG-0007Tk-A4 for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:28 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:43572) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6t7-0007JB-VU for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:19 -0400 Received: by mail-wr1-x443.google.com with SMTP id a12so1977899wrq.10 for ; Thu, 02 May 2019 01:16: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=9IF4rsqYBB5CcGAeM/Zis8CV+HM8l1BP4iU1qHaXB5E=; b=uUAX/zF+Z8eOgAIkBfhItK/EJAQjSlCS5CaZUuB5Hsgq1PYx+izpxQv2Vqxqm0oFop uOG2HsAykPzXSow2Ak/HEvveYdkB4mLQx3XnRQ9w/Yt3ldcqyhSREHrS9KKjKHsINZIT OnYlglovt4LH6bP6yDasAxnSAbUtmPw6KRLS/+5zQkngYvOeGY/ObdU66JtQU76Q0j0m kW+qhBrKofeqw0p4rurA3fO+YP0lrDjQmlpBfM7m3wzfDFiaax6Aznyk4BMKEHmTwgVS QLC5Iwkk0C8KbGv9hJ/vBbtQ2DxyrSeoaFpBLS3ytkKIoKK25NLjR6ElBhHax0iWwzzw 5AVQ== 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=9IF4rsqYBB5CcGAeM/Zis8CV+HM8l1BP4iU1qHaXB5E=; b=LCE6wRGgGLrWhs9MApPF5auz6NsONs9y3uwFJbscETLKBD+SW2sSFeVc5k8NaYdFe/ wvs/h2lQWcET5Jkx5fWA7GYKz9DE3WyXIdHDUxhWcSK5HRZ0mqq119fPoVHfr+EM3Mxm TNBeZCdFwhcMu5jUOBu0QSC3ovYXhRp9AzdTfI6R/wWU84E+sWEiZD4VACAMwsghSQlj CBU3I3XY+qlwe0Py9KgqXQtE1dnAt3eSao2aoyWGizOg93AJtoVvmkeCq5IQEOoD3XJT qz6ZFXqXBlvNfk7NX8TSz0wLsYuir9xsbCirxyqNIncAQu1ihhbqpui+Do7ykhFtJiqr R0/Q== X-Gm-Message-State: APjAAAVG/DH5A2xg1dOci/0rYSbZUUTWir7V3ytbqtEfzVBpvZcjsIGU TIelKt8pEi9eqK/+6bJw2kfGgLsz X-Google-Smtp-Source: APXvYqxWnLllbSFESY6Sgm7zYgl+y/uijNyIowzI9TF/6CK54U/JoIQr2c55BdFYTLdx5Nm7lHWlXw== X-Received: by 2002:a5d:54cd:: with SMTP id x13mr1709106wrv.121.1556784974069; Thu, 02 May 2019 01:16:14 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:13 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:31 +0300 Message-Id: <20190502081554.5521-5-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PATCH v9 04/27] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Jon Doron Reviewed-by: Alex Bennée --- gdbstub.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index c47ef7dd9c..89f1ab6524 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1522,6 +1522,16 @@ static void handle_thread_alive(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(gdb_ctx->s, "OK"); } +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 = 0; + gdb_continue(gdb_ctx->s); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1558,13 +1568,16 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) gdb_breakpoint_remove_all(); break; case 'c': - if (*p != '\0') { - addr = strtoull(p, (char **)&p, 16); - gdb_set_cpu_pc(s, addr); + { + static const GdbCmdParseEntry continue_cmd_desc = { + .handler = handle_continue, + .cmd = "c", + .cmd_startswith = 1, + .schema = "L0" + }; + cmd_parser = &continue_cmd_desc; } - s->signal = 0; - gdb_continue(s); - return RS_IDLE; + break; case 'C': s->signal = gdb_signal_to_target (strtoul(p, (char **)&p, 16)); if (s->signal == -1) From patchwork Thu May 2 08:15:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094061 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="j8/EocMQ"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vp9W40sjz9sBV for ; Thu, 2 May 2019 18:20:31 +1000 (AEST) Received: from localhost ([127.0.0.1]:47210 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6xA-0005eR-VP for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:20:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6th-0003YB-0B for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6te-00082k-BW for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:52 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:36592) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6ta-0007Ju-8E for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:46 -0400 Received: by mail-wr1-x441.google.com with SMTP id o4so2022997wra.3 for ; Thu, 02 May 2019 01:16: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=x82aHJMzl8f+PCXWhu2ZX9N8tzch1kuJG+XquT6URF0=; b=j8/EocMQSN+YsSPCgf0Jxc2age1N+MN2UfPqQJJQdcZGcYi+kGlSXtekV0qyeps2WT 6ZvRLWBjN7oEsLHKZBlbNqYISG4rqkH5a9mOfvmeSC5RCV+UyeXAfmOdf/0Xvyxf3WoA pWK0eDDukQMVIE/yaJKDDrdzBKKjSugkH6epUi0hITfAQIv5V/9shaqKaQITI4ixOzbd 7DLlD2/6z5fo3D/B9+wX7bFjHsMVdy2Sz/2VEXH9hwCl3GSa7CyemLQbxuIjSo3bPOFu OOnylwm8aAw6LgcoAcWoC1vGP3GdUKLj7QXv2ci2zu6iI8gSYP0YTcIeqSXnLMU7FqQB eKdw== 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=x82aHJMzl8f+PCXWhu2ZX9N8tzch1kuJG+XquT6URF0=; b=R5GcpqAqAlkE3ci8iAw7j0Qi4eQ9DNouL92doEMEhaSRhMVrbGlgZAFxRoY6SRcXRk TDSFgyZS7oVlzxW71rbBu70V/LOL7yJLx+qU5S0+CNe23FF7x/Ec0fYOmvDac4GTP9Mc O9xAOM+ubougHWsuZL52JWFzfa4pCo7ygeH4gaYh1R3tNAQ08P/vBXipUhBn6ZxnuEZN 3KVMjFAyZTKyER0TodwIvC99dMOuFKbMaMUdh+OQK95MCSFUR40IctimbAY08nyKtnB1 CuyMpYUDEkpWq4mbO3XnrgLtMZTe97GdPo3SZuxDQ5eLh8SNKSI0KKBFiUf7YqcjAypX cC7Q== X-Gm-Message-State: APjAAAUYxYFtBQ/ndwpiOSqXmA5rJhliz2BWo6+GRL31zoe3ZF0KBCH0 m/znMPYxteQN6kM7m/KI9vjssU9F X-Google-Smtp-Source: APXvYqxRS7sDRJ4yxgPWS2XIChyKLpTupJZtmYzffTXMyBjnrVlXZjHz2IMHhKPrVTYmaP4cwfLM9w== X-Received: by 2002:adf:ce0b:: with SMTP id p11mr1616830wrn.196.1556784975880; Thu, 02 May 2019 01:16:15 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:15 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:32 +0300 Message-Id: <20190502081554.5521-6-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PATCH v9 05/27] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Jon Doron Reviewed-by: Alex Bennée --- gdbstub.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 89f1ab6524..469aaeb875 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1532,6 +1532,21 @@ static void handle_continue(GdbCmdContext *gdb_ctx, void *user_ctx) gdb_continue(gdb_ctx->s); } +static void handle_cont_with_sig(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + unsigned long signal = 0; + + if (gdb_ctx->num_params) { + signal = gdb_ctx->params[0].val_ul; + } + + gdb_ctx->s->signal = gdb_signal_to_target(signal); + if (gdb_ctx->s->signal == -1) { + gdb_ctx->s->signal = 0; + } + gdb_continue(gdb_ctx->s); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1579,11 +1594,16 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } break; case 'C': - s->signal = gdb_signal_to_target (strtoul(p, (char **)&p, 16)); - if (s->signal == -1) - s->signal = 0; - gdb_continue(s); - return RS_IDLE; + { + static const GdbCmdParseEntry cont_with_sig_cmd_desc = { + .handler = handle_cont_with_sig, + .cmd = "C", + .cmd_startswith = 1, + .schema = "l0" + }; + cmd_parser = &cont_with_sig_cmd_desc; + } + break; case 'v': if (strncmp(p, "Cont", 4) == 0) { p += 4; From patchwork Thu May 2 08:15:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094074 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JIVes0a4"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vpM13SJrz9s9T for ; Thu, 2 May 2019 18:28:44 +1000 (AEST) Received: from localhost ([127.0.0.1]:47347 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM756-0005mq-Mx for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:28:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42630) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6ta-0003RX-A8 for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6tY-0007pQ-Aw for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:46 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:39540) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6tU-0007L5-Mo for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:42 -0400 Received: by mail-wr1-x443.google.com with SMTP id a9so1997324wrp.6 for ; Thu, 02 May 2019 01:16: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=8aM/3zkgxng0ie4nC212YmQwcdv5GpIX/biWiirdyy8=; b=JIVes0a4eaIRpR/FW3T7tTrn8D43Zz3zNpQxvvTduLo/E/oBuVY9gRFdNhTTn6AkUt X1R/Cnp0we9y3q1RF4H9GdrbV89LAO8m6LCqaWVy3wuWZoopgyKFZW3ZvUL/su0XO/J3 0pHaOcUzyqP9q0P/B+L0DOaxOc8nqMJkxOt9BElm1e74Q9WHGyv8Jx6tLVZkLX+/0RuR CY5TFnAgO699vO1GVFQ2hvMXYDRnKnsFRd9/i/3F4O+VV48cZ1EXLRzpfDb0I2QiMLx9 k9MWlEP0RLcb6EcFUy0juZZEEcPAzOAvdNcRGpP+TZftN/VzDZPGD1L9Ob+eLpFF6Pb0 n9Kg== 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=8aM/3zkgxng0ie4nC212YmQwcdv5GpIX/biWiirdyy8=; b=AEkcGCSayr8UMOylLh4Y7rhD/5Oz5Ehp7mCNmU2qLtjxFrZF9w/9+okn3GcuxyRWNw gRLwUm7pi+Q9XuP6KNpLlUR/94JdJiPseMjxs9FQBsgu/G4IHforXVWYURQUMzJt3olu 3qrQkmgVJFmhsOZqf2CdaXzJRht3ETs1vxiHgXxg9uDZBlU8L038XMZxjvI2WHGj7VGA UjvViOZDmQrromg27hPC+cgr/MoCVjN5CLPsjJaYjaDha3CCrrsQjPjtBQgtoqCiY2IB uExKvndUIHk+dFkqBGS/agsbpz1fCHU8/I5spCT2HOp3q3w/6S/RFvJB5Mm5nZO3lyL0 gkww== X-Gm-Message-State: APjAAAWPtowyVHg0vj/ed07FfaddtKg9v7agtvKaVsIuGzoxRKE8v+b/ dyTftuWtimaip9KbhBZ5YyrJuuEA X-Google-Smtp-Source: APXvYqx4r1R7Pr1Cre3yy7aCW+yoK1TUeJeOypws1VRJYjMukUtpzpI66oEn28XSHiuQZh1ubbUdyg== X-Received: by 2002:adf:eec8:: with SMTP id a8mr1733927wrp.64.1556784977985; Thu, 02 May 2019 01:16:17 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:17 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:33 +0300 Message-Id: <20190502081554.5521-7-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PATCH v9 06/27] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Jon Doron Reviewed-by: Alex Bennée --- gdbstub.c | 79 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 30 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 469aaeb875..21cdaf4678 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1547,6 +1547,47 @@ static void handle_cont_with_sig(GdbCmdContext *gdb_ctx, void *user_ctx) gdb_continue(gdb_ctx->s); } +static void handle_set_thread(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + CPUState *cpu; + + if (gdb_ctx->num_params < 2) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + if (gdb_ctx->params[1].thread_id.kind == GDB_READ_THREAD_ERR) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + if (gdb_ctx->params[1].thread_id.kind != GDB_ONE_THREAD) { + put_packet(gdb_ctx->s, "OK"); + return; + } + + cpu = 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; + } + + switch (gdb_ctx->params[0].opcode) { + case 'c': + gdb_ctx->s->c_cpu = cpu; + put_packet(gdb_ctx->s, "OK"); + break; + case 'g': + gdb_ctx->s->g_cpu = 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; @@ -1560,7 +1601,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 = NULL; trace_gdbstub_io_command(line_buf); @@ -1823,35 +1863,14 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) put_packet(s, "E22"); break; case 'H': - type = *p++; - - thread_kind = read_thread_id(p, &p, &pid, &tid); - if (thread_kind == GDB_READ_THREAD_ERR) { - put_packet(s, "E22"); - break; - } - - if (thread_kind != GDB_ONE_THREAD) { - put_packet(s, "OK"); - break; - } - cpu = gdb_get_cpu(s, pid, tid); - if (cpu == NULL) { - put_packet(s, "E22"); - break; - } - switch (type) { - case 'c': - s->c_cpu = cpu; - put_packet(s, "OK"); - break; - case 'g': - s->g_cpu = cpu; - put_packet(s, "OK"); - break; - default: - put_packet(s, "E22"); - break; + { + static const GdbCmdParseEntry set_thread_cmd_desc = { + .handler = handle_set_thread, + .cmd = "H", + .cmd_startswith = 1, + .schema = "o.t0" + }; + cmd_parser = &set_thread_cmd_desc; } break; case 'T': From patchwork Thu May 2 08:15:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094065 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="lt1UjKI0"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vpDk5sFyz9sBV for ; Thu, 2 May 2019 18:23:18 +1000 (AEST) Received: from localhost ([127.0.0.1]:47260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6zs-0008C3-6d for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:23:16 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6te-0003Ux-AX for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6ta-0007zA-CA for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:48 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:55513) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6tY-0007Lr-Dj for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:46 -0400 Received: by mail-wm1-x344.google.com with SMTP id y2so1154116wmi.5 for ; Thu, 02 May 2019 01:16:20 -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=y+n9UknESyjS5ywhVhGmu6RRpXVVQXSmReCo/GVxG50=; b=lt1UjKI06APntNZRaAWb7B1QGAwHDHvMiZXPszIVTaUrA55sHZQHRc/6AROAXrWwhf lzoANLTD+RHndEhLVLrICx6CojBmzMTu18Pb/lS9cOTsgQL3KLQ2EnTCaK5s//l2maMS P3RcNmgAKBN8V0KbITx9GF4IFq8EAWeMNKhaf3QgKHXTyBTvV1re1YKOwXQh7lMa4TM5 CG1T20XU5G/p2nkfNq24s3i4B7A0RHj+UDa3iZYyFpQ9oxwTSmJN60q/3BrQPzPY9M7I ZrR5Z9IlCf/cwBsyDDJ1+Fi0n2QEpN2B8APn5HXOEkCQHI6SlAD++bskfiC9/T1pKuYN stVA== 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=y+n9UknESyjS5ywhVhGmu6RRpXVVQXSmReCo/GVxG50=; b=J53vTyOLsnzRB7qWPbHosTEpFax5zPU17uixG9Fa6POWYC+x98rWrFoiAiuvQOOEc5 kDuANMLm3Q5xOJojXXaT7vLBpkplYHvd7xwWrLzRuyJDPQWr9XkYfpE8VVLas5V+FUtj V4GxhVpXbz8GjXA45j8ENDjwYbS3/ZSOsTduZaLj8SOLgDSSHBIWaHtuKt7C3HHy2HAU naLjlaSllwDciwmv9cOg+3/iz1B7uBD2tK+LFKn1glZaJiCvJIDXhiT+SeSAzuKVznyY AFBni4p4svoFWpS1ybSgXvbhOLLQxtHVwf46MhZWUf67z2hi9UMLuVrMx/KnNxdfScad iWLw== X-Gm-Message-State: APjAAAWgzgfGVdaNTAbKxBLLTVDnUN06opGM5PBtf1e6qp11IltvzPOC fVV3xTDRPE+JR20K1puX4rhECHid X-Google-Smtp-Source: APXvYqwl3kjSJi+Be1jR4+6VvhNE/RLIEd5hn8WhmBZaZjmJpQCLqlpQwISulfucyOQedJhkhhzJ3Q== X-Received: by 2002:a7b:c390:: with SMTP id s16mr1313169wmj.111.1556784979175; Thu, 02 May 2019 01:16:19 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:18 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:34 +0300 Message-Id: <20190502081554.5521-8-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 Subject: [Qemu-devel] [PATCH v9 07/27] gdbstub: Implement insert breakpoint (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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Jon Doron --- gdbstub.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index 21cdaf4678..36c7353a22 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1588,6 +1588,29 @@ static void handle_set_thread(GdbCmdContext *gdb_ctx, void *user_ctx) } } +static void handle_insert_bp(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + int res; + + if (gdb_ctx->num_params < 3) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + res = gdb_breakpoint_insert(gdb_ctx->params[1].val_ull, + gdb_ctx->params[2].val_ull, + gdb_ctx->params[0].val_ul); + if (res >= 0) { + put_packet(gdb_ctx->s, "OK"); + return; + } else if (res == -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; @@ -1843,6 +1866,16 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) put_packet(s, "OK"); break; case 'Z': + { + static const GdbCmdParseEntry insert_bp_cmd_desc = { + .handler = handle_insert_bp, + .cmd = "Z", + .cmd_startswith = 1, + .schema = "l?L?L0" + }; + cmd_parser = &insert_bp_cmd_desc; + } + break; case 'z': type = strtoul(p, (char **)&p, 16); if (*p == ',') From patchwork Thu May 2 08:15:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094071 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="NjeH4BvX"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vpKB2Cxjz9s55 for ; Thu, 2 May 2019 18:27:10 +1000 (AEST) Received: from localhost ([127.0.0.1]:47330 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM73c-0004It-5u for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:27:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42891) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6ti-0003aB-RU for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6th-0008Nm-8k for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:54 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:51691) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6te-0007Ma-VM for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:52 -0400 Received: by mail-wm1-x344.google.com with SMTP id t76so1484525wmt.1 for ; Thu, 02 May 2019 01:16:21 -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=U4fLhEZHxeWF7Ph12MqOmpuk/185Eq0Ogcw/FW+Pwwg=; b=NjeH4BvXjmor01vw3r0B7wiWYL0sx6K6aWpJuxKCnaEJ16yfOyVG9fv3XmTYyVaIgh 3pvDp4pmtPX8F8tQX3vm1agAqaI0n+9+EISIl33LPLUGvafVIkb3L96unCY71mX6FBZq fNMKXvtT52dq+EXFneizBdx/ESibAYsT9aisUuAbQLNtsnUdY0Z5PonEwhXnzc4N93dG vFJef1oZ7Kso1fY5i0xGjcDMqegrW3aimQndJOkQwAaupWMGQOSnM/MqGb39IsV0TOM9 u90r+lITiLOaMCjnbHkhpkd5RTzw1KEZU/n6SAD1VPZNdovWLX4mOkP+QtJHSXXr23a0 rIZQ== 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=U4fLhEZHxeWF7Ph12MqOmpuk/185Eq0Ogcw/FW+Pwwg=; b=YK/7ZPkSkv9/8IpDb9jCUjwFY/MJ6WwZapxk4Bv81PNDM9zje64EGUXJ/343oPq0CA lc5c6UEw4CTPtqKF2t3mE1zI8nSHRZzFkt91udFcfvhasD14KjMoaS/oJTldvs2TXRYI 4AXTVNWwSuwYvG42c0tLGdKbdVieCPBa+4om+xi5RByDpMvcoaqj5+5Voy+WfibhNbEB N4bc0aylaSgrVWowRAjgFTVlUr7uzeumFxA8SgpS+ftFUduAFWreA6A4N59dYkwIed59 A5Pd881vPYrHuOmW2eZ71pTOTFvDvcCrU4Lzt+M0mIOFulpIuesrLJPp1AUHZKAIk0mA ticg== X-Gm-Message-State: APjAAAV0ANN35bZKfepfAChfF914IS/xjvxozYEHnJVtjixyRwsWmpmD 5w1ocBASIDEtMLUeI5U6qGb664MX X-Google-Smtp-Source: APXvYqyu4iuZEPLGHqE1sG9WNZ4ScIkIGu7pjHTZClO99Drq1x4zuCMHHkIyJVgkC15hiqq//mwm8g== X-Received: by 2002:a1c:2090:: with SMTP id g138mr1400364wmg.117.1556784980413; Thu, 02 May 2019 01:16:20 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:19 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:35 +0300 Message-Id: <20190502081554.5521-9-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 Subject: [Qemu-devel] [PATCH v9 08/27] gdbstub: Implement remove breakpoint (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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Jon Doron --- gdbstub.c | 49 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 36c7353a22..b42425b24c 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1611,6 +1611,29 @@ static void handle_insert_bp(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(gdb_ctx->s, "E22"); } +static void handle_remove_bp(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + int res; + + if (gdb_ctx->num_params < 3) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + res = gdb_breakpoint_remove(gdb_ctx->params[1].val_ull, + gdb_ctx->params[2].val_ull, + gdb_ctx->params[0].val_ul); + if (res >= 0) { + put_packet(gdb_ctx->s, "OK"); + return; + } else if (res == -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; @@ -1877,23 +1900,15 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } break; case 'z': - type = strtoul(p, (char **)&p, 16); - if (*p == ',') - p++; - addr = strtoull(p, (char **)&p, 16); - if (*p == ',') - p++; - len = strtoull(p, (char **)&p, 16); - if (ch == 'Z') - res = gdb_breakpoint_insert(addr, len, type); - else - res = gdb_breakpoint_remove(addr, len, type); - if (res >= 0) - put_packet(s, "OK"); - else if (res == -ENOSYS) - put_packet(s, ""); - else - put_packet(s, "E22"); + { + static const GdbCmdParseEntry remove_bp_cmd_desc = { + .handler = handle_remove_bp, + .cmd = "z", + .cmd_startswith = 1, + .schema = "l?L?L0" + }; + cmd_parser = &remove_bp_cmd_desc; + } break; case 'H': { From patchwork Thu May 2 08:15:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094054 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Qg6WMq03"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vp9N0Js1z9sB8 for ; Thu, 2 May 2019 18:20:23 +1000 (AEST) Received: from localhost ([127.0.0.1]:47202 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6x0-0005Uy-RU for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:20:18 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42637) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6ta-0003Rc-BF for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6tY-0007p8-A4 for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:46 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:38472) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6tU-0007Rn-Ml for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:42 -0400 Received: by mail-wm1-x343.google.com with SMTP id w15so1390817wmc.3 for ; Thu, 02 May 2019 01:16:23 -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=6OoH0VZvs5cN/77prjtAmvXUSegJODVLc//0yGYVjjY=; b=Qg6WMq03GUglWUSrb7qqKs0RptQHnzcuQifvfD1OFNxt5dSB6XOq2dtHAtUhN7HzhX nLMHZh2GsE8uikqxez40DyP+2EaIW4gOTHHiMOPZ2qmvoiPfaLlcjizRYclDTG8ibQyV mLsvdaXcBAzO/9f0lqTu22hi7LQ6EDNpCQ7V9K5dh5hAiOA2rlPIGbczQbtMLikyARnf UEqfRq1AyIiPfE9jy+LFA+8vUL2k8YdQ0OGoPVorJYaGI9jji+z6HrTNkmKrBCHdLQcd stxvWAXHc1CbRvmaB1vQceKr8h9H5QsBLhbbbS497BJlzfnGKBwbJXcg5dwClunB5Rq9 CZFA== 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=6OoH0VZvs5cN/77prjtAmvXUSegJODVLc//0yGYVjjY=; b=BuvSsDlopb/qCw+kjkEKH91WcZrKzcP2DD8a6dG32e3HqpvlDu8VCbDB4Fi4b3o4eM Dk1vx0viJu7E7mh2s8TQWEbMoj0qxtUrtXn4lo2Q2DVPQxZZoAkVSYz5piqUbk1K0HAV GW0Xm+TOn0C2Mn/e8EbVFB3TOgt5eDE9gym76hPAU8i8oZrBTCiQ0Itgr8znsnYa+hgf 7Xffd7IwrXg/vDSZzi4cAvEoZex1GAB5pei6DgzKW3828A1HsFmPNTzadN7rMvgSZ2v5 H3R99glaREIPeDi4kBwbyETCwyuCXAfOuh/6ndeZqWnfsApzh4VkBnWFlUr7GYtZrqOp cR6w== X-Gm-Message-State: APjAAAXk66uoCwkTN8S961mJEz0Qt//9mGrKBfVm2ZfGSm3ILCa4fEqV k1Br6PFdtLbZv8tuaAV1fqMQf05l X-Google-Smtp-Source: APXvYqzt5wBoGEKdFeoWKUVHLXGjhk5Tpb0IDs4Du2eJhm8tlsxHnRgmvFcFsM3sR/+7MmYNk3Wj7g== X-Received: by 2002:a1c:1dd3:: with SMTP id d202mr1317337wmd.98.1556784981795; Thu, 02 May 2019 01:16:21 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:21 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:36 +0300 Message-Id: <20190502081554.5521-10-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PATCH v9 09/27] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Jon Doron --- gdbstub.c | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index b42425b24c..10e3f12a68 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1634,6 +1634,27 @@ static void handle_remove_bp(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(gdb_ctx->s, "E22"); } +static void handle_set_reg(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + int reg_size; + + if (!gdb_has_xml) { + put_packet(gdb_ctx->s, ""); + return; + } + + if (gdb_ctx->num_params < 2) { + put_packet(gdb_ctx->s, ""); + return; + } + + reg_size = 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; @@ -1878,15 +1899,15 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } break; case 'P': - if (!gdb_has_xml) - goto unknown_command; - addr = strtoull(p, (char **)&p, 16); - if (*p == '=') - p++; - reg_size = 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 = { + .handler = handle_set_reg, + .cmd = "P", + .cmd_startswith = 1, + .schema = "L?s0" + }; + cmd_parser = &set_reg_cmd_desc; + } break; case 'Z': { From patchwork Thu May 2 08:15:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094069 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="P973YXxR"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vpHt0Fklz9s55 for ; Thu, 2 May 2019 18:26:01 +1000 (AEST) Received: from localhost ([127.0.0.1]:47311 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM72U-0002pH-IY for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:25:58 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42641) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6ta-0003Re-Bs for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6tY-0007pD-Aw for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:46 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:38448) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6tU-0007SR-Nw for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:42 -0400 Received: by mail-wr1-x444.google.com with SMTP id k16so2002400wrn.5 for ; Thu, 02 May 2019 01:16:24 -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=C5wVxSSu9B3yjrVL1kbdSqghY5biwyr5/S2ykkoUubY=; b=P973YXxRkkAoD8ifvQ4auErj5Mf/eBggo1kuDyvPdSN4veKbOzGVjnH7PHerd+TyQh FI4faExZq2rZK/q9pJo71I7EEey4RH9ZoF+3ctmlwKC1kmv9/ozGdZ2P04D3P94FxRKw wJ7D3sN5tBG7USjzkrWTYk+QLXyy+DQcwlQMADcwBiZRY+0uK9kf+ZMndkS7htul423V lTzCTyzQXUG4RPPlH58AAiNJbV/+lPk8h4hOGrM2S+4ElCdpI8OZVGISraQBaY2zOG1z dMGLSn2It+DLA5NGMbSMJXVWLGV3kI20XlZ31n8B1U32kKOCab9/d+tcTHTdDE/rTW9Q iAnQ== 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=C5wVxSSu9B3yjrVL1kbdSqghY5biwyr5/S2ykkoUubY=; b=uIidda+1uWx0wyD240mOAltJz/NBdmigh0IHtHZfGSrYA84QhPQNETdHSLfxUrXLRY h0xA2IW4gUhxJNOv84UPMd8r1rkuw/PVryVhFHrqCbZN0EEV0hiZvxM196DhZSdcEA7E kNGCWuccJL3IUDtVAPab1xKRCkA8h3ySyxCwy65u1NcWqSbaMwDJoFMBi25ASZ3uDLyS gxWzgSmpdVMzdOHGKjWBo4i1zXyQubC3rzuYO7B2ZHtaSHlGv4tEnQx+kQb2dONjfqIw 2zMjH9qHVaPVwnpXOYb1H/jnox8kYfwducNjjkgbedsN2DZ4gMs+CtAMx7x3BTThH2RC lerg== X-Gm-Message-State: APjAAAV/RJXMJrrwaVLUqn836VB15bm9PHHO3BHCYUivUncOhiW1V9vA +shjtPlkX6iB6GWd5f2sA1PwpLV3 X-Google-Smtp-Source: APXvYqy+YNCNJabIbOwxjy7rwjUU3L89FuOqLVyO6ASkWAHtnYT8+BNbFVdlUhiMM5Ch/3n5RZmnuQ== X-Received: by 2002:a05:6000:10:: with SMTP id h16mr1355746wrx.151.1556784983117; Thu, 02 May 2019 01:16:23 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:22 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:37 +0300 Message-Id: <20190502081554.5521-11-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PATCH v9 10/27] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Jon Doron --- gdbstub.c | 50 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 10e3f12a68..e9a3d0c2bc 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1655,6 +1655,36 @@ static void handle_set_reg(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(gdb_ctx->s, "OK"); } +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 = 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; @@ -1884,18 +1914,14 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } break; case 'p': - /* 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) - goto unknown_command; - addr = strtoull(p, (char **)&p, 16); - reg_size = 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 = { + .handler = handle_get_reg, + .cmd = "p", + .cmd_startswith = 1, + .schema = "L0" + }; + cmd_parser = &get_reg_cmd_desc; } break; case 'P': From patchwork Thu May 2 08:15:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094072 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BThNabte"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vpKG6Xhmz9s55 for ; Thu, 2 May 2019 18:27:14 +1000 (AEST) Received: from localhost ([127.0.0.1]:47332 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM73g-0004NL-QU for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:27:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42812) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6tg-0003Y9-W1 for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6te-000835-Cq for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:52 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:50251) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6ta-0007Sx-CN for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:48 -0400 Received: by mail-wm1-x341.google.com with SMTP id p21so1485702wmc.0 for ; Thu, 02 May 2019 01:16:25 -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=7xWdg5J6VC6HFdEkoiuvTsAB/KgJAJp/2excD9374G8=; b=BThNabtes12/ukdL62x9lRwv9YhPEMdjuthmWPeS1XejuW6PhTJt36l/hvVY623Uli VhoE4Oslr9Mm9aZNGCnxDlzA4usObE4/yh9PLK8LX2Y1P6M1KtfRpRFPE7x4qvF+xjGR Ls9oYhK45Pnj1eoQfA6A8Xbz3enFBnia6jv/tLeLjQd8Ha76uOX2HpxHYUDALwBJixEP aSqHtFUsxjKp1DropT67Sg7Gz/42wFB2tKwYfqXMwtc+3UvZv6w5/0sz/IHFzLLjgOWS EG/sacIjXv3z/3ifk38Cz9NfRiW6UliwI9kwmlAqvTCAv5OFiq+yZjNgZO/ftCyJUcP+ PTXw== 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=7xWdg5J6VC6HFdEkoiuvTsAB/KgJAJp/2excD9374G8=; b=Jzg8tNhgSEfxp1KMav2CXW7S2hPylc1TEcqcnPiN006DPTEvMM+xONnlqk76Sk/7HK +sNGEAP5ZbqfbHcDaU1KdM64wIzhfx6xKZWxUCNw++J/2B5r/X9zuckXqGKloEoTGVCG vHTTEOghaps3mrPk7DnOSZ1fyDNbQAFJNmQEH3Q2o3z9ek1j7+lMtK7ps/52r1iVN8pz U4f4b28jqUf5J3lfaBmTRKS+3YnodORihQojh3ZxlheEmloNY/dT2jgIg18zqKBFsMQF AlOJqQvEEtaq/UQXBfSOmJsi+A0YoAsCVhXOcch8qLOwJko9xKPp/8XjyNz5LdGRT6V9 g73Q== X-Gm-Message-State: APjAAAV5ivXb/pbHIcIb/B7UjWVoQXhYqHFOpZmCdqglFhW2XPU/448m rQ3U973CVkzbpETfeBRAYUYGiGR+ X-Google-Smtp-Source: APXvYqyInea3b8Yd/SumCczzFz0MONMQFApGZICmKBTifun0l7Ya49e8C757zI1XJvc1SG3eI2bqyw== X-Received: by 2002:a1c:7d10:: with SMTP id y16mr1306371wmc.83.1556784984374; Thu, 02 May 2019 01:16:24 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:23 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:38 +0300 Message-Id: <20190502081554.5521-12-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 Subject: [Qemu-devel] [PATCH v9 11/27] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Jon Doron Reviewed-by: Alex Bennée --- gdbstub.c | 51 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index e9a3d0c2bc..8dc2e1d507 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1685,6 +1685,31 @@ static void handle_get_reg(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(gdb_ctx->s, gdb_ctx->str_buf); } +static void handle_write_mem(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (gdb_ctx->num_params < 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_ull, + 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; @@ -1893,24 +1918,14 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } break; case 'M': - addr = strtoull(p, (char **)&p, 16); - if (*p == ',') - p++; - len = strtoull(p, (char **)&p, 16); - if (*p == ':') - 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) != 0) { - put_packet(s, "E14"); - } else { - put_packet(s, "OK"); + { + static const GdbCmdParseEntry write_mem_cmd_desc = { + .handler = handle_write_mem, + .cmd = "M", + .cmd_startswith = 1, + .schema = "L,L:s0" + }; + cmd_parser = &write_mem_cmd_desc; } break; case 'p': From patchwork Thu May 2 08:15:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094053 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WXLPbXbp"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vp9M6v0Lz9s9y for ; Thu, 2 May 2019 18:20:23 +1000 (AEST) Received: from localhost ([127.0.0.1]:47206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6x3-0005Y8-8u for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:20:21 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6te-0003Uz-Aq for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6ta-0007z1-CP for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:48 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:38472) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6tY-0007UE-EO for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:46 -0400 Received: by mail-wm1-x342.google.com with SMTP id w15so1391130wmc.3 for ; Thu, 02 May 2019 01:16:27 -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=WRCcpUzuoRAzUaN5uQCeSKLXRQ6/9wuQJBWFZBJ3jI8=; b=WXLPbXbpa4YNKPP7Q9n6ioTQgMR4oNJvnsy9Wzv4XLTV48k3pkF2pZcBsJUYnMokLQ jXNEHKFhyu1a98YClKEHpLUM8FmlX71RCCXdoV7+l45XZKMuFOIsHSLJeVtj/lnkgKZW ZLacKRdZdsnwzU2sSlgsxIUDtpalxycQ0Eu1n+lVRhkzQuhrEj4zSmIZo0AKPoXukI9I 5MjRLf3kNScDKdqWjEXr82bFLBQQHjlgG6HUw5uZPazbJ1HdGB5TRTKHU0n+mDGljPaU R1SUSWJV/NsW/yglj+QBW+h0SYB+uoFHGYp6aoNKTJBLSNFtXkBjZ4C7r/z4EE6/usuE mQug== 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=WRCcpUzuoRAzUaN5uQCeSKLXRQ6/9wuQJBWFZBJ3jI8=; b=JLBT8cfRotp33l2whjuz1UutwcyLoU8hWOuPuGxi6wv8s0zMaNzfhb2ZgzYqdCHIA+ yPy4A2eycTUXjBqU4NtNvVUVWyb52FyqgXBlicFupVj0YIU7olv8Puw0xfeXS3xMamfp Pt/JQs6Ma4A68xGCN9LzT+1liN+8n6tmuXYeYOm6VdR64dpuw6rGK1u/ETQlwU2Djw0g MCWRbzX+NkvdrddUko+BUKDLRA51aRlxHCmlLSscEH99V2o2h2xwVV1D0eefduKryO1o tuUoI3Wyv084SbzuJqIrplJO7L1BE4E0lCdqSMY+pWbU3IgJAJoAUqh1gvefEIWxOLj5 7EYA== X-Gm-Message-State: APjAAAUwTZvv0HV/ne1hgNwKJnGtZXBx3KUwy4031KiKMkIF0v3SWD84 XmD0f5zMpqFFMF9am/C3PE3Mt4Fy X-Google-Smtp-Source: APXvYqx97FiytTJe0nSmzbK7qmFq8HKDysBHewunWB/EhHcXmPHDVia5gJLLuobhYG/1HVDuJYYMXw== X-Received: by 2002:a1c:a3c2:: with SMTP id m185mr1260120wme.17.1556784986217; Thu, 02 May 2019 01:16:26 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:25 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:39 +0300 Message-Id: <20190502081554.5521-13-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 Subject: [Qemu-devel] [PATCH v9 12/27] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Jon Doron Reviewed-by: Alex Bennée --- gdbstub.c | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 8dc2e1d507..daa602edc3 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1710,6 +1710,30 @@ static void handle_write_mem(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(gdb_ctx->s, "OK"); } +static void handle_read_mem(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (gdb_ctx->num_params < 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_ull, + 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_ull); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1899,22 +1923,14 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) put_packet(s, "OK"); break; case 'm': - addr = strtoull(p, (char **)&p, 16); - if (*p == ',') - p++; - len = 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) != 0) { - put_packet (s, "E14"); - } else { - memtohex(buf, mem_buf, len); - put_packet(s, buf); + { + static const GdbCmdParseEntry read_mem_cmd_desc = { + .handler = handle_read_mem, + .cmd = "m", + .cmd_startswith = 1, + .schema = "L,L0" + }; + cmd_parser = &read_mem_cmd_desc; } break; case 'M': From patchwork Thu May 2 08:15:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094077 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="YEK7mRAp"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vpQ56hSPz9s55 for ; Thu, 2 May 2019 18:31:25 +1000 (AEST) Received: from localhost ([127.0.0.1]:47405 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM77i-0008F5-EN for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:31:22 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6tg-0003YA-WE for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6te-00083W-Cz for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:52 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:33068) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6ta-0007Ul-C7 for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:48 -0400 Received: by mail-wr1-x442.google.com with SMTP id e28so2044715wra.0 for ; Thu, 02 May 2019 01:16:29 -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=brvpFyYDw1Z1o2sLMNd/sMXNZo4TYemLFYCJt79OgBg=; b=YEK7mRApxN1jtYp79yHPw85pTuFYiKOvF1Nm8h+vaxhBKpCqb1RbIcRRgV6sQ8GfHq W/JrEUH/Ui3wM0fxnUIIbFIruanOJm6KovDEL7MlY9ay3Z5YVchkDmbzJfXCUlid/0BO nVJaY1MJifLxxOc1WbssZ89wxQJb4SKTlscHuIpvN0fOLQ00TAWuE/Uhtm1gcTImiKaB jVw+TuGZ6XXKPRcB2GzWaYJE3p5ASVl8Dci2QVE10cITgw8lmfMtdLRfnB7ZiGmA3NXN elQxyiszMKi0WMyQhnSz+FaKCbRdTBDUCi6scgmNP+hqA5xT95JENTexfKwiLJgUqqbB obWQ== 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=brvpFyYDw1Z1o2sLMNd/sMXNZo4TYemLFYCJt79OgBg=; b=kl3r1JoB78ooZ6xoqaP+naZmDSARibu0W+KWlevkqGBs6Y0eHGjwdZETzzb7dDKdmw uryPj+UnhMHT12Hi80pVFb/WOrDvAnSCX2mM9iXBGaLhN8EnF9CIzUxs6rAnAqhXmrFy FIDhCT/gjjyuttqr8SEKqlHaSviIP+RcFt4AlgWHQQCrA2pAdHJMvWQN1RO4T2VxR+qw cELSr9IvydSSwzcx3K8vY6Um9APaX4H1F3WQinhurQvAW8CTKNykPlY4oMccp8FKn7wJ e7q/If97IsZannB8I6p86BBGZDa6IdHNdY3eBXo4GqJ7NV9VC+Z9gX08lFK062+GyArm xtWQ== X-Gm-Message-State: APjAAAXZ/0N/NcENlSZqwz3wXLO9jc74R7FWdq33Qqhj9LO++e0+3rYI SxtLYZZ4IrknfD5w8aC+yoRaacVT X-Google-Smtp-Source: APXvYqzYj1+moPN5Co8qqVcDuJeD0DW/R7cGBK49qXpm1oL2+q4fWB2q+ngy9Plzj2G8G1zuTeiutA== X-Received: by 2002:a5d:6189:: with SMTP id j9mr1680256wru.176.1556784988002; Thu, 02 May 2019 01:16:28 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:27 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:40 +0300 Message-Id: <20190502081554.5521-14-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PATCH v9 13/27] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Jon Doron Reviewed-by: Alex Bennée --- gdbstub.c | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index daa602edc3..adfe39b3a3 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1734,6 +1734,29 @@ static void handle_read_mem(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(gdb_ctx->s, gdb_ctx->str_buf); } +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 = gdb_ctx->mem_buf; + len = strlen(gdb_ctx->params[0].data) / 2; + hextomem(registers, gdb_ctx->params[0].data, len); + for (addr = 0; addr < gdb_ctx->s->g_cpu->gdb_num_g_regs && len > 0; + addr++) { + reg_size = gdb_write_register(gdb_ctx->s->g_cpu, registers, addr); + len -= reg_size; + registers += reg_size; + } + put_packet(gdb_ctx->s, "OK"); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1745,7 +1768,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 = NULL; @@ -1911,16 +1933,15 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) put_packet(s, buf); break; case 'G': - cpu_synchronize_state(s->g_cpu); - registers = mem_buf; - len = strlen(p) / 2; - hextomem((uint8_t *)registers, p, len); - for (addr = 0; addr < s->g_cpu->gdb_num_g_regs && len > 0; addr++) { - reg_size = gdb_write_register(s->g_cpu, registers, addr); - len -= reg_size; - registers += reg_size; + { + static const GdbCmdParseEntry write_all_regs_cmd_desc = { + .handler = handle_write_all_regs, + .cmd = "G", + .cmd_startswith = 1, + .schema = "s0" + }; + cmd_parser = &write_all_regs_cmd_desc; } - put_packet(s, "OK"); break; case 'm': { From patchwork Thu May 2 08:15:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094067 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dIYQvcIF"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vpDm0RB7z9sBb for ; Thu, 2 May 2019 18:23:20 +1000 (AEST) Received: from localhost ([127.0.0.1]:47262 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6zu-0008De-0G for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:23:18 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42636) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6ta-0003Rb-B3 for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6tY-0007pH-Av for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:46 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:37765) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6tU-0007WC-NN for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:42 -0400 Received: by mail-wm1-x342.google.com with SMTP id y5so1399354wma.2 for ; Thu, 02 May 2019 01:16:30 -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=b1bpFqGwMibMAfq1pbDbHkF4Xk3yQKA0SG1CtWad0g4=; b=dIYQvcIFgvmcsw6yS0NoxDKlnxkdCaYJLAtxlrs0fnSUmECAqdGEsQVWL2LoW3nPuT ZE2wbNyodTgCFi+Mzqp54+YcZOEZeyJHR0De7abVtsUz0bn7X2hCyS1vsyyIz20965xZ 82/FJV/qTaFId36/z53MsAGe4vfvXGCsU0yT0rjA7SJ0Ld4PjRnbF0TBeEprweQCKuSw yoD8PRRGr9qLhdrmaxHIEajVuDmZnJX4FYWvSDDGht8Jss8Fv7nGuw1Q9nHj4BIZAOBW k3gi8NLm4XcnbLoY+1yOM3HF6gOm2pfyXTY8gCcecyEm/GB7Xw8VfQNZf0RC162sw/Qh pHFA== 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=b1bpFqGwMibMAfq1pbDbHkF4Xk3yQKA0SG1CtWad0g4=; b=J68/XEJ4OhwBCkseJQI2odcHCdJXveJDZMNQBBQHI9kxjpmszmFQcsZg+qjx9T4nR9 n1PZZj32iHnlOUxjWjqkFWuuV5L9+CcWntlsWVunI9O5/HhH012/miXXx04A5mo+X5oA J4+Z0jtCg6uyo1jmV54p5/rjEcda9Z+mhTLDiQlsnz6IPVADtPNGjXA6g3i2d/0He05f 9zHekONUyHrd5YLorsTHFUqG/LmCiJq3Kmx4zGGctk/5NWlGGLwJCec4LWq8g4Q+m6lL Bpg8dHbFyzLpFtBAlT2UOju4ObK8VvpeSxjeyI++rzWE5c+5oCZ/3e/G+IyNXnwJecr1 4KmA== X-Gm-Message-State: APjAAAXgFB3Gw4l5zbdT9xvb7B6Yn+f8YnuT7VoGxDohzdgJ0xbAbyys 0/1IVZ1KjnrTnWdEYWfaZppxfNGF X-Google-Smtp-Source: APXvYqx8Dsf6BIhimBTuq6TL3aEZYgOdxV4ULDmc8y7AcPCkcF9K73gGY5FjlDCXGVY/Nop0jE1CzQ== X-Received: by 2002:a1c:4302:: with SMTP id q2mr1374324wma.28.1556784989304; Thu, 02 May 2019 01:16:29 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:28 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:41 +0300 Message-Id: <20190502081554.5521-15-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 Subject: [Qemu-devel] [PATCH v9 14/27] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Jon Doron Reviewed-by: Alex Bennée --- gdbstub.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index adfe39b3a3..3478ac778d 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1757,6 +1757,21 @@ static void handle_write_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(gdb_ctx->s, "OK"); } +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 = 0; + for (addr = 0; addr < gdb_ctx->s->g_cpu->gdb_num_g_regs; addr++) { + len += gdb_read_register(gdb_ctx->s->g_cpu, gdb_ctx->mem_buf + len, + 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; @@ -1764,7 +1779,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]; @@ -1923,14 +1938,14 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } break; case 'g': - cpu_synchronize_state(s->g_cpu); - len = 0; - for (addr = 0; addr < s->g_cpu->gdb_num_g_regs; addr++) { - reg_size = gdb_read_register(s->g_cpu, mem_buf + len, addr); - len += reg_size; + { + static const GdbCmdParseEntry read_all_regs_cmd_desc = { + .handler = handle_read_all_regs, + .cmd = "g", + .cmd_startswith = 1 + }; + cmd_parser = &read_all_regs_cmd_desc; } - memtohex(buf, mem_buf, len); - put_packet(s, buf); break; case 'G': { From patchwork Thu May 2 08:15:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094075 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="PepwTe7h"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vpNK2Dcxz9s55 for ; Thu, 2 May 2019 18:29:53 +1000 (AEST) Received: from localhost ([127.0.0.1]:47355 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM76F-0006pZ-6I for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:29:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42977) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6tk-0003cX-RO for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6th-0008OM-A6 for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:56 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:34196) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6tg-0007Ww-Vp for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:53 -0400 Received: by mail-wr1-x442.google.com with SMTP id e9so2033576wrc.1 for ; Thu, 02 May 2019 01:16:31 -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=/kC4Ra5FAbXCGpLaIRgx76fPd1eNM+Za2+9T+4B8JSs=; b=PepwTe7hStnTonZBcIzfB1nRJqu+OsGlAh9Ytf1s++5xl6bDau96T5sxQOkswuGF/S Tjexj5tqfuSfAgs5KdvxFlu8wH0Ii0MuHkJYPTpL7xY1hkkib797DP67F94wV1eUdlVc r4/0EhIC5MEcL6aGSzktKwkWA87JB2GWpd3TtlTzejy0xWgNsHaC96cP9nZSwXB1nPrG oIjtRwJ/mU6caogoh3PRCpbah+zFqZlEng1BaRu3RWhhPhPERkCZbPrEVGZnBvlFlVHV jbem4Y2WaBINlTS9pqWheoGYrZQJMIp1fbKVYFDHpbhqqOT1QXdPAoFoFLHMYCBMljgH LeLA== 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=/kC4Ra5FAbXCGpLaIRgx76fPd1eNM+Za2+9T+4B8JSs=; b=fjOCw5xalsBYs1zLsEx0GNQKI8iBL1gVScNcBwQ+ZFcYkngJACJAloMrUiTH5TxVzV Lb8lXysyjnBnNMYZIEA065aKpk1ZuiKSuyqnHlqZfAFzwqA/BzTY+MTfKZWiadmMrai3 SlWfZ3KzoTR2qfP/KJiJSCX6252LZDEjIc9uMAqYzR+9CZFxavW/v0ggsna74ywGzuxb oaMthnTlHgVEBXXwnKL8MECFtJeCyZtxYK7MSm3020tp13DBAhPnn9MTYhZgbdlNURVw LdasYFHXp3r+Z3v7uYCOyIpHdQdJMm2w/gzGM0Dkf6NSqBNiidiaAzB5mMhg4BrVPgpo oeTw== X-Gm-Message-State: APjAAAXoIQ6PjChZKH7c3hM83g7LoaYnWjScKkR/jotNRqXnase/ij4p EdjPTT09Bj6VMzJFmIEQvS2wlHao X-Google-Smtp-Source: APXvYqxSN3+joOhM7XNbgNiUGTOc0WTN9dG72C/4ml0YKnkNvOAyHIC2sHbykct2AQ3dfDR1JwSqDw== X-Received: by 2002:adf:eb03:: with SMTP id s3mr878251wrn.170.1556784990882; Thu, 02 May 2019 01:16:30 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:30 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:42 +0300 Message-Id: <20190502081554.5521-16-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PATCH v9 15/27] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Jon Doron --- gdbstub.c | 62 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 3478ac778d..9fe130f30d 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1772,6 +1772,39 @@ static void handle_read_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(gdb_ctx->s, gdb_ctx->str_buf); } +static void handle_file_io(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + int num_syscall_params; + GdbCmdVariant syscall_params[3] = {}; + + if (!gdb_ctx->num_params) { + return; + } + + if (cmd_parse_params(gdb_ctx->params[0].data, "L,L,o0", syscall_params, + &num_syscall_params)) { + return; + } + + if (!num_syscall_params) { + return; + } + + if (gdb_ctx->s->current_syscall_cb) { + gdb_ctx->s->current_syscall_cb(gdb_ctx->s->c_cpu, + (target_ulong)syscall_params[0].val_ull, + (target_ulong)syscall_params[1].val_ull); + gdb_ctx->s->current_syscall_cb = NULL; + } + + if (syscall_params[2].opcode == (uint8_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; @@ -1913,28 +1946,13 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) return RS_IDLE; case 'F': { - target_ulong ret; - target_ulong err; - - ret = strtoull(p, (char **)&p, 16); - if (*p == ',') { - p++; - err = strtoull(p, (char **)&p, 16); - } else { - err = 0; - } - if (*p == ',') - p++; - type = *p; - if (s->current_syscall_cb) { - s->current_syscall_cb(s->c_cpu, ret, err); - s->current_syscall_cb = NULL; - } - if (type == 'C') { - put_packet(s, "T02"); - } else { - gdb_continue(s); - } + static const GdbCmdParseEntry file_io_cmd_desc = { + .handler = handle_file_io, + .cmd = "F", + .cmd_startswith = 1, + .schema = "s0" + }; + cmd_parser = &file_io_cmd_desc; } break; case 'g': From patchwork Thu May 2 08:15:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094068 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="t9GKjeCM"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vpDt4m75z9s55 for ; Thu, 2 May 2019 18:23:26 +1000 (AEST) Received: from localhost ([127.0.0.1]:47266 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM700-0008Ls-HR for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:23:24 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42816) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6th-0003YC-0f for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6te-00085U-NA for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:52 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:38447) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6te-0007YJ-DK for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:50 -0400 Received: by mail-wr1-x442.google.com with SMTP id k16so2003032wrn.5 for ; Thu, 02 May 2019 01:16:34 -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=EShIhnyclfVo57FnSdW5zX6W2mQ/1wfNmEis7PfWfkY=; b=t9GKjeCMehyP0OgaBi1osrSMjK4uwBNkRZnRfwW424vTdd7tjMa3fsZws4H1FJ2VDK AL8G6qpp7SFryQfeSlgDba6+S4069N0WOlJLZELGwO6vZUD5B2FTdVRyA3zaHfT8aakY HvVvlIAFY9+RxkbzLlQAagn8mpc+OYEPQzR7vwMGZapycnK6PDCU3/1euV/fx3h6jFtb YyWI99D8gEsoJ1Xakq06dJyxOlRk6TnoyFA1/RK0SRCxKuRauPr0HtQqPjxsQSn8p+Ox j6SJRc4H/3UdJfPfBY9Hs7VsfHhDAlSAKhj1g5mcLpPiDDEpCfVkiDUVtwNi65A9aXDk VpWQ== 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=EShIhnyclfVo57FnSdW5zX6W2mQ/1wfNmEis7PfWfkY=; b=HBKUMsL2/fIuNQ6PQ7OzAhlnnXi7RlbeKSP/yRhQFHKsjC2jnLcUYtpZp+bgAln0Ye vZ8DP6AJargDp3cKJChgsRC+SrOQh1dd4YivgX84fW9HXJat77Ji6B3zjsgYMLsb6i3D DiuK+Vv+fN7xKCnmTPkfFO+07+x5m1kiSdbux1uA8yk/2GHCbMpup1jf/+DZKCwyi2RG pWODXKNn4m10wnRwBHLZlE4ifTIm5gV0gD3uz+Sk7p9MRLGzIMR8xIR64+snpIKYT/ep EDZH+ZNHa24W6mYrzMYkJjTwIeLRAcJh8dW7LXNblS1b+f65QdGT6ryahAtTsuHLp5Of 0szg== X-Gm-Message-State: APjAAAUHFd+sS7d+tvzhlvgA2fbLSa/awInTQ9USYjL6D3u1XlEDT8Ws 2jLqfTVuv/VY/ET9WjyNn3vVXrZB X-Google-Smtp-Source: APXvYqxgrSOhA7AlF9OAMKlnjyB4gdEl2ANwG0OYBiCRptNLPMXChTn+K4jcKAXpi0cDPYDtWTVrfw== X-Received: by 2002:adf:cd90:: with SMTP id q16mr1669186wrj.75.1556784993176; Thu, 02 May 2019 01:16:33 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:32 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:43 +0300 Message-Id: <20190502081554.5521-17-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PATCH v9 16/27] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Jon Doron Reviewed-by: Alex Bennée --- gdbstub.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 9fe130f30d..9b0556f8be 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1805,6 +1805,16 @@ static void handle_file_io(GdbCmdContext *gdb_ctx, void *user_ctx) gdb_continue(gdb_ctx->s); } +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_ull); + } + + 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; @@ -1937,13 +1947,16 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } break; case 's': - if (*p != '\0') { - addr = strtoull(p, (char **)&p, 16); - gdb_set_cpu_pc(s, addr); + { + static const GdbCmdParseEntry step_cmd_desc = { + .handler = handle_step, + .cmd = "s", + .cmd_startswith = 1, + .schema = "L0" + }; + cmd_parser = &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 = { From patchwork Thu May 2 08:15:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094066 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="AkwgYepc"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vpDk5mPxz9sB8 for ; Thu, 2 May 2019 18:23:16 +1000 (AEST) Received: from localhost ([127.0.0.1]:47258 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6zp-000896-VK for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:23:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42635) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6ta-0003Ra-Aj for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6tY-0007q0-DN for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:46 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:33069) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6tW-0007aB-Bw for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:44 -0400 Received: by mail-wr1-x442.google.com with SMTP id e28so2045153wra.0 for ; Thu, 02 May 2019 01:16:35 -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=kKebEya2GiWvJfCSlb0vx4oLqKZ12SF6Am+XqCA7M8o=; b=AkwgYepcWyF+IP6sX5GVDp12NdIFVHm0MkiB/GX/YRnlKRQkcKxErlP0n+Py8PXIbU noV2VtCpss9IIxKo16uIrx9ZKaxaD3mv5zFqwlFNnYs0uJ8b4/Sq7Ft37seHXCY3y0LV HG9Lx/kK09IcE+6M3Nme1pmqRAjPXrY+cAPu5c72L1QFQm5fLgHXnC71D4OUA0Jqlb+t 8SlVjOGLeyXNWbEKXioA2T97ME/nAiJFIH1W1YyNeYV4kdiGS1MpGwsQhoDvMOPbrD3X +1zvy45WUcIvMhNz6VYkFV4nM51bMPE/0XfwhFTM42cZ/bEXSzFHxpTaMvrf/svBsEdv 7zwA== 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=kKebEya2GiWvJfCSlb0vx4oLqKZ12SF6Am+XqCA7M8o=; b=CaTokYBU4lW3IpkqNdSn16I7pYTSB8KwBKjEvi0RGaLhkpdnFnnnjL3Kfs+KBZ0xqo MQKuT5vcpfRvcgyngas5lwCZWU6bNUTqH8FeOhUIDZAAvqlh543hlv1CV9Vtq7HsS2pd G/JLPoqPfcAtDrPD52NDLqIfIec76GRqkts+InZD9ZXCAmGcLwXJoKM2HJ/W60qGTFlj 7fZgc5E7fxeYat3f23ue6Idq6DCYVUx6cuUbodyHYwZjPNyixS9x6FBUhnvponsIgy2u 2KoPZT6YBvhTzAZ8RE5tW3CQd8S7lnZ02VLHuRMFi27UIOpVGwXpE1K7elICvzhdefy1 xE6A== X-Gm-Message-State: APjAAAUCuYEkuJ0YNUFOJNSNLulP84S3OM0nCH/sxxLypxWKOGbM+u6u 8GshMFAoEzK7su8Ap1AO6vxyj7J5 X-Google-Smtp-Source: APXvYqxcGpbOCSeSu5ekA5KsQg/dFwpDRDn/QoykW+5As9gaPAnVsWGNCLao2Y5C0lBh8AOyLj1qhg== X-Received: by 2002:a5d:6b48:: with SMTP id x8mr1613377wrw.266.1556784994630; Thu, 02 May 2019 01:16:34 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:34 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:44 +0300 Message-Id: <20190502081554.5521-18-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PATCH v9 17/27] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Jon Doron --- gdbstub.c | 170 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 110 insertions(+), 60 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 9b0556f8be..d56d0fd235 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1815,6 +1815,106 @@ static void handle_step(GdbCmdContext *gdb_ctx, void *user_ctx) gdb_continue(gdb_ctx->s); } +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 = gdb_handle_vcont(gdb_ctx->s, gdb_ctx->params[0].data); + if ((res == -EINVAL) || (res == -ERANGE)) { + put_packet(gdb_ctx->s, "E22"); + } else if (res) { + put_packet(gdb_ctx->s, "\0"); + } +} + +static void handle_v_attach(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + GDBProcess *process; + CPUState *cpu; + char thread_id[16]; + + strcpy(gdb_ctx->str_buf, "E22"); + if (!gdb_ctx->num_params) { + goto cleanup; + } + + process = gdb_get_process(gdb_ctx->s, gdb_ctx->params[0].val_ul); + if (!process) { + goto cleanup; + } + + cpu = get_first_cpu_in_process(gdb_ctx->s, process); + if (!cpu) { + goto cleanup; + } + + process->attached = true; + gdb_ctx->s->g_cpu = cpu; + gdb_ctx->s->c_cpu = 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[] = { + /* Order is important if has same prefix */ + { + .handler = handle_v_cont_query, + .cmd = "Cont?", + .cmd_startswith = 1 + }, + { + .handler = handle_v_cont, + .cmd = "Cont", + .cmd_startswith = 1, + .schema = "s0" + }, + { + .handler = handle_v_attach, + .cmd = "Attach;", + .cmd_startswith = 1, + .schema = "l0" + }, + { + .handler = handle_v_kill, + .cmd = "Kill;", + .cmd_startswith = 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; @@ -1822,7 +1922,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]; @@ -1871,66 +1971,16 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } break; case 'v': - if (strncmp(p, "Cont", 4) == 0) { - p += 4; - if (*p == '?') { - put_packet(s, "vCont;c;C;s;S"); - break; - } - - res = gdb_handle_vcont(s, p); - - if (res) { - if ((res == -EINVAL) || (res == -ERANGE)) { - put_packet(s, "E22"); - break; - } - goto unknown_command; - } - break; - } else if (strncmp(p, "Attach;", 7) == 0) { - unsigned long pid; - - p += 7; - - if (qemu_strtoul(p, &p, 16, &pid)) { - put_packet(s, "E22"); - break; - } - - process = gdb_get_process(s, pid); - - if (process == NULL) { - put_packet(s, "E22"); - break; - } - - cpu = get_first_cpu_in_process(s, process); - - if (cpu == NULL) { - /* Refuse to attach an empty process */ - put_packet(s, "E22"); - break; - } - - process->attached = true; - - s->g_cpu = cpu; - s->c_cpu = 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) == 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 = { + .handler = handle_v_commands, + .cmd = "v", + .cmd_startswith = 1, + .schema = "s0" + }; + cmd_parser = &v_cmd_desc; } + break; case 'k': /* Kill the target */ error_report("QEMU: Terminated via GDBstub"); From patchwork Thu May 2 08:15:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094078 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="g7rweuhQ"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vpQ746BZz9s55 for ; Thu, 2 May 2019 18:31:27 +1000 (AEST) Received: from localhost ([127.0.0.1]:47407 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM77l-0008Gy-HH for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:31:25 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42697) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6te-0003Uy-Aq for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6ta-0007zF-D4 for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:48 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:51695) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6tY-0007ay-Dq for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:46 -0400 Received: by mail-wm1-x343.google.com with SMTP id t76so1485709wmt.1 for ; Thu, 02 May 2019 01:16:37 -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=6XppYMRruE5laPQu4tuOEJD3R2TgHj9UJ0kj9FF2Z0o=; b=g7rweuhQ02WGqqpLl3LfGFc8M8PAHVu8jQ0b1SQEBBEwp0fMqm6ajS3Mcsa9DP4TY2 fvKPN8lA8YRBso40lUF2I2CZGx17GpSZPVd5bbFFJeWjPAN76nbnKYN8tHMWxqV1lJh6 gmUOjT3haCTuIGp+I6VycaG3H2x+SNkAvArxf8ZD+AbdrfEWj8WuT+FsQfiygmLIYCXf PlvCseUHCRnzafDoHwnb4jJid54IxEUu6U5J/V50en5xxQHCb66mJ2LTenUsQKpPST8p 76HuYgWDzSQBVFoZs2idvEuq+h6GTW3xRE6uT5GwlDF1NG51RYp3JI/5lhnvmL8wqmg/ 98cQ== 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=6XppYMRruE5laPQu4tuOEJD3R2TgHj9UJ0kj9FF2Z0o=; b=oPZNHMtmtaS2H0RiA8QrOH/oeWalL7A+Dsgg31dm/0sD0F92F1sWHWbuuAWLWt1jbN tB0Wbxpsgf+FOKpbscCGt9k+Tde+AHmYKhzupr0zKD43O4JmhHbQn10okXXpZbb2Ywnw S8+f2UBrAE2gEFY2sd3cQ/qat/Ip8woN1WvV8AWlOSw7Bz4G4fp5PFOekQPDm4r+US6r e7khno2WP2jVjLh2Q9qiJP9giCCV5CSVujd8x72tPnbD794E2OprL3umjrCBLyPGkUkC K6mnHlO0rjWFMjgtV6KyE3M5+2v/ec61LOou1A3ESKyR9tsexzkcu1ghdsfZ+GNFjq9d JUSg== X-Gm-Message-State: APjAAAX9oui5LET+UBU50SkvIIWpVJ+RveuJgIyez/niBiDNdjiQve/o S+Jb9DBiiSp3wqJc1JHpxM6gkTT8 X-Google-Smtp-Source: APXvYqyTQ8y7jwgvskmmJOSkyGztugXNVraM649dBe2fZVaBTEv8wime0EYcjm1JYDCBzxOE9DtKLA== X-Received: by 2002:a1c:a00f:: with SMTP id j15mr1307511wme.148.1556784996071; Thu, 02 May 2019 01:16:36 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:35 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:45 +0300 Message-Id: <20190502081554.5521-19-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PATCH v9 18/27] gdbstub: Implement generic query (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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Jon Doron --- gdbstub.c | 327 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 327 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index d56d0fd235..83ae8738cc 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1915,6 +1915,323 @@ static void handle_v_commands(GdbCmdContext *gdb_ctx, void *user_ctx) } } +static void handle_query_qemu_sstepbits(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), + "ENABLE=%x,NOIRQ=%x,NOTIMER=%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 = 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_flags); + 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 = gdb_get_cpu_process(gdb_ctx->s, gdb_ctx->s->g_cpu); + cpu = 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 = + 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 = 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_ctx) +{ + CPUState *cpu; + int len; + + if (!gdb_ctx->num_params || + gdb_ctx->params[0].thread_id.kind == GDB_READ_THREAD_ERR) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + cpu = 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 = object_get_class(OBJECT(cpu)); + const char *cpu_model = object_class_get_name(oc); + char *cpu_name = object_get_canonical_path_component(OBJECT(cpu)); + len = 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 = 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 = gdb_ctx->s->c_cpu->opaque; + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), + "Text=" TARGET_ABI_FMT_lx ";Data=" TARGET_ABI_FMT_lx + ";Bss=" 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 = strlen(gdb_ctx->params[0].data); + if (len % 2) { + put_packet(gdb_ctx->s, "E01"); + return; + } + + len = len / 2; + hextomem(gdb_ctx->mem_buf, gdb_ctx->params[0].data, len); + gdb_ctx->mem_buf[len++] = 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=%x", + MAX_PACKET_LENGTH); + cc = 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 = 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; + + if (gdb_ctx->num_params < 3) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + process = gdb_get_cpu_process(gdb_ctx->s, gdb_ctx->s->g_cpu); + cc = CPU_GET_CLASS(gdb_ctx->s->g_cpu); + if (!cc->gdb_core_xml_file) { + put_packet(gdb_ctx->s, ""); + return; + } + + gdb_has_xml = true; + p = gdb_ctx->params[0].data; + xml = get_feature_xml(gdb_ctx->s, p, &p, process); + if (!xml) { + put_packet(gdb_ctx->s, "E00"); + return; + } + + addr = gdb_ctx->params[1].val_ul; + len = gdb_ctx->params[2].val_ul; + total_len = strlen(xml); + if (addr > total_len) { + put_packet(gdb_ctx->s, "E00"); + return; + } + + if (len > (MAX_PACKET_LENGTH - 5) / 2) { + len = (MAX_PACKET_LENGTH - 5) / 2; + } + + if (len < total_len - addr) { + gdb_ctx->str_buf[0] = 'm'; + len = memtox(gdb_ctx->str_buf + 1, xml + addr, len); + } else { + gdb_ctx->str_buf[0] = 'l'; + len = 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 GdbCmdParseEntry gdb_gen_query_set_common_table[] = { + /* Order is important if has same prefix */ + { + .handler = handle_query_qemu_sstepbits, + .cmd = "qemu.sstepbits", + }, + { + .handler = handle_query_qemu_sstep, + .cmd = "qemu.sstep", + }, + { + .handler = handle_set_qemu_sstep, + .cmd = "qemu.sstep=", + .cmd_startswith = 1, + .schema = "l0" + }, +}; + +static GdbCmdParseEntry gdb_gen_query_table[] = { + { + .handler = handle_query_curr_tid, + .cmd = "C", + }, + { + .handler = handle_query_threads, + .cmd = "sThreadInfo", + }, + { + .handler = handle_query_first_threads, + .cmd = "fThreadInfo", + }, + { + .handler = handle_query_thread_extra, + .cmd = "ThreadExtraInfo,", + .cmd_startswith = 1, + .schema = "t0" + }, +#ifdef CONFIG_USER_ONLY + { + .handler = handle_query_offsets, + .cmd = "Offsets", + }, +#else + { + .handler = handle_query_rcmd, + .cmd = "Rcmd,", + .cmd_startswith = 1, + .schema = "s0" + }, +#endif + { + .handler = handle_query_supported, + .cmd = "Supported:", + .cmd_startswith = 1, + .schema = "s0" + }, + { + .handler = handle_query_supported, + .cmd = "Supported", + .schema = "s0" + }, + { + .handler = handle_query_xfer_features, + .cmd = "Xfer:features:read:", + .cmd_startswith = 1, + .schema = "s:l,l0" + }, + { + .handler = handle_query_attached, + .cmd = "Attached:", + .cmd_startswith = 1 + }, + { + .handler = handle_query_attached, + .cmd = "Attached", + }, +}; + +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 int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -2128,6 +2445,16 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } break; case 'q': + { + static const GdbCmdParseEntry gen_query_cmd_desc = { + .handler = handle_gen_query, + .cmd = "q", + .cmd_startswith = 1, + .schema = "s0" + }; + cmd_parser = &gen_query_cmd_desc; + } + break; case 'Q': /* parse any 'q' packets here */ if (!strcmp(p,"qemu.sstepbits")) { From patchwork Thu May 2 08:15:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094095 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="A4jux+EN"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vpcR0V08z9sBV for ; Thu, 2 May 2019 18:40:23 +1000 (AEST) Received: from localhost ([127.0.0.1]:47543 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM7GP-0007Ry-2p for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:40:21 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42966) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6tk-0003bZ-8L for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6th-0008Nd-6V for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:55 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:34197) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6te-0007dd-Uh for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:52 -0400 Received: by mail-wr1-x442.google.com with SMTP id e9so2033954wrc.1 for ; Thu, 02 May 2019 01:16:38 -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=9rzWu4duvgFxDEBnKAIuNQA/7quDWlJb65aR2J7JxiI=; b=A4jux+ENCuhtWTSrnCh5ENhh5ZnFcFlzyVcE61x4X8LetUQlEcBnnJBBPbaQ63sMGm /tANAiA/REQ1N/uxjQo/uHH9b+etHDkyIaNFflL3Q5sQfkYBQu0zhzDnR3Kwuf6Ad22M IxbJINqrCnGIYlcbDPB3UiFKS0zrZvaf5FgGKCJf+dea1bipz56Sx0Pfvc4G3q4KxqxH JdbeEIY/GACflhQXLUdW2ZImrIRW3WGdDZ7iHDcI3AaJl2czIJAkF0l9TsYz0EZPUpxV JAMYoBrAKlEv5aEXBrhGzXAhVIL9PTchmhN165luG/djAT8i459XuEssDT4ITigZEEMX s4Bg== 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=9rzWu4duvgFxDEBnKAIuNQA/7quDWlJb65aR2J7JxiI=; b=nmWgqodjY1GuLqp7mUNpDcl9qrhn15iVM78eHXwVEP/3CFgJxiBqWRrq+Necu66A+4 d/i94tvs/QH3Vm+KZjZApza9WwExDGBC/fFJkV8Tp+IEXHQpSRrbiZ377rpxuetzaNiQ yswNEYYniVx2rrYKsCoRm3a4Anw/LBxU1THEnpAFyK7A2ekJpi97axpnlNHdmIBMChCO e7vCgF/7dFzlbLNjo24YfznCvg29dbuIfNRmAU3MFDYk0edDH3LOqt+WgLqlhZLCyxEe wvcuodpYPf0qbuJMig+PFezyWkXqWrQrs8IZ7E6oDsR4dmlAvAcr9YeENMTHThrcNRw4 TfRA== X-Gm-Message-State: APjAAAXIFReIbwJNR8veRdwu0z/UZ4xIzl9xLEBn55mM3e2Q2QBxrm+o i6Z7w1CfHDMIxIRx7KCD371Ma6LD X-Google-Smtp-Source: APXvYqx32IlAsUvmrU6tQ1611x1T79nzAWtGjpzkSpuw/uN11tg1HGLlmERgqUYy6rQZU8KzbctsWQ== X-Received: by 2002:adf:df04:: with SMTP id y4mr1847896wrl.100.1556784997481; Thu, 02 May 2019 01:16:37 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:36 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:46 +0300 Message-Id: <20190502081554.5521-20-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PATCH v9 19/27] gdbstub: Implement generic set (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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Jon Doron --- gdbstub.c | 213 +++++++----------------------------------------------- 1 file changed, 25 insertions(+), 188 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 83ae8738cc..2fd0d66f4d 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1130,14 +1130,6 @@ static GDBThreadIdKind read_thread_id(const char *buf, const char **end_buf, return GDB_ONE_THREAD; } -static int is_query_packet(const char *p, const char *query, char separator) -{ - unsigned int query_len = strlen(query); - - return strncmp(p, query, query_len) == 0 && - (p[query_len] == '\0' || p[query_len] == separator); -} - /** * gdb_handle_vcont - Parses and handles a vCont packet. * returns -ENOTSUP if a command is unsupported, -EINVAL or -ERANGE if there is @@ -2232,18 +2224,28 @@ static void handle_gen_query(GdbCmdContext *gdb_ctx, void *user_ctx) } } +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; + } + + put_packet(gdb_ctx->s, ""); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { - CPUState *cpu; - GDBProcess *process; - CPUClass *cc; const char *p; - uint32_t pid, tid; - int ch, type; + 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 = NULL; trace_gdbstub_io_command(line_buf); @@ -2456,182 +2458,17 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } break; case 'Q': - /* parse any 'q' packets here */ - if (!strcmp(p,"qemu.sstepbits")) { - /* Query Breakpoint bit definitions */ - snprintf(buf, sizeof(buf), "ENABLE=%x,NOIRQ=%x,NOTIMER=%x", - SSTEP_ENABLE, - SSTEP_NOIRQ, - SSTEP_NOTIMER); - put_packet(s, buf); - break; - } else if (is_query_packet(p, "qemu.sstep", '=')) { - /* Display or change the sstep_flags */ - p += 10; - if (*p != '=') { - /* Display current setting */ - snprintf(buf, sizeof(buf), "0x%x", sstep_flags); - put_packet(s, buf); - break; - } - p++; - type = strtoul(p, (char **)&p, 16); - sstep_flags = type; - put_packet(s, "OK"); - break; - } else if (strcmp(p,"C") == 0) { - /* - * "Current thread" remains vague in the spec, so always return - * the first thread of the current process (gdb returns the - * first thread). - */ - cpu = 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") == 0) { - s->query_cpu = gdb_first_attached_cpu(s); - goto report_cpuinfo; - } else if (strcmp(p,"sThreadInfo") == 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 = gdb_next_attached_cpu(s, s->query_cpu); - } else - put_packet(s, "l"); - break; - } else if (strncmp(p,"ThreadExtraInfo,", 16) == 0) { - if (read_thread_id(p + 16, &p, &pid, &tid) == GDB_READ_THREAD_ERR) { - put_packet(s, "E22"); - break; - } - cpu = gdb_get_cpu(s, pid, tid); - if (cpu != NULL) { - cpu_synchronize_state(cpu); - - if (s->multiprocess && (s->process_num > 1)) { - /* Print the CPU model and name in multiprocess mode */ - ObjectClass *oc = object_get_class(OBJECT(cpu)); - const char *cpu_model = object_class_get_name(oc); - char *cpu_name = - object_get_canonical_path_component(OBJECT(cpu)); - len = 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 = 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") == 0) { - TaskState *ts = s->c_cpu->opaque; - - snprintf(buf, sizeof(buf), - "Text=" TARGET_ABI_FMT_lx ";Data=" TARGET_ABI_FMT_lx - ";Bss=" 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) == 0) { - int len = strlen(p + 5); - - if ((len % 2) != 0) { - put_packet(s, "E01"); - break; - } - len = len / 2; - hextomem(mem_buf, p + 5, len); - mem_buf[len++] = 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=%x", MAX_PACKET_LENGTH); - cc = CPU_GET_CLASS(first_cpu); - if (cc->gdb_core_xml_file != NULL) { - pstrcat(buf, sizeof(buf), ";qXfer:features:read+"); - } - - if (strstr(p, "multiprocess+")) { - s->multiprocess = true; - } - pstrcat(buf, sizeof(buf), ";multiprocess+"); - - put_packet(s, buf); - break; - } - if (strncmp(p, "Xfer:features:read:", 19) == 0) { - const char *xml; - target_ulong total_len; - - process = gdb_get_cpu_process(s, s->g_cpu); - cc = CPU_GET_CLASS(s->g_cpu); - if (cc->gdb_core_xml_file == NULL) { - goto unknown_command; - } - - gdb_has_xml = true; - p += 19; - xml = get_feature_xml(s, p, &p, process); - if (!xml) { - snprintf(buf, sizeof(buf), "E00"); - put_packet(s, buf); - break; - } - - if (*p == ':') - p++; - addr = strtoul(p, (char **)&p, 16); - if (*p == ',') - p++; - len = strtoul(p, (char **)&p, 16); - - total_len = strlen(xml); - if (addr > total_len) { - snprintf(buf, sizeof(buf), "E00"); - put_packet(s, buf); - break; - } - if (len > (MAX_PACKET_LENGTH - 5) / 2) - len = (MAX_PACKET_LENGTH - 5) / 2; - if (len < total_len - addr) { - buf[0] = 'm'; - len = memtox(buf + 1, xml + addr, len); - } else { - buf[0] = 'l'; - len = memtox(buf + 1, xml + addr, total_len - addr); - } - put_packet_binary(s, buf, len + 1, true); - break; - } - if (is_query_packet(p, "Attached", ':')) { - put_packet(s, GDB_ATTACHED); - break; + { + static const GdbCmdParseEntry gen_set_cmd_desc = { + .handler = handle_gen_set, + .cmd = "Q", + .cmd_startswith = 1, + .schema = "s0" + }; + cmd_parser = &gen_set_cmd_desc; } - /* Unrecognised 'q' command. */ - goto unknown_command; - + break; default: - unknown_command: /* put empty packet */ buf[0] = '\0'; put_packet(s, buf); From patchwork Thu May 2 08:15:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094073 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hGAW++dN"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vpM13SGMz9s55 for ; Thu, 2 May 2019 18:28:44 +1000 (AEST) Received: from localhost ([127.0.0.1]:47349 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM758-0005pO-EE for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:28:42 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6te-0003V1-BB for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6ta-0007yj-B5 for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:48 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:53881) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6tY-0007gt-BO for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:46 -0400 Received: by mail-wm1-x341.google.com with SMTP id q15so1477341wmf.3 for ; Thu, 02 May 2019 01:16:39 -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=NvRXYl/vjqrIbJL0BHzsmEe5eGi5MjJ6JeUBkCbtEUs=; b=hGAW++dNphmEM4sCUbSRvIoH0u+r41+sd7nmMYfGM1e370ZX4TfZPly+IIi6ha6Ti9 uHkoDIeaHGclEdiJfF+0VJp0A+YsTKvV5OT4/i2LSDcE8Ggl3n0WtyHPngBnY48L5Yxz H2qUyG5fl+LV01TX3CiPrZMJz/rsEEXTfaft1p7FDPEg7xAybCEpc2bvcSLZN5P0D0Wv kvsMYcnR+CElDBFlIXs63GO9qjWgNpkQo9zvrMpSMzuSeHTKxO/+vNqj7nGlGwwHxzGE JLRzv2CGg1fFiA3PqLt2hglbZePwNQNG+jwfxO+aFsqAuoS24P0fAmgjjyfskEpF5ZOg HaAQ== 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=NvRXYl/vjqrIbJL0BHzsmEe5eGi5MjJ6JeUBkCbtEUs=; b=thRieGEYUemvY5StpcQUcerpJ5sR7ltryyXMnzb4jx0xvhQEYzjHT2TL8wSZgWIFus erDmZ788MO3jPUurjoukpubZExeWvLh+5xK5FqBctx3LTcATuuBJMY9loVpE3m/eBI4A U47ThCRjOyxetS8jQwhnImKt7sLDLsXPI7v5iSJsEmwqycZg2p2/KoaPfEe5gr9F2St8 ZhCA7Ez2BZPdWs9kude5YNBVbuBZkN3Pg8XDBT6bBTDxS9DQJKKFQ4ud0rTX9YYLGQyX SxxdjewuEE+ooddxy8q+MrK9NSyprOeeb6Du/x4ezlzGiq9Z5GSpsBwB+yEvIgBzbWj4 unKQ== X-Gm-Message-State: APjAAAVDcsDpEEUIhIjkAKiiQTbMrsf4UHCLPASfGCGd+n4nAPGhDMMJ KgqlvPDvOgsP2Aim8NIlU+QFuydD X-Google-Smtp-Source: APXvYqzsb7UfgQXuITPyezrterGBVaGwZjxVx8+4IhCutl9KfMIE4RmBklg+eCntDHTRsuQReJszZg== X-Received: by 2002:a1c:4c09:: with SMTP id z9mr1309991wmf.87.1556784998784; Thu, 02 May 2019 01:16:38 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:38 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:47 +0300 Message-Id: <20190502081554.5521-21-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 Subject: [Qemu-devel] [PATCH v9 20/27] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Jon Doron --- gdbstub.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 2fd0d66f4d..d678191705 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2239,13 +2239,30 @@ static void handle_gen_set(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(gdb_ctx->s, ""); } +static void handle_target_halt(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + char thread_id[16]; + + /* TODO: Make this return the correct value for user-mode. */ + 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 and 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 = NULL; trace_gdbstub_io_command(line_buf); @@ -2257,15 +2274,14 @@ static int gdb_handle_packet(GDBState *s, const char *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_id))); - 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 = { + .handler = handle_target_halt, + .cmd = "?", + .cmd_startswith = 1 + }; + cmd_parser = &target_halted_cmd_desc; + } break; case 'c': { From patchwork Thu May 2 08:15:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094081 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Ocjw+b60"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vpVh3Yd7z9s3Z for ; Thu, 2 May 2019 18:35:24 +1000 (AEST) Received: from localhost ([127.0.0.1]:47450 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM7Ba-0003Cd-FP for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:35:22 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6tk-0003bX-7j for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6th-0008OW-Ce for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:55 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:50256) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6th-0007k4-1V for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:53 -0400 Received: by mail-wm1-x342.google.com with SMTP id p21so1486781wmc.0 for ; Thu, 02 May 2019 01:16:41 -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=PH0hXIwENcqo6TbPIzo2Qw9MFujZWmL0zJ/Tm+4JKGw=; b=Ocjw+b600EID3SmwmdlKFoILn6PyqIdLOu17mVLYrTPfq6e7z77r8FpScYh0F5vNpA 9NLH55MR3terbSYIQbynHQaGzCBT9nseDqeI8D7mzKYLnUDja8RqJCTxwKY66chdB0T6 9fZAxxK8YSJLxWmdD7S4+kNVyN6F9A2j5rfQNV/Yv+4sM02SpgulaHRRprHUMaiJqDnH FnrGAVM3QeHBg9VN4cSV8yTbW6hkvw+CktbPsJQDbV+FMl5z4RSSssvx6nw/6dloR/B7 UlGaqDTc3Q5P5OjxLNS1g8P/NES1AKgNn8RxvIjtvloKI382szoZFp7NyZ3nE53vW0/t RW7w== 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=PH0hXIwENcqo6TbPIzo2Qw9MFujZWmL0zJ/Tm+4JKGw=; b=OeRkGd8pRQtt0rjg1m6v8uAkJSlNXQ//VFaM5GDHoU+Y3X1lTcO987uVtQWHusWMrW QGih18oNTDK1kq2FBVr73w226HtLouN07FBziwppIEJsmg5VuFclE9DXC1ZylYvBHYSN MSyG8B1UptdO+feCB1gO7+RKQEe+N+XUk/YI67z4my0q3+1+kmVuOE374as4K6tOFF8l S4v65gTAhJBUn2xcnRWAJFKF5JoUf9zea1OKR3QJ16MvUwMYWhrtuHTAKIy+5FRUKAfE TP8MB09nqDmoOyodhB6e/zCInFAvXecZhq6przKkwSIH4Nt4zcqZrV9QL5vCMAxPtD0S cuIw== X-Gm-Message-State: APjAAAVzCd/SX1lCoI+gBUucxvQWkimHEGZD67whDLGGWXEPPnkvI9+w /c3Jg/Da/pxqM3RA/qPy2m9ynqGO X-Google-Smtp-Source: APXvYqwSNcbUr8dZAwuoXmAaQY+UGrayJvVJ264Bbn9tw26Vwq59Ur7Iz6w87iEicoufUevluyK6yw== X-Received: by 2002:a1c:4302:: with SMTP id q2mr1374998wma.28.1556785000126; Thu, 02 May 2019 01:16:40 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:39 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:48 +0300 Message-Id: <20190502081554.5521-22-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 Subject: [Qemu-devel] [PATCH v9 21/27] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Jon Doron Reviewed-by: Alex Bennée --- gdbstub.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index d678191705..8bdfae4b29 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2259,17 +2259,11 @@ static void handle_target_halt(GdbCmdContext *gdb_ctx, void *user_ctx) 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 = NULL; trace_gdbstub_io_command(line_buf); - p = line_buf; - ch = *p++; - switch(ch) { + switch (line_buf[0]) { case '!': put_packet(s, "OK"); break; @@ -2486,8 +2480,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) break; default: /* put empty packet */ - buf[0] = '\0'; - put_packet(s, buf); + put_packet(s, ""); break; } From patchwork Thu May 2 08:15:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094070 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="KXgsuRQd"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vpHt4Bl8z9s9T for ; Thu, 2 May 2019 18:26:02 +1000 (AEST) Received: from localhost ([127.0.0.1]:47313 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM72W-0002qm-Ew for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:26:00 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42699) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6te-0003V0-At for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6ta-0007z6-Cv for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:48 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:36600) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6tY-0007mD-Ej for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:46 -0400 Received: by mail-wr1-x444.google.com with SMTP id o4so2024719wra.3 for ; Thu, 02 May 2019 01:16:42 -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=0s6me8TS+YJwMJaLYgFa/gUYh4mdTLo/usW+gDFwuc4=; b=KXgsuRQdQojeqMmAJ6wkiSC1QotI7q+wigaTorSC8jpfYuHHwqAV+Zt1FW8eH1EL6i 37IqjBZ5MIz1ZJzgBOkkei8ZcL7H9Aw4ny3KFBsLKpvgSvRzRDCxjMl+cWJJ3skCzEA7 ptOj+hzkoPPIZM9e8GSaOgEVaW2uIKU2fhYUAsQ165WfsUJmMfz2HGDR2DuDU3S907nL tzo0XNFSHpRX7qByTS9QFT4qKHjfcXlOyuH4r9mbNxGpX3ol5GobmthfLZaR1JIiZCRg KplbRXGHIfsVsvgJ3F+nEmgdk0fvHVKb52eUT/yc39JfXPPqy4JQGhLUDISFYTVML+CF 4neQ== 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=0s6me8TS+YJwMJaLYgFa/gUYh4mdTLo/usW+gDFwuc4=; b=KA3e/J4ZKYj4cEm7LnjlFFGe6TLCkSm7yKLrwQCpPwOgWGxHpoxwD0Q7fETRqEwnHJ RtKRvQ3F/NckCgnzZFAOGhe9/weLPi7JooUClh39OB9t5t78lYxzW+vVi3e3ovoMujAQ eADToCp1yPh5RouL7uXV0lykE8mcpBFZdKashVCKuAUMqQXJEfYaJIEULFeZKIaTGw/F YOp5/xEPuvu4C4Eqz7E0wMfz2qGvYaxe2Rq5W4jPpln24ndQIGf4Ht5mzwy6ipTqM4bD aVofnA2/Rq6CDrtVIjFuYZm8uXxFCcnj4vVvGfGLSmGv3qugXRuMkw9TiXJbtxncr8hu E+LQ== X-Gm-Message-State: APjAAAUdbnfEVXrZR3pmvn/6+HEYxx1UeujU58oSTMX+f8ELzPr7kKQl aS2Bhvuv6GSK7Jopv6vA6WIrA+E+ X-Google-Smtp-Source: APXvYqxM7OIbbHRws0Pgz7QBsaiKNDV7LkYNLWY/tYmKUOge3EhNmy/mkMhCf9wl9YV4HQ8QDQbtiw== X-Received: by 2002:adf:f7cd:: with SMTP id a13mr1793293wrq.289.1556785001590; Thu, 02 May 2019 01:16:41 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:40 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:49 +0300 Message-Id: <20190502081554.5521-23-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PATCH v9 22/27] gdbstub: Implement generic query qemu.Supported 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" qemu.Supported query reply back with the supported qemu query/set commands (commands are seperated with a semicolon from each other). gdb> maint packet qqemu.Supported Signed-off-by: Jon Doron --- gdbstub.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index 8bdfae4b29..00c07d6ec0 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2127,6 +2127,11 @@ 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[] = { /* Order is important if has same prefix */ { @@ -2203,6 +2208,10 @@ static GdbCmdParseEntry gdb_gen_query_table[] = { .handler = handle_query_attached, .cmd = "Attached", }, + { + .handler = handle_query_qemu_supported, + .cmd = "qemu.Supported", + }, }; static void handle_gen_query(GdbCmdContext *gdb_ctx, void *user_ctx) From patchwork Thu May 2 08:15:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094076 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Irxp139Z"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vpNQ5Q87z9s55 for ; Thu, 2 May 2019 18:29:58 +1000 (AEST) Received: from localhost ([127.0.0.1]:47359 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM76K-0006wJ-KO for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:29:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6th-0003YP-6G for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6te-00085x-O9 for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:53 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:40660) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6te-0007ot-F5 for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:50 -0400 Received: by mail-wm1-x343.google.com with SMTP id h11so1376514wmb.5 for ; Thu, 02 May 2019 01:16:44 -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=DkxdB1SSP3ygac21G5Sl2UZoz/G9CYkw1Wrg+VlI4Ww=; b=Irxp139ZMKljG8THkEBhszOYzo3QX5Z7Y75xFX6M6UqhpBw04QkKvd6jKr8qEn4fpD Ochl4S5GDn1rA3mCphbXAETmJ64sCerkERiZKl71tTGnwTxwvIPfQ33LUjjP9wObzJVa gKsCvzj6r0jils+fbcUTPGgRb8CE2P+jAikp9U6j1Nv7/98FCBpbaC405cIbaOgpbApz Yukn70e1zx7vNUhDDKNiExUx3eMISHGmnDBFpHFtudP7ENVQJkFeRrb836YUUvTOjr9L J8LDR9Wx0Qhd0viY+qJck4DpnPMT9lWyfduFIQGVtS5zh6EYmBWGzwEop9sGEc3NFg+U +wWg== 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=DkxdB1SSP3ygac21G5Sl2UZoz/G9CYkw1Wrg+VlI4Ww=; b=eJo0SyX/hD+zXe27a+FW384bpmhNjfXfK74Yln+g9N9pvlzWQ/c3FdlXhyqLHkwOSB t/qduYKZ027677lQqYDhIl7uUysKgMfRKyI4+MxY7621ODk7Olq4EycSkinhDxuqHysZ voptm9iKmFle+V1fKmSsTsi6fGtix4nZRli3N8efZ22n4v2o7789qnGNcRbQWcfXKR2f tAzGFxSu4jc9CFMewhDJetOTwwPPzZdBafaXDMJ0MVINy1Wzp0EwEtYygAnNCz9Q+s5Q JGKxCKEC9yn+ZSUaLzGgDiMoBbqHBnMi6TLcSKQhIIccsMFl6vciKzhuOi56BnERPRpd Wf+Q== X-Gm-Message-State: APjAAAVpXPkXIefnl6f5y2xAwIhUrBvSEc1q6AZGWvVOZASa7Ea22qCj xZcU/vDKSXYz7d0xdRmYm6SXuJup X-Google-Smtp-Source: APXvYqww2nVnlKoSjNaZp0o8YMmbUNXoDxJroOI04BLexpfBg+24La05NLr35TpssCL0A365sUVC+Q== X-Received: by 2002:a1c:67c1:: with SMTP id b184mr1344235wmc.12.1556785003232; Thu, 02 May 2019 01:16:43 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:42 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:50 +0300 Message-Id: <20190502081554.5521-24-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PATCH v9 23/27] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- gdbstub.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 3 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 00c07d6ec0..88ff6224e6 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -46,11 +46,23 @@ #define GDB_ATTACHED "1" #endif +static int phy_memory_mode; + static inline int target_memory_rw_debug(CPUState *cpu, target_ulong addr, uint8_t *buf, int len, bool is_write) { - CPUClass *cc = CPU_GET_CLASS(cpu); + CPUClass *cc; + if (phy_memory_mode) { + if (is_write) { + cpu_physical_memory_write(addr, buf, len); + } else { + cpu_physical_memory_read(addr, buf, len); + } + return 0; + } + + cc = CPU_GET_CLASS(cpu); if (cc->memory_rw_debug) { return cc->memory_rw_debug(cpu, addr, buf, len, is_write); } @@ -2129,7 +2141,29 @@ static void handle_query_attached(GdbCmdContext *gdb_ctx, void *user_ctx) static void handle_query_qemu_supported(GdbCmdContext *gdb_ctx, void *user_ctx) { - put_packet(gdb_ctx->s, "sstepbits;sstep"); + put_packet(gdb_ctx->s, "sstepbits;sstep;PhyMemMode"); +} + +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 *user_ctx) +{ + if (!gdb_ctx->num_params) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + if (!gdb_ctx->params[0].val_ul) { + phy_memory_mode = 0; + } else { + phy_memory_mode = 1; + } + put_packet(gdb_ctx->s, "OK"); } static GdbCmdParseEntry gdb_gen_query_set_common_table[] = { @@ -2212,6 +2246,20 @@ static GdbCmdParseEntry gdb_gen_query_table[] = { .handler = handle_query_qemu_supported, .cmd = "qemu.Supported", }, + { + .handler = handle_query_qemu_phy_mem_mode, + .cmd = "qemu.PhyMemMode", + }, +}; + +static GdbCmdParseEntry gdb_gen_set_table[] = { + /* Order is important if has same prefix */ + { + .handler = handle_set_qemu_phy_mem_mode, + .cmd = "qemu.PhyMemMode:", + .cmd_startswith = 1, + .schema = "l0" + }, }; static void handle_gen_query(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -2245,7 +2293,11 @@ static void handle_gen_set(GdbCmdContext *gdb_ctx, void *user_ctx) return; } - put_packet(gdb_ctx->s, ""); + 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 void handle_target_halt(GdbCmdContext *gdb_ctx, void *user_ctx) From patchwork Thu May 2 08:15:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094080 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="piynL98K"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vpTS5Srqz9s3Z for ; Thu, 2 May 2019 18:34:20 +1000 (AEST) Received: from localhost ([127.0.0.1]:47441 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM7AY-0002IU-LT for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:34:18 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6ti-0003ZJ-2Y for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6th-0008Mo-2T for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:54 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:45388) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6te-0007vw-Uv for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:52 -0400 Received: by mail-wr1-x442.google.com with SMTP id s15so1967051wra.12 for ; Thu, 02 May 2019 01:16:45 -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=AI2gF6CcF107YLL+Yoq5vMjKHAR9DjS56SI4WgjZi0M=; b=piynL98KoF2lYG2pnxpAFEV884EF7MppJxl1Y7dVEezW5SS50WPdjaK7XdXXkwMWnl UVA/Sd1PEZKl3i0nsIJp5FAdZ28PZG6Ekd/S7vqkKBYyzqnzD5EonhncOV7Bg2ztIle7 2m5m/4OmycAWbyDIHMm8fLJToty5h+mNa+lHSk8O629TyR0Gi5FpiVxI2rQtPDX2mKDr PLf2qKJ766iFOP0wjuznRCFEq4UnjASbkbMVAxI3t8OSjR1FkATBZ6UkEjOdtLToxQ3V Bu1jWhl4mq99EQl91OYoUnoWTxXVKBAEXocaDMuV/2TeddVkgEA8UgbrdIaw3F5bYEXU E6Jg== 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=AI2gF6CcF107YLL+Yoq5vMjKHAR9DjS56SI4WgjZi0M=; b=YmnpXKDmZ7P6IUaR2cuSjQRcoQASl0+8Pz/GkD66MYRnysrJ8QYGK34a+L/4IMIDew ow3wpbfY9IkZvi0bZFTL9B7vFpQ/8RZcBuEJ3rNuzu73CxEZ0IGNVTQvUOuh52N4zYJC hP44Sk7kPPfw82edhs87aIL45NZmHXiI4vEuvU6SlwI//6LTwAeNN6cKrBxbXckCxAo6 EdbtawJRGBNjdfwYNPKI3MJIOc2f85LPvPT+NoQUexji6tDEXPINnPaJCEUybmGQehnP 68gu4A7O27NCbt8SHuhoCFoQEWS8xsFGON7MASV8pCbGMxgFD8u8KlBv7iIngvJuxwJy jK1g== X-Gm-Message-State: APjAAAVhZJFZCwlGtw1We0PK6QZtksjU6P1mEbhdqY7oSw05PC21H2ui awVxr6V9zCnCTdOAi4gKEzbbG3dh X-Google-Smtp-Source: APXvYqw38V7g47CQb4Wj5hbDYky7H0vByjEcEoKYEzUx7GrvdHiaH7/y0z4E9wszCshi/1kCE/z7Kg== X-Received: by 2002:a5d:4acc:: with SMTP id y12mr1756570wrs.234.1556785004744; Thu, 02 May 2019 01:16:44 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:44 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:51 +0300 Message-Id: <20190502081554.5521-25-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PATCH v9 24/27] gdbstub: Add another handler for setting qemu.sstep 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Follow GDB general query/set packet conventions, qemu.sstep can now be set with the following command as well: gdb> maint packet Qqemu.sstep:Value Signed-off-by: Jon Doron --- gdbstub.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index 88ff6224e6..34da10260d 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2260,6 +2260,12 @@ static GdbCmdParseEntry gdb_gen_set_table[] = { .cmd_startswith = 1, .schema = "l0" }, + { + .handler = handle_set_qemu_sstep, + .cmd = "qemu.sstep:", + .cmd_startswith = 1, + .schema = "l0" + }, }; static void handle_gen_query(GdbCmdContext *gdb_ctx, void *user_ctx) From patchwork Thu May 2 08:15:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094079 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="grpkV6ns"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vpRs2XVPz9s55 for ; Thu, 2 May 2019 18:32:57 +1000 (AEST) Received: from localhost ([127.0.0.1]:47415 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM79D-00010F-8K for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:32:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42973) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6tk-0003cU-PN for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6th-0008OG-9j for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:56 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:38474) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6tg-000805-Vm for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:53 -0400 Received: by mail-wm1-x341.google.com with SMTP id w15so1392460wmc.3 for ; Thu, 02 May 2019 01:16:47 -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=Fq+y9Y8taPmtsyd8oOc7f9ZWDD3UWEkWOvqVLG/Lt40=; b=grpkV6nsRirFoFebYjC6MxNOtEAlrmjk4xmZdRENo8+NFdj8E4YmUbEy6w8x5uWIiB fVeL1722iLSrmD/gRUaJ5BijubBeonzVXGiFZ615e8QWTxuyLCgFhaoY1xR8BwdFGJvB tUOo5pFcTXd5grPFqmLkpM3kK1fHcJIxRvFt77VgPYN8ecwBrmH4k09VmX2jCI/6MjXh g2zjnN3HMcFroQGQoZy316iUxDJdzfU1OMPxTrYWByWK5DqVh1UYR+/BzD0+hDX0+i6S G5a7/FMKtcnmMGUURDoKSJAiQwAByr4wHgmlKnlDWmfRkQGWK64RqVs9PCheLVUNQoRJ 9ssw== 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=Fq+y9Y8taPmtsyd8oOc7f9ZWDD3UWEkWOvqVLG/Lt40=; b=TwEisCo3gIihh+PT0UpkoPcLBgMzy8xGc+MeSp7NvetJ/EV1jcJC1/4q76TxbnZykG dQU6TWmAt6V6h/k1bIlcaRiikYYtHf9Mp7axiMY6DJMwSF6aWeqBjkWg99P6aVtYFmWE G3KKPVW3aMObeo3+AyLhxSM2wH1J3BY5x+8cooAq5L/R107am7r9tnnoJ6ZciyFdGZ2T Lqwl7hcklAjKEsu5RBWw+2Vp18cnBcy24ZPwxpCBOOVYN8TDi14iKFFdDrxWpZr2B4RB akmQERONzcMIGxSJRwWZkPjn7FFgp/XqO2pIJSaP+yqXovgM2qN/9XqdbPU0cMUB3He/ HRsQ== X-Gm-Message-State: APjAAAXdtYfWPpOcU05KsnDq4lL2HEEWllupkytt19jxPAZnLZSlpZVf ICy12wukU5Q/iQR3m6F864pYDk83 X-Google-Smtp-Source: APXvYqxai+JM1yRaeKDe8Ko1NKXeAr/fb9HVj9Du0pq7EoYCTb3hrMeRJqOs2kgT5p7pp/5UpJw9gg== X-Received: by 2002:a1c:a00f:: with SMTP id j15mr1308089wme.148.1556785006192; Thu, 02 May 2019 01:16:46 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:45 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:52 +0300 Message-Id: <20190502081554.5521-26-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 Subject: [Qemu-devel] [PATCH v9 25/27] kvm: Add API to read/write a CPU MSR value 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Jon Doron --- accel/kvm/kvm-all.c | 39 +++++++++++++++++++++++++++++++++++++++ include/sysemu/kvm.h | 2 ++ 2 files changed, 41 insertions(+) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 524c4ddfbd..35207d910b 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2444,6 +2444,45 @@ void kvm_remove_all_breakpoints(CPUState *cpu) } #endif /* !KVM_CAP_SET_GUEST_DEBUG */ +int kvm_arch_read_msr(CPUState *cpu, uint32_t index, uint64_t *value) +{ + struct { + struct kvm_msrs info; + struct kvm_msr_entry entries[1]; + } msr_data; + int ret; + + msr_data.info.nmsrs = 1; + msr_data.entries[0].index = index; + ret = kvm_vcpu_ioctl(cpu, KVM_GET_MSRS, &msr_data); + if (ret < 0) { + return ret; + } + + *value = msr_data.entries[0].data; + return 0; +} + +int kvm_arch_write_msr(CPUState *cpu, uint32_t index, uint64_t value) +{ + struct { + struct kvm_msrs info; + struct kvm_msr_entry entries[1]; + } msr_data; + int ret; + + msr_data.info.nmsrs = 1; + msr_data.entries[0].index = index; + msr_data.entries[0].reserved = 0; + msr_data.entries[0].data = value; + ret = kvm_vcpu_ioctl(cpu, KVM_SET_MSRS, &msr_data); + if (ret < 0) { + return ret; + } + + return 0; +} + static int kvm_set_signal_mask(CPUState *cpu, const sigset_t *sigset) { KVMState *s = kvm_state; diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index a6d1cd190f..409b1a5444 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -462,6 +462,8 @@ int kvm_vm_check_extension(KVMState *s, unsigned int extension); uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function, uint32_t index, int reg); uint32_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index); +int kvm_arch_read_msr(CPUState *cpu, uint32_t index, uint64_t *value); +int kvm_arch_write_msr(CPUState *cpu, uint32_t index, uint64_t value); void kvm_set_sigmask_len(KVMState *s, unsigned int sigmask_len); From patchwork Thu May 2 08:15:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094082 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JVE+MA8u"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vpZS4LHFz9sB8 for ; Thu, 2 May 2019 18:38:40 +1000 (AEST) Received: from localhost ([127.0.0.1]:47527 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM7Ek-00061Q-KG for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:38:38 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6th-0003YR-7K for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6te-00087a-WB for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:52 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:53885) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6te-000814-O4 for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:50 -0400 Received: by mail-wm1-x344.google.com with SMTP id q15so1477857wmf.3 for ; Thu, 02 May 2019 01:16:48 -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=V970oHIFnq0Kvqk/KuBLurpV9POQpj8H67OjZYl9GKE=; b=JVE+MA8uHJmdGb0pXW0ZWcTkiPz76nlcXxZIt9B+wQJeN34fekZRHrB43J6t3ylSeE pl02kidL0wG8+1LjihpdMv02f+lxBXcw9VljMWUnASITh3bnGsKdN6KX0jH13c3XSWyF lultsoYIQV5LWtZDmiVYMa5n2QAIWJwF2z6PBp5hD9j4/NHWGXGPTHrSxmvXJSqEZpH8 Soy84b5RL5v5EgdnK8pYENjnG8dg9vURT4Q/D0h6R/MJ9UEuo5m2pmVf8COvFpG5zwRG w5mkSNN8Fc2tSKKtV0zdLfbrhXFjclG3daDnrJUMIfdds5n8p8yVmEiFdWOW4fN79cKb vcPA== 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=V970oHIFnq0Kvqk/KuBLurpV9POQpj8H67OjZYl9GKE=; b=E2yTDhGt6PtWGbC3Vn+/BSpkQ7fSYqOwK73GksZWv0zHqr0h8PvIqtMR4dc0bL2CAA TcqmXsXzLBXoZz+FPT70TKkCyfT9GHl7HG5feUQNzt3NIb7czLs8tooF7UeHXhEXFUUH EBEUsAFbRFDx9lTX5jYb8djpJusTkmwNRIQvxS9NjIFwZf+mLInPQa08rMpmghlUsDFa iGIhnf66YzK02RzSvJgZmgmZjLnM8CG6JlcpDCTqJeeeGmRPnQDD30msMuaS+Rrt6U+f a8MipxuNCh49vmWm+TyzN4w1c0F1wU4PusGLaM2nS7NFKSh7f2gJptv85wHF3EshmnWf ZVow== X-Gm-Message-State: APjAAAWL5t1xaazwpsNhh9QUdFaiIOZBYtYJM/dcyiylse951Ze1w3nq ao1njnugbNeQQKbzbRS0yyA9H4Ya X-Google-Smtp-Source: APXvYqy90wpaXB9zz/QH11hiJ4+j4LK3wJ8/RuPYRKEjsGL8vnxtEwz6bQj6vU/REiXLUU3kYzof6A== X-Received: by 2002:a7b:c00e:: with SMTP id c14mr1318197wmb.110.1556785007725; Thu, 02 May 2019 01:16:47 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:47 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:53 +0300 Message-Id: <20190502081554.5521-27-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 Subject: [Qemu-devel] [PATCH v9 26/27] gdbstub: Add support to read a MSR for KVM target 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" gdb> maint packet qqemu.kvm.Rdmsr:MsrIndex Signed-off-by: Jon Doron --- gdbstub.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/gdbstub.c b/gdbstub.c index 34da10260d..f48c3a2b5f 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2141,7 +2141,14 @@ static void handle_query_attached(GdbCmdContext *gdb_ctx, void *user_ctx) static void handle_query_qemu_supported(GdbCmdContext *gdb_ctx, void *user_ctx) { - put_packet(gdb_ctx->s, "sstepbits;sstep;PhyMemMode"); + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), + "sstepbits;sstep;PhyMemMode"); + + if (kvm_enabled()) { + pstrcat(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), ";kvm.Rdmsr"); + } + + put_packet(gdb_ctx->s, gdb_ctx->str_buf); } static void handle_query_qemu_phy_mem_mode(GdbCmdContext *gdb_ctx, @@ -2166,6 +2173,29 @@ static void handle_set_qemu_phy_mem_mode(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(gdb_ctx->s, "OK"); } +static void handle_query_kvm_read_msr(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + uint64_t msr_val; + + if (!kvm_enabled()) { + return; + } + + if (!gdb_ctx->num_params) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + if (kvm_arch_read_msr(gdbserver_state->c_cpu, gdb_ctx->params[0].val_ul, + &msr_val)) { + put_packet(gdb_ctx->s, "E00"); + return; + } + + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "0x%" PRIx64, msr_val); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + static GdbCmdParseEntry gdb_gen_query_set_common_table[] = { /* Order is important if has same prefix */ { @@ -2250,6 +2280,12 @@ static GdbCmdParseEntry gdb_gen_query_table[] = { .handler = handle_query_qemu_phy_mem_mode, .cmd = "qemu.PhyMemMode", }, + { + .handler = handle_query_kvm_read_msr, + .cmd = "qemu.kvm.Rdmsr:", + .cmd_startswith = 1, + .schema = "l0" + }, }; static GdbCmdParseEntry gdb_gen_set_table[] = { From patchwork Thu May 2 08:15:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094096 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gHWAX6VN"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vpfP4HxYz9sBV for ; Thu, 2 May 2019 18:42:04 +1000 (AEST) Received: from localhost ([127.0.0.1]:47589 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM7Hz-0000Ye-UC for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:41:59 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42978) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6tk-0003cY-Rb for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6th-0008Oo-Du for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:56 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:35259) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6th-0008EY-1X for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:53 -0400 Received: by mail-wr1-x441.google.com with SMTP id f7so2034714wrs.2 for ; Thu, 02 May 2019 01:16:52 -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=IQ+Z9R6NydncJMKRI0TwB1Gcuq7KLY744W/ZlSezhlU=; b=gHWAX6VNFtWqbR/rCkEIGTs4FXbsFANrgE0ZljIZf4DSTjutF2IQsA2zA/17uDVPG+ NA2q/6Cg5bKcv42S6eDJZ8kcgnS+W9jLOcYdazQgw4tTQhZkqWmS6Mz2X1cylDVV8pTR Z9SXKFkI28fHudGv4DZSy+sAvVPSv/uq7BQN1/r6/DFjRq+9FtdE1ms+VrfNE2bltqOL VqVMJ5ygkTFOP7dT91o/+WLuWLDmLlEHWiXRhO2bUr3j5a/YKf5fLwZXA45NHWFkqODD kyD/MEi0fJuJZaVJRL96/0fEQc4h4/s54ID4W6Ym9riIWRuwEFs6SNDml1VWmgwWymkh EI7A== 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=IQ+Z9R6NydncJMKRI0TwB1Gcuq7KLY744W/ZlSezhlU=; b=QC1ukT1k1DEK6NJRk00T8zLR/mSkXHw+Av1S06BS7oPA5coxWV9gOoFhsxqB+ElREu t9NUK6lOH+ZldFaUPlRE3jwq8kJxCoSzecjasbB+GS6eSK2KYbjOyoKVQSmL7jLm4/Qd y4bLNtP47/U1ZYeTxIg7bWimuAQyjdpARMHVkhYn+twlXkeyYbYEY30umZAcbgMFNqh8 Hws4mArXzWWmi/70mv4f8QQ7r5pgy/4ghzNAqIdBf7OadSSRgiJX4Dww1iN/XriZ3fiU EkArblD/Itj9k9Jk4K1aJuiziuAyZ1mnGo/FTlMRHXC3SRpb4uhYCGff/4AJwYJVhoP6 8Yew== X-Gm-Message-State: APjAAAXXzN38hCX4/67BmvnMQXMM+a/JVyWP0U679Vk3IFwoG7TPJ1S+ Vp4atDXT1qp22K0rKnd4diov0quU X-Google-Smtp-Source: APXvYqytfjUxf8Z1vZ0yv0EDziDtIlPnFjJOJPPleMUewruz/fwDuSv7KxIk9ilBAF9aDVl0bCFgYA== X-Received: by 2002:a5d:4dc1:: with SMTP id f1mr1753355wru.300.1556785010899; Thu, 02 May 2019 01:16:50 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:50 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:54 +0300 Message-Id: <20190502081554.5521-28-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PATCH v9 27/27] gdbstub: Add support to write a MSR for KVM target 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" gdb> maint packet Qqemu.kvm.Wrmsr:MsrIndex,Value Signed-off-by: Jon Doron --- gdbstub.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/gdbstub.c b/gdbstub.c index f48c3a2b5f..a434a3749e 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2145,7 +2145,8 @@ static void handle_query_qemu_supported(GdbCmdContext *gdb_ctx, void *user_ctx) "sstepbits;sstep;PhyMemMode"); if (kvm_enabled()) { - pstrcat(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), ";kvm.Rdmsr"); + pstrcat(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), + ";kvm.Rdmsr;kvm.Wrmsr"); } put_packet(gdb_ctx->s, gdb_ctx->str_buf); @@ -2196,6 +2197,26 @@ static void handle_query_kvm_read_msr(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(gdb_ctx->s, gdb_ctx->str_buf); } +static void handle_set_kvm_write_msr(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (!kvm_enabled()) { + return; + } + + if (gdb_ctx->num_params < 2) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + if (kvm_arch_write_msr(gdbserver_state->c_cpu, gdb_ctx->params[0].val_ul, + gdb_ctx->params[1].val_ull)) { + put_packet(gdb_ctx->s, "E00"); + return; + } + + put_packet(gdb_ctx->s, "OK"); +} + static GdbCmdParseEntry gdb_gen_query_set_common_table[] = { /* Order is important if has same prefix */ { @@ -2302,6 +2323,12 @@ static GdbCmdParseEntry gdb_gen_set_table[] = { .cmd_startswith = 1, .schema = "l0" }, + { + .handler = handle_set_kvm_write_msr, + .cmd = "qemu.kvm.Wrmsr:", + .cmd_startswith = 1, + .schema = "l,L0" + }, }; static void handle_gen_query(GdbCmdContext *gdb_ctx, void *user_ctx)