From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: Gustavo Romero <gustavo.romero@linaro.org>,
qemu-devel@nongnu.org, richard.henderson@linaro.org,
peter.maydell@linaro.org
Subject: Re: [PATCH v5 7/9] gdbstub: Make get cpu and hex conversion functions non-internal
Date: Thu, 27 Jun 2024 14:26:17 +0200 [thread overview]
Message-ID: <b7a9150f-3271-456b-a4fd-05d77107155a@linaro.org> (raw)
In-Reply-To: <874j9eprwd.fsf@draig.linaro.org>
On 27/6/24 13:05, Alex Bennée wrote:
> Philippe Mathieu-Daudé <philmd@linaro.org> writes:
>
>> On 27/6/24 06:13, Gustavo Romero wrote:
>>> Make the gdb_first_attached_cpu and gdb_hextomem non-internal so they
>>> are not confined to use only in gdbstub.c.
>>> Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
>>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>>> ---
>>> gdbstub/internals.h | 2 --
>>> include/exec/gdbstub.h | 5 +++++
>>> include/gdbstub/commands.h | 6 ++++++
>>> 3 files changed, 11 insertions(+), 2 deletions(-)
>>
>>
>>> diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h
>>> index 1bd2c4ec2a..77e5ec9a5b 100644
>>> --- a/include/exec/gdbstub.h
>>> +++ b/include/exec/gdbstub.h
>>> @@ -135,4 +135,9 @@ void gdb_set_stop_cpu(CPUState *cpu);
>>> /* in gdbstub-xml.c, generated by scripts/feature_to_c.py */
>>> extern const GDBFeature gdb_static_features[];
>>> +/**
>>> + * Return the first attached CPU
>>> + */
>>> +CPUState *gdb_first_attached_cpu(void);
>>
>> Alex, it seems dubious to expose the API like that.
>>
>> IMHO GdbCmdHandler should take a GDBRegisterState argument,
>> then this would become:
>>
>> CPUState *gdb_first_attached_cpu(GDBRegisterState *s);
>
> Maybe instead of exposing this we can use user_ctx for something? If we
> look at handle_set_reg/handle_get_reg we can see that passes down
> gdbserver_state.g_cpu down to the eventual helpers. We could define
> something like:
>
> --8<---------------cut here---------------start------------->8---
> fixups to avoid get_first_cpu()
>
> 5 files changed, 25 insertions(+), 18 deletions(-)
> gdbstub/internals.h | 1 +
> include/exec/gdbstub.h | 5 -----
> include/gdbstub/commands.h | 3 +++
> gdbstub/gdbstub.c | 7 ++++++-
> target/arm/gdbstub64.c | 27 +++++++++++++++------------
> @@ -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 to command 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;
>
> #define get_cmd_parsers(p) (&g_array_index(p, GdbCmdParseEntry, 0))
> modified 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;
LGTM.
> + }
> +
> gdbserver_state.allow_stop_reply = cmd->allow_stop_reply;
> - cmd->handler(params, NULL);
> + cmd->handler(params, user_ctx);
> return true;
> }
next prev parent reply other threads:[~2024-06-27 12:27 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-27 4:13 [PATCH v5 0/9] Add MTE stubs for aarch64 user mode Gustavo Romero
2024-06-27 4:13 ` [PATCH v5 1/9] gdbstub: Clean up process_string_cmd Gustavo Romero
2024-06-27 4:13 ` [PATCH v5 2/9] gdbstub: Move GdbCmdParseEntry into a new header file Gustavo Romero
2024-06-27 6:02 ` Philippe Mathieu-Daudé
2024-06-28 5:10 ` Gustavo Romero
2024-06-27 4:13 ` [PATCH v5 3/9] gdbstub: Add support for target-specific stubs Gustavo Romero
2024-06-27 4:13 ` [PATCH v5 4/9] target/arm: Fix exception case in allocation_tag_mem_probe Gustavo Romero
2024-06-27 4:13 ` [PATCH v5 5/9] target/arm: Make some MTE helpers widely available Gustavo Romero
2024-06-27 6:02 ` Philippe Mathieu-Daudé
2024-06-27 4:13 ` [PATCH v5 6/9] target/arm: Factor out code for setting MTE TCF0 field Gustavo Romero
2024-06-27 6:05 ` Philippe Mathieu-Daudé
2024-06-28 5:20 ` Gustavo Romero
2024-06-28 9:22 ` Philippe Mathieu-Daudé
2024-06-27 4:13 ` [PATCH v5 7/9] gdbstub: Make get cpu and hex conversion functions non-internal Gustavo Romero
2024-06-27 6:10 ` Philippe Mathieu-Daudé
2024-06-27 6:19 ` Philippe Mathieu-Daudé
2024-06-27 11:05 ` Alex Bennée
2024-06-27 12:26 ` Philippe Mathieu-Daudé [this message]
2024-06-28 5:12 ` Gustavo Romero
2024-06-27 4:13 ` [PATCH v5 8/9] gdbstub: Add support for MTE in user mode Gustavo Romero
2024-06-27 4:13 ` [PATCH v5 9/9] tests/tcg/aarch64: Add MTE gdbstub tests Gustavo Romero
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=b7a9150f-3271-456b-a4fd-05d77107155a@linaro.org \
--to=philmd@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=gustavo.romero@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).