From patchwork Sun Oct 29 17:35:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 78688 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 D440638654A3 for ; Sun, 29 Oct 2023 17:40:05 +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 BB69B38618D9 for ; Sun, 29 Oct 2023 17:38:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BB69B38618D9 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 BB69B38618D9 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=1698601115; cv=none; b=O14t2Y+3fQknfzUfhtb0tfQOTFT8DglGOiXAxyGEDEeD1+NvRwPbIZBfyXfsJKaiZU1McegsKocbPxHCuId38Fyzpc8uGSMrJySE3fClab3VTxcJiwVREtq2bqs33Fpy6MT3P+BaMZio9HrHLkPx4I0YJDSbOE7KaIef5EohM6E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698601115; c=relaxed/simple; bh=KqwgF9gSQEkc244NS3zrwjHm9RVIhpHO1KQAlin8yNw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=KK7aqW+RRzN+kpgizogDmjXSi8zpEmmc83Crpiz5n2LwGcyebxjUmle39TouwQqoJIEyjCToAaqfyUbPsRn8zVr+9ynzwQye6la7eL2e/Wr8shOOhEwb+S6KwVdruiByoXAhQsg7gm+sRK96Fjh8+WEOmFCEuF4L9cstSMNvy6Y= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5003a.ext.cloudfilter.net ([10.0.29.159]) by cmsmtp with ESMTPS id wxuCqrz5SL9Agx9k3qcQgC; Sun, 29 Oct 2023 17:38:28 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id x9k3qJ5zYZs8Wx9k3qLmQm; Sun, 29 Oct 2023 17:38:27 +0000 X-Authority-Analysis: v=2.4 cv=YKGMdDKx c=1 sm=1 tr=0 ts=653e9893 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=bhdUkHdE2iEA:10 a=Qbun_eYptAEA:10 a=iZoEup0oKZo78n3hRxoA: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=ytCVXBIFaHm9cVeobclqOlbmSi27GAXGuMMyeDJAax0=; b=aQIH68odgbM+XGdCwrZ1+x9KGV OzN15bCc1I+5rPkGtLgb4hdczQYDdBmASShzWQHruhJZGDrsVF0Ym43cAj9ANCAceawYyhP9Gh6s3 n8IVqLsuO+X8/9OqXq22WuyGy; Received: from 97-122-77-73.hlrn.qwest.net ([97.122.77.73]:47472 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 1qx9k2-000nop-3A; Sun, 29 Oct 2023 11:38:27 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 14/15] Avoid language-based lookups in startup path Date: Sun, 29 Oct 2023 11:35:33 -0600 Message-ID: <20231029173839.471514-15-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: 1qx9k2-000nop-3A X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-77-73.hlrn.qwest.net (localhost.localdomain) [97.122.77.73]:47472 X-Source-Auth: tom+tromey.com X-Email-Count: 15 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfE8foJ/1mk/43I/b+d8LMquYJzR+U5CQo6HuR3pyrTg3NpkyLDnARLIJytHeatHsA7xa7izEKRke1o4SJE6lexrAtszQMLQ3M6j8mGCVbbrCxjNYSpG5 kgRTfvq8jhL9M5fFXDgYCQMEqvwlIANrCfTyGmj2ZJ1CaUnKVvfYfioQ/QtqCuwZlzjSXqr17lEeq6O+zu5gK5SNCXzIORQ6wQg= X-Spam-Status: No, score=-3024.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_LOW, 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 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 828c99cabc0..c57741514b3 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) {