[04/30] Use block_symbol::address in ada-tasks.c

Message ID 20231029-split-objfile-2023-bound-sym-october-v1-4-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 ada-tasks.c to use block_symbol::address.
---
 gdb/ada-tasks.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
  

Comments

Simon Marchi Nov. 3, 2023, 3:40 a.m. UTC | #1
On 2023-10-29 19:23, Tom Tromey wrote:
> This changes ada-tasks.c to use block_symbol::address.
> ---
>  gdb/ada-tasks.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
> index 047566e6228..9f2d670e71e 100644
> --- a/gdb/ada-tasks.c
> +++ b/gdb/ada-tasks.c
> @@ -914,7 +914,7 @@ static void
>  ada_tasks_inferior_data_sniffer (struct ada_tasks_inferior_data *data)
>  {
>    struct bound_minimal_symbol msym;
> -  struct symbol *sym;
> +  struct block_symbol sym;

I'd suggest declaring separate sym variables in the two scopes where
it's needed (ideally where it's initialized).  This helps show that the
two uses are not related and specific to those scopes.

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

>> struct bound_minimal_symbol msym;
>> -  struct symbol *sym;
>> +  struct block_symbol sym;

Simon> I'd suggest declaring separate sym variables in the two scopes where
Simon> it's needed (ideally where it's initialized).  This helps show that the
Simon> two uses are not related and specific to those scopes.

I made this change.

Tom
  

Patch

diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index 047566e6228..9f2d670e71e 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -914,7 +914,7 @@  static void
 ada_tasks_inferior_data_sniffer (struct ada_tasks_inferior_data *data)
 {
   struct bound_minimal_symbol msym;
-  struct symbol *sym;
+  struct block_symbol sym;
 
   /* Return now if already set.  */
   if (data->known_tasks_kind != ADA_TASKS_UNKNOWN)
@@ -930,11 +930,11 @@  ada_tasks_inferior_data_sniffer (struct ada_tasks_inferior_data *data)
 
       /* Try to get pointer type and array length from the symtab.  */
       sym = lookup_symbol_in_language (KNOWN_TASKS_NAME, NULL, VAR_DOMAIN,
-				       language_c, NULL).symbol;
-      if (sym != NULL)
+				       language_c, NULL);
+      if (sym.symbol != nullptr)
 	{
 	  /* Validate.  */
-	  struct type *type = check_typedef (sym->type ());
+	  struct type *type = check_typedef (sym.symbol->type ());
 	  struct type *eltype = NULL;
 	  struct type *idxtype = NULL;
 
@@ -976,11 +976,11 @@  ada_tasks_inferior_data_sniffer (struct ada_tasks_inferior_data *data)
       data->known_tasks_length = 1;
 
       sym = lookup_symbol_in_language (KNOWN_TASKS_LIST, NULL, VAR_DOMAIN,
-				       language_c, NULL).symbol;
-      if (sym != NULL && sym->value_address () != 0)
+				       language_c, NULL);
+      if (sym.symbol != nullptr && sym.address () != 0)
 	{
 	  /* Validate.  */
-	  struct type *type = check_typedef (sym->type ());
+	  struct type *type = check_typedef (sym.symbol->type ());
 
 	  if (type->code () == TYPE_CODE_PTR)
 	    {