[PATCH] gdbserver: add client_state destructor

Simon Marchi simark@simark.ca
Fri May 3 17:00:07 GMT 2024



On 2024-05-03 12:14, Pedro Alves wrote:
> On 2024-05-03 16:17, Tom Tromey wrote:
>>>> At some point we went through the tree and removed all these IIRC.
>>
>> Guinevere> I think I have a case of friday brains. You mean removed all nullptr
>> Guinevere> checks, or removed unnecessary xfrees?
>>
>> Sorry.  All the checks of null before free were removed at some point.
>>
>> Though I see that gdb-xfree.h still does the check.  Lol.
>> IIRC, the gnulib folks looked into this and concluded that no existing
>> system requires the check before a call to free.
> 
> That is the original point of xfree existing.  It was needed on some ancient
> Solaris, IIRC.  It's free didn't work right with a null argument.
> 
> Note that bfd uses xmalloc, but does not use xfree, so all such hosts are surely
> gone.
> 
> Nowadays, having xfree is still important for the POD checking, of course,
> and it's nice to have xmalloc/xfree for balance IMHO, thought that's of course
> debatable.

We delete free for !IsFreeable types:

template <typename T, typename = gdb::Requires<gdb::Not<IsFreeable<T>>>>
void free (T *ptr) = delete;

So I guess that xfree isn't technically necessary for that.

Anyway, our goal should be for free/xfree to never be called manually :)

Simon


More information about the Gdb-patches mailing list