Re: [PATCH 05/26] gdbserver: add a pointer to the owner thread in regcache

Simon Marchi
2023-12-21T20:29:07Z

On 2/28/23 06:28, Tankut Baris Aktemur via Gdb-patches wrote:
> Add a back-link in regcache to the thread that owns the regcache.
> This will help us in future patches to refer to the right thread
> object without having to rely on the global current_thread pointer.

I'm a bit hesitant with this change as-is, because it sets the thread
field only in some instances of regcache. There are code paths that
create regcaches but don't set it. It adds a bit of cognitive load to
have to think about when it is set and when it isn't.

I'll have to see how it's used in the rest of the series. Perhaps that
doesn't work, but intuitively I'm thinking that it might be better to
get the thread from the context in another way, like passing it down to
functions as an argument.

Simon