Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Compute register name once in default_print_one_register_info
@ 2026-02-27 14:33 Tom Tromey
  2026-02-27 15:46 ` Tom de Vries
  2026-02-27 15:55 ` Schimpe, Christina
  0 siblings, 2 replies; 5+ messages in thread
From: Tom Tromey @ 2026-02-27 14:33 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

PR gdb/9884 points out that default_print_one_register_info could call
gdbarch_register_name a single time.  The current code seems harmless
but OTOH the proposed change is also harmless and perhaps slightly
faster, so why not.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=9884
---
 gdb/infcmd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 319d17d95eb..d0d1c142041 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2505,11 +2505,12 @@ default_print_registers_info (struct gdbarch *gdbarch,
 
       /* If the register name is empty, it is undefined for this
 	 processor, so don't display anything.  */
-      if (*(gdbarch_register_name (gdbarch, i)) == '\0')
+      const char *regname = gdbarch_register_name (gdbarch, i);
+      if (*regname == '\0')
 	continue;
 
       default_print_one_register_info
-	(file, gdbarch_register_name (gdbarch, i),
+	(file, regname,
 	 value_of_register (i, get_next_frame_sentinel_okay (frame)));
     }
 }

base-commit: e302db71359c85e3c1f1eb90e8f0aaa06ee81752
-- 
2.53.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Compute register name once in default_print_one_register_info
  2026-02-27 14:33 [PATCH] Compute register name once in default_print_one_register_info Tom Tromey
@ 2026-02-27 15:46 ` Tom de Vries
  2026-02-27 15:55 ` Schimpe, Christina
  1 sibling, 0 replies; 5+ messages in thread
From: Tom de Vries @ 2026-02-27 15:46 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2/27/26 3:33 PM, Tom Tromey wrote:
> PR gdb/9884 points out that default_print_one_register_info could call
> gdbarch_register_name a single time.  The current code seems harmless
> but OTOH the proposed change is also harmless and perhaps slightly
> faster, so why not.
> 

LGTM, obvious even.

Approved-By: Tom de Vries <tdevries@suse.de>

Thanks,
- Tom

> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=9884
> ---
>   gdb/infcmd.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/gdb/infcmd.c b/gdb/infcmd.c
> index 319d17d95eb..d0d1c142041 100644
> --- a/gdb/infcmd.c
> +++ b/gdb/infcmd.c
> @@ -2505,11 +2505,12 @@ default_print_registers_info (struct gdbarch *gdbarch,
>   
>         /* If the register name is empty, it is undefined for this
>   	 processor, so don't display anything.  */
> -      if (*(gdbarch_register_name (gdbarch, i)) == '\0')
> +      const char *regname = gdbarch_register_name (gdbarch, i);
> +      if (*regname == '\0')
>   	continue;
>   
>         default_print_one_register_info
> -	(file, gdbarch_register_name (gdbarch, i),
> +	(file, regname,
>   	 value_of_register (i, get_next_frame_sentinel_okay (frame)));
>       }
>   }
> 
> base-commit: e302db71359c85e3c1f1eb90e8f0aaa06ee81752


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] Compute register name once in default_print_one_register_info
  2026-02-27 14:33 [PATCH] Compute register name once in default_print_one_register_info Tom Tromey
  2026-02-27 15:46 ` Tom de Vries
@ 2026-02-27 15:55 ` Schimpe, Christina
  2026-02-27 16:09   ` Tom Tromey
  1 sibling, 1 reply; 5+ messages in thread
From: Schimpe, Christina @ 2026-02-27 15:55 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

> -----Original Message-----
> From: Tom Tromey <tromey@adacore.com>
> Sent: Freitag, 27. Februar 2026 15:34
> To: gdb-patches@sourceware.org
> Cc: Tom Tromey <tromey@adacore.com>
> Subject: [PATCH] Compute register name once in
> default_print_one_register_info
> 
> PR gdb/9884 points out that default_print_one_register_info could call
> gdbarch_register_name a single time.  The current code seems harmless but
> OTOH the proposed change is also harmless and perhaps slightly faster, so
> why not.
> 
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=9884
> ---
>  gdb/infcmd.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 319d17d95eb..d0d1c142041
> 100644
> --- a/gdb/infcmd.c
> +++ b/gdb/infcmd.c
> @@ -2505,11 +2505,12 @@ default_print_registers_info (struct gdbarch
> *gdbarch,
> 
>        /* If the register name is empty, it is undefined for this
>  	 processor, so don't display anything.  */
> -      if (*(gdbarch_register_name (gdbarch, i)) == '\0')
> +      const char *regname = gdbarch_register_name (gdbarch, i);
> +      if (*regname == '\0')
>  	continue;
> 
>        default_print_one_register_info
> -	(file, gdbarch_register_name (gdbarch, i),
> +	(file, regname,
>  	 value_of_register (i, get_next_frame_sentinel_okay (frame)));
>      }
>  }
> 
> base-commit: e302db71359c85e3c1f1eb90e8f0aaa06ee81752
> --
> 2.53.0
> 

Good that we can finally close this issue. I only wondered why you called it
default_print_*one*_register_info in the commit message header, it should
be default_print_register_info I think.

With that fixed LGTM.

Reviewed-By: Christina Schimpe <christina.schimpe@intel.com>

Thanks,
Christina

Intel Deutschland GmbH
Registered Address: Dornacher Straße 1, 85622 Feldkirchen, Germany
Tel: +49 89 991 430, www.intel.de
Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell
Chairperson of the Supervisory Board: Nicole Lau
Registered Seat: Munich
Commercial Register: Amtsgericht München HRB 186928

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Compute register name once in default_print_one_register_info
  2026-02-27 15:55 ` Schimpe, Christina
