public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Move search_symbol_list to symtab.c
Date: Fri, 14 Jun 2024 17:17:25 +0000 (GMT)	[thread overview]
Message-ID: <20240614171725.91AEB3883009@sourceware.org> (raw)

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

                 reply	other threads:[~2024-06-14 17:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240614171725.91AEB3883009@sourceware.org \
    --to=tromey@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).