This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Use get_thread_regcache instead of get_current_regcache in post_create_inferior
- From: Simon Marchi <simark at simark dot ca>
- To: Simon Marchi <simon dot marchi at efficios dot com>, gdb-patches at sourceware dot org
- Date: Wed, 15 Jan 2020 12:50:53 -0500
- Subject: Re: [PATCH] Use get_thread_regcache instead of get_current_regcache in post_create_inferior
- References: <20191220175006.23147-1-simon.marchi@efficios.com>
On 2019-12-20 12:50 p.m., Simon Marchi wrote:
> In post_create_inferior, we get the current thread using the
> inferior_thread function and store it in `thr`. We then call
> get_current_regcache immediately after, which does:
>
> return get_thread_regcache (inferior_thread ());
>
> This patch makes post_create_inferior use get_thread_regcache, passing
> `thr`, saving an unnecessary inferior_thread call.
>
> gdb/ChangeLog:
>
> * infcmd.c (post_create_inferior): Use get_thread_regcache
> instead of get_current_regcache.
> ---
> gdb/infcmd.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/infcmd.c b/gdb/infcmd.c
> index af66eaffd8a4..7aa1f77af005 100644
> --- a/gdb/infcmd.c
> +++ b/gdb/infcmd.c
> @@ -441,7 +441,8 @@ post_create_inferior (struct target_ops *target, int from_tty)
> thr->suspend.stop_pc = 0;
> try
> {
> - thr->suspend.stop_pc = regcache_read_pc (get_current_regcache ());
> + regcache *rc = get_thread_regcache (thr);
> + thr->suspend.stop_pc = regcache_read_pc (rc);
> }
> catch (const gdb_exception_error &ex)
> {
> --
> 2.24.1
>
I have pushed this patch.
Simon