This adds a block search flags parameter to expand_symtabs_matching.
All callers are updated to search both the static and global blocks,
as that was the implied behavior before this patch.
This is a step toward replacing lookup_symbol with
expand_symtabs_matching.
gdb/ChangeLog
2021-04-17 Tom Tromey <tom@tromey.com>
* symtab.c (global_symbol_searcher::expand_symtabs)
(default_collect_symbol_completion_matches_break_on): Update.
* symmisc.c (maintenance_expand_symtabs): Update.
* symfile.h (expand_symtabs_matching): Add search_flags
parameter.
* symfile.c (expand_symtabs_matching): Add search_flags
parameter.
* symfile-debug.c (objfile::expand_symtabs_matching): Add
search_flags parameter.
* quick-symbol.h (struct quick_symbol_functions)
<expand_symtabs_matching>: Add search_flags parameter.
* python/py-symbol.c (gdbpy_lookup_static_symbols): Update.
* psymtab.c (recursively_search_psymtabs)
(psymbol_functions::expand_symtabs_matching): Add search_flags
parameter.
* psympriv.h (struct psymbol_functions) <expand_symtabs_matching>:
Add search_flags parameter.
* objfiles.h (struct objfile) <expand_symtabs_matching>: Add
search_flags parameter.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* dwarf2/read.c (struct dwarf2_gdb_index)
<expand_symtabs_matching>: Add search_flags parameter.
(struct dwarf2_debug_names_index) <expand_symtabs_matching>: Add
search_flags parameter.
(dw2_map_matching_symbols): Update.
(dw2_expand_marked_cus, dw2_expand_symtabs_matching)
(dwarf2_gdb_index::expand_symtabs_matching): Add search_flags
parameter.
(dw2_debug_names_iterator): Change block_index to search flags.
<m_block_index>: Likewise.
(dw2_debug_names_iterator::next)
(dwarf2_debug_names_index::lookup_symbol)
(dwarf2_debug_names_index::expand_symtabs_for_function)
(dwarf2_debug_names_index::map_matching_symbols)
(dwarf2_debug_names_index::map_matching_symbols): Update.
(dwarf2_debug_names_index::expand_symtabs_matching): Add
search_flags parameter.
* ada-lang.c (ada_add_global_exceptions)
(collect_symbol_completion_matches): Update.
+2021-04-17 Tom Tromey <tom@tromey.com>
+
+ * symtab.c (global_symbol_searcher::expand_symtabs)
+ (default_collect_symbol_completion_matches_break_on): Update.
+ * symmisc.c (maintenance_expand_symtabs): Update.
+ * symfile.h (expand_symtabs_matching): Add search_flags
+ parameter.
+ * symfile.c (expand_symtabs_matching): Add search_flags
+ parameter.
+ * symfile-debug.c (objfile::expand_symtabs_matching): Add
+ search_flags parameter.
+ * quick-symbol.h (struct quick_symbol_functions)
+ <expand_symtabs_matching>: Add search_flags parameter.
+ * python/py-symbol.c (gdbpy_lookup_static_symbols): Update.
+ * psymtab.c (recursively_search_psymtabs)
+ (psymbol_functions::expand_symtabs_matching): Add search_flags
+ parameter.
+ * psympriv.h (struct psymbol_functions) <expand_symtabs_matching>:
+ Add search_flags parameter.
+ * objfiles.h (struct objfile) <expand_symtabs_matching>: Add
+ search_flags parameter.
+ * linespec.c (iterate_over_all_matching_symtabs): Update.
+ * dwarf2/read.c (struct dwarf2_gdb_index)
+ <expand_symtabs_matching>: Add search_flags parameter.
+ (struct dwarf2_debug_names_index) <expand_symtabs_matching>: Add
+ search_flags parameter.
+ (dw2_map_matching_symbols): Update.
+ (dw2_expand_marked_cus, dw2_expand_symtabs_matching)
+ (dwarf2_gdb_index::expand_symtabs_matching): Add search_flags
+ parameter.
+ (dw2_debug_names_iterator): Change block_index to search flags.
+ <m_block_index>: Likewise.
+ (dw2_debug_names_iterator::next)
+ (dwarf2_debug_names_index::lookup_symbol)
+ (dwarf2_debug_names_index::expand_symtabs_for_function)
+ (dwarf2_debug_names_index::map_matching_symbols)
+ (dwarf2_debug_names_index::map_matching_symbols): Update.
+ (dwarf2_debug_names_index::expand_symtabs_matching): Add
+ search_flags parameter.
+ * ada-lang.c (ada_add_global_exceptions)
+ (collect_symbol_completion_matches): Update.
+
2021-04-17 Tom Tromey <tom@tromey.com>
* symtab.c (default_collect_symbol_completion_matches_break_on):
return name_matches_regex (decoded.c_str (), preg);
},
NULL,
+ SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
VARIABLES_DOMAIN);
for (objfile *objfile : current_program_space->objfiles ())
lookup_name,
NULL,
NULL,
+ SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
ALL_DOMAIN);
/* At this point scan through the misc symbol vectors and add each
const lookup_name_info *lookup_name,
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
+ block_search_flags search_flags,
enum search_domain kind) override;
};
const lookup_name_info *lookup_name,
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
+ block_search_flags search_flags,
enum search_domain kind) override;
};
(dwarf2_per_objfile *per_objfile, offset_type idx,
gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
+ block_search_flags search_flags,
search_domain kind)
{
offset_type *vec, vec_len, vec_idx;
/* Only check the symbol's kind if it has one. */
if (attrs_valid)
{
+ if (is_static)
+ {
+ if ((search_flags & SEARCH_STATIC_BLOCK) == 0)
+ continue;
+ }
+ else
+ {
+ if ((search_flags & SEARCH_GLOBAL_BLOCK) == 0)
+ continue;
+ }
+
switch (kind)
{
case VARIABLES_DOMAIN:
const lookup_name_info *lookup_name,
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
+ block_search_flags search_flags,
enum search_domain kind)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
[&] (offset_type idx)
{
if (!dw2_expand_marked_cus (per_objfile, idx, file_matcher,
- expansion_notify, kind))
+ expansion_notify, search_flags, kind))
return false;
return true;
}, per_objfile);
{
public:
dw2_debug_names_iterator (const mapped_debug_names &map,
- gdb::optional<block_enum> block_index,
+ block_search_flags block_index,
domain_enum domain,
const char *name, dwarf2_per_objfile *per_objfile)
: m_map (map), m_block_index (block_index), m_domain (domain),
{}
dw2_debug_names_iterator (const mapped_debug_names &map,
- search_domain search, uint32_t namei, dwarf2_per_objfile *per_objfile)
+ search_domain search, uint32_t namei,
+ dwarf2_per_objfile *per_objfile)
: m_map (map),
m_search (search),
m_addr (find_vec_in_debug_names (map, namei, per_objfile)),
{}
dw2_debug_names_iterator (const mapped_debug_names &map,
- block_enum block_index, domain_enum domain,
+ block_search_flags block_index, domain_enum domain,
uint32_t namei, dwarf2_per_objfile *per_objfile)
: m_map (map), m_block_index (block_index), m_domain (domain),
m_addr (find_vec_in_debug_names (map, namei, per_objfile)),
/* The internalized form of .debug_names. */
const mapped_debug_names &m_map;
- /* If set, only look for symbols that match that block. Valid values are
- GLOBAL_BLOCK and STATIC_BLOCK. */
- const gdb::optional<block_enum> m_block_index;
+ /* Restrict the search to these blocks. */
+ block_search_flags m_block_index = (SEARCH_GLOBAL_BLOCK
+ | SEARCH_STATIC_BLOCK);
/* The kind of symbol we're looking for. */
const domain_enum m_domain = UNDEF_DOMAIN;
goto again;
/* Check static vs global. */
- if (symbol_linkage_ != symbol_linkage::unknown && m_block_index.has_value ())
+ if (symbol_linkage_ != symbol_linkage::unknown)
{
- const bool want_static = *m_block_index == STATIC_BLOCK;
- const bool symbol_is_static =
- symbol_linkage_ == symbol_linkage::static_;
- if (want_static != symbol_is_static)
- goto again;
+ if (symbol_linkage_ == symbol_linkage::static_)
+ {
+ if ((m_block_index & SEARCH_STATIC_BLOCK) == 0)
+ goto again;
+ }
+ else
+ {
+ if ((m_block_index & SEARCH_GLOBAL_BLOCK) == 0)
+ goto again;
+ }
}
/* Match dw2_symtab_iter_next, symbol_kind
}
const auto &map = *mapp;
- dw2_debug_names_iterator iter (map, block_index, domain, name, per_objfile);
+ dw2_debug_names_iterator iter (map,
+ block_index == GLOBAL_BLOCK
+ ? SEARCH_GLOBAL_BLOCK
+ : SEARCH_STATIC_BLOCK,
+ domain, name, per_objfile);
struct compunit_symtab *stab_best = NULL;
struct dwarf2_per_cu_data *per_cu;
{
const mapped_debug_names &map = *per_objfile->per_bfd->debug_names_table;
- dw2_debug_names_iterator iter (map, {}, VAR_DOMAIN, func_name,
+ dw2_debug_names_iterator iter (map,
+ (SEARCH_GLOBAL_BLOCK
+ | SEARCH_STATIC_BLOCK),
+ VAR_DOMAIN, func_name,
per_objfile);
struct dwarf2_per_cu_data *per_cu;
mapped_debug_names &map = *per_objfile->per_bfd->debug_names_table;
const block_enum block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
+ const block_search_flags block_flags
+ = global ? SEARCH_GLOBAL_BLOCK : SEARCH_STATIC_BLOCK;
const char *match_name = name.ada ().lookup_name ().c_str ();
auto matcher = [&] (const char *symname)
{
/* The name was matched, now expand corresponding CUs that were
marked. */
- dw2_debug_names_iterator iter (map, block_kind, domain, namei,
+ dw2_debug_names_iterator iter (map, block_flags, domain, namei,
per_objfile);
struct dwarf2_per_cu_data *per_cu;
const lookup_name_info *lookup_name,
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
+ block_search_flags search_flags,
enum search_domain kind)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
for (objfile *objfile : current_program_space->objfiles ())
{
objfile->expand_symtabs_matching (NULL, &lookup_name, NULL, NULL,
+ (SEARCH_GLOBAL_BLOCK
+ | SEARCH_STATIC_BLOCK),
search_domain);
for (compunit_symtab *cu : objfile->compunits ())
const lookup_name_info *lookup_name,
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
+ block_search_flags search_flags,
enum search_domain kind);
/* See quick_symbol_functions. */
const lookup_name_info *lookup_name,
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
+ block_search_flags search_flags,
enum search_domain kind) override;
struct compunit_symtab *find_pc_sect_compunit_symtab
recursively_search_psymtabs
(struct partial_symtab *ps,
struct objfile *objfile,
+ block_search_flags search_flags,
enum search_domain domain,
const lookup_name_info &lookup_name,
gdb::function_view<expand_symtabs_symbol_matcher_ftype> sym_matcher)
continue;
r = recursively_search_psymtabs (ps->dependencies[i],
- objfile, domain, lookup_name,
- sym_matcher);
+ objfile, search_flags, domain,
+ lookup_name, sym_matcher);
if (r != 0)
{
ps->searched_flag = PST_SEARCHED_AND_FOUND;
/* Go through all of the symbols stored in a partial
symtab in one loop. */
partial_symbol **psym = ps->global_psymbols.data ();
+
+ if ((search_flags & SEARCH_GLOBAL_BLOCK) == 0)
+ {
+ if (ps->static_psymbols.empty ())
+ keep_going = 0;
+ else
+ {
+ psym = ps->static_psymbols.data ();
+ bound = sbound;
+ }
+ }
+
while (keep_going)
{
if (psym >= bound)
{
- if (bound == gbound && !ps->static_psymbols.empty ())
+ if (bound == gbound && !ps->static_psymbols.empty ()
+ && (search_flags & SEARCH_STATIC_BLOCK) != 0)
{
psym = ps->static_psymbols.data ();
bound = sbound;
const lookup_name_info *lookup_name,
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
+ block_search_flags search_flags,
enum search_domain domain)
{
/* Clear the search flags. */
}
if ((symbol_matcher == NULL && lookup_name == NULL)
- || recursively_search_psymtabs (ps, objfile, domain,
+ || recursively_search_psymtabs (ps, objfile, search_flags, domain,
*psym_lookup_name,
symbol_matcher))
{
{
/* Expand any symtabs that contain potentially matching symbols. */
lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
- expand_symtabs_matching (NULL, lookup_name, NULL, NULL, ALL_DOMAIN);
+ expand_symtabs_matching (NULL, lookup_name, NULL, NULL,
+ SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
+ ALL_DOMAIN);
for (objfile *objfile : current_program_space->objfiles ())
{
const lookup_name_info *lookup_name,
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
+ block_search_flags search_flags,
enum search_domain kind) = 0;
/* Return the comp unit from OBJFILE that contains PC and
const lookup_name_info *lookup_name,
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
+ block_search_flags search_flags,
enum search_domain kind)
{
if (debug_symfile)
for (const auto &iter : qf)
if (!iter->expand_symtabs_matching (this, file_matcher, lookup_name,
symbol_matcher, expansion_notify,
- kind))
+ search_flags, kind))
return false;
return true;
}
const lookup_name_info &lookup_name,
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
+ block_search_flags search_flags,
enum search_domain kind)
{
for (objfile *objfile : current_program_space->objfiles ())
if (!objfile->expand_symtabs_matching (file_matcher,
&lookup_name,
symbol_matcher,
- expansion_notify, kind))
+ expansion_notify,
+ search_flags,
+ kind))
return false;
return true;
}
const lookup_name_info &lookup_name,
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
+ block_search_flags search_flags,
enum search_domain kind);
void map_symbol_filenames (gdb::function_view<symbol_filename_ftype> fun,
NULL,
NULL,
NULL,
+ SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
ALL_DOMAIN);
}
\f
|| preg->exec (symname, 0, NULL, 0) == 0);
},
NULL,
+ SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
kind);
/* Here, we search through the minimal symbol tables for functions and
sym_text, word, code);
return true;
},
+ SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
ALL_DOMAIN);
/* Search upwards from currently selected frame (so that we can