qemu-devel
[Top][All Lists]
Advanced

[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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]