public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Move search_symbol_list to symtab.c
@ 2024-06-14 17:17 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2024-06-14 17:17 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=fd7b969b9ecb5b983bfd6560098306ee030c4649

commit fd7b969b9ecb5b983bfd6560098306ee030c4649
Author: Tom Tromey <tromey@adacore.com>
Date:   Thu May 23 09:41:07 2024 -0600

    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:
---
 gdb/cp-namespace.c | 17 -----------------
 gdb/symtab.c       | 13 +++++++++++++
 gdb/symtab.h       |  7 +++++++
 3 files changed, 20 insertions(+), 17 deletions(-)

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<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) */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-06-14 17:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-14 17:17 [binutils-gdb] Move search_symbol_list to symtab.c Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).