Richard Henderson <richard.hender...@linaro.org> 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 <alex.ben...@linaro.org> >> --- >> 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 <richard.hender...@linaro.org> 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