From: Tom Tromey Date: Thu, 23 May 2024 15:41:07 +0000 (-0600) Subject: Move search_symbol_list to symtab.c X-Git-Tag: binutils-2_43~400 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd7b969b9ecb5b983bfd6560098306ee030c4649;p=thirdparty%2Fbinutils-gdb.git 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. --- diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index 544ebcfddb7..e5ef54dd3cc 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 5e65b893d6b..9aa7064009e 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 d5fe90a19d9..3d766fd5685 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -2980,4 +2980,11 @@ extern void info_sources_worker (struct ui_out *uiout, std::optional 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) */