@ 2026-02-27 16:09   ` Tom Tromey
  2026-02-27 16:19     ` Schimpe, Christina
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2026-02-27 16:09 UTC (permalink / raw)
  To: Schimpe, Christina; +Cc: Tom Tromey, gdb-patches

> Good that we can finally close this issue. I only wondered why you called it
> default_print_*one*_register_info in the commit message header, it should
> be default_print_register_info I think.

Oops, sorry about that.
And unfortunately I pushed it when I saw Tom's note.

Tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] Compute register name once in default_print_one_register_info
  2026-02-27 16:09   ` Tom Tromey
@ 2026-02-27 16:19     ` Schimpe, Christina
  0 siblings, 0 replies; 5+ messages in thread
From: Schimpe, Christina @ 2026-02-27 16:19 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> -----Original Message-----
> From: Tom Tromey <tromey@adacore.com>
> Sent: Freitag, 27. Februar 2026 17:09
> To: Schimpe, Christina <christina.schimpe@intel.com>
> Cc: Tom Tromey <tromey@adacore.com>; gdb-patches@sourceware.org
> Subject: Re: [PATCH] Compute register name once in
> default_print_one_register_info
> 
> > Good that we can finally close this issue. I only wondered why you
> > called it default_print_*one*_register_info in the commit message
> > header, it should be default_print_register_info I think.
> 
> Oops, sorry about that.
> And unfortunately I pushed it when I saw Tom's note.
> 
> Tom

No problem at all. 

Christina
Intel Deutschland GmbH
Registered Address: Dornacher Straße 1, 85622 Feldkirchen, Germany
Tel: +49 89 991 430, www.intel.de
Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell
Chairperson of the Supervisory Board: Nicole Lau
Registered Seat: Munich
Commercial Register: Amtsgericht München HRB 186928

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-02-27 16:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-27 14:33 [PATCH] Compute register name once in default_print_one_register_info Tom Tromey
2026-02-27 15:46 ` Tom de Vries
2026-02-27 15:55 ` Schimpe, Christina
2026-02-27 16:09   ` Tom Tromey
2026-02-27 16:19     ` Schimpe, Christina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox