From patchwork Sun Nov 12 20:25:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 79674 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 694EB3857C44 for ; Sun, 12 Nov 2023 20:27:30 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta40.uswest2.a.cloudfilter.net (omta40.uswest2.a.cloudfilter.net [35.89.44.39]) by sourceware.org (Postfix) with ESMTPS id 2F69F3858C20 for ; Sun, 12 Nov 2023 20:25:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2F69F3858C20 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 2F69F3858C20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699820741; cv=none; b=NQCh4lG7dI7l1kVTmpovzn36n39A2iUU3T9FWFaVVMhPdQMBt5T1cCmv/qeFDpYLPAc1JQxaFIbH3Nu2QC7QBDRkBpSyHpOcyNoU3K5Lr/9sZQyPAJJDJrDiudpqH3igF8gWiyHTnwDFQCFmq6YvgZVuHdg5HbelYJywfEi/V/8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699820741; c=relaxed/simple; bh=0AC340bEJx35EcuxKZhjAQC2y1IO+4y0WWQqYtOgiX0=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=JQu9yVM7OS8b9OgDoXK4Jt1QZla9Dij/2yMESBuBSlnPmXcB6RXqzbmctxvUnTgKVYyDP8Pb7abLxrEejecQzCgtRiHHOzESoTDRG9mwktILR01wJLgSHb3BEyBp5RX/MuBmDg0maGZmsq9jWX7GkbYuZpQfxlHq59guR2tTGDk= 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 2BiCruORYL9Ag2H1TrVwda; Sun, 12 Nov 2023 20:25:35 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 2H1SrqUSOAKSc2H1Sr5Hla; Sun, 12 Nov 2023 20:25:34 +0000 X-Authority-Analysis: v=2.4 cv=N6w6qkxB c=1 sm=1 tr=0 ts=655134be a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=BNY50KLci1gA:10 a=Qbun_eYptAEA:10 a=iZoEup0oKZo78n3hRxoA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc: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=AH2xXdjQeEC0XgKkTCeeEiTl8Ww/HxjYNr8V2vPzPzA=; b=mZ6rOqHfl1kfqXHSHOeN2KQBSX KvokuJFkLuXNamSz8OoA29RZnsWdc5+Ue0BVcTjIP8i5X+TfDlK/RDkzjGWUOCQ4JAKVfDZfYFvpU d4/6mLFCzWS7xtgOytXpsX8Lh; Received: from 97-122-77-73.hlrn.qwest.net ([97.122.77.73]:34540 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1r2H1S-000cUU-07 for gdb-patches@sourceware.org; Sun, 12 Nov 2023 13:25:34 -0700 From: Tom Tromey Date: Sun, 12 Nov 2023 13:25:54 -0700 Subject: [PATCH v2 17/18] Avoid language-based lookups in startup path MIME-Version: 1.0 Message-Id: <20231112-t-bg-dwarf-reading-v2-17-70fb170012ba@tromey.com> References: <20231112-t-bg-dwarf-reading-v2-0-70fb170012ba@tromey.com> In-Reply-To: <20231112-t-bg-dwarf-reading-v2-0-70fb170012ba@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 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: 1r2H1S-000cUU-07 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-77-73.hlrn.qwest.net ([192.168.0.21]) [97.122.77.73]:34540 X-Source-Auth: tom+tromey.com X-Email-Count: 18 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfH92YSMdLGezDry3hpDjJNnQtGEQOge4jAUU+nc2KjSmBHXFmYji2g7uc8t7wsCdyMuOm8SWAJtTfN498AJpOMLy8CgldaOgtBhLCf4py02Uk59p15+M rWbUUmbawXfBX/ZRGi7xH1tB6WsRPND2yQZXHip/WXcsjBtJDY6HT9oKnaIEN8ovhypbbOfrlYwpJoApWKKmiIgkE78gsnzlABk= X-Spam-Status: No, score=-3024.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, 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.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 The previous patches are nearly enough to enable background DWARF reading. However, this hack in language_defn::get_symbol_name_matcher causes an early computation of current_language: /* If currently in Ada mode, and the lookup name is wrapped in '<...>', hijack all symbol name comparisons using the Ada matcher, which handles the verbatim matching. */ if (current_language->la_language == language_ada && lookup_name.ada ().verbatim_p ()) return current_language->get_symbol_name_matcher_inner (lookup_name); I considered various options here -- reversing the order of the checks, or promoting the verbatim mode to not be a purely Ada feature -- but in the end found that the few calls to this during startup could be handled more directly. In the JIT code, and in create_exception_master_breakpoint_hook, gdb is really looking for a certain kind of symbol (text or data) using a linkage name. Changing the lookup here is clearer and probably more efficient as well. In create_std_terminate_master_breakpoint, the lookup can't really be done by linkage name (it would require relying on a certain mangling scheme, and also may trip over versioned symbols) -- but we know that this spot is C++-specific, and so the language ought to be temporarily set to C++ here. After this patch, the "file" case is much faster: (gdb) file /tmp/gdb 2023-10-23 13:16:54.456 - command started Reading symbols from /tmp/gdb... 2023-10-23 13:16:54.520 - command finished Command execution time: 0.225906 (cpu), 0.064313 (wall) --- gdb/breakpoint.c | 4 +++- gdb/jit.c | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index fe09dbcbeee..0ff36108682 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -3733,6 +3733,8 @@ create_std_terminate_master_breakpoint (void) const char *const func_name = "std::terminate()"; scoped_restore_current_program_space restore_pspace; + scoped_restore_current_language save_language; + set_language (language_cplus); for (struct program_space *pspace : program_spaces) { @@ -3845,7 +3847,7 @@ create_exception_master_breakpoint_hook (objfile *objfile) { struct bound_minimal_symbol debug_hook; - debug_hook = lookup_minimal_symbol (func_name, NULL, objfile); + debug_hook = lookup_minimal_symbol_text (func_name, objfile); if (debug_hook.minsym == NULL) { bp_objfile_data->exception_msym.minsym = &msym_not_found; diff --git a/gdb/jit.c b/gdb/jit.c index 9e8325ab803..9e256173dd6 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -880,7 +880,7 @@ jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, program_space *pspace) /* Lookup the registration symbol. If it is missing, then we assume we are not attached to a JIT. */ bound_minimal_symbol reg_symbol - = lookup_minimal_symbol (jit_break_name, nullptr, the_objfile); + = lookup_minimal_symbol_text (jit_break_name, the_objfile); if (reg_symbol.minsym == NULL || reg_symbol.value_address () == 0) { @@ -890,7 +890,7 @@ jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, program_space *pspace) } bound_minimal_symbol desc_symbol - = lookup_minimal_symbol (jit_descriptor_name, NULL, the_objfile); + = lookup_minimal_symbol_linkage (jit_descriptor_name, the_objfile); if (desc_symbol.minsym == NULL || desc_symbol.value_address () == 0) {