summary refs log tree commit diff stats
path: root/gdbstub/gdbstub.c
diff options
context:
space:
mode:
authorGustavo Romero <gustavo.romero@linaro.org>2024-07-05 09:40:44 +0100
committerAlex Bennée <alex.bennee@linaro.org>2024-07-05 12:35:23 +0100
commit2be4d5db1e50f5aabdeea6d1e63ef75cccd0bbdb (patch)
tree1ed2c76f8b69da757ef1104db39ecfed61f0132a /gdbstub/gdbstub.c
parent3ce0fc57a0e7d528ce0435c93205f9f6558c38ff (diff)
downloadfocaccia-qemu-2be4d5db1e50f5aabdeea6d1e63ef75cccd0bbdb.tar.gz
focaccia-qemu-2be4d5db1e50f5aabdeea6d1e63ef75cccd0bbdb.zip
gdbstub: Pass CPU context to command handler
Allow passing the current CPU context to command handlers via user_ctx
when the handler requires it.

Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-Id: <20240628050850.536447-9-gustavo.romero@linaro.org>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240705084047.857176-38-alex.bennee@linaro.org>
Diffstat (limited to 'gdbstub/gdbstub.c')
-rw-r--r--gdbstub/gdbstub.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
index b1ca253f97..5c1612ed2a 100644
--- a/gdbstub/gdbstub.c
+++ b/gdbstub/gdbstub.c
@@ -938,6 +938,7 @@ static bool process_string_cmd(const char *data,
 
     for (i = 0; i < num_cmds; i++) {
         const GdbCmdParseEntry *cmd = &cmds[i];
+        void *user_ctx = NULL;
         g_assert(cmd->handler && cmd->cmd);
 
         if ((cmd->cmd_startswith && !startswith(data, cmd->cmd)) ||
@@ -952,8 +953,12 @@ static bool process_string_cmd(const char *data,
             }
         }
 
+        if (cmd->need_cpu_context) {
+            user_ctx = (void *)gdbserver_state.g_cpu;
+        }
+
         gdbserver_state.allow_stop_reply = cmd->allow_stop_reply;
-        cmd->handler(params, NULL);
+        cmd->handler(params, user_ctx);
         return true;
     }