[05/30] Use block_symbol::address in printcmd.c

Message ID 20231029-split-objfile-2023-bound-sym-october-v1-5-612531df2734@tromey.com
State New
Headers
Series Baby step for objfile splitting |

Commit Message

Tom Tromey Oct. 29, 2023, 11:23 p.m. UTC
  This changes printcmd.c to use block_symbol::address.
---
 gdb/printcmd.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
  

Comments

Simon Marchi Nov. 3, 2023, 3:42 a.m. UTC | #1
On 2023-10-29 19:23, Tom Tromey wrote:
> This changes printcmd.c to use block_symbol::address.
> ---
>  gdb/printcmd.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/gdb/printcmd.c b/gdb/printcmd.c
> index b9b6a3b8648..94ce5113e06 100644
> --- a/gdb/printcmd.c
> +++ b/gdb/printcmd.c
> @@ -1647,8 +1647,10 @@ info_address_command (const char *exp, int from_tty)
>    if (exp == 0)
>      error (_("Argument required."));
>  
> -  sym = lookup_symbol (exp, get_selected_block (&context_pc), VAR_DOMAIN,
> -		       &is_a_field_of_this).symbol;
> +  block_symbol bsym = lookup_symbol (exp, get_selected_block (&context_pc),
> +				     VAR_DOMAIN,
> +				     &is_a_field_of_this);
> +  sym = bsym.symbol;

I would suggest moving the declaration of sym there.

Simon
  
Tom Tromey Nov. 5, 2023, 4:35 p.m. UTC | #2
>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

>> -  sym = lookup_symbol (exp, get_selected_block (&context_pc), VAR_DOMAIN,
>> -		       &is_a_field_of_this).symbol;
>> +  block_symbol bsym = lookup_symbol (exp, get_selected_block (&context_pc),
>> +				     VAR_DOMAIN,
>> +				     &is_a_field_of_this);
>> +  sym = bsym.symbol;

Simon> I would suggest moving the declaration of sym there.

I did this.

Tom
  

Patch

diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index b9b6a3b8648..94ce5113e06 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1647,8 +1647,10 @@  info_address_command (const char *exp, int from_tty)
   if (exp == 0)
     error (_("Argument required."));
 
-  sym = lookup_symbol (exp, get_selected_block (&context_pc), VAR_DOMAIN,
-		       &is_a_field_of_this).symbol;
+  block_symbol bsym = lookup_symbol (exp, get_selected_block (&context_pc),
+				     VAR_DOMAIN,
+				     &is_a_field_of_this);
+  sym = bsym.symbol;
   if (sym == NULL)
     {
       if (is_a_field_of_this.type != NULL)
@@ -1725,7 +1727,7 @@  info_address_command (const char *exp, int from_tty)
 
     case LOC_LABEL:
       gdb_printf ("a label at address ");
-      load_addr = sym->value_address ();
+      load_addr = bsym.address ();
       fputs_styled (paddress (gdbarch, load_addr), address_style.style (),
 		    gdb_stdout);
       if (section_is_overlay (section))
@@ -1761,7 +1763,7 @@  info_address_command (const char *exp, int from_tty)
 
     case LOC_STATIC:
       gdb_printf (_("static storage at address "));
-      load_addr = sym->value_address ();
+      load_addr = bsym.address ();
       fputs_styled (paddress (gdbarch, load_addr), address_style.style (),
 		    gdb_stdout);
       if (section_is_overlay (section))