aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2024-05-23 09:41:07 -0600
committerTom Tromey <tromey@adacore.com>2024-06-14 10:56:36 -0600
commitfd7b969b9ecb5b983bfd6560098306ee030c4649 (patch)
treea4f920e3013af3be90d09fede9d9ae95807d2f8d
parent6b23978d2e6f7e36f46efece7ec13918d258fbc9 (diff)
downloadgdb-fd7b969b9ecb5b983bfd6560098306ee030c4649.zip
gdb-fd7b969b9ecb5b983bfd6560098306ee030c4649.tar.gz
gdb-fd7b969b9ecb5b983bfd6560098306ee030c4649.tar.bz2
Move search_symbol_list to symtab.c
This moves search_symbol_list to symtab.c and exports it. It will be useful in a later patch.
-rw-r--r--gdb/cp-namespace.c17
-rw-r--r--gdb/symtab.c13
-rw-r--r--gdb/symtab.h7
3 files changed, 20 insertions, 17 deletions
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index 544ebcf..e5ef54d 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -539,23 +539,6 @@ cp_lookup_symbol_via_imports (const char *scope,
return {};
}
-/* Helper function that searches an array of symbols for one named NAME. */
-
-static struct symbol *
-search_symbol_list (const char *name, int num,
- struct symbol **syms)
-{
- int i;
-
- /* Maybe we should store a dictionary in here instead. */
- for (i = 0; i < num; ++i)
- {
- if (strcmp (name, syms[i]->natural_name ()) == 0)
- return syms[i];
- }
- return NULL;
-}
-
/* Search for symbols whose name match NAME in the given SCOPE.
if BLOCK is a function, we'll search first through the template
parameters and function type. Afterwards (or if BLOCK is not a function)
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 5e65b89..9aa7064 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -372,6 +372,19 @@ from_scripting_domain (int val)
/* See symtab.h. */
+struct symbol *
+search_symbol_list (const char *name, int num, struct symbol **syms)
+{
+ for (int i = 0; i < num; ++i)
+ {
+ if (strcmp (name, syms[i]->natural_name ()) == 0)
+ return syms[i];
+ }
+ return nullptr;
+}
+
+/* See symtab.h. */
+
CORE_ADDR
linetable_entry::pc (const struct objfile *objfile) const
{
diff --git a/gdb/symtab.h b/gdb/symtab.h
index d5fe90a..3d766fd 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -2980,4 +2980,11 @@ extern void info_sources_worker (struct ui_out *uiout,
std::optional<CORE_ADDR> find_epilogue_using_linetable (CORE_ADDR func_addr);
+/* Search an array of symbols for one named NAME. Name comparison is
+ done using strcmp -- i.e., this is only useful for simple names.
+ Returns the symbol, if found, or nullptr if not. */
+
+extern struct symbol *search_symbol_list (const char *name, int num,
+ struct symbol **syms);
+
#endif /* !defined(SYMTAB_H) */