aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Metzger <markus.t.metzger@intel.com>2022-05-02 16:33:32 +0200
committerMarkus Metzger <markus.t.metzger@intel.com>2022-10-18 14:16:10 +0200
commit531bd03892bbf95f346819006b365c0b0ccb6d06 (patch)
tree6b222b747744d5090d6bbe3c81aeee4cb7a1013d
parent6f96c196beccb6f30b78ef878b3eaa420dfaa687 (diff)
downloadgdb-531bd03892bbf95f346819006b365c0b0ccb6d06.zip
gdb-531bd03892bbf95f346819006b365c0b0ccb6d06.tar.gz
gdb-531bd03892bbf95f346819006b365c0b0ccb6d06.tar.bz2
gdb, symtab: inline find_quick_global_symbol_language
There is only one use of find_quick_global_symbol_language that calls it for the special symbol "main". Inline the function as it is probably not correct in the general case where we may have multiple instances of global symbols with the same name but different languages in different libraries in different linker namespaces. Further, change the objfiles iteration into a call to gdbarch_iterate_over_objfiles_in_search_order, which would only search the initial linker namespace, where we expect "main" to be located.
-rw-r--r--gdb/symtab.c43
1 files changed, 19 insertions, 24 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 50ee87e..7bb3224 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2610,23 +2610,6 @@ lookup_symbol_in_objfile (struct objfile *objfile, enum block_enum block_index,
return result;
}
-/* Find the language for partial symbol with NAME. */
-
-static enum language
-find_quick_global_symbol_language (const char *name, const domain_enum domain)
-{
- for (objfile *objfile : current_program_space->objfiles ())
- {
- bool symbol_found_p;
- enum language lang
- = objfile->lookup_global_symbol_language (name, domain, &symbol_found_p);
- if (symbol_found_p)
- return lang;
- }
-
- return language_unknown;
-}
-
/* This function contains the common code of lookup_{global,static}_symbol.
OBJFILE is only used if BLOCK_INDEX is GLOBAL_SCOPE, in which case it is
the objfile to start the lookup in. */
@@ -6367,13 +6350,25 @@ find_main_name (void)
Fallback to "main". */
/* Try to find language for main in psymtabs. */
- enum language lang
- = find_quick_global_symbol_language ("main", VAR_DOMAIN);
- if (lang != language_unknown)
- {
- set_main_name ("main", lang);
- return;
- }
+ bool symbol_found_p = false;
+ gdbarch_iterate_over_objfiles_in_search_order
+ (target_gdbarch (),
+ [&symbol_found_p] (objfile *obj)
+ {
+ language lang
+ = obj->lookup_global_symbol_language ("main", VAR_DOMAIN,
+ &symbol_found_p);
+ if (symbol_found_p)
+ {
+ set_main_name ("main", lang);
+ return 1;
+ }
+
+ return 0;
+ }, nullptr);
+
+ if (symbol_found_p)
+ return;
set_main_name ("main", language_unknown);
}