All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jon Doron <arilou@gmail.com>
To: qemu-devel@nongnu.org
Cc: Jon Doron <arilou@gmail.com>
Subject: [Qemu-devel] [PATCH v4 13/20] gdbstub: Implement write all registers (G pkt) with new infra
Date: Wed, 24 Apr 2019 21:45:53 +0300	[thread overview]
Message-ID: <20190424184600.8445-13-arilou@gmail.com> (raw)
In-Reply-To: <20190424184600.8445-1-arilou@gmail.com>

Signed-off-by: Jon Doron <arilou@gmail.com>
---
 gdbstub.c | 41 +++++++++++++++++++++++++++++++----------
 1 file changed, 31 insertions(+), 10 deletions(-)

diff --git a/gdbstub.c b/gdbstub.c
index af37222034..084c688f75 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1744,6 +1744,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;
@@ -1755,7 +1778,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;
 
     trace_gdbstub_io_command(line_buf);
@@ -1920,16 +1942,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 GdbCmdParseEntry write_all_regs_cmd_desc = {
+                .handler = handle_write_all_regs,
+                .cmd = "G",
+                .cmd_startswith = 1,
+                .schema = "s0"
+            };
+            process_string_cmd(s, NULL, line_buf, &write_all_regs_cmd_desc, 1);
         }
-        put_packet(s, "OK");
         break;
     case 'm':
         {
-- 
2.20.1

  parent reply	other threads:[~2019-04-24 18:58 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-24 18:45 [Qemu-devel] [PATCH v4 01/20] gdbstub: Add infrastructure to parse cmd packets Jon Doron
2019-04-24 18:45 ` [Qemu-devel] [PATCH v4 02/20] gdbstub: Implement deatch (D pkt) with new infra Jon Doron
2019-04-24 18:45 ` [Qemu-devel] [PATCH v4 03/20] gdbstub: Implement thread_alive (T " Jon Doron
2019-04-24 18:45 ` [Qemu-devel] [PATCH v4 04/20] gdbstub: Implement continue (c " Jon Doron
2019-04-24 18:45 ` [Qemu-devel] [PATCH v4 05/20] gdbstub: Implement continue with signal (C " Jon Doron
2019-04-24 18:45 ` [Qemu-devel] [PATCH v4 06/20] gdbstub: Implement set_thread (H " Jon Doron
2019-04-24 18:45 ` [Qemu-devel] [PATCH v4 07/20] gdbstub: Implement insert breakpoint (Z " Jon Doron
2019-04-24 18:45 ` [Qemu-devel] [PATCH v4 08/20] gdbstub: Implement remove breakpoint (z " Jon Doron
2019-04-24 18:45 ` [Qemu-devel] [PATCH v4 09/20] gdbstub: Implement set register (P " Jon Doron
2019-04-24 18:45 ` [Qemu-devel] [PATCH v4 10/20] gdbstub: Implement get register (p " Jon Doron
2019-04-24 18:45 ` [Qemu-devel] [PATCH v4 11/20] gdbstub: Implement write memory (M " Jon Doron
2019-04-24 18:45 ` [Qemu-devel] [PATCH v4 12/20] gdbstub: Implement read memory (m " Jon Doron
2019-04-24 18:45 ` Jon Doron [this message]
2019-04-24 18:45 ` [Qemu-devel] [PATCH v4 14/20] gdbstub: Implement read all registers (g " Jon Doron
2019-04-24 18:45 ` [Qemu-devel] [PATCH v4 15/20] gdbstub: Implement file io (F " Jon Doron
2019-04-24 18:45 ` [Qemu-devel] [PATCH v4 16/20] gdbstub: Implement step (s " Jon Doron
2019-04-24 18:45 ` [Qemu-devel] [PATCH v4 17/20] gdbstub: Implement v commands " Jon Doron
2019-04-24 18:45 ` [Qemu-devel] [PATCH v4 18/20] gdbstub: Implement generic query (q pkt) " Jon Doron
2019-04-24 18:45 ` [Qemu-devel] [PATCH v4 19/20] gdbstub: Implement generic set (Q " Jon Doron
2019-04-24 18:46 ` [Qemu-devel] [PATCH v4 20/20] gdbstub: Refactor parse handle packet to work with a static array Jon Doron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190424184600.8445-13-arilou@gmail.com \
    --to=arilou@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.