Replace search_domain with domain_search_flags

This patch changes gdb to replace search_domain with
domain_search_flags everywhere.  search_domain is removed.
This commit is contained in:
Tom Tromey
2023-03-02 15:05:17 -07:00
parent 25f31e1820
commit c92d4de16a
20 changed files with 187 additions and 194 deletions

View File

@@ -5514,7 +5514,7 @@ map_matching_symbols (struct objfile *objfile,
global global
? SEARCH_GLOBAL_BLOCK ? SEARCH_GLOBAL_BLOCK
: SEARCH_STATIC_BLOCK, : SEARCH_STATIC_BLOCK,
domain, ALL_DOMAIN); domain, SEARCH_ALL);
const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK; const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
for (compunit_symtab *symtab : objfile->compunits ()) for (compunit_symtab *symtab : objfile->compunits ())
@@ -12997,7 +12997,7 @@ ada_add_global_exceptions (compiled_regex *preg,
}, },
NULL, NULL,
SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
VARIABLES_DOMAIN); SEARCH_VAR_DOMAIN);
/* Iterate over all objfiles irrespective of scope or linker namespaces /* Iterate over all objfiles irrespective of scope or linker namespaces
so we get all exceptions anywhere in the progspace. */ so we get all exceptions anywhere in the progspace. */
@@ -13542,7 +13542,7 @@ public:
NULL, NULL,
NULL, NULL,
SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
ALL_DOMAIN); SEARCH_ALL);
/* At this point scan through the misc symbol vectors and add each /* At this point scan through the misc symbol vectors and add each
symbol you find to the list. Eventually we want to ignore symbol you find to the list. Eventually we want to ignore

View File

@@ -368,7 +368,7 @@ gcc_cplus_convert_symbol (void *datum,
symbol_searcher searcher; symbol_searcher searcher;
searcher.find_all_symbols (identifier, current_language, searcher.find_all_symbols (identifier, current_language,
ALL_DOMAIN, nullptr, nullptr); SEARCH_ALL, nullptr, nullptr);
/* Convert any found symbols. */ /* Convert any found symbols. */
for (const auto &it : searcher.matching_symbols ()) for (const auto &it : searcher.matching_symbols ())

View File

