diff mbox series

[v3,4/7] gdb: Use passed gdbarch instead of calling current_inferior

Message ID 20240404064819.2848899-5-gustavo.romero@linaro.org
State Superseded
Headers show
Series Add another way to check tagged addresses on remote targets | expand

Commit Message

Gustavo Romero April 4, 2024, 6:48 a.m. UTC
In do_examine function, use passed gdbarch when checking if an address
is tagged instead of calling current_inferior()->arch() to make the code
more localized and help modularity by not calling a current_* function,
which disguises the use of a global state/variable. There is no change
in the code behavior.

Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
---
 gdb/printcmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Luis Machado April 4, 2024, 2:20 p.m. UTC | #1
On 4/4/24 07:48, Gustavo Romero wrote:
> In do_examine function, use passed gdbarch when checking if an address
> is tagged instead of calling current_inferior()->arch() to make the code
> more localized and help modularity by not calling a current_* function,
> which disguises the use of a global state/variable. There is no change
> in the code behavior.
> 
> Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
> ---
>  gdb/printcmd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gdb/printcmd.c b/gdb/printcmd.c
> index 774e3ec74ae..62fbcb98cfb 100644
> --- a/gdb/printcmd.c
> +++ b/gdb/printcmd.c
> @@ -1132,7 +1132,7 @@ do_examine (struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR addr)
>  	    = value_from_ulongest (builtin_type (gdbarch)->builtin_data_ptr,
>  				   tag_laddr);
>  
> -	  if (gdbarch_tagged_address_p (current_inferior ()->arch  (), v_addr))
> +	  if (gdbarch_tagged_address_p (gdbarch, v_addr))
>  	    {
>  	      /* Fetch the allocation tag.  */
>  	      struct value *tag

Thanks. This is OK and can go in separately, or alongside the rest of the series if you wish.

Approved-By: Luis Machado <luis.machado@arm.com>
Tested-By: Luis Machado <luis.machado@arm.com>
diff mbox series

Patch

diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 774e3ec74ae..62fbcb98cfb 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1132,7 +1132,7 @@  do_examine (struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR addr)
 	    = value_from_ulongest (builtin_type (gdbarch)->builtin_data_ptr,
 				   tag_laddr);
 
-	  if (gdbarch_tagged_address_p (current_inferior ()->arch  (), v_addr))
+	  if (gdbarch_tagged_address_p (gdbarch, v_addr))
 	    {
 	      /* Fetch the allocation tag.  */
 	      struct value *tag