public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Markus Metzger <mmetzger@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb, ada: update ada_lookup_simple_minsym Date: Tue, 18 Oct 2022 13:25:23 +0000 (GMT) [thread overview] Message-ID: <20221018132523.5CBA53858401@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=06a670e280f39b0dd7fe0b0e0e21efa488c2729f commit 06a670e280f39b0dd7fe0b0e0e21efa488c2729f Author: Markus Metzger <markus.t.metzger@intel.com> Date: Tue Apr 12 16:05:26 2022 +0200 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. Diff: --- gdb/ada-exp.y | 9 ++++++++- gdb/ada-lang.c | 32 ++++++++++++++++++-------------- gdb/ada-lang.h | 3 ++- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index f67c221d873..3ec9e4d610c 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -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); diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index f4d3f32d339..a24b1b5b8ef 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -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; } diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h index 84c691b94ee..d9c74f0a552 100644 --- a/gdb/ada-lang.h +++ b/gdb/ada-lang.h @@ -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 *);
reply other threads:[~2022-10-18 13:25 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20221018132523.5CBA53858401@sourceware.org \ --to=mmetzger@sourceware.org \ --cc=gdb-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).