aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2024-12-18 18:49:45 -0700
committerTom Tromey <tom@tromey.com>2025-01-05 11:58:49 -0700
commit64800e8954245cd32c797fb2e207a66793193bf3 (patch)
treeb3e8232341ffb9455d52568a6f191c76310ae14e /gdb/dwarf2
parent05248f5ff0b92ada207dea4fab8f20df35746564 (diff)
downloadgdb-64800e8954245cd32c797fb2e207a66793193bf3.zip
gdb-64800e8954245cd32c797fb2e207a66793193bf3.tar.gz
gdb-64800e8954245cd32c797fb2e207a66793193bf3.tar.bz2
Fix latent bug in Ada import symbol handling
The code in dwarf2/read.c:new_symbol that handles Ada 'import' symbols has a bug. It uses the current scope, which by default this is the file scope -- even for a global symbol like: <1><1186>: Abbrev Number: 4 (DW_TAG_variable) <1187> DW_AT_name : (indirect string, offset: 0x1ad2): pkg__imported_var_ada ... <1196> DW_AT_external : 1 This disagrees with the scope computed by the DWARF indexer. Now, IMO new_symbol and its various weirdness really has to go. And, ideally, this information would come from the indexer rather than perhaps being erroneously recomputed. But meanwhile, this patch fixes the issue at hand. This came up while working on another change that exposes the bug. Reviewed-By: Tom de Vries <tdevries@suse.de>
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r--gdb/dwarf2/read.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 86448ab..a008f0e 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -19465,7 +19465,11 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
be seen here, because it will have a location and
so will be handled above. */
sym->set_linkage_name (name);
- list_to_add = cu->list_in_scope;
+ list_to_add
+ = ((cu->list_in_scope
+ == cu->get_builder ()->get_file_symbols ())
+ ? cu->get_builder ()->get_global_symbols ()
+ : cu->list_in_scope);
SYMBOL_LOCATION_BATON (sym) = (void *) linkagename;
sym->set_aclass_index (ada_imported_index);
}