]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add search_symbols_multiple.
authorKeith Seitz <keiths@redhat.com>
Tue, 21 Feb 2017 21:32:55 +0000 (13:32 -0800)
committerKeith Seitz <keiths@redhat.com>
Tue, 21 Feb 2017 21:32:55 +0000 (13:32 -0800)
NOTE: All this symbol stuff should be checked against Pedro's cp-linespec
branch, which might clean-up a LOT of this. [Actually, I think Pedro's work
might simplify gcc_cplus_convert_symbol and eliminate regexp_search_symbols
and related nastiness.]

gdb/linespec.c
gdb/minsyms.h
gdb/symtab.h

index c758a8b911bb80a9faabb654aac947b6edd32fc9..d15d6f2bc730ca9aa41008501679d2f632a4508d 100644 (file)
@@ -58,10 +58,6 @@ struct address_entry
   CORE_ADDR addr;
 };
 
-typedef struct bound_minimal_symbol bound_minimal_symbol_d;
-
-DEF_VEC_O (bound_minimal_symbol_d);
-
 /* A linespec.  Elements of this structure are filled in by a parser
    (either parse_linespec or some other function).  The structure is
    then converted into SALs by convert_linespec_to_sals.  */
@@ -163,11 +159,7 @@ struct collect_info
   VEC (symtab_ptr) *file_symtabs;
 
   /* The result being accumulated.  */
-  struct
-  {
-    VEC (block_symbol_d) *symbols;
-    VEC (bound_minimal_symbol_d) *minimal_symbols;
-  } result;
+  struct search_multiple_result result;
 };
 
 /* Token types  */
@@ -3182,6 +3174,67 @@ symtabs_from_filename (const char *filename,
   return result;
 }
 
+/* See description in symtab.h.  */
+
+struct search_multiple_result
+search_symbols_multiple (const char *name,
+                        const struct language_defn *language,
+                        domain_enum domain,
+                        VEC (symtab_ptr) *search_symtabs,
+                        struct program_space *search_pspace)
+{
+  struct collect_info info;
+  struct linespec_state state;
+  struct cleanup *back_to = make_cleanup (null_cleanup, NULL);
+
+  memset (&state, 0, sizeof (state));
+  state.language = language;
+  info.state = &state;
+  info.result.symbols = NULL;
+  info.result.minimal_symbols = NULL;
+  info.file_symtabs = search_symtabs;
+  if (info.file_symtabs == NULL)
+    {
+      VEC_safe_push (symtab_ptr, info.file_symtabs, NULL);
+      make_cleanup (VEC_cleanup (symtab_ptr), &info.file_symtabs);
+    }
+
+  add_matching_symbols_to_info (name, domain, &info, search_pspace);
+
+  if (VEC_empty (block_symbol_d, info.result.symbols))
+    {
+      VEC_free (block_symbol_d, info.result.symbols);
+      info.result.symbols = NULL;
+    }
+  if (VEC_empty (bound_minimal_symbol_d, info.result.minimal_symbols))
+    {
+      VEC_free (bound_minimal_symbol_d, info.result.minimal_symbols);
+      info.result.minimal_symbols = NULL;
+    }
+
+  do_cleanups (back_to);
+  return info.result;
+}
+
+/* See description in symtab.h.  */
+
+void
+free_search_multiple_result (struct search_multiple_result *result)
+{
+  VEC_free (block_symbol_d, result->symbols);
+  VEC_free (bound_minimal_symbol_d, result->minimal_symbols);
+}
+
+/* See the description in symtab.h.  */
+
+void
+search_multiple_result_cleanup (void *resultp)
+{
+  struct search_multiple_result *r = (struct search_multiple_result *) resultp;
+
+  free_search_multiple_result (r);
+}
+
 /* Look up a function symbol named NAME in symtabs FILE_SYMTABS.  Matching
    debug symbols are returned in SYMBOLS.  Matching minimal symbols are
    returned in MINSYMS.  */
index b82a22af71b74d974d820652cea049fd8ce854d3..8d582b1d0d56a6bbba384919801d394518394cd6 100644 (file)
@@ -37,6 +37,9 @@ struct bound_minimal_symbol
   struct objfile *objfile;
 };
 
+typedef struct bound_minimal_symbol bound_minimal_symbol_d;
+DEF_VEC_O (bound_minimal_symbol_d);
+
 /* This header declares most of the API for dealing with minimal
    symbols and minimal symbol tables.  A few things are declared
    elsewhere; see below.
index df4ef856a7dfd7f3f31626291674cf0090741c9c..07de87e51cae4296d6ae360f911726f58257a551 100644 (file)
@@ -1687,4 +1687,34 @@ void initialize_objfile_symbol (struct symbol *);
 
 struct template_symbol *allocate_template_symbol (struct objfile *);
 
+/* Result of a multi-symbol search.  */
+
+struct search_multiple_result
+{
+  /* Matching debug symbols.  */
+  VEC (block_symbol_d) *symbols;
+
+  /* Matching non-debug symbols.  */
+  VEC (bound_minimal_symbol_d) *minimal_symbols;
+};
+
+/* Search for all symbols named NAME in LANGUAGE with DOMAIN, restricting
+   search to FILE_SYMTABS and SEARCH_PSPACE, both of which may be NULL
+   to search all symtabs and program spaces.  */
+
+extern struct search_multiple_result
+  search_symbols_multiple (const char *name,
+                          const struct language_defn *language,
+                          domain_enum domain,
+                          VEC (symtab_ptr) *file_symtabs,
+                          struct program_space *search_pspace);
+
+/* Free the result of search_symbols_multiple.  */
+
+extern void free_search_multiple_result (struct search_multiple_result *);
+
+/* A cleanup function for the return result of search_symbols_multiple.  */
+
+extern void search_multiple_result_cleanup (void *);
+
 #endif /* !defined(SYMTAB_H) */