+/* In order to search for global symbols of a particular kind matching
+ particular regular expressions, create an instance of this structure and
+ call the SEARCH member function. */
+class global_symbol_searcher
+{
+public:
+
+ /* Constructor. */
+ global_symbol_searcher (enum search_domain kind,
+ const char *symbol_name_regexp)
+ : m_kind (kind),
+ m_symbol_name_regexp (symbol_name_regexp)
+ {
+ /* The symbol searching is designed to only find one kind of thing. */
+ gdb_assert (m_kind != ALL_DOMAIN);
+ }
+
+ /* Set the optional regexp that matches against the symbol type. */
+ void set_symbol_type_regexp (const char *regexp)
+ {
+ m_symbol_type_regexp = regexp;
+ }
+
+ /* Set the flag to exclude minsyms from the search results. */
+ void set_exclude_minsyms (bool exclude_minsyms)
+ {
+ m_exclude_minsyms = exclude_minsyms;
+ }
+
+ /* Set the maximum number of search results to be returned. */
+ void set_max_search_results (size_t max_search_results)
+ {
+ m_max_search_results = max_search_results;
+ }
+
+ /* Search the symbols from all objfiles in the current program space
+ looking for matches as defined by the current state of this object.
+
+ Within each file the results are sorted locally; each symtab's global
+ and static blocks are separately alphabetized. Duplicate entries are
+ removed. */
+ std::vector<symbol_search> search () const;
+
+ /* The set of source files to search in for matching symbols. This is
+ currently public so that it can be populated after this object has
+ been constructed. */
+ std::vector<const char *> filenames;
+
+private:
+ /* The kind of symbols are we searching for.
+ VARIABLES_DOMAIN - Search all symbols, excluding functions, type
+ names, and constants (enums).
+ FUNCTIONS_DOMAIN - Search all functions..
+ TYPES_DOMAIN - Search all type names.
+ MODULES_DOMAIN - Search all Fortran modules.
+ ALL_DOMAIN - Not valid for this function. */
+ enum search_domain m_kind;
+
+ /* Regular expression to match against the symbol name. */
+ const char *m_symbol_name_regexp = nullptr;
+
+ /* Regular expression to match against the symbol type. */
+ const char *m_symbol_type_regexp = nullptr;
+
+ /* When this flag is false then minsyms that match M_SYMBOL_REGEXP will
+ be included in the results, otherwise they are excluded. */
+ bool m_exclude_minsyms = false;
+
+ /* Maximum number of search results. We currently impose a hard limit
+ of SIZE_MAX, there is no "unlimited". */
+ size_t m_max_search_results = SIZE_MAX;
+
+ /* Expand symtabs in OBJFILE that match PREG, are of type M_KIND. Return
+ true if any msymbols were seen that we should later consider adding to
+ the results list. */
+ bool expand_symtabs (objfile *objfile,
+ const gdb::optional<compiled_regex> &preg) const;
+
+ /* Add symbols from symtabs in OBJFILE that match PREG, and TREG, and are
+ of type M_KIND, to the results set RESULTS_SET. Return false if we
+ stop adding results early due to having already found too many results
+ (based on M_MAX_SEARCH_RESULTS limit), otherwise return true.
+ Returning true does not indicate that any results were added, just
+ that we didn't _not_ add a result due to reaching MAX_SEARCH_RESULTS. */
+ bool add_matching_symbols (objfile *objfile,
+ const gdb::optional<compiled_regex> &preg,
+ const gdb::optional<compiled_regex> &treg,
+ std::set<symbol_search> *result_set) const;
+
+ /* Add msymbols from OBJFILE that match PREG and M_KIND, to the results
+ vector RESULTS. Return false if we stop adding results early due to
+ having already found too many results (based on max search results
+ limit M_MAX_SEARCH_RESULTS), otherwise return true. Returning true
+ does not indicate that any results were added, just that we didn't
+ _not_ add a result due to reaching MAX_SEARCH_RESULTS. */
+ bool add_matching_msymbols (objfile *objfile,
+ const gdb::optional<compiled_regex> &preg,
+ std::vector<symbol_search> *results) const;
+
+ /* Return true if MSYMBOL is of type KIND. */
+ static bool is_suitable_msymbol (const enum search_domain kind,
+ const minimal_symbol *msymbol);
+};
+
+/* When searching for Fortran symbols within modules (functions/variables)
+ we return a vector of this type. The first item in the pair is the
+ module symbol, and the second item is the symbol for the function or
+ variable we found. */
+typedef std::pair<symbol_search, symbol_search> module_symbol_search;
+
+/* Searches the symbols to find function and variables symbols (depending
+ on KIND) within Fortran modules. The MODULE_REGEXP matches against the
+ name of the module, REGEXP matches against the name of the symbol within
+ the module, and TYPE_REGEXP matches against the type of the symbol
+ within the module. */
+extern std::vector<module_symbol_search> search_module_symbols
+ (const char *module_regexp, const char *regexp,
+ const char *type_regexp, search_domain kind);
+
+/* Convert a global or static symbol SYM (based on BLOCK, which should be
+ either GLOBAL_BLOCK or STATIC_BLOCK) into a string for use in 'info'
+ type commands (e.g. 'info variables', 'info functions', etc). KIND is
+ the type of symbol that was searched for which gave us SYM. */
+
+extern std::string symbol_to_info_string (struct symbol *sym, int block,
+ enum search_domain kind);
+