Re: [PATCH 1/4] gdb: rename regcache::current_regcache to regcache::regcaches

Pedro Alves
2020-07-23T20:02:01Z

Hi!

On 7/20/20 9:40 PM, Simon Marchi via Gdb-patches wrote:
> The name `current_regcache` for the list of currently-existing regcaches
> sounds wrong. The name is singular, but it holds multiple regcaches, so
> it could at least be `current_regcaches`.
>
> But in other places in GDB, "current" usually means "the object we are
> working with right now". For example, we swap the "current thread" when
> we want to operate on a given thread. This is not the case here, this
> variable just holds all regcaches that exist at any given time, not "the
> regcache we are working with right now".

It used to hold a single regcache, and then it was made a list:

https://sourceware.org/pipermail/gdb-patches/2009-June/065986.html

... but the name wasn't changed.

>
> So, I think calling it `regcaches` is better. I also considered
> `regcache_list`, but a subsequent patch will make it a map and not a
> list, so it would sound wrong again. `regcaches` sounds right for any
> collection of regcache, whatever the type.
>
> Rename a few other things that were related to this `current_regcache`
> field. Note that there is a `get_current_regcache` function, which
> returns the regcache of the current thread. That one is fine, because
> it returns the regcache for the current thread.
>
> gdb/ChangeLog:
>
> * regcache.h (class regcache) <current_regcache>: Rename to...
> <regcaches>: ... this. Move doc here.
> * regcache.c (regcache::current_regcache) Rename to...
> (regcache::regcaches): ... this. Move doc to header.
> (get_thread_arch_aspace_regcache): Update.
> (regcache::regcache_thread_ptid_changed): Update.
> (registers_changed_ptid): Update.
> (class regcache_access) <current_regcache_size>: Rename to...
> <regcaches_size>: ... this.
> (current_regcache_test): Rename to...
> (regcaches_test): ... this.
> (_initialize_regcache): Update.

OK.

Thanks,
Pedro Alves