[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH 02/11] gdbstub: stop passing GDBState * around
From: |
Alex Bennée |
Subject: |
Re: [RFC PATCH 02/11] gdbstub: stop passing GDBState * around |
Date: |
Mon, 18 Nov 2019 11:52:14 +0000 |
User-agent: |
mu4e 1.3.5; emacs 27.0.50 |
Richard Henderson <address@hidden> writes:
> On 11/15/19 6:29 PM, Alex Bennée wrote:
>> We only have one GDBState which should be allocated at the time we
>> process any commands. This will make further clean-up a bit easier.
>>
>> Signed-off-by: Alex Bennée <address@hidden>
>> ---
>> gdbstub.c | 307 +++++++++++++++++++++++++++++++-----------------------
>> 1 file changed, 177 insertions(+), 130 deletions(-)
>>
>> diff --git a/gdbstub.c b/gdbstub.c
>> index c5b6701825f..2e6ff5f583c 100644
>> --- a/gdbstub.c
>> +++ b/gdbstub.c
>> @@ -1399,7 +1399,6 @@ static int cmd_parse_params(const char *data, const
>> char *schema,
>> }
>>
>> typedef struct GdbCmdContext {
>> - GDBState *s;
>> GdbCmdVariant *params;
>> int num_params;
>> uint8_t mem_buf[MAX_PACKET_LENGTH];
>> @@ -1480,7 +1479,7 @@ static int process_string_cmd(GDBState *s, void
>> *user_ctx, const char *data,
>> return -1;
>> }
>>
>> - gdb_ctx.s = s;
>> + g_assert(s == gdbserver_state);
>> cmd->handler(&gdb_ctx, user_ctx);
>> return 0;
>> }
>> @@ -1505,7 +1504,7 @@ static void run_cmd_parser(GDBState *s, const char
>> *data,
>> static void handle_detach(GdbCmdContext *gdb_ctx, void *user_ctx)
>> {
>> GDBProcess *process;
>> - GDBState *s = gdb_ctx->s;
>> + GDBState *s = gdbserver_state;
>> uint32_t pid = 1;
>>
>> if (s->multiprocess) {
> [...]
>
> Modulo my question about why not use a non-pointer variable,
>
> Reviewed-by: Richard Henderson <address@hidden>
Sure - we might as well go for static assignment. My main worry was
overly long lines but we could shorten the global to compensate or wrap
a helper around.
>
>
> r~
--
Alex Bennée
- [RFC PATCH 05/11] gdbstub: add helper for 128 bit registers, (continued)
- [RFC PATCH 05/11] gdbstub: add helper for 128 bit registers, Alex Bennée, 2019/11/15
- [RFC PATCH 04/11] gdbstub: move mem_buf to GDBState and use GByteArray, Alex Bennée, 2019/11/15
- [RFC PATCH 07/11] target/m68k: use gdb_get_reg helpers, Alex Bennée, 2019/11/15
- [RFC PATCH 03/11] gdbstub: move str_buf to GDBState and use GString, Alex Bennée, 2019/11/15
- [RFC PATCH 02/11] gdbstub: stop passing GDBState * around, Alex Bennée, 2019/11/15
- Re: [RFC PATCH 02/11] gdbstub: stop passing GDBState * around, Damien Hedde, 2019/11/18
- [RFC PATCH 10/11] target/arm: explicitly encode regnum in our XML, Alex Bennée, 2019/11/15
- [RFC PATCH 09/11] target/arm: prepare for multiple dynamic XMLs, Alex Bennée, 2019/11/15
- [RFC PATCH 11/11] target/arm: generate xml description of our SVE registers, Alex Bennée, 2019/11/15
- [RFC PATCH 08/11] gdbstub: extend GByteArray to read register helpers, Alex Bennée, 2019/11/15