+int
+find_minimal_symbol_address (const char *name, CORE_ADDR *addr,
+ struct objfile *objfile)
+{
+ struct bound_minimal_symbol sym
+ = lookup_minimal_symbol (name, NULL, objfile);
+
+ if (sym.minsym != NULL)
+ *addr = BMSYMBOL_VALUE_ADDRESS (sym);
+
+ return sym.minsym == NULL;
+}
+
+/* Get the lookup name form best suitable for linkage name
+ matching. */
+
+static const char *
+linkage_name_str (const lookup_name_info &lookup_name)
+{
+ /* Unlike most languages (including C++), Ada uses the
+ encoded/linkage name as the search name recorded in symbols. So
+ if debugging in Ada mode, prefer the Ada-encoded name. This also
+ makes Ada's verbatim match syntax ("<...>") work, because
+ "lookup_name.name()" includes the "<>"s, while
+ "lookup_name.ada().lookup_name()" is the encoded name with "<>"s
+ stripped. */
+ if (current_language->la_language == language_ada)
+ return lookup_name.ada ().lookup_name ().c_str ();
+
+ return lookup_name.name ().c_str ();
+}
+
+/* See minsyms.h. */
+
+void
+iterate_over_minimal_symbols
+ (struct objfile *objf, const lookup_name_info &lookup_name,
+ gdb::function_view<bool (struct minimal_symbol *)> callback)
+{
+ /* The first pass is over the ordinary hash table. */
+ {
+ const char *name = linkage_name_str (lookup_name);
+ unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
+ auto *mangled_cmp
+ = (case_sensitivity == case_sensitive_on
+ ? strcmp
+ : strcasecmp);
+
+ for (minimal_symbol *iter = objf->per_bfd->msymbol_hash[hash];
+ iter != NULL;
+ iter = iter->hash_next)
+ {
+ if (mangled_cmp (MSYMBOL_LINKAGE_NAME (iter), name) == 0)
+ if (callback (iter))
+ return;
+ }
+ }
+
+ /* The second pass is over the demangled table. Once for each
+ language in the demangled hash names table (usually just zero or
+ one). */
+ for (auto lang : objf->per_bfd->demangled_hash_languages)
+ {
+ const language_defn *lang_def = language_def (lang);
+ symbol_name_matcher_ftype *name_match
+ = get_symbol_name_matcher (lang_def, lookup_name);
+
+ unsigned int hash
+ = lookup_name.search_name_hash (lang) % MINIMAL_SYMBOL_HASH_SIZE;
+ for (minimal_symbol *iter = objf->per_bfd->msymbol_demangled_hash[hash];
+ iter != NULL;
+ iter = iter->demangled_hash_next)
+ if (name_match (MSYMBOL_SEARCH_NAME (iter), lookup_name, NULL))
+ if (callback (iter))
+ return;
+ }
+}
+
+/* See minsyms.h. */
+
+struct bound_minimal_symbol