From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by sourceware.org (Postfix) with ESMTPS id C8A74396E415 for ; Thu, 2 Jun 2022 14:29:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C8A74396E415 X-IronPort-AV: E=McAfee;i="6400,9594,10365"; a="275973036" X-IronPort-AV: E=Sophos;i="5.91,271,1647327600"; d="scan'208";a="275973036" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2022 07:29:13 -0700 X-IronPort-AV: E=Sophos;i="5.91,271,1647327600"; d="scan'208";a="563331281" Received: from labpc2407.iul.intel.com (HELO localhost) ([172.28.50.61]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2022 07:29:12 -0700 From: Markus Metzger To: gdb-patches@sourceware.org Subject: [PATCH v5 10/15] gdb, ada: update ada_add_all_symbols Date: Thu, 2 Jun 2022 15:25:09 +0200 Message-Id: <20220602132514.957983-11-markus.t.metzger@intel.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220602132514.957983-1-markus.t.metzger@intel.com> References: <20220602132514.957983-1-markus.t.metzger@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Jun 2022 14:29:16 -0000 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. --- gdb/ada-lang.c | 66 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 22 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 20ea4c8f6aa..110c246181e 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -5582,37 +5582,52 @@ map_matching_symbols (struct objfile *objfile, static void add_nonlocal_symbols (std::vector &result, + const struct block *block, const lookup_name_info &lookup_name, domain_enum domain, int global) { - struct match_data data (&result); + struct objfile *objfile = nullptr; + if (block != nullptr) + objfile = block_objfile (block); bool is_wild_match = lookup_name.ada ().wild_match_p (); - for (objfile *objfile : current_program_space->objfiles ()) - { - map_matching_symbols (objfile, lookup_name, is_wild_match, domain, - global, data); + match_data data (&result); - for (compunit_symtab *cu : objfile->compunits ()) - { - const struct block *global_block - = cu->blockvector ()->global_block (); + gdbarch_iterate_over_objfiles_in_search_order + (objfile != nullptr ? objfile->arch () : target_gdbarch (), + [&data, lookup_name, domain, global, is_wild_match] (struct objfile *obj) + { + map_matching_symbols (obj, lookup_name, is_wild_match, domain, + global, data); - if (ada_add_block_renamings (result, global_block, lookup_name, - domain)) - data.found_sym = true; - } - } + for (compunit_symtab *cu : obj->compunits ()) + { + const struct block *global_block + = cu->blockvector ()->global_block (); - if (result.empty () && global && !is_wild_match) + if (ada_add_block_renamings (*data.resultp, global_block, + lookup_name, domain)) + data.found_sym = true; + } + + return 0; + }, objfile); + + if (data.resultp->empty () && global && !is_wild_match) { const char *name = ada_lookup_name (lookup_name); std::string bracket_name = std::string ("<_ada_") + name + '>'; lookup_name_info name1 (bracket_name, symbol_name_match_type::FULL); - for (objfile *objfile : current_program_space->objfiles ()) - map_matching_symbols (objfile, name1, false, domain, global, data); + gdbarch_iterate_over_objfiles_in_search_order + (objfile != nullptr ? objfile->arch () : target_gdbarch (), + [&data, name1, domain, global] (struct objfile *obj) + { + map_matching_symbols (obj, name1, false, domain, global, data); + + return 0; + }, objfile); } } @@ -5642,6 +5657,7 @@ ada_add_all_symbols (std::vector &result, int *made_global_lookup_p) { struct symbol *sym; + const struct block *orig_block = block; if (made_global_lookup_p) *made_global_lookup_p = 0; @@ -5688,15 +5704,21 @@ ada_add_all_symbols (std::vector &result, if (made_global_lookup_p) *made_global_lookup_p = 1; - /* Search symbols from all global blocks. */ + /* Search symbols from all global blocks. + + Pass the original block to restrict the search to that block's + namespace. */ - add_nonlocal_symbols (result, lookup_name, domain, 1); + add_nonlocal_symbols (result, orig_block, lookup_name, domain, 1); + + /* Now add symbols from all per-file blocks if we've gotten no hits (not + strictly correct, but perhaps better than an error). - /* Now add symbols from all per-file blocks if we've gotten no hits - (not strictly correct, but perhaps better than an error). */ + Pass the original block to restrict the search to that block's + namespace. */ if (result.empty ()) - add_nonlocal_symbols (result, lookup_name, domain, 0); + add_nonlocal_symbols (result, orig_block, lookup_name, domain, 0); } /* Find symbols in DOMAIN matching LOOKUP_NAME, in BLOCK and, if FULL_SEARCH -- 2.35.3 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928