This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Use get_thread_regcache instead of get_current_regcache in post_create_inferior


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]