[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 37/40] gdbstub: Pass CPU context to command handler
From: |
Manos Pitsidianakis |
Subject: |
Re: [PATCH v2 37/40] gdbstub: Pass CPU context to command handler |
Date: |
Fri, 5 Jul 2024 13:08:30 +0300 |
On Fri, 5 Jul 2024 at 11:47, Alex Bennée <alex.bennee@linaro.org> wrote:
>
> From: Gustavo Romero <gustavo.romero@linaro.org>
>
> 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>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> Message-Id: <20240628050850.536447-9-gustavo.romero@linaro.org>
> ---
> include/gdbstub/commands.h | 3 +++
> gdbstub/gdbstub.c | 7 ++++++-
> 2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/include/gdbstub/commands.h b/include/gdbstub/commands.h
> index e51f276b40..f3058f9dda 100644
> --- a/include/gdbstub/commands.h
> +++ b/include/gdbstub/commands.h
> @@ -54,6 +54,8 @@ typedef union GdbCmdVariant {
> * "stop reply" packet. The list of commands that accept such response is
> * defined at the GDB Remote Serial Protocol documentation. See:
> *
> https://sourceware.org/gdb/onlinedocs/gdb/Stop-Reply-Packets.html#Stop-Reply-Packets.
> + *
> + * @need_cpu_context: Pass current CPU context to command handler via
> user_ctx.
> */
> typedef struct GdbCmdParseEntry {
> GdbCmdHandler handler;
> @@ -61,6 +63,7 @@ typedef struct GdbCmdParseEntry {
> bool cmd_startswith;
> const char *schema;
> bool allow_stop_reply;
> + bool need_cpu_context;
> } GdbCmdParseEntry;
>
> /**
> 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;
> }
>
> --
> 2.39.2
>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
- [PATCH v2 11/40] tests/tcg/aarch64: Do not use x constraint, (continued)
- [PATCH v2 11/40] tests/tcg/aarch64: Do not use x constraint, Alex Bennée, 2024/07/05
- [PATCH v2 31/40] gdbstub: Move GdbCmdParseEntry into a new header file, Alex Bennée, 2024/07/05
- [PATCH v2 12/40] tests/tcg/aarch64: Add -fno-integrated-as for sme, Alex Bennée, 2024/07/05
- [PATCH v2 27/40] plugins: Ensure vCPU index is assigned in init/exit hooks, Alex Bennée, 2024/07/05
- [PATCH v2 29/40] accel/tcg: Move qemu_plugin_vcpu_init__async() to plugins/, Alex Bennée, 2024/07/05
- [PATCH v2 28/40] plugins: Free CPUPluginState before destroying vCPU state, Alex Bennée, 2024/07/05
- [PATCH v2 30/40] gdbstub: Clean up process_string_cmd, Alex Bennée, 2024/07/05
- [PATCH v2 16/40] tests/tcg/arm: Manually register allocate half-precision numbers, Alex Bennée, 2024/07/05
- [PATCH v2 39/40] gdbstub: Add support for MTE in user mode, Alex Bennée, 2024/07/05
- [PATCH v2 37/40] gdbstub: Pass CPU context to command handler, Alex Bennée, 2024/07/05
- Re: [PATCH v2 37/40] gdbstub: Pass CPU context to command handler,
Manos Pitsidianakis <=
- [PATCH v2 35/40] target/arm: Factor out code for setting MTE TCF0 field, Alex Bennée, 2024/07/05
- [PATCH v2 25/40] plugins/lockstep: mention the one-insn-per-tb option, Alex Bennée, 2024/07/05
- [PATCH v2 19/40] linux-user/main: Suppress out-of-range comparison warning for clang, Alex Bennée, 2024/07/05
- [PATCH v2 34/40] target/arm: Make some MTE helpers widely available, Alex Bennée, 2024/07/05
- [PATCH v2 32/40] gdbstub: Add support for target-specific stubs, Alex Bennée, 2024/07/05
- [PATCH v2 26/40] plugins/lockstep: clean-up output, Alex Bennée, 2024/07/05
- [PATCH v2 24/40] plugins/lockstep: make mixed-mode safe, Alex Bennée, 2024/07/05
- [PATCH v2 14/40] tests/tcg/arm: Drop -N from LDFLAGS, Alex Bennée, 2024/07/05