qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH 01/11] gdbstub: move allocation of GDBState to one place


From: Richard Henderson
Subject: Re: [RFC PATCH 01/11] gdbstub: move allocation of GDBState to one place
Date: Mon, 18 Nov 2019 12:24:48 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

On 11/18/19 10:19 AM, Damien Hedde wrote:
> 
> 
> On 11/18/19 8:41 AM, Richard Henderson wrote:
>> On 11/15/19 6:29 PM, Alex Bennée wrote:
>>>  
>>>  static GDBState *gdbserver_state;
>>>  
>>> +static GDBState *gdb_allocate_state(void)
>>> +{
>>> +    g_assert(!gdbserver_state);
>>> +    gdbserver_state = g_new0(GDBState, 1);
>>> +    return gdbserver_state;
>>> +}
>>> +
>>
>> Actually, if we're only going to have one, why are we allocating it
>> dynamically?  We might as well allocate it statically and drop the pointer
>> indirection.
> 
> In use_gdb_syscalls(), we check if gdbserver_state is NULL:
> | /* -semihosting-config target=auto */
> | /* On the first call check if gdb is connected and remember. */
> | if (gdb_syscall_mode == GDB_SYS_UNKNOWN) {
> | gdb_syscall_mode = (gdbserver_state ? GDB_SYS_ENABLED
> |                                     : GDB_SYS_DISABLED);
> | }
> 
> So we cannot drop the pointer or we have to add some flag to do this test.

True, but perhaps a bool gdbserver_state.in_use is a clearer way to do this?


r~



reply via email to

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