From: Tom Tromey Date: Thu, 19 Dec 2024 01:49:45 +0000 (-0700) Subject: Fix latent bug in Ada import symbol handling X-Git-Tag: binutils-2_44~263 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=64800e8954245cd32c797fb2e207a66793193bf3;p=thirdparty%2Fbinutils-gdb.git 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 --- diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 86448abc339..a008f0ee88b 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); }