From patchwork Sun Oct 29 17:35:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 78682 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2044D3864C69 for ; Sun, 29 Oct 2023 17:39:25 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta040.useast.a.cloudfilter.net (omta040.useast.a.cloudfilter.net [44.202.169.39]) by sourceware.org (Postfix) with ESMTPS id 872D1385276F for ; Sun, 29 Oct 2023 17:38:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 872D1385276F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 872D1385276F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698601113; cv=none; b=FDsZXwmd5ghgvc61rji7nRXSZOq60RVkNHsFocTNDPmMHkKo3tyJ2MzscLiLoNEQ/kGBCBZXYYU5pzF6bqfMbNRN4pHvwza9siRAKqoCDDmO05Uwt89/VPq+pEjjn6NbArfyewxSnRr9Z8RAh1019p3kuZo3k376ePZQz/xDQBw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698601113; c=relaxed/simple; bh=4zSLm2s38YyLN7SKujXbhhPb6kZHmNAyHZ6SpgDQOIs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=lWh4ybgKgyb0jiBq+B+LFjKHbM02ATmMgqMstelRQWa2j5j69luIRPrNdbc22K6GEdp5a6/EVxdWkd7iaEsWVjWKvojIERRiYsDvVTidbYVqfFRlu3/rmoIqM/8/QLTONQPQhcqzTtt/CTheFekpxjxhY1d58ubzZ+bamOB0RGg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6003a.ext.cloudfilter.net ([10.0.30.151]) by cmsmtp with ESMTPS id wjr9q7ofG6nOZx9k1qvsTh; Sun, 29 Oct 2023 17:38:26 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id x9k0qFKmFRqxCx9k1qt81T; Sun, 29 Oct 2023 17:38:25 +0000 X-Authority-Analysis: v=2.4 cv=IY2U5Ema c=1 sm=1 tr=0 ts=653e9891 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=bhdUkHdE2iEA:10 a=Qbun_eYptAEA:10 a=NCcGvFC-7IuRexjrVQYA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=pfYZ4T2j6YRz5gVDDTXgzF+kufDYl1YWw4+5+5NCAgE=; b=l8rpStazj6EMc+dByDB73vsKiS iCp1RPMQfi+jppQeCpDtbPcu7qB/xh762+FXclVyC3eAkVzX9UJhD3ynDe48zNabjTxocuZoXSdf9 CAmv+xsB1MvbJj/WePEF6uXQ2; Received: from 97-122-77-73.hlrn.qwest.net ([97.122.77.73]:47464 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1qx9k0-000nk4-1r; Sun, 29 Oct 2023 11:38:24 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 03/15] Add quick_symbol_functions::compute_main_name Date: Sun, 29 Oct 2023 11:35:22 -0600 Message-ID: <20231029173839.471514-4-tom@tromey.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231029173839.471514-1-tom@tromey.com> References: <20231029173839.471514-1-tom@tromey.com> MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.77.73 X-Source-L: No X-Exim-ID: 1qx9k0-000nk4-1r X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-77-73.hlrn.qwest.net (localhost.localdomain) [97.122.77.73]:47464 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfKMcnIIn4EY/pcXdCGbqRYDoHkti+ar5PjSHMSNobOV68CUXzBJxTa7ECgqOuyUizkYlm2mFEngdBukp6Ovq3FADFzXjaKzJXdY16qEtc12JJgTatYhf mPoK+j2aegaA/Y342CyG6y772pY3cZ7xj0zJFGk2efVQOn37bHeyYg4iKo3vQ6CzmVLVDAmZP3u3l7Si413NQ7G/KS6efTOveD0= X-Spam-Status: No, score=-3024.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This adds a new compute_main_name method to quick_symbol_functions. Currently there are no implementations of this, but a subsequent patch will add one. --- gdb/objfiles.h | 3 +++ gdb/quick-symbol.h | 9 +++++++++ gdb/symfile-debug.c | 12 ++++++++++++ gdb/symtab.c | 2 ++ 4 files changed, 26 insertions(+) diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 4b8aa9bfcec..c0ca9de6874 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -601,6 +601,9 @@ struct objfile void map_symbol_filenames (gdb::function_view fun, bool need_fullname); + /* See quick_symbol_functions. */ + void compute_main_name (); + /* See quick_symbol_functions. */ struct compunit_symtab *find_compunit_symtab_by_address (CORE_ADDR address); diff --git a/gdb/quick-symbol.h b/gdb/quick-symbol.h index a7fea2ccb49..49505aef64a 100644 --- a/gdb/quick-symbol.h +++ b/gdb/quick-symbol.h @@ -212,6 +212,15 @@ struct quick_symbol_functions gdb::function_view fun, bool need_fullname) = 0; + /* Compute the name and language of the main function for the given + objfile. Normally this is done during symbol reading, but this + method exists in case this work is done in a worker thread and + must be waited for. The implementation can call + set_objfile_main_name if results are found. */ + virtual void compute_main_name (struct objfile *objfile) + { + } + /* Return true if this class can lazily read the symbols. This may only return true if there are in fact symbols to be read, because this is used in the implementation of 'has_partial_symbols'. */ diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c index 850da4147a3..4b27d9eb406 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -483,6 +483,18 @@ objfile::map_symbol_filenames (gdb::function_view fun, iter->map_symbol_filenames (this, fun, need_fullname); } +void +objfile::compute_main_name () +{ + if (debug_symfile) + gdb_printf (gdb_stdlog, + "qf->compute_main_name (%s)\n", + objfile_debug_name (this)); + + for (const auto &iter : qf_require_partial_symbols ()) + iter->compute_main_name (this); +} + struct compunit_symtab * objfile::find_compunit_symtab_by_address (CORE_ADDR address) { diff --git a/gdb/symtab.c b/gdb/symtab.c index 5ec56f4f2af..ea003a4d4c9 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -6237,6 +6237,8 @@ find_main_name (void) accurate. */ for (objfile *objfile : current_program_space->objfiles ()) { + objfile->compute_main_name (); + if (objfile->per_bfd->name_of_main != NULL) { set_main_name (pspace,