From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 8F1SANLKmGKI6wkAWB0awg (envelope-from ) for ; Thu, 02 Jun 2022 10:36:02 -0400 Received: by simark.ca (Postfix, from userid 112) id C561D1E222; Thu, 2 Jun 2022 10:36:01 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=p0Iy8M/Z; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 8E2691E220 for ; Thu, 2 Jun 2022 10:36:00 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2F6653836E4E for ; Thu, 2 Jun 2022 14:36:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F6653836E4E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1654180560; bh=yYNfTjyWP27oMi984VxNHlP+TMOCIHIKH4ege5dqMRs=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=p0Iy8M/ZVnhx8K+cM2u9gQN9XYuUQeyojPq79Gd+1yXt/oFj+IBAAyzoVZdZxs3HE BfAQoUrvSC1sHzngXuh3iPq6HIYokoEItdAX/X1nLOcOh0KdPw6kMri5Qvk6k+hI5T IYUycjHBHc0eALLWXr7Yi9olEB1UXPA7Q+lwAj08= Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by sourceware.org (Postfix) with ESMTPS id 9F04B384B833 for ; Thu, 2 Jun 2022 14:29:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9F04B384B833 X-IronPort-AV: E=McAfee;i="6400,9594,10365"; a="276039287" X-IronPort-AV: E=Sophos;i="5.91,271,1647327600"; d="scan'208";a="276039287" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2022 07:29:22 -0700 X-IronPort-AV: E=Sophos;i="5.91,271,1647327600"; d="scan'208";a="612843381" Received: from labpc2407.iul.intel.com (HELO localhost) ([172.28.50.61]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2022 07:29:21 -0700 To: gdb-patches@sourceware.org Subject: [PATCH v5 13/15] gdb, symtab: inline find_quick_global_symbol_language Date: Thu, 2 Jun 2022 15:25:12 +0200 Message-Id: <20220602132514.957983-14-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-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: , From: Markus Metzger via Gdb-patches Reply-To: Markus Metzger Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" There is only one use of find_quick_global_symbol_language that calls it for the special symbol "main". Inline the function as it is probably not correct in the general case where we may have multiple instances of global symbols with the same name but different languages in different libraries in different linker namespaces. Further, change the objfiles iteration into a call to gdbarch_iterate_over_objfiles_in_search_order, which would only search the initial linker namespace, where we expect "main" to be located. --- gdb/symtab.c | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index 8564986f66d..11dac0f4432 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2610,23 +2610,6 @@ lookup_symbol_in_objfile (struct objfile *objfile, enum block_enum block_index, return result; } -/* Find the language for partial symbol with NAME. */ - -static enum language -find_quick_global_symbol_language (const char *name, const domain_enum domain) -{ - for (objfile *objfile : current_program_space->objfiles ()) - { - bool symbol_found_p; - enum language lang - = objfile->lookup_global_symbol_language (name, domain, &symbol_found_p); - if (symbol_found_p) - return lang; - } - - return language_unknown; -} - /* This function contains the common code of lookup_{global,static}_symbol. OBJFILE is only used if BLOCK_INDEX is GLOBAL_SCOPE, in which case it is the objfile to start the lookup in. */ @@ -6367,13 +6350,25 @@ find_main_name (void) Fallback to "main". */ /* Try to find language for main in psymtabs. */ - enum language lang - = find_quick_global_symbol_language ("main", VAR_DOMAIN); - if (lang != language_unknown) - { - set_main_name ("main", lang); - return; - } + bool symbol_found_p = false; + gdbarch_iterate_over_objfiles_in_search_order + (target_gdbarch (), + [&symbol_found_p] (objfile *obj) + { + language lang + = obj->lookup_global_symbol_language ("main", VAR_DOMAIN, + &symbol_found_p); + if (symbol_found_p) + { + set_main_name ("main", lang); + return 1; + } + + return 0; + }, nullptr); + + if (symbol_found_p) + return; set_main_name ("main", language_unknown); } -- 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