@@ -198,6 +198,42 @@ test_compare ()
/* See cooked-index.h. */ /* See cooked-index.h. */
bool
cooked_index_entry::matches (domain_search_flags kind) const
{
/* Just reject type declarations. */
if ((flags & IS_TYPE_DECLARATION) != 0)
return false;
if ((kind & SEARCH_VAR_DOMAIN) != 0
&& (tag == DW_TAG_variable
|| tag == DW_TAG_constant
|| tag == DW_TAG_enumerator))
return true;
if ((kind & SEARCH_STRUCT_DOMAIN) != 0
&& (tag == DW_TAG_structure_type
|| tag == DW_TAG_class_type
|| tag == DW_TAG_union_type
|| tag == DW_TAG_enumeration_type))
return true;
if ((kind & SEARCH_MODULE_DOMAIN) != 0 && tag == DW_TAG_module)
return true;
if ((kind & SEARCH_TYPE_DOMAIN) != 0 && tag_is_type (tag))
return true;
if ((kind & SEARCH_FUNCTION_DOMAIN) != 0
&& (tag == DW_TAG_subprogram
|| tag == DW_TAG_entry_point))
return true;
return false;
}
/* See cooked-index.h. */
const char * const char *
cooked_index_entry::full_name (struct obstack *storage, bool for_main) const cooked_index_entry::full_name (struct obstack *storage, bool for_main) const
{ {

View File

@@ -160,29 +160,7 @@ struct cooked_index_entry : public allocate_on_obstack
} }
/* Return true if this entry matches KIND. */ /* Return true if this entry matches KIND. */
bool matches (enum search_domain kind) const bool matches (domain_search_flags kind) const;
{
/* Just reject type declarations. */
if ((flags & IS_TYPE_DECLARATION) != 0)
return false;
switch (kind)
{
case VARIABLES_DOMAIN:
return (tag == DW_TAG_variable
|| tag == DW_TAG_constant
|| tag == DW_TAG_enumerator);
case FUNCTIONS_DOMAIN:
return (tag == DW_TAG_subprogram
|| tag == DW_TAG_entry_point);
case TYPES_DOMAIN:
return tag_is_type (tag);
case MODULES_DOMAIN:
return tag == DW_TAG_module;
}
return true;
}
/* Construct the fully-qualified name of this entry and return a /* Construct the fully-qualified name of this entry and return a
pointer to it. If allocation is needed, it will be done on pointer to it. If allocation is needed, it will be done on
@@ -798,7 +776,7 @@ struct cooked_index_functions : public dwarf2_base_index_functions
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags, block_search_flags search_flags,
domain_enum domain, domain_enum domain,
enum search_domain kind) override; domain_search_flags kind) override;
struct compunit_symtab *find_pc_sect_compunit_symtab struct compunit_symtab *find_pc_sect_compunit_symtab
(struct objfile *objfile, struct bound_minimal_symbol msymbol, (struct objfile *objfile, struct bound_minimal_symbol msymbol,

View File

@@ -147,7 +147,7 @@ struct dwarf2_gdb_index : public dwarf2_base_index_functions
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags, block_search_flags search_flags,
domain_enum domain, domain_enum domain,
enum search_domain kind) override; domain_search_flags kind) override;
}; };
/* This dumps minimal information about the index. /* This dumps minimal information about the index.
@@ -176,7 +176,7 @@ dw2_expand_marked_cus
gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags, block_search_flags search_flags,
search_domain kind) domain_search_flags kind)
{ {
offset_type vec_len, vec_idx; offset_type vec_len, vec_idx;
bool global_seen = false; bool global_seen = false;
@@ -227,27 +227,24 @@ dw2_expand_marked_cus
continue; continue;
} }
switch (kind) domain_search_flags mask = 0;
switch (symbol_kind)
{ {
case VARIABLES_DOMAIN: case GDB_INDEX_SYMBOL_KIND_VARIABLE:
if (symbol_kind != GDB_INDEX_SYMBOL_KIND_VARIABLE) mask = SEARCH_VAR_DOMAIN;
continue;
break; break;
case FUNCTIONS_DOMAIN: case GDB_INDEX_SYMBOL_KIND_FUNCTION:
if (symbol_kind != GDB_INDEX_SYMBOL_KIND_FUNCTION) mask = SEARCH_FUNCTION_DOMAIN;
continue;
break; break;
case TYPES_DOMAIN: case GDB_INDEX_SYMBOL_KIND_TYPE:
if (symbol_kind != GDB_INDEX_SYMBOL_KIND_TYPE) mask = SEARCH_TYPE_DOMAIN;
continue;
break; break;
case MODULES_DOMAIN: case GDB_INDEX_SYMBOL_KIND_OTHER:
if (symbol_kind != GDB_INDEX_SYMBOL_KIND_OTHER) mask = SEARCH_MODULE_DOMAIN;
continue;
break;
default:
break; break;
} }
if ((kind & mask) == 0)
continue;
} }
/* Don't crash on bad data. */ /* Don't crash on bad data. */
@@ -276,7 +273,7 @@ dwarf2_gdb_index::expand_symtabs_matching
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags, block_search_flags search_flags,
domain_enum domain, domain_enum domain,
enum search_domain kind) domain_search_flags kind)
{ {
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);

View File

@@ -1638,7 +1638,7 @@ struct readnow_functions : public dwarf2_base_index_functions
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags, block_search_flags search_flags,
domain_enum domain, domain_enum domain,
enum search_domain kind) override domain_search_flags kind) override
{ {
return true; return true;
} }
@@ -16625,7 +16625,7 @@ cooked_index_functions::expand_symtabs_matching
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags, block_search_flags search_flags,
domain_enum domain, domain_enum domain,
enum search_domain kind) domain_search_flags kind)
{ {
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);

View File

@@ -387,13 +387,13 @@ static int symbol_to_sal (struct symtab_and_line *result,
static void add_matching_symbols_to_info (const char *name, static void add_matching_symbols_to_info (const char *name,
symbol_name_match_type name_match_type, symbol_name_match_type name_match_type,
enum search_domain search_domain, domain_search_flags domain_search_flags,
struct collect_info *info, struct collect_info *info,
struct program_space *pspace); struct program_space *pspace);
static void add_all_symbol_names_from_pspace static void add_all_symbol_names_from_pspace
(struct collect_info *info, struct program_space *pspace, (struct collect_info *info, struct program_space *pspace,
const std::vector<const char *> &names, enum search_domain search_domain); const std::vector<const char *> &names, domain_search_flags domain_search_flags);
static std::vector<symtab *> static std::vector<symtab *>
collect_symtabs_from_filename (const char *file, collect_symtabs_from_filename (const char *file,
@@ -1155,7 +1155,7 @@ iterate_over_all_matching_symtabs
(struct linespec_state *state, (struct linespec_state *state,
const lookup_name_info &lookup_name, const lookup_name_info &lookup_name,
const domain_enum name_domain, const domain_enum name_domain,
enum search_domain search_domain, domain_search_flags domain_search_flags,
struct program_space *search_pspace, bool include_inline, struct program_space *search_pspace, bool include_inline,
gdb::function_view<symbol_found_callback_ftype> callback) gdb::function_view<symbol_found_callback_ftype> callback)
{ {
@@ -1174,7 +1174,7 @@ iterate_over_all_matching_symtabs
(SEARCH_GLOBAL_BLOCK (SEARCH_GLOBAL_BLOCK
| SEARCH_STATIC_BLOCK), | SEARCH_STATIC_BLOCK),
UNDEF_DOMAIN, UNDEF_DOMAIN,
search_domain); domain_search_flags);
for (compunit_symtab *cu : objfile->compunits ()) for (compunit_symtab *cu : objfile->compunits ())
{ {
@@ -3331,7 +3331,7 @@ decode_objc (struct linespec_state *self, linespec *ls, const char *arg)
return {}; return {};
add_all_symbol_names_from_pspace (&info, NULL, symbol_names, add_all_symbol_names_from_pspace (&info, NULL, symbol_names,
FUNCTIONS_DOMAIN); SEARCH_FUNCTION_DOMAIN);
std::vector<symtab_and_line> values; std::vector<symtab_and_line> values;
if (!symbols.empty () || !minimal_symbols.empty ()) if (!symbols.empty () || !minimal_symbols.empty ())
@@ -3450,10 +3450,10 @@ lookup_prefix_sym (struct linespec_state *state,
if (elt == nullptr) if (elt == nullptr)
{ {
iterate_over_all_matching_symtabs (state, lookup_name, iterate_over_all_matching_symtabs (state, lookup_name,
STRUCT_DOMAIN, ALL_DOMAIN, STRUCT_DOMAIN, SEARCH_ALL,
NULL, false, collector); NULL, false, collector);
iterate_over_all_matching_symtabs (state, lookup_name, iterate_over_all_matching_symtabs (state, lookup_name,
VAR_DOMAIN, ALL_DOMAIN, VAR_DOMAIN, SEARCH_ALL,
NULL, false, collector); NULL, false, collector);
} }
else else
@@ -3531,12 +3531,12 @@ static void
add_all_symbol_names_from_pspace (struct collect_info *info, add_all_symbol_names_from_pspace (struct collect_info *info,
struct program_space *pspace, struct program_space *pspace,
const std::vector<const char *> &names, const std::vector<const char *> &names,
enum search_domain search_domain) domain_search_flags domain_search_flags)
{ {
for (const char *iter : names) for (const char *iter : names)
add_matching_symbols_to_info (iter, add_matching_symbols_to_info (iter,
symbol_name_match_type::FULL, symbol_name_match_type::FULL,
search_domain, info, pspace); domain_search_flags, info, pspace);
} }
static void static void
@@ -3630,7 +3630,7 @@ find_method (struct linespec_state *self,
iterate over the symbol tables looking for all iterate over the symbol tables looking for all
matches in this pspace. */ matches in this pspace. */
add_all_symbol_names_from_pspace (&info, pspace, result_names, add_all_symbol_names_from_pspace (&info, pspace, result_names,
FUNCTIONS_DOMAIN); SEARCH_FUNCTION_DOMAIN);
superclass_vec.clear (); superclass_vec.clear ();
last_result_len = result_names.size (); last_result_len = result_names.size ();
@@ -3753,7 +3753,7 @@ symtabs_from_filename (const char *filename,
void void
symbol_searcher::find_all_symbols (const std::string &name, symbol_searcher::find_all_symbols (const std::string &name,
const struct language_defn *language, const struct language_defn *language,
enum search_domain search_domain, domain_search_flags domain_search_flags,
std::vector<symtab *> *search_symtabs, std::vector<symtab *> *search_symtabs,
struct program_space *search_pspace) struct program_space *search_pspace)
{ {
@@ -3775,7 +3775,7 @@ symbol_searcher::find_all_symbols (const std::string &name,
info.file_symtabs = search_symtabs; info.file_symtabs = search_symtabs;
add_matching_symbols_to_info (name.c_str (), symbol_name_match_type::WILD, add_matching_symbols_to_info (name.c_str (), symbol_name_match_type::WILD,
search_domain, &info, search_pspace); domain_search_flags, &info, search_pspace);
} }
/* Look up a function symbol named NAME in symtabs FILE_SYMTABS. Matching /* Look up a function symbol named NAME in symtabs FILE_SYMTABS. Matching
@@ -3801,9 +3801,10 @@ find_function_symbols (struct linespec_state *state,
find_imps (name, &symbol_names); find_imps (name, &symbol_names);
if (!symbol_names.empty ()) if (!symbol_names.empty ())
add_all_symbol_names_from_pspace (&info, state->search_pspace, add_all_symbol_names_from_pspace (&info, state->search_pspace,
symbol_names, FUNCTIONS_DOMAIN); symbol_names, SEARCH_FUNCTION_DOMAIN);
else else
add_matching_symbols_to_info (name, name_match_type, FUNCTIONS_DOMAIN, add_matching_symbols_to_info (name, name_match_type,
SEARCH_FUNCTION_DOMAIN,
&info, state->search_pspace); &info, state->search_pspace);
} }
@@ -4322,7 +4323,7 @@ search_minsyms_for_name (struct collect_info *info,
static void static void
add_matching_symbols_to_info (const char *name, add_matching_symbols_to_info (const char *name,
symbol_name_match_type name_match_type, symbol_name_match_type name_match_type,
enum search_domain search_domain, domain_search_flags domain_search_flags,
struct collect_info *info, struct collect_info *info,
struct program_space *pspace) struct program_space *pspace)
{ {
@@ -4333,7 +4334,7 @@ add_matching_symbols_to_info (const char *name,
if (elt == nullptr) if (elt == nullptr)
{ {
iterate_over_all_matching_symtabs (info->state, lookup_name, iterate_over_all_matching_symtabs (info->state, lookup_name,
VAR_DOMAIN, search_domain, VAR_DOMAIN, domain_search_flags,
pspace, true, pspace, true,
[&] (block_symbol *bsym) [&] (block_symbol *bsym)
{ return info->add_symbol (bsym); }); { return info->add_symbol (bsym); });

View File

@@ -72,7 +72,7 @@ mi_cmd_symbol_list_lines (const char *command, const char *const *argv,
results. */ results. */
static void static void
output_debug_symbol (ui_out *uiout, enum search_domain kind, output_debug_symbol (ui_out *uiout, domain_search_flags kind,
struct symbol *sym, int block) struct symbol *sym, int block)
{ {
ui_out_emit_tuple tuple_emitter (uiout, NULL); ui_out_emit_tuple tuple_emitter (uiout, NULL);
@@ -81,7 +81,7 @@ output_debug_symbol (ui_out *uiout, enum search_domain kind,
uiout->field_unsigned ("line", sym->line ()); uiout->field_unsigned ("line", sym->line ());
uiout->field_string ("name", sym->print_name ()); uiout->field_string ("name", sym->print_name ());
if (kind == FUNCTIONS_DOMAIN || kind == VARIABLES_DOMAIN) if ((kind & (SEARCH_FUNCTION_DOMAIN | SEARCH_VAR_DOMAIN)) != 0)
{ {
string_file tmp_stream; string_file tmp_stream;
type_print (sym->type (), "", &tmp_stream, -1); type_print (sym->type (), "", &tmp_stream, -1);
@@ -113,7 +113,7 @@ output_nondebug_symbol (ui_out *uiout,
and then prints the matching [m]symbols in an MI structured format. */ and then prints the matching [m]symbols in an MI structured format. */
static void static void
mi_symbol_info (enum search_domain kind, const char *name_regexp, mi_symbol_info (domain_search_flags kind, const char *name_regexp,
const char *type_regexp, bool exclude_minsyms, const char *type_regexp, bool exclude_minsyms,
size_t max_results) size_t max_results)
{ {
@@ -190,7 +190,7 @@ parse_max_results_option (const char *arg)
Processes command line options from ARGV and ARGC. */ Processes command line options from ARGV and ARGC. */
static void static void
mi_info_functions_or_variables (enum search_domain kind, mi_info_functions_or_variables (domain_search_flags kind,
const char *const *argv, int argc) const char *const *argv, int argc)
{ {
size_t max_results = SIZE_MAX; size_t max_results = SIZE_MAX;
@@ -217,7 +217,7 @@ mi_info_functions_or_variables (enum search_domain kind,
while (1) while (1)
{ {
const char *cmd_string const char *cmd_string
= ((kind == FUNCTIONS_DOMAIN) = ((kind == SEARCH_FUNCTION_DOMAIN)
? "-symbol-info-functions" : "-symbol-info-variables"); ? "-symbol-info-functions" : "-symbol-info-variables");
int opt = mi_getopt (cmd_string, argc, argv, opts, &oind, &oarg); int opt = mi_getopt (cmd_string, argc, argv, opts, &oind, &oarg);
if (opt < 0) if (opt < 0)
@@ -253,7 +253,7 @@ typedef std::vector<module_symbol_search>::const_iterator
static module_symbol_search_iterator static module_symbol_search_iterator
output_module_symbols_in_single_module_and_file output_module_symbols_in_single_module_and_file
(struct ui_out *uiout, module_symbol_search_iterator iter, (struct ui_out *uiout, module_symbol_search_iterator iter,
const module_symbol_search_iterator end, enum search_domain kind) const module_symbol_search_iterator end, domain_search_flags kind)
{ {
/* The symbol for the module in which the first result resides. */ /* The symbol for the module in which the first result resides. */
const symbol *first_module_symbol = iter->first.symbol; const symbol *first_module_symbol = iter->first.symbol;
@@ -288,7 +288,7 @@ output_module_symbols_in_single_module_and_file
static module_symbol_search_iterator static module_symbol_search_iterator
output_module_symbols_in_single_module output_module_symbols_in_single_module
(struct ui_out *uiout, module_symbol_search_iterator iter, (struct ui_out *uiout, module_symbol_search_iterator iter,
const module_symbol_search_iterator end, enum search_domain kind) const module_symbol_search_iterator end, domain_search_flags kind)
{ {
gdb_assert (iter->first.symbol != nullptr); gdb_assert (iter->first.symbol != nullptr);
gdb_assert (iter->second.symbol != nullptr); gdb_assert (iter->second.symbol != nullptr);
@@ -316,7 +316,7 @@ output_module_symbols_in_single_module
command line options passed to the MI command. */ command line options passed to the MI command. */
static void static void
mi_info_module_functions_or_variables (enum search_domain kind, mi_info_module_functions_or_variables (domain_search_flags kind,
const char *const *argv, int argc) const char *const *argv, int argc)
{ {
const char *module_regexp = nullptr; const char *module_regexp = nullptr;
@@ -343,7 +343,7 @@ mi_info_module_functions_or_variables (enum search_domain kind,
while (1) while (1)
{ {
const char *cmd_string const char *cmd_string
= ((kind == FUNCTIONS_DOMAIN) = ((kind == SEARCH_FUNCTION_DOMAIN)
? "-symbol-info-module-functions" ? "-symbol-info-module-functions"
: "-symbol-info-module-variables"); : "-symbol-info-module-variables");
int opt = mi_getopt (cmd_string, argc, argv, opts, &oind, &oarg); int opt = mi_getopt (cmd_string, argc, argv, opts, &oind, &oarg);
@@ -385,7 +385,7 @@ void
mi_cmd_symbol_info_functions (const char *command, const char *const *argv, mi_cmd_symbol_info_functions (const char *command, const char *const *argv,
int argc) int argc)
{ {
mi_info_functions_or_variables (FUNCTIONS_DOMAIN, argv, argc); mi_info_functions_or_variables (SEARCH_FUNCTION_DOMAIN, argv, argc);
} }
/* Implement -symbol-info-module-functions command. */ /* Implement -symbol-info-module-functions command. */
@@ -394,7 +394,7 @@ void
mi_cmd_symbol_info_module_functions (const char *command, mi_cmd_symbol_info_module_functions (const char *command,
const char *const *argv, int argc) const char *const *argv, int argc)
{ {
mi_info_module_functions_or_variables (FUNCTIONS_DOMAIN, argv, argc); mi_info_module_functions_or_variables (SEARCH_FUNCTION_DOMAIN, argv, argc);
} }
/* Implement -symbol-info-module-variables command. */ /* Implement -symbol-info-module-variables command. */
@@ -403,7 +403,7 @@ void
mi_cmd_symbol_info_module_variables (const char *command, mi_cmd_symbol_info_module_variables (const char *command,
const char *const *argv, int argc) const char *const *argv, int argc)
{ {
mi_info_module_functions_or_variables (VARIABLES_DOMAIN, argv, argc); mi_info_module_functions_or_variables (SEARCH_VAR_DOMAIN, argv, argc);
} }
/* Implement -symbol-inf-modules command. */ /* Implement -symbol-inf-modules command. */
@@ -446,7 +446,7 @@ mi_cmd_symbol_info_modules (const char *command, const char *const *argv,
} }
} }
mi_symbol_info (MODULES_DOMAIN, regexp, nullptr, true, max_results); mi_symbol_info (SEARCH_MODULE_DOMAIN, regexp, nullptr, true, max_results);
} }
/* Implement -symbol-info-types command. */ /* Implement -symbol-info-types command. */
@@ -489,7 +489,8 @@ mi_cmd_symbol_info_types (const char *command, const char *const *argv,
} }
} }
mi_symbol_info (TYPES_DOMAIN, regexp, nullptr, true, max_results); mi_symbol_info (SEARCH_TYPE_DOMAIN | SEARCH_STRUCT_DOMAIN, regexp, nullptr,
true, max_results);
} }
/* Implement -symbol-info-variables command. */ /* Implement -symbol-info-variables command. */
@@ -498,5 +499,5 @@ void
mi_cmd_symbol_info_variables (const char *command, const char *const *argv, mi_cmd_symbol_info_variables (const char *command, const char *const *argv,
int argc) int argc)
{ {
mi_info_functions_or_variables (VARIABLES_DOMAIN, argv, argc); mi_info_functions_or_variables (SEARCH_VAR_DOMAIN, argv, argc);
} }

View File

@@ -592,7 +592,7 @@ public:
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags, block_search_flags search_flags,
domain_enum domain, domain_enum domain,
enum search_domain kind); domain_search_flags kind);
/* See quick_symbol_functions. */ /* See quick_symbol_functions. */
struct compunit_symtab *find_pc_sect_compunit_symtab struct compunit_symtab *find_pc_sect_compunit_symtab

View File

@@ -803,7 +803,7 @@ recursively_search_psymtabs
struct objfile *objfile, struct objfile *objfile,
block_search_flags search_flags, block_search_flags search_flags,
domain_enum domain, domain_enum domain,
enum search_domain search, domain_search_flags search,
const lookup_name_info &lookup_name, const lookup_name_info &lookup_name,
gdb::function_view<expand_symtabs_symbol_matcher_ftype> sym_matcher) gdb::function_view<expand_symtabs_symbol_matcher_ftype> sym_matcher)
{ {
@@ -876,15 +876,15 @@ recursively_search_psymtabs
if ((domain == UNDEF_DOMAIN if ((domain == UNDEF_DOMAIN
|| symbol_matches_domain ((*psym)->ginfo.language (), || symbol_matches_domain ((*psym)->ginfo.language (),
(*psym)->domain, domain)) (*psym)->domain, domain))
&& (search == ALL_DOMAIN && (search == SEARCH_ALL
|| (search == MODULES_DOMAIN || (search == SEARCH_MODULE_DOMAIN
&& (*psym)->domain == MODULE_DOMAIN) && (*psym)->domain == MODULE_DOMAIN)
|| (search == VARIABLES_DOMAIN || (search == SEARCH_VAR_DOMAIN
&& (*psym)->aclass != LOC_TYPEDEF && (*psym)->aclass != LOC_TYPEDEF
&& (*psym)->aclass != LOC_BLOCK) && (*psym)->aclass != LOC_BLOCK)
|| (search == FUNCTIONS_DOMAIN || (search == SEARCH_FUNCTION_DOMAIN
&& (*psym)->aclass == LOC_BLOCK) && (*psym)->aclass == LOC_BLOCK)
|| (search == TYPES_DOMAIN || (search == SEARCH_TYPE_DOMAIN
&& (*psym)->aclass == LOC_TYPEDEF)) && (*psym)->aclass == LOC_TYPEDEF))
&& psymbol_name_matches (*psym, lookup_name) && psymbol_name_matches (*psym, lookup_name)
&& (sym_matcher == NULL && (sym_matcher == NULL
@@ -914,7 +914,7 @@ psymbol_functions::expand_symtabs_matching
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags, block_search_flags search_flags,
domain_enum domain, domain_enum domain,
enum search_domain search) domain_search_flags search)
{ {
/* Clear the search flags. */ /* Clear the search flags. */
for (partial_symtab *ps : partial_symbols (objfile)) for (partial_symtab *ps : partial_symbols (objfile))

View File

@@ -634,7 +634,7 @@ struct psymbol_functions : public quick_symbol_functions
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags, block_search_flags search_flags,
domain_enum domain, domain_enum domain,
enum search_domain kind) override; domain_search_flags kind) override;
struct compunit_symtab *find_pc_sect_compunit_symtab struct compunit_symtab *find_pc_sect_compunit_symtab
(struct objfile *objfile, struct bound_minimal_symbol msymbol, (struct objfile *objfile, struct bound_minimal_symbol msymbol,

View File

@@ -596,7 +596,7 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw)
lookup_name_info lookup_name (name, symbol_name_match_type::FULL); lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
expand_symtabs_matching (NULL, lookup_name, NULL, NULL, expand_symtabs_matching (NULL, lookup_name, NULL, NULL,
SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
ALL_DOMAIN); SEARCH_ALL);
for (objfile *objfile : current_program_space->objfiles ()) for (objfile *objfile : current_program_space->objfiles ())
{ {

View File

@@ -736,7 +736,7 @@ gdbpy_rbreak (PyObject *self, PyObject *args, PyObject *kw)
minsyms_p = cmp; minsyms_p = cmp;
} }
global_symbol_searcher spec (FUNCTIONS_DOMAIN, regex); global_symbol_searcher spec (SEARCH_FUNCTION_DOMAIN, regex);
SCOPE_EXIT { SCOPE_EXIT {
for (const char *elem : spec.filenames) for (const char *elem : spec.filenames)
xfree ((void *) elem); xfree ((void *) elem);

View File

@@ -156,7 +156,7 @@ struct quick_symbol_functions
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags, block_search_flags search_flags,
domain_enum domain, domain_enum domain,
enum search_domain kind) = 0; domain_search_flags kind) = 0;
/* Return the comp unit from OBJFILE that contains PC and /* Return the comp unit from OBJFILE that contains PC and
SECTION. Return NULL if there is no such compunit. This SECTION. Return NULL if there is no such compunit. This

View File

@@ -223,7 +223,7 @@ objfile::map_symtabs_matching_filename
(SEARCH_GLOBAL_BLOCK (SEARCH_GLOBAL_BLOCK
| SEARCH_STATIC_BLOCK), | SEARCH_STATIC_BLOCK),
UNDEF_DOMAIN, UNDEF_DOMAIN,
ALL_DOMAIN)) SEARCH_ALL))
{ {
retval = false; retval = false;
break; break;
@@ -289,7 +289,7 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain)
? SEARCH_GLOBAL_BLOCK ? SEARCH_GLOBAL_BLOCK
: SEARCH_STATIC_BLOCK, : SEARCH_STATIC_BLOCK,
domain, domain,
ALL_DOMAIN)) SEARCH_ALL))
break; break;
} }
@@ -344,7 +344,7 @@ objfile::expand_symtabs_for_function (const char *func_name)
(SEARCH_GLOBAL_BLOCK (SEARCH_GLOBAL_BLOCK
| SEARCH_STATIC_BLOCK), | SEARCH_STATIC_BLOCK),
VAR_DOMAIN, VAR_DOMAIN,
ALL_DOMAIN); SEARCH_ALL);
} }
void void
@@ -381,7 +381,7 @@ objfile::expand_symtabs_with_fullname (const char *fullname)
(SEARCH_GLOBAL_BLOCK (SEARCH_GLOBAL_BLOCK
| SEARCH_STATIC_BLOCK), | SEARCH_STATIC_BLOCK),
UNDEF_DOMAIN, UNDEF_DOMAIN,
ALL_DOMAIN); SEARCH_ALL);
} }
bool bool
@@ -392,7 +392,7 @@ objfile::expand_symtabs_matching
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags, block_search_flags search_flags,
domain_enum domain, domain_enum domain,
enum search_domain kind) domain_search_flags kind)
{ {
/* This invariant is documented in quick-functions.h. */ /* This invariant is documented in quick-functions.h. */
gdb_assert (lookup_name != nullptr || symbol_matcher == nullptr); gdb_assert (lookup_name != nullptr || symbol_matcher == nullptr);
@@ -404,7 +404,7 @@ objfile::expand_symtabs_matching
host_address_to_string (&file_matcher), host_address_to_string (&file_matcher),
host_address_to_string (&symbol_matcher), host_address_to_string (&symbol_matcher),
host_address_to_string (&expansion_notify), host_address_to_string (&expansion_notify),
search_domain_name (kind)); domain_name (kind).c_str ());
for (const auto &iter : qf) for (const auto &iter : qf)
if (!iter->expand_symtabs_matching (this, file_matcher, lookup_name, if (!iter->expand_symtabs_matching (this, file_matcher, lookup_name,

View File

@@ -3769,7 +3769,7 @@ expand_symtabs_matching
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher, gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags, block_search_flags search_flags,
enum search_domain kind) domain_search_flags kind)
{ {
for (objfile *objfile : current_program_space->objfiles ()) for (objfile *objfile : current_program_space->objfiles ())
if (!objfile->expand_symtabs_matching (file_matcher, if (!objfile->expand_symtabs_matching (file_matcher,

View File

@@ -352,7 +352,7 @@ bool expand_symtabs_matching
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher, gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags, block_search_flags search_flags,
enum search_domain kind); domain_search_flags kind);
void map_symbol_filenames (gdb::function_view<symbol_filename_ftype> fun, void map_symbol_filenames (gdb::function_view<symbol_filename_ftype> fun,
bool need_fullname); bool need_fullname);

View File

@@ -920,7 +920,7 @@ maintenance_expand_symtabs (const char *args, int from_tty)
NULL, NULL,
SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
UNDEF_DOMAIN, UNDEF_DOMAIN,
ALL_DOMAIN); SEARCH_ALL);
} }

View File

@@ -313,22 +313,6 @@ domain_name (domain_enum e)
} }
} }
/* Return the name of a search_domain . */
const char *
search_domain_name (enum search_domain e)
{
switch (e)
{
case VARIABLES_DOMAIN: return "VARIABLES_DOMAIN";
case FUNCTIONS_DOMAIN: return "FUNCTIONS_DOMAIN";
case TYPES_DOMAIN: return "TYPES_DOMAIN";
case MODULES_DOMAIN: return "MODULES_DOMAIN";
case ALL_DOMAIN: return "ALL_DOMAIN";
default: gdb_assert_not_reached ("bad search_domain");
}
}
/* See symtab.h. */ /* See symtab.h. */
std::string std::string
@@ -4774,7 +4758,7 @@ treg_matches_sym_type_name (const compiled_regex &treg,
bool bool
global_symbol_searcher::is_suitable_msymbol global_symbol_searcher::is_suitable_msymbol
(const enum search_domain kind, const minimal_symbol *msymbol) (const domain_search_flags kind, const minimal_symbol *msymbol)
{ {
switch (msymbol->type ()) switch (msymbol->type ())
{ {
@@ -4782,12 +4766,12 @@ global_symbol_searcher::is_suitable_msymbol
case mst_bss: case mst_bss:
case mst_file_data: case mst_file_data:
case mst_file_bss: case mst_file_bss:
return kind == VARIABLES_DOMAIN; return (kind & SEARCH_VAR_DOMAIN) != 0;
case mst_text: case mst_text:
case mst_file_text: case mst_file_text:
case mst_solib_trampoline: case mst_solib_trampoline:
case mst_text_gnu_ifunc: case mst_text_gnu_ifunc:
return kind == FUNCTIONS_DOMAIN; return (kind & SEARCH_FUNCTION_DOMAIN) != 0;
default: default:
return false; return false;
} }
@@ -4799,7 +4783,7 @@ bool
global_symbol_searcher::expand_symtabs global_symbol_searcher::expand_symtabs
(objfile *objfile, const std::optional<compiled_regex> &preg) const (objfile *objfile, const std::optional<compiled_regex> &preg) const
{ {
enum search_domain kind = m_kind; domain_search_flags kind = m_kind;
bool found_msymbol = false; bool found_msymbol = false;
auto do_file_match = [&] (const char *filename, bool basenames) auto do_file_match = [&] (const char *filename, bool basenames)
@@ -4838,7 +4822,7 @@ global_symbol_searcher::expand_symtabs
all objfiles. In large programs (1000s of shared libs) searching all all objfiles. In large programs (1000s of shared libs) searching all
objfiles is not worth the pain. */ objfiles is not worth the pain. */
if (filenames.empty () if (filenames.empty ()
&& (kind == VARIABLES_DOMAIN || kind == FUNCTIONS_DOMAIN)) && (kind & (SEARCH_VAR_DOMAIN | SEARCH_FUNCTION_DOMAIN)) != 0)
{ {
for (minimal_symbol *msymbol : objfile->msymbols ()) for (minimal_symbol *msymbol : objfile->msymbols ())
{ {
@@ -4858,7 +4842,7 @@ global_symbol_searcher::expand_symtabs
in the process we will add matching symbols or in the process we will add matching symbols or
msymbols to the results list, and that requires that msymbols to the results list, and that requires that
the symbols tables are expanded. */ the symbols tables are expanded. */
if (kind == FUNCTIONS_DOMAIN if ((kind & SEARCH_FUNCTION_DOMAIN) != 0
? (find_pc_compunit_symtab ? (find_pc_compunit_symtab
(msymbol->value_address (objfile)) == NULL) (msymbol->value_address (objfile)) == NULL)
: (lookup_symbol_in_objfile_from_linkage_name : (lookup_symbol_in_objfile_from_linkage_name
@@ -4883,7 +4867,7 @@ global_symbol_searcher::add_matching_symbols
const std::optional<compiled_regex> &treg, const std::optional<compiled_regex> &treg,
std::set<symbol_search> *result_set) const std::set<symbol_search> *result_set) const
{ {
enum search_domain kind = m_kind; domain_search_flags kind = m_kind;
/* Add matching symbols (if not already present). */ /* Add matching symbols (if not already present). */
for (compunit_symtab *cust : objfile->compunits ()) for (compunit_symtab *cust : objfile->compunits ())
@@ -4916,7 +4900,7 @@ global_symbol_searcher::add_matching_symbols
continue; continue;
bool matches = false; bool matches = false;
if (!matches && kind == VARIABLES_DOMAIN) if (!matches && (kind & SEARCH_VAR_DOMAIN) != 0)
{ {
if (sym->aclass () != LOC_TYPEDEF if (sym->aclass () != LOC_TYPEDEF
&& sym->aclass () != LOC_UNRESOLVED && sym->aclass () != LOC_UNRESOLVED
@@ -4932,7 +4916,7 @@ global_symbol_searcher::add_matching_symbols
|| treg_matches_sym_type_name (*treg, sym))) || treg_matches_sym_type_name (*treg, sym)))
matches = true; matches = true;
} }
if (!matches && kind == FUNCTIONS_DOMAIN) if (!matches && (kind & SEARCH_FUNCTION_DOMAIN) != 0)
{ {
if (sym->aclass () == LOC_BLOCK if (sym->aclass () == LOC_BLOCK
&& (!treg.has_value () && (!treg.has_value ()
@@ -4940,13 +4924,13 @@ global_symbol_searcher::add_matching_symbols
sym))) sym)))
matches = true; matches = true;
} }
if (!matches && kind == TYPES_DOMAIN) if (!matches && (kind & SEARCH_TYPE_DOMAIN) != 0)
{ {
if (sym->aclass () == LOC_TYPEDEF if (sym->aclass () == LOC_TYPEDEF
&& sym->domain () != MODULE_DOMAIN) && sym->domain () != MODULE_DOMAIN)
matches = true; matches = true;
} }
if (!matches && kind == MODULES_DOMAIN) if (!matches && (kind & SEARCH_MODULE_DOMAIN) != 0)
{ {
if (sym->domain () == MODULE_DOMAIN if (sym->domain () == MODULE_DOMAIN
&& sym->line () != 0) && sym->line () != 0)
@@ -4978,7 +4962,7 @@ global_symbol_searcher::add_matching_msymbols
(objfile *objfile, const std::optional<compiled_regex> &preg, (objfile *objfile, const std::optional<compiled_regex> &preg,
std::vector<symbol_search> *results) const std::vector<symbol_search> *results) const
{ {
enum search_domain kind = m_kind; domain_search_flags kind = m_kind;
for (minimal_symbol *msymbol : objfile->msymbols ()) for (minimal_symbol *msymbol : objfile->msymbols ())
{ {
@@ -4995,7 +4979,7 @@ global_symbol_searcher::add_matching_msymbols
{ {
/* For functions we can do a quick check of whether the /* For functions we can do a quick check of whether the
symbol might be found via find_pc_symtab. */ symbol might be found via find_pc_symtab. */
if (kind != FUNCTIONS_DOMAIN if ((kind & SEARCH_FUNCTION_DOMAIN) == 0
|| (find_pc_compunit_symtab || (find_pc_compunit_symtab
(msymbol->value_address (objfile)) == NULL)) (msymbol->value_address (objfile)) == NULL))
{ {
@@ -5025,8 +5009,6 @@ global_symbol_searcher::search () const
std::optional<compiled_regex> preg; std::optional<compiled_regex> preg;
std::optional<compiled_regex> treg; std::optional<compiled_regex> treg;
gdb_assert (m_kind != ALL_DOMAIN);
if (m_symbol_name_regexp != NULL) if (m_symbol_name_regexp != NULL)
{ {
const char *symbol_name_regexp = m_symbol_name_regexp; const char *symbol_name_regexp = m_symbol_name_regexp;
@@ -5103,11 +5085,13 @@ global_symbol_searcher::search () const
user wants to see symbols matching a type regexp, then never give a user wants to see symbols matching a type regexp, then never give a
minimal symbol, as we assume that a minimal symbol does not have a minimal symbol, as we assume that a minimal symbol does not have a
type. */ type. */
if ((found_msymbol || (filenames.empty () && m_kind == VARIABLES_DOMAIN)) if ((found_msymbol
|| (filenames.empty () && (m_kind & SEARCH_VAR_DOMAIN) != 0))
&& !m_exclude_minsyms && !m_exclude_minsyms
&& !treg.has_value ()) && !treg.has_value ())
{ {
gdb_assert (m_kind == VARIABLES_DOMAIN || m_kind == FUNCTIONS_DOMAIN); gdb_assert ((m_kind & (SEARCH_VAR_DOMAIN | SEARCH_FUNCTION_DOMAIN))
!= 0);
for (objfile *objfile : current_program_space->objfiles ()) for (objfile *objfile : current_program_space->objfiles ())
if (!add_matching_msymbols (objfile, preg, &result)) if (!add_matching_msymbols (objfile, preg, &result))
break; break;
@@ -5238,36 +5222,55 @@ print_msymbol_info (struct bound_minimal_symbol msymbol)
static void static void
symtab_symbol_info (bool quiet, bool exclude_minsyms, symtab_symbol_info (bool quiet, bool exclude_minsyms,
const char *regexp, enum search_domain kind, const char *regexp, domain_enum kind,
const char *t_regexp, int from_tty) const char *t_regexp, int from_tty)
{ {
static const char * const classnames[] =
{"variable", "function", "type", "module"};
const char *last_filename = ""; const char *last_filename = "";
int first = 1; int first = 1;
gdb_assert (kind != ALL_DOMAIN);
if (regexp != nullptr && *regexp == '\0') if (regexp != nullptr && *regexp == '\0')
regexp = nullptr; regexp = nullptr;
global_symbol_searcher spec (kind, regexp); domain_search_flags flags = to_search_flags (kind);
if (kind == TYPE_DOMAIN)
flags |= SEARCH_STRUCT_DOMAIN;
global_symbol_searcher spec (flags, regexp);
spec.set_symbol_type_regexp (t_regexp); spec.set_symbol_type_regexp (t_regexp);
spec.set_exclude_minsyms (exclude_minsyms); spec.set_exclude_minsyms (exclude_minsyms);
std::vector<symbol_search> symbols = spec.search (); std::vector<symbol_search> symbols = spec.search ();
if (!quiet) if (!quiet)
{ {
const char *classname;
switch (kind)
{
case VAR_DOMAIN:
classname = "variable";
break;
case FUNCTION_DOMAIN:
classname = "function";
break;
case TYPE_DOMAIN:
classname = "type";
break;
case MODULE_DOMAIN:
classname = "module";
break;
default:
gdb_assert_not_reached ("invalid domain enum");
}
if (regexp != NULL) if (regexp != NULL)
{ {
if (t_regexp != NULL) if (t_regexp != NULL)
gdb_printf gdb_printf
(_("All %ss matching regular expression \"%s\"" (_("All %ss matching regular expression \"%s\""
" with type matching regular expression \"%s\":\n"), " with type matching regular expression \"%s\":\n"),
classnames[kind], regexp, t_regexp); classname, regexp, t_regexp);
else else
gdb_printf (_("All %ss matching regular expression \"%s\":\n"), gdb_printf (_("All %ss matching regular expression \"%s\":\n"),
classnames[kind], regexp); classname, regexp);
} }
else else
{ {
@@ -5275,9 +5278,9 @@ symtab_symbol_info (bool quiet, bool exclude_minsyms,
gdb_printf gdb_printf
(_("All defined %ss" (_("All defined %ss"
" with type matching regular expression \"%s\" :\n"), " with type matching regular expression \"%s\" :\n"),
classnames[kind], t_regexp); classname, t_regexp);
else else
gdb_printf (_("All defined %ss:\n"), classnames[kind]); gdb_printf (_("All defined %ss:\n"), classname);
} }
} }
@@ -5380,7 +5383,7 @@ info_variables_command (const char *args, int from_tty)
args = nullptr; args = nullptr;
symtab_symbol_info symtab_symbol_info
(opts.quiet, opts.exclude_minsyms, args, VARIABLES_DOMAIN, (opts.quiet, opts.exclude_minsyms, args, VAR_DOMAIN,
opts.type_regexp.empty () ? nullptr : opts.type_regexp.c_str (), opts.type_regexp.empty () ? nullptr : opts.type_regexp.c_str (),
from_tty); from_tty);
} }
@@ -5399,7 +5402,7 @@ info_functions_command (const char *args, int from_tty)
args = nullptr; args = nullptr;
symtab_symbol_info symtab_symbol_info
(opts.quiet, opts.exclude_minsyms, args, FUNCTIONS_DOMAIN, (opts.quiet, opts.exclude_minsyms, args, FUNCTION_DOMAIN,
opts.type_regexp.empty () ? nullptr : opts.type_regexp.c_str (), opts.type_regexp.empty () ? nullptr : opts.type_regexp.c_str (),
from_tty); from_tty);
} }
@@ -5442,7 +5445,8 @@ info_types_command (const char *args, int from_tty)
(&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp); (&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp);
if (args != nullptr && *args == '\0') if (args != nullptr && *args == '\0')
args = nullptr; args = nullptr;
symtab_symbol_info (opts.quiet, false, args, TYPES_DOMAIN, NULL, from_tty); symtab_symbol_info (opts.quiet, false, args, TYPE_DOMAIN, nullptr,
from_tty);
} }
/* Command completer for 'info types' command. */ /* Command completer for 'info types' command. */
@@ -5474,7 +5478,7 @@ info_modules_command (const char *args, int from_tty)
(&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp); (&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp);
if (args != nullptr && *args == '\0') if (args != nullptr && *args == '\0')
args = nullptr; args = nullptr;
symtab_symbol_info (opts.quiet, true, args, MODULES_DOMAIN, NULL, symtab_symbol_info (opts.quiet, true, args, MODULE_DOMAIN, nullptr,
from_tty); from_tty);
} }
@@ -5517,7 +5521,7 @@ rbreak_command (const char *regexp, int from_tty)
} }
} }
global_symbol_searcher spec (FUNCTIONS_DOMAIN, regexp); global_symbol_searcher spec (SEARCH_FUNCTION_DOMAIN, regexp);
if (file_name != nullptr) if (file_name != nullptr)
spec.filenames.push_back (file_name); spec.filenames.push_back (file_name);
std::vector<symbol_search> symbols = spec.search (); std::vector<symbol_search> symbols = spec.search ();
@@ -6015,7 +6019,7 @@ default_collect_symbol_completion_matches_break_on
return true; return true;
}, },
SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
ALL_DOMAIN); SEARCH_ALL);
/* Search upwards from currently selected frame (so that we can /* Search upwards from currently selected frame (so that we can
complete on local vars). Also catch fields of types defined in complete on local vars). Also catch fields of types defined in
@@ -6714,12 +6718,12 @@ static struct cmd_list_element *info_module_cmdlist = NULL;
std::vector<module_symbol_search> std::vector<module_symbol_search>
search_module_symbols (const char *module_regexp, const char *regexp, search_module_symbols (const char *module_regexp, const char *regexp,
const char *type_regexp, search_domain kind) const char *type_regexp, domain_search_flags kind)
{ {
std::vector<module_symbol_search> results; std::vector<module_symbol_search> results;
/* Search for all modules matching MODULE_REGEXP. */ /* Search for all modules matching MODULE_REGEXP. */
global_symbol_searcher spec1 (MODULES_DOMAIN, module_regexp); global_symbol_searcher spec1 (SEARCH_MODULE_DOMAIN, module_regexp);
spec1.set_exclude_minsyms (true); spec1.set_exclude_minsyms (true);
std::vector<symbol_search> modules = spec1.search (); std::vector<symbol_search> modules = spec1.search ();
@@ -6765,8 +6769,10 @@ search_module_symbols (const char *module_regexp, const char *regexp,
static void static void
info_module_subcommand (bool quiet, const char *module_regexp, info_module_subcommand (bool quiet, const char *module_regexp,
const char *regexp, const char *type_regexp, const char *regexp, const char *type_regexp,
search_domain kind) domain_search_flags kind)
{ {
gdb_assert (kind == SEARCH_FUNCTION_DOMAIN || kind == SEARCH_VAR_DOMAIN);
/* Print a header line. Don't build the header line bit by bit as this /* Print a header line. Don't build the header line bit by bit as this
prevents internationalisation. */ prevents internationalisation. */
if (!quiet) if (!quiet)
@@ -6776,12 +6782,12 @@ info_module_subcommand (bool quiet, const char *module_regexp,
if (type_regexp == nullptr) if (type_regexp == nullptr)
{ {
if (regexp == nullptr) if (regexp == nullptr)
gdb_printf ((kind == VARIABLES_DOMAIN gdb_printf ((kind == SEARCH_VAR_DOMAIN
? _("All variables in all modules:") ? _("All variables in all modules:")
: _("All functions in all modules:"))); : _("All functions in all modules:")));
else else
gdb_printf gdb_printf
((kind == VARIABLES_DOMAIN ((kind == SEARCH_VAR_DOMAIN
? _("All variables matching regular expression" ? _("All variables matching regular expression"
" \"%s\" in all modules:") " \"%s\" in all modules:")
: _("All functions matching regular expression" : _("All functions matching regular expression"
@@ -6792,7 +6798,7 @@ info_module_subcommand (bool quiet, const char *module_regexp,
{ {
if (regexp == nullptr) if (regexp == nullptr)
gdb_printf gdb_printf
((kind == VARIABLES_DOMAIN ((kind == SEARCH_VAR_DOMAIN
? _("All variables with type matching regular " ? _("All variables with type matching regular "
"expression \"%s\" in all modules:") "expression \"%s\" in all modules:")
: _("All functions with type matching regular " : _("All functions with type matching regular "
@@ -6800,7 +6806,7 @@ info_module_subcommand (bool quiet, const char *module_regexp,
type_regexp); type_regexp);
else else
gdb_printf gdb_printf
((kind == VARIABLES_DOMAIN ((kind == SEARCH_VAR_DOMAIN
? _("All variables matching regular expression " ? _("All variables matching regular expression "
"\"%s\",\n\twith type matching regular " "\"%s\",\n\twith type matching regular "
"expression \"%s\" in all modules:") "expression \"%s\" in all modules:")
@@ -6816,7 +6822,7 @@ info_module_subcommand (bool quiet, const char *module_regexp,
{ {
if (regexp == nullptr) if (regexp == nullptr)
gdb_printf gdb_printf
((kind == VARIABLES_DOMAIN ((kind == SEARCH_VAR_DOMAIN
? _("All variables in all modules matching regular " ? _("All variables in all modules matching regular "
"expression \"%s\":") "expression \"%s\":")
: _("All functions in all modules matching regular " : _("All functions in all modules matching regular "
@@ -6824,7 +6830,7 @@ info_module_subcommand (bool quiet, const char *module_regexp,
module_regexp); module_regexp);
else else
gdb_printf gdb_printf
((kind == VARIABLES_DOMAIN ((kind == SEARCH_VAR_DOMAIN
? _("All variables matching regular expression " ? _("All variables matching regular expression "
"\"%s\",\n\tin all modules matching regular " "\"%s\",\n\tin all modules matching regular "
"expression \"%s\":") "expression \"%s\":")
@@ -6837,7 +6843,7 @@ info_module_subcommand (bool quiet, const char *module_regexp,
{ {
if (regexp == nullptr) if (regexp == nullptr)
gdb_printf gdb_printf
((kind == VARIABLES_DOMAIN ((kind == SEARCH_VAR_DOMAIN
? _("All variables with type matching regular " ? _("All variables with type matching regular "
"expression \"%s\"\n\tin all modules matching " "expression \"%s\"\n\tin all modules matching "
"regular expression \"%s\":") "regular expression \"%s\":")
@@ -6847,7 +6853,7 @@ info_module_subcommand (bool quiet, const char *module_regexp,
type_regexp, module_regexp); type_regexp, module_regexp);
else else
gdb_printf gdb_printf
((kind == VARIABLES_DOMAIN ((kind == SEARCH_VAR_DOMAIN
? _("All variables matching regular expression " ? _("All variables matching regular expression "
"\"%s\",\n\twith type matching regular expression " "\"%s\",\n\twith type matching regular expression "
"\"%s\",\n\tin all modules matching regular " "\"%s\",\n\tin all modules matching regular "
@@ -6962,7 +6968,7 @@ info_module_functions_command (const char *args, int from_tty)
(opts.quiet, (opts.quiet,
opts.module_regexp.empty () ? nullptr : opts.module_regexp.c_str (), args, opts.module_regexp.empty () ? nullptr : opts.module_regexp.c_str (), args,
opts.type_regexp.empty () ? nullptr : opts.type_regexp.c_str (), opts.type_regexp.empty () ? nullptr : opts.type_regexp.c_str (),
FUNCTIONS_DOMAIN); SEARCH_FUNCTION_DOMAIN);
} }
/* Implements the 'info module variables' command. */ /* Implements the 'info module variables' command. */
@@ -6981,7 +6987,7 @@ info_module_variables_command (const char *args, int from_tty)
(opts.quiet, (opts.quiet,
opts.module_regexp.empty () ? nullptr : opts.module_regexp.c_str (), args, opts.module_regexp.empty () ? nullptr : opts.module_regexp.c_str (), args,
opts.type_regexp.empty () ? nullptr : opts.type_regexp.c_str (), opts.type_regexp.empty () ? nullptr : opts.type_regexp.c_str (),
VARIABLES_DOMAIN); SEARCH_VAR_DOMAIN);
} }
/* Command completer for 'info module ...' sub-commands. */ /* Command completer for 'info module ...' sub-commands. */

View File

@@ -947,30 +947,6 @@ search_flags_matches (domain_search_flags flags, domain_enum domain)
return (flags & to_search_flags (domain)) != 0; return (flags & to_search_flags (domain)) != 0;
} }
/* Searching domains, used when searching for symbols. Element numbers are
hardcoded in GDB, check all enum uses before changing it. */
enum search_domain
{
/* Everything in VAR_DOMAIN minus FUNCTIONS_DOMAIN and
TYPES_DOMAIN. */
VARIABLES_DOMAIN = 0,
/* All functions -- for some reason not methods, though. */
FUNCTIONS_DOMAIN = 1,
/* All defined types */
TYPES_DOMAIN = 2,
/* All modules. */
MODULES_DOMAIN = 3,
/* Any type. */
ALL_DOMAIN = 4
};
extern const char *search_domain_name (enum search_domain);
/* An address-class says where to find the value of a symbol. */ /* An address-class says where to find the value of a symbol. */
enum address_class enum address_class
@@ -2584,13 +2560,11 @@ class global_symbol_searcher
public: public:
/* Constructor. */ /* Constructor. */
global_symbol_searcher (enum search_domain kind, global_symbol_searcher (domain_search_flags kind,
const char *symbol_name_regexp) const char *symbol_name_regexp)
: m_kind (kind), : m_kind (kind),
m_symbol_name_regexp (symbol_name_regexp) 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. */ /* Set the optional regexp that matches against the symbol type. */
@@ -2632,7 +2606,7 @@ private:
TYPES_DOMAIN - Search all type names. TYPES_DOMAIN - Search all type names.
MODULES_DOMAIN - Search all Fortran modules. MODULES_DOMAIN - Search all Fortran modules.
ALL_DOMAIN - Not valid for this function. */ ALL_DOMAIN - Not valid for this function. */
enum search_domain m_kind; domain_search_flags m_kind;
/* Regular expression to match against the symbol name. */ /* Regular expression to match against the symbol name. */
const char *m_symbol_name_regexp = nullptr; const char *m_symbol_name_regexp = nullptr;
@@ -2676,7 +2650,7 @@ private:
std::vector<symbol_search> *results) const; std::vector<symbol_search> *results) const;
/* Return true if MSYMBOL is of type KIND. */ /* Return true if MSYMBOL is of type KIND. */
static bool is_suitable_msymbol (const enum search_domain kind, static bool is_suitable_msymbol (const domain_search_flags kind,
const minimal_symbol *msymbol); const minimal_symbol *msymbol);
}; };
@@ -2693,7 +2667,7 @@ typedef std::pair<symbol_search, symbol_search> module_symbol_search;
within the module. */ within the module. */
extern std::vector<module_symbol_search> search_module_symbols extern std::vector<module_symbol_search> search_module_symbols
(const char *module_regexp, const char *regexp, (const char *module_regexp, const char *regexp,
const char *type_regexp, search_domain kind); const char *type_regexp, domain_search_flags kind);
/* Convert a global or static symbol SYM (based on BLOCK, which should be /* 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' either GLOBAL_BLOCK or STATIC_BLOCK) into a string for use in 'info'
@@ -2895,7 +2869,7 @@ public:
to search all symtabs and program spaces. */ to search all symtabs and program spaces. */
void find_all_symbols (const std::string &name, void find_all_symbols (const std::string &name,
const struct language_defn *language, const struct language_defn *language,
enum search_domain search_domain, domain_search_flags domain_search_flags,
std::vector<symtab *> *search_symtabs, std::vector<symtab *> *search_symtabs,
struct program_space *search_pspace); struct program_space *search_pspace);