gdb, ada: update ada_lookup_simple_minsym

Iterate over objfile in search order using the objfile of the context
block as current_objfile so the iteration can stay inside the block's
linker namespace.
This commit is contained in:
Markus Metzger
2022-04-12 16:05:26 +02:00
parent 4326580d44
commit 06a670e280
3 changed files with 28 additions and 16 deletions

View File

@ -1698,8 +1698,15 @@ write_var_or_type (struct parser_state *par_state,
}
else if (syms.empty ())
{
if (block == nullptr)
block = get_selected_block (nullptr);
struct objfile *objfile = nullptr;
if (block != nullptr)
objfile = block_objfile (block);
struct bound_minimal_symbol msym
= ada_lookup_simple_minsym (decoded_name.c_str ());
= ada_lookup_simple_minsym (decoded_name.c_str (), objfile);
if (msym.minsym != NULL)
{
par_state->push_new<ada_var_msym_value_operation> (msym);

View File

@ -4901,7 +4901,7 @@ add_defn_to_vec (std::vector<struct block_symbol> &result,
global symbols are searched. */
struct bound_minimal_symbol
ada_lookup_simple_minsym (const char *name)
ada_lookup_simple_minsym (const char *name, struct objfile *objfile)
{
struct bound_minimal_symbol result;
@ -4911,19 +4911,23 @@ ada_lookup_simple_minsym (const char *name)
symbol_name_matcher_ftype *match_name
= ada_get_symbol_name_matcher (lookup_name);
for (objfile *objfile : current_program_space->objfiles ())
{
for (minimal_symbol *msymbol : objfile->msymbols ())
{
if (match_name (msymbol->linkage_name (), lookup_name, NULL)
&& msymbol->type () != mst_solib_trampoline)
{
result.minsym = msymbol;
result.objfile = objfile;
break;
}
}
}
gdbarch_iterate_over_objfiles_in_search_order
(objfile != NULL ? objfile->arch () : target_gdbarch (),
[&result, lookup_name, match_name] (struct objfile *obj)
{
for (minimal_symbol *msymbol : obj->msymbols ())
{
if (match_name (msymbol->linkage_name (), lookup_name, nullptr)
&& msymbol->type () != mst_solib_trampoline)
{
result.minsym = msymbol;
result.objfile = obj;
return 1;
}
}
return 0;
}, objfile);
return result;
}

View File

@ -234,7 +234,8 @@ extern void ada_lookup_encoded_symbol
(const char *name, const struct block *block, domain_enum domain,
struct block_symbol *symbol_info);
extern struct bound_minimal_symbol ada_lookup_simple_minsym (const char *);
extern struct bound_minimal_symbol ada_lookup_simple_minsym (const char *,
objfile *);
extern int ada_scan_number (const char *, int, LONGEST *, int *);