From patchwork Thu Jan 18 20:31:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84365 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 BC13A38582B3 for ; Thu, 18 Jan 2024 20:32:53 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id 4CB383858C53 for ; Thu, 18 Jan 2024 20:32:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4CB383858C53 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 4CB383858C53 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609933; cv=none; b=SMKEZefh7ffhw0aWIrrZAIqVyu+1duUnNnJhdWm9ZaE+YktKNoRr1BKnWLv6svBY5WVeVje3UPJv3uujeg3lpO/Lrw23HfwjEBiSORf/m9CVD7a3cUSkzmdDDPEpDlSPs91p+1n7a2geXHvFiRPKbjqeqxcJeaYfe4hOsEsRnDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609933; c=relaxed/simple; bh=zeQCNFTuTyd5DFISTNgzo8fXtz3xInmzdy4T7HwQO9E=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=OKIqnHawNf/AGOdbGoij0LP0bJPXqubbM3PDD5QL5imWStdOQarFoI/wJVelkKQI1EkVByAZqXSV2q5q4ZIUFXqYW0bqiLv+2os4ZIWjbWmGlI6bJ5uuY7yTMmyaPovfWTp2Kil7DxIWTbqyRR+cmRgvsykT2j92gLZCEWOxBz8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6005a.ext.cloudfilter.net ([10.0.30.201]) by cmsmtp with ESMTPS id QViwrN2eYMVQiQZ3YrEcPn; Thu, 18 Jan 2024 20:32:08 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3XrrEwQ1UTRQZ3Xrmnb5; Thu, 18 Jan 2024 20:32:07 +0000 X-Authority-Analysis: v=2.4 cv=ZOXEJF3b c=1 sm=1 tr=0 ts=65a98ac7 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=N5RK8avXPxMtqR0ytacA: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=5ZGzgdLrbQ9sFTSQgh1tB4Yb2j8aK8kiKYYON2e4xEY=; b=n4Hapay+OjGBpqM1iI3Zj93j3h TMkiPR0Cg5XesbiKdyl/85UTlTzXoFsfEW8A6exhNuUywL3TAjuGPZ0A1kd5+dGeyRqZoJ/YcDaoK ec78zuFccML788GRQaVDt7Xgt; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3X-002DCj-0M for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:07 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:31:59 -0700 Subject: [PATCH v2 01/30] Fix bug in cooked index scanner MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-1-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3X-002DCj-0M X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfPLafGjFBcF2ghcjtbXhpWiHRhdM88FFxZKLkqgHjuAvPSQR91xDfUb3E7wAPoaS8LkYL95e/zIYB7Z0UU5UjbLLCjjyDi+zVo/H3QZgOy9VVVp844ly CZ+29T3zE3+2q0YmSCKnq5f5NNlcPViTP+keRj+k85qYsmr7T2ihAlRruHD94J7sYmO7nnL/Q5Pql3s2+m0K7/n+xHnC/YsF4Co= X-Spam-Status: No, score=-3022.7 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 Testing this entire series pointed out that the cooked index scanner disagrees with new_symbol about certain symbols. In particular, new_symbol has this comment: Ada and Fortran subprograms, whether marked external or not, are always stored as a global symbol, because we want This patch updates the scanner to match. I don't know why the current code does not cause failures. It's maybe worth noting that incremental CU expansion -- creating symtabs directly from the index -- would eliminate this sort of bug. --- gdb/dwarf2/read.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 8f2b7a35f27..7b523d93e07 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -16405,6 +16405,12 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu, || abbrev->tag == DW_TAG_enumeration_type || abbrev->tag == DW_TAG_enumerator)) *flags &= ~IS_STATIC; + + /* Keep in sync with new_symbol. */ + if (abbrev->tag == DW_TAG_subprogram + && (m_language == language_ada + || m_language == language_fortran)) + *flags &= ~IS_STATIC; } return info_ptr; From patchwork Thu Jan 18 20:32:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84367 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 62FC938582A3 for ; Thu, 18 Jan 2024 20:33:00 +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 70ADC3858C62 for ; Thu, 18 Jan 2024 20:32:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 70ADC3858C62 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 70ADC3858C62 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=1705609933; cv=none; b=C9edSp+BIy1jW5uLunOgBDB03JTIbbunKLb1AF+w7dSsQIzs1F2u5L+eJAr5A2LsWyg2LBZUxRLRpS4fvmxDhJXsgUcPwzEFV9QGQXDkNFVM1OquM8Bvp9HZKWm1wZFZVFRpU2C6p4LT44QvPSRnf0YotghC99NdnyQiVyZGGLM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609933; c=relaxed/simple; bh=vKG0TKuYvHcBIvUecFme1asZywgtdaZIWDNihvHtHR0=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=MIpIYigFYRUZwm2niHFxZ4qH8z1Qup5mz/80MFc+lIlYhbdS3NX9yF23eCocUKn1ACvIFjY6irLvxXjuK70BtP/RVsHhPYMrxeuHp95/+xOzVcs2CuvaBeMO49M5rCkppaJYGJESmCzvRpt9rioKtpvDsUeD8dYE9s0KDNrWwVg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6008a.ext.cloudfilter.net ([10.0.30.227]) by cmsmtp with ESMTPS id QPBrrQ3fOTHHuQZ3Yr9Wvi; Thu, 18 Jan 2024 20:32:08 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3XrEcC4ZKctQZ3XrDY50; Thu, 18 Jan 2024 20:32:08 +0000 X-Authority-Analysis: v=2.4 cv=a+kjSGeF c=1 sm=1 tr=0 ts=65a98ac8 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=B_Tv2JfvxkIVyvo0GuEA: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=W11NdvI7zzadwPpCtCumXC4VUgMZHAZ5bJy2AV6YWHU=; b=EXzmH98jpBhf1BokDrKsbSWEfb +t32/0w+5+oL0XpoDV31mzjfEvcNdvOs6OC8JdwtdkdFqLvWhxS3ZfrBTJDWROHuZgYjacj6oQsTt Hj0bdllubPoW8AzsLFO9a9dkA; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3X-002DCj-1A for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:07 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:00 -0700 Subject: [PATCH v2 02/30] Small cleanup in DWARF reader MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-2-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3X-002DCj-1A X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 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: MS4xfIXxX9PnhsroJnaRhnBHLBaylxSZmicZqlq7ewUfE9gQIzB2KpsLfBT+4wKakpbr0ox3jYDJyfZxrwfowNpbWO6fIxDgYXuH7g/IlRVCjNjsn7vzNTGd zqrKh5OjMG3W0t/jmMCWh+8XN7hzHIRQB75imRCqGVogvVuDJfWgozrReMwTe0zFaZ0sWEZRbzfuhlXdhqmf6ka+MOHIfJpOeak= X-Spam-Status: No, score=-3022.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, 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 I noticed a couple of spots in dwarf/read.c:new_symbol that call add_symbol_to_list. However, this function is generally written to set list_to_add, and then have a single call to add_symbol_to_list at the end. This patch cleans up this discrepancy. Note that new_symbol is overlong and should probably be split up. --- gdb/dwarf2/read.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 7b523d93e07..b55b208ff4b 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -19053,7 +19053,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, sym->set_aclass_index (LOC_OPTIMIZED_OUT); sym->set_type (builtin_type (objfile)->builtin_core_addr); sym->set_domain (LABEL_DOMAIN); - add_symbol_to_list (sym, cu->list_in_scope); + list_to_add = cu->list_in_scope; break; case DW_TAG_entry_point: /* SYMBOL_BLOCK_VALUE (sym) will be filled in later by @@ -19392,7 +19392,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, case DW_TAG_common_block: sym->set_aclass_index (LOC_COMMON_BLOCK); sym->set_domain (COMMON_BLOCK_DOMAIN); - add_symbol_to_list (sym, cu->list_in_scope); + list_to_add = cu->list_in_scope; break; default: /* Not a tag we recognize. Hopefully we aren't processing From patchwork Thu Jan 18 20:32:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84366 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 DACE83858C2F for ; Thu, 18 Jan 2024 20:32:53 +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 5D5763858C56 for ; Thu, 18 Jan 2024 20:32:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5D5763858C56 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 5D5763858C56 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=1705609933; cv=none; b=ZOYhatLvO4fTSbfGuXYW/RwHd5ADIWv2c2G9swC6BIoX+pGhrESxovk+sbBIucrRlLIZ4+ykXbwXWevnBAcLj53kIH6FeS0L4T3RjTJjJ2d9bX/6eIWpoxCGYjSzwicVdv3J0u5FVQtgTD81eG93s54j79u4u+IbobU5uKNGynk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609933; c=relaxed/simple; bh=Hcc79opCBSztboDTBWZrjjZu2b+YmRYHKRphKc1vWI4=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=fwqiP8yV6bNIqipjiWufh9TCiuPeHulVSdQygF7MCqMPCkjCfUD7bY2/y4pQaOVDevYW/NzyQi0TsiR3a2t7O3yPvggNitVzvXUZQTU92XhaYFjwPm5TdTSW358xwu/atIP2vC6gmc80eiWsABUyrSX2rCLnWmcKLyv1ZlJanI4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6002a.ext.cloudfilter.net ([10.0.30.222]) by cmsmtp with ESMTPS id QXcSraDwa80oiQZ3Yr0O5Y; Thu, 18 Jan 2024 20:32:08 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3XrsCCbD6lhQZ3YrjjRb; Thu, 18 Jan 2024 20:32:08 +0000 X-Authority-Analysis: v=2.4 cv=LNR1/ba9 c=1 sm=1 tr=0 ts=65a98ac8 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=MatczMKtvbaZHu8P7h8A: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=YNcx1GzvX3FKzUasaO8qaaD0Vs1LcqYGAKcrB5yG/po=; b=pdqFGqIT5wYWJwQyhhpxiDo2+X Ykq6eFVOeeRvDPpPh/JluoI5jl1TbcghpBcNe+eWF2wDWOPrbCN47+DQMjq2lk6FtTLwKYGoFDvTy pz9J84dIYNIlLhZr7TmUwjlw5; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3X-002DCj-1z for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:07 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:01 -0700 Subject: [PATCH v2 03/30] Fix latent bug in DW_TAG_entry_point handling MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-3-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3X-002DCj-1z X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfK6HHbqRzFgaLRp16yl4X52RCQF2etaMIE2G5c5yO35F3UNDs3m328RTgPbXu8Tbpa9+u6A3ociijw5OqmISZoc3bRfIF8IblFCsLsMOwJmZitWu2IhR 674oX9sWleDw1hxEKRUzC+W0tydYLDGq8+itXa/KPA0ledyD5ZtLNzp1+n+77aUhBFMGAXXfmcuSsX2Fcj29yiZw+0zsRAvVsVE= X-Spam-Status: No, score=-3022.8 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 A DW_TAG_entry_point symbol inherits its extern/static property from the enclosing subroutine. This is encoded in new_symbol -- but the cooked indexer does not agree. --- gdb/dwarf2/read.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index b55b208ff4b..a4b8a855e24 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -16526,6 +16526,13 @@ cooked_indexer::index_dies (cutu_reader *reader, info_ptr, abbrev, &name, &linkage_name, &flags, &sibling, &this_parent_entry, &defer, false); + /* A DW_TAG_entry_point inherits its static/extern property from + the enclosing subroutine. */ + if (abbrev->tag == DW_TAG_entry_point) + { + flags &= ~IS_STATIC; + flags |= parent_entry->flags & IS_STATIC; + } if (abbrev->tag == DW_TAG_namespace && m_language == language_cplus From patchwork Thu Jan 18 20:32:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84369 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 83134385829F for ; Thu, 18 Jan 2024 20:33:45 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id A2B9B3858C2A for ; Thu, 18 Jan 2024 20:32:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A2B9B3858C2A 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 A2B9B3858C2A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609933; cv=none; b=enr4NYdmRVg8izP85Z6nVBh8B3TCoqGoQEUcj26rVoRPDXeMixYBmJQ9GO4FjlWCTOq83D9pw4qvJY8FHOamtMt8F+g5dnMJQ4E1G7UZW59DSnH+PrVJaUQxCMQcoEfQJI3oU7t6wYoIE5Di4J1gcfs0CO89EKmBIclm/CU9/es= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609933; c=relaxed/simple; bh=VZgvU/OpulU3EF8WXv+I50HiT8wkB1f1xzlPSN7WzH0=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=VBdPFty8aLPb3eBzY+s0Iac7Xm9h3h3Q18ckA4R7nyIawUovUHZ2k9LKFKENjaaHYCqb+8xKSV+5ErF04mfZ5n8FgiySjtyO4k61Hns/Ub5t5rRZ07XwT3c6UA6Nm89AHU9HoImWEwL/OWxll5tRF+gvWHrtL2jnelx1V/UtL34= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5006a.ext.cloudfilter.net ([10.0.29.179]) by cmsmtp with ESMTPS id QUDSrHUNf8uLRQZ3Zrw3AX; Thu, 18 Jan 2024 20:32:09 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3YrhZQnim6EQZ3YrQzg3; Thu, 18 Jan 2024 20:32:08 +0000 X-Authority-Analysis: v=2.4 cv=Qft1A+Xv c=1 sm=1 tr=0 ts=65a98ac8 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=eoaZ9IUwQebqolqbARkA: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=2UeD7aB5h5XNbwhzTZs16We8Zlc+IoMX7AkwOh3p8dA=; b=t3BhsRNgagBA8F3/IufJWbypSv mKdKa7+OPF3rF2NFjzmIzZnpULgrfwBvJXHnCram+hrjyVeqPe8EhDd/CctJN4v9EP6IwQLowJvhz 9pjFOp8BdPxPG1a7BcM0QU5Di; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3X-002DCj-2v for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:07 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:02 -0700 Subject: [PATCH v2 04/30] Make nsalias.exp more reliable MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-4-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3X-002DCj-2v X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 6 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfGsbv3fe5OSKO7ZP3Grv00mECYZMMjjYuHBJjuH27+a5C/Kl1qt9BmgoQcWNg+l3vFuMUr/gZAp1HsoY0siybrfEFd2k5vOOfZ8k5G63Ap5PuBj/r6jS qhRw1Rrk3+cd7d39os7rzw4dKtCIWHX3bKQN1FTUodvSl/zpai+RBsDEiVeBGXaTvXhYsB8whNzAAYPi6+m7BdZukcyhLsO1V3g= X-Spam-Status: No, score=-3022.8 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, 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 nsalias.exp tries to detect a complaint that is issued when expanding a CU. However, the test is a bit funny in that, while gdb does currently expand the CU and issue the complaint, it also emits this error: No symbol "N100" in current context. This series will change gdb such that this CU is not expanded -- which makes sense, the symbol in question doesn't actually match the lookups that are done. So, to make the test more robust, a direct request to expand symtabs is done instead. --- gdb/testsuite/gdb.cp/nsalias.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.cp/nsalias.exp b/gdb/testsuite/gdb.cp/nsalias.exp index b727437abc2..0c29e6f2d40 100644 --- a/gdb/testsuite/gdb.cp/nsalias.exp +++ b/gdb/testsuite/gdb.cp/nsalias.exp @@ -324,5 +324,5 @@ if { $readnow_p } { global gdb_file_cmd_msg gdb_assert {[regexp $re $gdb_file_cmd_msg]} $test } else { - gdb_test "print N100::x" $re $test + gdb_test "maint expand-symtabs" $re $test } From patchwork Thu Jan 18 20:32:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84368 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 3C9FC385829B for ; Thu, 18 Jan 2024 20:33:04 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id 9F7153858C74 for ; Thu, 18 Jan 2024 20:32:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9F7153858C74 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 9F7153858C74 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609933; cv=none; b=B6KZIfFGaLaaWShDKheUIGqN4c8Tu63pfdTxZKpCMDSkknZkEDEzDm5u7ZngG6t/WBatDgPadrbUCdNh8dnR5U7poEaW/iQZIx9Pv4XLQ4dqWdhpLt8gwmP6t7rTfKDFxsoCWng99uGmt/0MFwS8FmYxG8Z3xzFj3TZfv2ux5Sg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609933; c=relaxed/simple; bh=hQEhJrKqm9rN6UI+KYwAw+5024426lrNfdE3DVggwEU=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=bEkZuZdSsoTcvjBb/QBcCYUiFKye5UfPYt9CX3KIeoBYA2SOj2VXCqRM+mt5mIU8tjy5BWcPFlb/0fhyMBB1QQwJ1MbaHQLjWstZC5xYpHC5dxJMVeXxMSv0ELC2CqWcq/ptOcmRR/yQdOv12VcP+LGoK9jQ5zD9muKKwqD/BLY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6006a.ext.cloudfilter.net ([10.0.30.182]) by cmsmtp with ESMTPS id QS04rGmNt8uLRQZ3Zrw3AD; Thu, 18 Jan 2024 20:32:09 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3YrG48xYjq0QZ3YrfHaE; Thu, 18 Jan 2024 20:32:08 +0000 X-Authority-Analysis: v=2.4 cv=afxyIDkt c=1 sm=1 tr=0 ts=65a98ac8 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=pfhLtNyfPs45aFG1YTEA: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=cy3tp7beAVodUpmYjflV0cYVItki3TESwl0+ZHwFNws=; b=A5CxqoUkxzJG6KLoe4qPqGSKjR Q+8Acv9HL43JZZEQi0y2ieOeBb5ze41iyVcY9WoYNxFy8L92sPXXqjEhAmlYTL4uR5pwGhxCvMhxE oyDVih+/p0vojWKuBmt6tx5Ll; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3Y-002DCj-0V for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:08 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:03 -0700 Subject: [PATCH v2 05/30] Fix latent bug in mdebugread.c MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-5-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3Y-002DCj-0V X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 7 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfPtBgB/fgCQmvn9so8JKbS4v52r7toqOcsnK0hVmdp/3WdpKrUvOBCgNz96knccz/ZAZXf76HoCVGH7n6UZ2+7KwLQv2N/rirkiwuSKN97UMye5fVVHM VAMmlEX0XdRs3CLdRIcEM9oAwL3k+LApsoKG4HOUyvDPKePlT90DpIJXxInHCggc+gi/4irnqpZ2XVZHt3R8kpQeqXy+enZykls= X-Spam-Status: No, score=-3022.8 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, 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 mdebugread.c makes a label symbol but puts it into VAR_DOMAIN. I think LABEL_DOMAIN is more appropriate. I don't have a way to test this. --- gdb/mdebugread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 73df0ed8165..13c9401d171 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -711,7 +711,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, case stLabel: /* label, goes into current block. */ s = new_symbol (name); - s->set_domain (VAR_DOMAIN); /* So that it can be used */ + s->set_domain (LABEL_DOMAIN); /* So that it can be used */ s->set_aclass_index (LOC_LABEL); /* but not misused. */ s->set_section_index (section_index); s->set_value_address (sh->value); From patchwork Thu Jan 18 20:32:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84375 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 122643858294 for ; Thu, 18 Jan 2024 20:34:44 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta38.uswest2.a.cloudfilter.net (omta38.uswest2.a.cloudfilter.net [35.89.44.37]) by sourceware.org (Postfix) with ESMTPS id 102903858C33 for ; Thu, 18 Jan 2024 20:32:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 102903858C33 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 102903858C33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609936; cv=none; b=jQcPKOCc+ZdNCOHdZFZ0FDECqHtcRLofELP0QJM8YSVz7mjUYfvFyz15gxN/nbl/bae7vqGX5YDn2odKL3owSbbWH9pra6WiOs97htXuS62VPc5vYzoZNbAT6FgQIzg8Sdba1jHkX0++FqDShRYhW0N+Hgtxh83u9gLTqnu23wA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609936; c=relaxed/simple; bh=PDXNB9UVBsX9KHWnh5UOhYjCBQ1bYKg7qkYm4a2ZjMk=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=Cv/kOVVWCsDx6o81l8RR7U1hmemkLqmMPJPZ1U7Wsetnm0/4dwDQTS4j3PYwXkMXm6MF+Xt8gNwIV66XEyqX2jDinvGcUGt3dq/FESgytwBX51FMpAovVVJ9XpRj2Ffv+xy/ozSiSoib7ZH5BMwKr9d+XDIONimBygxuyftlg+A= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5002a.ext.cloudfilter.net ([10.0.29.215]) by cmsmtp with ESMTPS id QVe7rgMBzoMN9QZ3arOoA6; Thu, 18 Jan 2024 20:32:10 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3Yr6xsuBnVCQZ3Zrv2Oy; Thu, 18 Jan 2024 20:32:09 +0000 X-Authority-Analysis: v=2.4 cv=H+TIfsUi c=1 sm=1 tr=0 ts=65a98ac9 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=1fc2yS3rMq-BXBd_2S0A: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=8Pr5MsK3sARx0lVSdN8gtoIIaMyaPY3h1f5jrpT+2oI=; b=jXHqNGtUmUGp+orxiU4ljicEEJ ckZ6dA9bAXJVCVLFbkNR3n/3gI03GIh1nmUQ40tc4/QqXxbbzrpHlXpihth6ximN1SbfToODzKFDa rXMSvZuisFUhVxNzrS0d6TuqV; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3Y-002DCj-1L for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:08 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:04 -0700 Subject: [PATCH v2 06/30] Give names to unspecified types MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-6-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3Y-002DCj-1L X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 8 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfGPe8ofd1CvUzDDm8fBVq3mxmPeLNbbRA/7KNXU9Bz/JAOWW5R/AUCQHM1qVAJCOvO3wvA7jHPL06eAYkBxhlUDjAgzv+o5sKRLnOwk6Zd46LPxvyJLL s56aVJXeivyN3K/mX8F8s3BdCcb5w1fl3zSX/vj+I3dguBEl7xItOAeBUFcFbLTU42AQMEnomFNPUFyR0zVvfrpyvdqD43I3I/0= X-Spam-Status: No, score=-3022.8 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 A patch later in this series will change check_typedef to also look in the type domain. This change by itself caused a regression, but one that revealed some peculiar behavior. The regression is in nullptr_t.exp, where examining a std::nullptr_t will change from the correct: typedef decltype(nullptr) std::nullptr_t; to typedef void std::nullptr_t; Right now, the DWARF reader marks all unspecified types as stub types. However, this interacts weirdly with check_typedef, which currently does not try to resolve types -- only struct-domain objects. My first attempt here was to fix this by changing void types not to be stub types, as I didn't see what value that provided. However, this caused another regression, because call_function_by_hand_dummy checks for stub-ness: if (values_type == NULL || values_type->is_stub ()) values_type = default_return_type; I'm not really sure why it does this rather than check for TYPE_CODE_VOID. While looking into this, I found another oddity: the DWARF reader correctly creates a type named 'decltype(nullptr)' when it seems a DW_TAG_unspecified_type -- but it creates a symbol named "void" instead. This patch changes the DWARF reader to give the symbol the correct name. This avoids the regression. --- gdb/dwarf2/read.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index a4b8a855e24..078edd8c842 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -6593,6 +6593,7 @@ process_die (struct die_info *die, struct dwarf2_cu *cu) case DW_TAG_subrange_type: case DW_TAG_generic_subrange: case DW_TAG_typedef: + case DW_TAG_unspecified_type: /* Add a typedef symbol for the type definition, if it has a DW_AT_name. */ new_symbol (die, read_type_die (die, cu), cu); From patchwork Thu Jan 18 20:32:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84371 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 11D6B38582BF for ; Thu, 18 Jan 2024 20:33:57 +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 5B0723858C2F for ; Thu, 18 Jan 2024 20:32:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5B0723858C2F 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 5B0723858C2F 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=1705609935; cv=none; b=G0lDCHZhmt+2xFPei7hxWBiZxoCCg5cpP78osmnJzze6I6NJu60Xr4bn/3EOR0Jn920VXe9gycV/l5xnEt0QFHsHeVu20XofEYrviefVDOBsyACwPkb2E0gVMu7nL4qPbUVHLoyqfZFpZ1o55QbAt4vFgZ4UWMBsGwol7HiOuoo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609935; c=relaxed/simple; bh=nkm7PjJoBeFzefaCRQ27O2aKROgfjPgqHD72fuaAD7w=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=QCug+EHscHgR9UD6Bu+IdRSCtIn7+Wz//Qus94g2MOn3D7RWuarN7AWLM/bmc/O9A3TSb8D9tm/wgsNl4o21JjuJlXwmcd3VXfJvDMXWJcBd47emcbngx94AKgktqxT9Ccr0wHzFUMjkSuxYOqV7dqBf77OnWsZUC5keF4ZXrvw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5009a.ext.cloudfilter.net ([10.0.29.176]) by cmsmtp with ESMTPS id QXSmrSdPaTHHuQZ3ar9Wwr; Thu, 18 Jan 2024 20:32:10 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3Zr1sUwV9xYQZ3ZrCTkh; Thu, 18 Jan 2024 20:32:09 +0000 X-Authority-Analysis: v=2.4 cv=NfP1akP4 c=1 sm=1 tr=0 ts=65a98ac9 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=j2nSuGdwE-VHdcfjFbAA:9 a=QEXdDO2ut3YA:10 a=ZXulRonScM0A: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=qyRIJN0KBvkD6eKFh2XcbAyxxi+74ubBY62q46wRwuc=; b=WnDFYrCSXOEvR07WmMPgGtBSMv dExz0ADMbUKBQa/4AhsVH3tjWG2tluc1jVH4o0xnhoIx26Zi3sxEUNAO7dzLbEnKltuhJ8WQlhUsm FqV48XkDda/GMuuOdtRNGG0iX; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3Y-002DCj-2C for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:08 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:05 -0700 Subject: [PATCH v2 07/30] Remove NR_DOMAINS MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-7-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3Y-002DCj-2C X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 9 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfEpzuecdhtE0BTQqm/dDSBc77x38VYD2CUUFhFjm+mN28Djx2/gOoOjzCleAlUnL08uFRm3TRvC3WZF6BzHQIj7qvsD9cK+s+blsmjDuSCIlsSX/P8Zf 9FYAqi27i4lKkvd7UUma2V185M17BZPemLCIdKdr5Ej5H+NgzlhvDFuFNYEiuaZ/gNN7PeRKSyjz0bgCEmdjSMPe5XmS0xXqDV0= X-Spam-Status: No, score=-3022.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, 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 NR_DOMAINS is only used for a static assert, but we no longer need it now. If we add too many constants to this enum, GCC will warn about the bitfield overflow: error: ‘symbol::m_domain’ is too small to hold all values of ‘enum domain_enum’ --- gdb/symtab.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/gdb/symtab.h b/gdb/symtab.h index eecd999b7e6..3f2d98add1e 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -922,15 +922,11 @@ enum domain_enum /* Fortran common blocks. Their naming must be separate from VAR_DOMAIN. They also always use LOC_COMMON_BLOCK. */ COMMON_BLOCK_DOMAIN, - - /* This must remain last. */ - NR_DOMAINS }; /* The number of bits in a symbol used to represent the domain. */ #define SYMBOL_DOMAIN_BITS 3 -static_assert (NR_DOMAINS <= (1 << SYMBOL_DOMAIN_BITS)); extern const char *domain_name (domain_enum); From patchwork Thu Jan 18 20:32:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84370 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 F326138582B7 for ; Thu, 18 Jan 2024 20:33:51 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta38.uswest2.a.cloudfilter.net (omta38.uswest2.a.cloudfilter.net [35.89.44.37]) by sourceware.org (Postfix) with ESMTPS id C47A43858C31 for ; Thu, 18 Jan 2024 20:32:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C47A43858C31 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 C47A43858C31 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609936; cv=none; b=i7XQ4VuIl5TORwy0WDZZJg7nj12dtwL+SimyHsO3HYsdkLV3V+NegukiQkwOm2QKmyV+iXRxO+rNvZ/jk5WnVW+fXKp66tQAnXWzaTrV6DwCGa1tS3mo9Vpo4yI7VF83syUkpPimpf+nOQdjLNCDeXtzfMdGEQyOKeovuvuhDKA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609936; c=relaxed/simple; bh=+xxWby9p7bL5LLVlFfyhH3Eh9HWGG7wDQk0SUZvumw4=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=sReCqaqsNm9moJhuR1XFBEsqv1h6QYCMpDFaJIMmUjg1HZjnWpaQtdCwMOxbGch417lzqCTsOJWNhNhUH7jaFC87+o5E6f+KsOsCdQaV9V5k/17t3Z3L9HxkY7r9JiB1PqWx2c0Yz9BB6r6ehwPoW0Lq3upqUo+cQuCzdPtamTk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6010a.ext.cloudfilter.net ([10.0.30.248]) by cmsmtp with ESMTPS id QWJqrgbIkoMN9QZ3ZrOoA4; Thu, 18 Jan 2024 20:32:10 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3ZrjZHufPByQZ3Zrj6Ig; Thu, 18 Jan 2024 20:32:09 +0000 X-Authority-Analysis: v=2.4 cv=T+af8tGQ c=1 sm=1 tr=0 ts=65a98ac9 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=cCc6LzOX12iO7udG6-IA: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=NyIYbjj8O+kyAh64YeTveIs0NMjMOfNq1m05UkSoYnc=; b=TiK5L9yN/NF0wNJdtMhw4KJgIQ Fy5b+O8ac9TvL4fxYTxHcWMmn8KtNWcrzHxgOT62GEwlJb+it+VDcXY8CwuCarAuHq1THGOxhsgRl nVhO87cPgxemiH4igNCqQs/lM; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3Y-002DCj-38 for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:09 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:06 -0700 Subject: [PATCH v2 08/30] Simplify symbol_to_info_string MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-8-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3Y-002DCj-38 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 10 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfKA14jNDwuoETeLVcuFg7W5gFo5SdwYdwfVTPsgA3k5RwbjlTNe3EpqYkKujOd9FOgWCcij2KlRyv3XPYqxUWW8TbonZO4VSjV8Dn55+LBLprPjZT4N0 xdKqiLvdo2cxWq32AJaPAn300GBc01ARTIpBcp4LN/VkbTVoqAMi2jDKafsUAkY8Ww4Q5+/JDw4Gbhu+QDlakvCto+N0q3NEE+0= X-Spam-Status: No, score=-3022.8 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 Thi simplifies symbol_to_info_string, removing the 'kind' parameter and instead having it use the symbol's domain. --- gdb/mi/mi-symbol-cmds.c | 2 +- gdb/symtab.c | 44 ++++++++++++++++++-------------------------- gdb/symtab.h | 6 ++---- 3 files changed, 21 insertions(+), 31 deletions(-) diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c index d3ec16fcb21..758f5974706 100644 --- a/gdb/mi/mi-symbol-cmds.c +++ b/gdb/mi/mi-symbol-cmds.c @@ -87,7 +87,7 @@ output_debug_symbol (ui_out *uiout, enum search_domain kind, type_print (sym->type (), "", &tmp_stream, -1); uiout->field_string ("type", tmp_stream.string ()); - std::string str = symbol_to_info_string (sym, block, kind); + std::string str = symbol_to_info_string (sym, block); uiout->field_string ("description", str); } } diff --git a/gdb/symtab.c b/gdb/symtab.c index 7c0a69108d4..b408941f998 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -5054,19 +5054,19 @@ global_symbol_searcher::search () const /* See symtab.h. */ std::string -symbol_to_info_string (struct symbol *sym, int block, - enum search_domain kind) +symbol_to_info_string (struct symbol *sym, int block) { std::string str; gdb_assert (block == GLOBAL_BLOCK || block == STATIC_BLOCK); - if (kind != TYPES_DOMAIN && block == STATIC_BLOCK) + if (block == STATIC_BLOCK + && sym->domain () == VAR_DOMAIN + && sym->aclass () != LOC_TYPEDEF) str += "static "; /* Typedef that is not a C++ class. */ - if (kind == TYPES_DOMAIN - && sym->domain () != STRUCT_DOMAIN) + if (sym->domain () == VAR_DOMAIN && sym->aclass () == LOC_TYPEDEF) { string_file tmp_stream; @@ -5085,9 +5085,7 @@ symbol_to_info_string (struct symbol *sym, int block, str += tmp_stream.string (); } /* variable, func, or typedef-that-is-c++-class. */ - else if (kind < TYPES_DOMAIN - || (kind == TYPES_DOMAIN - && sym->domain () == STRUCT_DOMAIN)) + else if (sym->domain () == VAR_DOMAIN || sym->domain () == STRUCT_DOMAIN) { string_file tmp_stream; @@ -5102,23 +5100,21 @@ symbol_to_info_string (struct symbol *sym, int block, /* Printing of modules is currently done here, maybe at some future point we might want a language specific method to print the module symbol so that we can customise the output more. */ - else if (kind == MODULES_DOMAIN) + else if (sym->domain () == MODULE_DOMAIN) str += sym->print_name (); return str; } -/* Helper function for symbol info commands, for example 'info functions', - 'info variables', etc. KIND is the kind of symbol we searched for, and - BLOCK is the type of block the symbols was found in, either GLOBAL_BLOCK - or STATIC_BLOCK. SYM is the symbol we found. If LAST is not NULL, - print file and line number information for the symbol as well. Skip - printing the filename if it matches LAST. */ +/* Helper function for symbol info commands, for example 'info + functions', 'info variables', etc. BLOCK is the type of block the + symbols was found in, either GLOBAL_BLOCK or STATIC_BLOCK. SYM is + the symbol we found. If LAST is not NULL, print file and line + number information for the symbol as well. Skip printing the + filename if it matches LAST. */ static void -print_symbol_info (enum search_domain kind, - struct symbol *sym, - int block, const char *last) +print_symbol_info (struct symbol *sym, int block, const char *last) { scoped_switch_to_sym_language_if_auto l (sym); struct symtab *s = sym->symtab (); @@ -5140,7 +5136,7 @@ print_symbol_info (enum search_domain kind, gdb_puts ("\t"); } - std::string str = symbol_to_info_string (sym, block, kind); + std::string str = symbol_to_info_string (sym, block); gdb_printf ("%s\n", str.c_str ()); } @@ -5236,10 +5232,7 @@ symtab_symbol_info (bool quiet, bool exclude_minsyms, } else { - print_symbol_info (kind, - p.symbol, - p.block, - last_filename); + print_symbol_info (p.symbol, p.block, last_filename); last_filename = symtab_to_filename_for_display (p.symbol->symtab ()); } @@ -5475,7 +5468,7 @@ rbreak_command (const char *regexp, int from_tty) string = string_printf ("%s:'%s'", fullname, p.symbol->linkage_name ()); break_command (&string[0], from_tty); - print_symbol_info (FUNCTIONS_DOMAIN, p.symbol, p.block, NULL); + print_symbol_info (p.symbol, p.block, nullptr); } else { @@ -6838,8 +6831,7 @@ info_module_subcommand (bool quiet, const char *module_regexp, last_filename = ""; } - print_symbol_info (FUNCTIONS_DOMAIN, q.symbol, q.block, - last_filename); + print_symbol_info (q.symbol, q.block, last_filename); last_filename = symtab_to_filename_for_display (q.symbol->symtab ()); } diff --git a/gdb/symtab.h b/gdb/symtab.h index 3f2d98add1e..0a5f2633fe8 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -2664,11 +2664,9 @@ extern std::vector search_module_symbols /* Convert a global or static symbol SYM (based on BLOCK, which should be either GLOBAL_BLOCK or STATIC_BLOCK) into a string for use in 'info' - type commands (e.g. 'info variables', 'info functions', etc). KIND is - the type of symbol that was searched for which gave us SYM. */ + type commands (e.g. 'info variables', 'info functions', etc). */ -extern std::string symbol_to_info_string (struct symbol *sym, int block, - enum search_domain kind); +extern std::string symbol_to_info_string (struct symbol *sym, int block); extern bool treg_matches_sym_type_name (const compiled_regex &treg, const struct symbol *sym); From patchwork Thu Jan 18 20:32:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84372 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 E2CD43858287 for ; Thu, 18 Jan 2024 20:34:15 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta36.uswest2.a.cloudfilter.net (omta36.uswest2.a.cloudfilter.net [35.89.44.35]) by sourceware.org (Postfix) with ESMTPS id 133543858C3A for ; Thu, 18 Jan 2024 20:32:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 133543858C3A 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 133543858C3A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609937; cv=none; b=phHeItkwIkRr2pV8b01QeG5FopZ4axnJ4hlARPPJwEYzW0tErK19l3g3leYrAGelbM9XVi/NdaXzcodR1kyrjCMzmQymrAJzkEn/tCJ2VgRiZ4/+VUGyo4DrWUlgqgfJfHUdKOeIgYULn3A14Te87y3Iwjq9KFu3Cj3/ziZ8+GM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609937; c=relaxed/simple; bh=CLd0I1nBi1K4qmdjyIIgDRWiv8wSK2yIeelNFyTrGok=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=fSJCYQqSlnTYOfCbpN1fWhmQkjcvwzkA/oj34H2gBwLLhH+/haYM0Wtcvb9IMgb3AlI2KtTEUSYLd+vcIHO0r2aaTAlkbV1KM86gR8YJz9bElneGOBSYHcZSSv/ZHIrs0onkckzThUw03cl7Cz42tdyj+yjn3JkaO4IIOk8gpfA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6002a.ext.cloudfilter.net ([10.0.30.222]) by cmsmtp with ESMTPS id QWa3rCejWCF6GQZ3arrcwn; Thu, 18 Jan 2024 20:32:10 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3ZrsCFlD6lhQZ3arjjTX; Thu, 18 Jan 2024 20:32:10 +0000 X-Authority-Analysis: v=2.4 cv=LNR1/ba9 c=1 sm=1 tr=0 ts=65a98aca a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=2tzb9Mj3oDOa-0_ZHs0A: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=uDZXODANSWbd3KK9SvxZaTGZlq6l+I6NAwa4z9PCWQI=; b=FTl71aOyIYXkVGibGmAjesjvkS F4f671YhcAKftPv4zNjqbDhxMDtFjmCMbkxZOPrWuXNfT+PmAZ/Ukk2DTN3KGerQoyP90b1YocK+x +0QTeqd3Nin82oN8c7MHa6Ol6; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3Z-002DCj-1W for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:09 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:07 -0700 Subject: [PATCH v2 09/30] Split up a big 'if' in symtab.c MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-9-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3Z-002DCj-1W X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 11 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfJpIoupor8JiCxMSFniBC1UdgeA4n0kZjqlLeQFkgKPNFUnb+O8ifPgRGmFcapE8ILY2TN30pCWVkMoy58CPsDI60mjvxNP3cndg0G02qKYqnSQ0rNmp wRZUgkn1o6F6tLBmIUYxn4gAzcT2D4EiTQBQQCkgI1yUOcM4uxAiJ38X2cVGzS/bN6PAvHtWfOHOi13Mo1hsOvBNhymb5Zt2vGs= X-Spam-Status: No, score=-3022.8 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 global_symbol_searcher::add_matching_symbols in symtab.c has a gigantic 'if' statement -- 33 lines of conditional expression. This patch splits it up into a series of separate 'if's. --- gdb/symtab.c | 83 ++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 50 insertions(+), 33 deletions(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index b408941f998..2020210c5f4 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -4855,39 +4855,56 @@ global_symbol_searcher::add_matching_symbols /* Check first sole REAL_SYMTAB->FILENAME. It does not need to be a substring of symtab_to_fullname as it may contain "./" etc. */ - if ((file_matches (real_symtab->filename, filenames, false) - || ((basenames_may_differ - || file_matches (lbasename (real_symtab->filename), - filenames, true)) - && file_matches (symtab_to_fullname (real_symtab), - filenames, false))) - && ((!preg.has_value () - || preg->exec (sym->natural_name (), 0, - NULL, 0) == 0) - && ((kind == VARIABLES_DOMAIN - && sym->aclass () != LOC_TYPEDEF - && sym->aclass () != LOC_UNRESOLVED - && sym->aclass () != LOC_BLOCK - /* LOC_CONST can be used for more than - just enums, e.g., c++ static const - members. We only want to skip enums - here. */ - && !(sym->aclass () == LOC_CONST - && (sym->type ()->code () - == TYPE_CODE_ENUM)) - && (!treg.has_value () - || treg_matches_sym_type_name (*treg, sym))) - || (kind == FUNCTIONS_DOMAIN - && sym->aclass () == LOC_BLOCK - && (!treg.has_value () - || treg_matches_sym_type_name (*treg, - sym))) - || (kind == TYPES_DOMAIN - && sym->aclass () == LOC_TYPEDEF - && sym->domain () != MODULE_DOMAIN) - || (kind == MODULES_DOMAIN - && sym->domain () == MODULE_DOMAIN - && sym->line () != 0)))) + if (!(file_matches (real_symtab->filename, filenames, false) + || ((basenames_may_differ + || file_matches (lbasename (real_symtab->filename), + filenames, true)) + && file_matches (symtab_to_fullname (real_symtab), + filenames, false)))) + continue; + + if (preg.has_value () && !preg->exec (sym->natural_name (), 0, + nullptr, 0) == 0) + continue; + + bool matches = false; + if (!matches && kind == VARIABLES_DOMAIN) + { + if (sym->aclass () != LOC_TYPEDEF + && sym->aclass () != LOC_UNRESOLVED + && sym->aclass () != LOC_BLOCK + /* LOC_CONST can be used for more than + just enums, e.g., c++ static const + members. We only want to skip enums + here. */ + && !(sym->aclass () == LOC_CONST + && (sym->type ()->code () + == TYPE_CODE_ENUM)) + && (!treg.has_value () + || treg_matches_sym_type_name (*treg, sym))) + matches = true; + } + if (!matches && kind == FUNCTIONS_DOMAIN) + { + if (sym->aclass () == LOC_BLOCK + && (!treg.has_value () + || treg_matches_sym_type_name (*treg, + sym))) + matches = true; + } + if (!matches && kind == TYPES_DOMAIN) + { + if (sym->aclass () == LOC_TYPEDEF + && sym->domain () != MODULE_DOMAIN) + matches = true; + } + if (!matches && kind == MODULES_DOMAIN) + { + if (sym->domain () == MODULE_DOMAIN + && sym->line () != 0) + matches = true; + } + if (matches) { if (result_set->size () < m_max_search_results) { From patchwork Thu Jan 18 20:32:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84373 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 A882838582B6 for ; Thu, 18 Jan 2024 20:34:36 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta038.useast.a.cloudfilter.net (omta038.useast.a.cloudfilter.net [44.202.169.37]) by sourceware.org (Postfix) with ESMTPS id D751D3858CDB for ; Thu, 18 Jan 2024 20:32:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D751D3858CDB 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 D751D3858CDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609937; cv=none; b=Sy8oIkNZBpOohV9I4qC3Gd53qDyL1kh8dgc//NGM0I+ua9wERvP3pbkGa78KMLEeRlRW03WKb8ssARVrNhDaOc9XTbHYiJR+nV1lU05rhAMZ5L8VELu9Rqkn2faDnniJa6lR00ojKqmYoIslN/x6u3WvYdocfLLP9h87JVp13kM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609937; c=relaxed/simple; bh=SWF7r1jYfk2/mXX1PIBZxmONO4yny//if4uV5CeuqWY=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=o5DZiwerqS2iJ2FpvpdR+ZArPmvIK3NdyvB10DIXsdbuCgedxNmICBw8AX4G466P6rDa3NniAhKn9P/ullDjByCppLghLMN9Ti7xie2l9V2T/DaFGnjbk4hl6u4d53STWs91WDv6Y1II4W+6VGHzdgQzYiab73HJ3cmdJuIgho8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6002a.ext.cloudfilter.net ([10.0.30.222]) by cmsmtp with ESMTPS id QSw7rOXAB9gG6QZ3arf5w3; Thu, 18 Jan 2024 20:32:10 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3ZrsCGAD6lhQZ3arjjTy; Thu, 18 Jan 2024 20:32:10 +0000 X-Authority-Analysis: v=2.4 cv=LNR1/ba9 c=1 sm=1 tr=0 ts=65a98aca a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=mDV3o1hIAAAA:8 a=z3Xw3AbGaEhUEUh7u4IA:9 a=QEXdDO2ut3YA:10 a=_FVE-zBwftR9WsbkzFJk:22 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=NF7GBtqPlH7L/4Yzz5xFCMbjqQcscogCsZ7FxQwNxG8=; b=F1RCXE69tOOKh/tmKSdwYzJL/R oUCDErfqYcn2eyMVvjTj3NSKQUQrrjR5A80dpf3fg8RIRNNcOirQo7iS8lK90eePgDpCxkUn8gquT EveWBiGi5tea8sQaUmuo2bJfT; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3Z-002DCj-2H for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:09 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:08 -0700 Subject: [PATCH v2 10/30] Use a .def file for domain_enum MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-10-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3Z-002DCj-2H X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 12 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfJpIoupor8JiCxMSFniBC1UdgeA4n0kZjqlLeQFkgKPNFUnb+O8ifPgRGmFcapE8ILY2TN30pCWVkMoy58CPsDI60mjvxNP3cndg0G02qKYqnSQ0rNmp wRZUgkn1o6F6tLBmIUYxn4gAzcT2D4EiTQBQQCkgI1yUOcM4uxAiJ38X2cVGzS/bN6PAvHtWfOHOi13Mo1hsOvBNhymb5Zt2vGs= X-Spam-Status: No, score=-3022.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, 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 Future patches will change and reuse the names from domain_enum. This patch makes this less error-prone by having a single point to define these names, using the typical gdb ".def" file. --- gdb/guile/scm-symbol.c | 18 ++++++++++-------- gdb/python/py-symbol.c | 21 ++++++++------------- gdb/sym-domains.def | 47 +++++++++++++++++++++++++++++++++++++++++++++++ gdb/symtab.c | 10 ++++------ gdb/symtab.h | 31 +++---------------------------- 5 files changed, 72 insertions(+), 55 deletions(-) diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c index 801c3f13b96..bf5fe24f23d 100644 --- a/gdb/guile/scm-symbol.c +++ b/gdb/guile/scm-symbol.c @@ -693,16 +693,18 @@ static const scheme_integer_constant symbol_integer_constants[] = X (LOC_OPTIMIZED_OUT), X (LOC_COMPUTED), X (LOC_REGPARM_ADDR), - - X (UNDEF_DOMAIN), - X (VAR_DOMAIN), - X (STRUCT_DOMAIN), - X (LABEL_DOMAIN), - X (VARIABLES_DOMAIN), - X (FUNCTIONS_DOMAIN), - X (TYPES_DOMAIN), #undef X +#define DOMAIN(X) \ + { "SYMBOL_" #X "_DOMAIN", X ## _DOMAIN }, +#include "sym-domains.def" +#undef DOMAIN + + /* These were never correct. */ + { "SYMBOL_VARIABLES_DOMAIN", VAR_DOMAIN }, + { "SYMBOL_FUNCTIONS_DOMAIN", VAR_DOMAIN }, + { "SYMBOL_TYPES_DOMAIN", VAR_DOMAIN }, + END_INTEGER_CONSTANTS }; diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index 82ea5c59c63..52a25b632e0 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -670,20 +670,15 @@ gdbpy_initialize_symbols (void) || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_COMMON_BLOCK", LOC_COMMON_BLOCK) < 0 || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_REGPARM_ADDR", - LOC_REGPARM_ADDR) < 0 - || PyModule_AddIntConstant (gdb_module, "SYMBOL_UNDEF_DOMAIN", - UNDEF_DOMAIN) < 0 - || PyModule_AddIntConstant (gdb_module, "SYMBOL_VAR_DOMAIN", - VAR_DOMAIN) < 0 - || PyModule_AddIntConstant (gdb_module, "SYMBOL_STRUCT_DOMAIN", - STRUCT_DOMAIN) < 0 - || PyModule_AddIntConstant (gdb_module, "SYMBOL_LABEL_DOMAIN", - LABEL_DOMAIN) < 0 - || PyModule_AddIntConstant (gdb_module, "SYMBOL_MODULE_DOMAIN", - MODULE_DOMAIN) < 0 - || PyModule_AddIntConstant (gdb_module, "SYMBOL_COMMON_BLOCK_DOMAIN", - COMMON_BLOCK_DOMAIN) < 0) + LOC_REGPARM_ADDR) < 0) + return -1; + +#define DOMAIN(X) \ + if (PyModule_AddIntConstant (gdb_module, "SYMBOL_" #X "_DOMAIN", \ + X ## _DOMAIN) < 0) \ return -1; +#include "sym-domains.def" +#undef DOMAIN /* These remain defined for compatibility, but as they were never correct, they are no longer documented. Eventually we can remove diff --git a/gdb/sym-domains.def b/gdb/sym-domains.def new file mode 100644 index 00000000000..251c66fa04b --- /dev/null +++ b/gdb/sym-domains.def @@ -0,0 +1,47 @@ +/* Symbol domains -*- c++ -*- + + Copyright (C) 2023 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* UNDEF_DOMAIN is used when a domain has not been discovered or + none of the following apply. This usually indicates an error either + in the symbol information or in gdb's handling of symbols. */ + +DOMAIN (UNDEF) + +/* VAR_DOMAIN is the usual domain. In C, this contains variables, + function names, typedef names and enum type values. */ + +DOMAIN (VAR) + +/* STRUCT_DOMAIN is used in C to hold struct, union and enum type names. + Thus, if `struct foo' is used in a C program, it produces a symbol named + `foo' in the STRUCT_DOMAIN. */ + +DOMAIN (STRUCT) + +/* MODULE_DOMAIN is used in Fortran to hold module type names. */ + +DOMAIN (MODULE) + +/* LABEL_DOMAIN may be used for names of labels (for gotos). */ + +DOMAIN (LABEL) + +/* Fortran common blocks. Their naming must be separate from VAR_DOMAIN. + They also always use LOC_COMMON_BLOCK. */ +DOMAIN (COMMON_BLOCK) diff --git a/gdb/symtab.c b/gdb/symtab.c index 2020210c5f4..b1deb9d6767 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -305,12 +305,10 @@ domain_name (domain_enum e) { switch (e) { - case UNDEF_DOMAIN: return "UNDEF_DOMAIN"; - case VAR_DOMAIN: return "VAR_DOMAIN"; - case STRUCT_DOMAIN: return "STRUCT_DOMAIN"; - case MODULE_DOMAIN: return "MODULE_DOMAIN"; - case LABEL_DOMAIN: return "LABEL_DOMAIN"; - case COMMON_BLOCK_DOMAIN: return "COMMON_BLOCK_DOMAIN"; +#define DOMAIN(X) \ + case X ## _DOMAIN: return #X "_DOMAIN"; +#include "sym-domains.def" +#undef DOMAIN default: gdb_assert_not_reached ("bad domain_enum"); } } diff --git a/gdb/symtab.h b/gdb/symtab.h index 0a5f2633fe8..7e841c4033f 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -894,34 +894,9 @@ struct minimal_symbol : public general_symbol_info enum domain_enum { - /* UNDEF_DOMAIN is used when a domain has not been discovered or - none of the following apply. This usually indicates an error either - in the symbol information or in gdb's handling of symbols. */ - - UNDEF_DOMAIN, - - /* VAR_DOMAIN is the usual domain. In C, this contains variables, - function names, typedef names and enum type values. */ - - VAR_DOMAIN, - - /* STRUCT_DOMAIN is used in C to hold struct, union and enum type names. - Thus, if `struct foo' is used in a C program, it produces a symbol named - `foo' in the STRUCT_DOMAIN. */ - - STRUCT_DOMAIN, - - /* MODULE_DOMAIN is used in Fortran to hold module type names. */ - - MODULE_DOMAIN, - - /* LABEL_DOMAIN may be used for names of labels (for gotos). */ - - LABEL_DOMAIN, - - /* Fortran common blocks. Their naming must be separate from VAR_DOMAIN. - They also always use LOC_COMMON_BLOCK. */ - COMMON_BLOCK_DOMAIN, +#define DOMAIN(X) X ## _DOMAIN, +#include "sym-domains.def" +#undef DOMAIN }; /* The number of bits in a symbol used to represent the domain. */ From patchwork Thu Jan 18 20:32:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84377 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 E21433858014 for ; Thu, 18 Jan 2024 20:34:55 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta038.useast.a.cloudfilter.net (omta038.useast.a.cloudfilter.net [44.202.169.37]) by sourceware.org (Postfix) with ESMTPS id 88F373858408 for ; Thu, 18 Jan 2024 20:32:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 88F373858408 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 88F373858408 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609938; cv=none; b=pMPgDN5rBF4c81FrPaew7k0qvEU+STxhSM3JBTXoYrstA8czmR314sB+qah7Qkv2KnDaj3ac4Tri0O76azD+jR1C9LvZ8Xd1eym3nIaR9AWdrg23cZbrdiNk9XavRrkZcdDK+mDqU0UEudACeq5zaMycRZdygVQI6CzWeB1thFk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609938; c=relaxed/simple; bh=PV6xTph9+Yww3j/XhT7iObW4wt0SVlsIYqBR0xfrVAY=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=L3FHDtU7FYRUqnsX1i6Z59Fy2HvlbBPEmQ59gH0rSBqFLXX5b81UfBQZgQRJcZLHMNDVkviTw9bySA9u3sNL9YEUM6zdlfijR9UsTmNAWhDMqoP/zftIzSucm3zw15cDdCEnbTn6Oor5pLBynIlv7PkUovlN70HE+2I6Ogs+XDs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5006a.ext.cloudfilter.net ([10.0.29.179]) by cmsmtp with ESMTPS id QW09rPaNc9gG6QZ3brf5wg; Thu, 18 Jan 2024 20:32:11 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3arhZU4im6EQZ3arQziW; Thu, 18 Jan 2024 20:32:10 +0000 X-Authority-Analysis: v=2.4 cv=Qft1A+Xv c=1 sm=1 tr=0 ts=65a98aca a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=r7Wzu623eIwutHv_wZcA: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=y0BdliTsQEXA/j8EZ72MtMshRYY7+zfsOpV1SgTrzmg=; b=vVgqv08EL77gzmQj4WKUpK8Oqs 2L2uRRaozP6jTrbT7WZZnG3sFhDpsFVYYoby0gkxPYD0cIoz+F1NYHBkJkWAtWFPkBx8wqcWfm0dB BLDr7pTRgI93cX0Oi+66cnxfZ; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3Z-002DCj-36 for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:09 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:09 -0700 Subject: [PATCH v2 11/30] Add two new symbol domains MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-11-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3Z-002DCj-36 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 13 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfGwV9hc8aw4AbPOsN3TNHDg8MPjOZpWIbOhvjwc8u/u4Nxaslc/TCskvnOJZ544hXcBnETWwaYabZk2mtQ1KP88r+ZfL52B/gmPH1PzaVG4KpRwH59od hfWKz2il58yjuRRsHswA3oG5Ow1Hvn8eb1JGPTk2r0w/xPuaOg3PIoxYd4JucqEAygswVTreb9X85R/Jow2vGecmGziVYaHhr5E= X-Spam-Status: No, score=-3022.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, 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 This adds two new symbol domain constants, TYPE_DOMAIN and FUNCTION_DOMAIN. Historically, gdb was a C debugger, and the symbol tables continue to reflect this. In particular, symbol domains match the C language, with VAR_DOMAIN including variables, functions, and types. However, other languages have other approaches to namespacing. And, in any case, it is often useful for other parts of gdb to be able to distinguish between some domains at lookup time, without resorting to examining a symbol's location -- in some situations, this sort of filtering happens too late. Nothing uses these new domains yet, but the idea behind the patch is to separate symbols into more domains and then let the language-specific parts of gdb implement their semantics in terms of these categories. --- gdb/sym-domains.def | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gdb/sym-domains.def b/gdb/sym-domains.def index 251c66fa04b..cea25a5f5b3 100644 --- a/gdb/sym-domains.def +++ b/gdb/sym-domains.def @@ -45,3 +45,12 @@ DOMAIN (LABEL) /* Fortran common blocks. Their naming must be separate from VAR_DOMAIN. They also always use LOC_COMMON_BLOCK. */ DOMAIN (COMMON_BLOCK) + +/* TYPE_DOMAIN is for types and typedefs. Note that tags are not + found here, see STRUCT_DOMAIN above. */ + +DOMAIN (TYPE) + +/* FUNCTION_DOMAIN is for functions and methods. */ + +DOMAIN (FUNCTION) From patchwork Thu Jan 18 20:32:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84378 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 B5D023858295 for ; Thu, 18 Jan 2024 20:35:27 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id F179C385840A for ; Thu, 18 Jan 2024 20:32:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F179C385840A 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 F179C385840A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609938; cv=none; b=mILVkIIFJHypaQfC1aPthJ+oBxqMk+1Lr79MTOu6i6xfJlqYFV3GdsUsnDBwUkJPavco6WDGWK7s5GPK7FrqID7T3SJZP6qwGWF0Q1Lwuh8FXlHl7gBenoNRPEKtyKpOT+i4/wqJu4oEPcVqLpFbnMk7MAqK3+MXTW0p9NOGNwI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609938; c=relaxed/simple; bh=9E8UCZikUeWZl1/ZsnY+rtCYBe0Xs1B5zQZtQ70Ouwc=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=X24sG/S/oDbb9A2P61hjgIQPE+Q596TC+WDNntkKBtvhrbqy4pEcQfxVRIIedgEzNEg6boCJ5o8cxRYBioCEi/kizFEkIip0Cou4k9ADju8CurrPxg1FVHrzqVzYr82v9XsXe6F1Sq15QRqsYIbj1smE5bWGRt+3cJzjE+DNV+4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5004a.ext.cloudfilter.net ([10.0.29.221]) by cmsmtp with ESMTPS id QXcSrIb0D8uLRQZ3brw3Bz; Thu, 18 Jan 2024 20:32:11 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3arzsGlKleDQZ3arNM1w; Thu, 18 Jan 2024 20:32:11 +0000 X-Authority-Analysis: v=2.4 cv=KcbBDCUD c=1 sm=1 tr=0 ts=65a98acb a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=INT8-sjlIe3v6QsWUHQA: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=VGRFr1bN/0PA6vb2PC8ANUVGbJsemINTjJUTA+1LBV4=; b=eAjEqxqcrDHMJZBzofVvO1j2Cb 46vx9kO/oe0emCm5k7HmSo9GgljweFauAHo5jviqwhEfZzNlQmC4lFJNgjPHLZOuA5qlkKVk2gWZD mkp/cSZp+b8B6ISo5eCm0tV5p; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3a-002DCj-0d for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:10 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:10 -0700 Subject: [PATCH v2 12/30] Add domain_search_flags MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-12-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3a-002DCj-0d X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 14 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfHl3oLZCqYrWhHnynsYEF4Q3W291hJ8+iCWb2t5p73uFYh9eEIF7qUBiMXvqQTXuzuRrfd237fKDuKDNhEnxZOtRfMht5MmOsOqEhOIQESPGXpjFbtpK uznXttzTmFMtSEur6djeNE/8XF4Q8bBSWfMQd6Pss6s42prLcL7vY/EWgtRJfRFZytnJW0pixmJ3S28cpnz90cc6MuWJpSZatuM= X-Spam-Status: No, score=-3022.8 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, 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 This adds a new flag enum type, domain_search_flags, which is the flag version of domain_enum. Nothing uses this yet, but the goal here is to have all symbol searches and lookups use these flags. The new names are chosen to exactly parallel domain_enum. --- gdb/symtab.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ gdb/symtab.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/gdb/symtab.c b/gdb/symtab.c index b1deb9d6767..779e1ff82fe 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -331,6 +331,21 @@ search_domain_name (enum search_domain e) /* See symtab.h. */ +std::string +domain_name (domain_search_flags flags) +{ + static constexpr domain_search_flags::string_mapping mapping[] = { +#define DOMAIN(X) \ + MAP_ENUM_FLAG (SEARCH_ ## X ## _DOMAIN), +#include "sym-domains.def" +#undef DOMAIN + }; + + return flags.to_string (mapping); +} + +/* See symtab.h. */ + CORE_ADDR linetable_entry::pc (const struct objfile *objfile) const { @@ -2666,6 +2681,41 @@ symbol_matches_domain (enum language symbol_language, /* See symtab.h. */ +bool +symbol::matches (domain_search_flags flags) const +{ + if (language () != language_c + && language () != language_objc + && language () != language_opencl) + { + /* Only C languages distinguish tag and type namespaces. */ + if ((flags & SEARCH_TYPE_DOMAIN) != 0) + flags |= SEARCH_STRUCT_DOMAIN; + } + + if ((flags & SEARCH_FUNCTION_DOMAIN) != 0 + && domain () == VAR_DOMAIN + && aclass () == LOC_BLOCK) + return true; + + if ((flags & SEARCH_VAR_DOMAIN) != 0 + && domain () == VAR_DOMAIN) + return true; + + if ((flags & SEARCH_TYPE_DOMAIN) != 0 + && domain () == VAR_DOMAIN + && aclass () == LOC_TYPEDEF) + return true; + + if ((flags & SEARCH_STRUCT_DOMAIN) != 0 + && domain () == STRUCT_DOMAIN) + return true; + + return search_flags_matches (flags, m_domain); +} + +/* See symtab.h. */ + struct type * lookup_transparent_type (const char *name) { diff --git a/gdb/symtab.h b/gdb/symtab.h index 7e841c4033f..c02a58367c6 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -905,6 +905,48 @@ enum domain_enum extern const char *domain_name (domain_enum); +/* Flags used for searching symbol tables. These can be combined to + let the search match multiple kinds of symbol. */ +enum domain_search_flag +{ +#define DOMAIN(X) \ + SEARCH_ ## X ## _DOMAIN = (1 << X ## _DOMAIN), +#include "sym-domains.def" +#undef DOMAIN +}; +DEF_ENUM_FLAGS_TYPE (enum domain_search_flag, domain_search_flags); + +/* A convenience constant to search for any symbol. */ +constexpr domain_search_flags SEARCH_ALL + = ((domain_search_flags) 0 +#define DOMAIN(X) | SEARCH_ ## X ## _DOMAIN +#include "sym-domains.def" +#undef DOMAIN + ); + +/* A convenience define for "C-like" name lookups, matching variables, + types, and functions. */ +#define SEARCH_VFT \ + (SEARCH_VAR_DOMAIN | SEARCH_FUNCTION_DOMAIN | SEARCH_TYPE_DOMAIN) + +/* Return a string representing the given flags. */ +extern std::string domain_name (domain_search_flags); + +/* Convert a symbol domain to search flags. */ +static inline domain_search_flags +to_search_flags (domain_enum domain) +{ + return domain_search_flags (domain_search_flag (1 << domain)); +} + +/* Return true if the given domain matches the given flags, false + otherwise. */ +static inline bool +search_flags_matches (domain_search_flags flags, domain_enum domain) +{ + return (flags & to_search_flags (domain)) != 0; +} + /* Searching domains, used when searching for symbols. Element numbers are hardcoded in GDB, check all enum uses before changing it. */ @@ -1250,6 +1292,9 @@ struct symbol : public general_symbol_info, public allocate_on_obstack return symbol_matches_domain (language (), domain (), d); } + /* Return true if this symbol's domain matches FLAGS. */ + bool matches (domain_search_flags flags) const; + domain_enum domain () const { return m_domain; From patchwork Thu Jan 18 20:32:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84376 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 2EF4038582B4 for ; Thu, 18 Jan 2024 20:34:55 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta36.uswest2.a.cloudfilter.net (omta36.uswest2.a.cloudfilter.net [35.89.44.35]) by sourceware.org (Postfix) with ESMTPS id 8A5E6385840C for ; Thu, 18 Jan 2024 20:32:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8A5E6385840C 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 8A5E6385840C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609942; cv=none; b=pFwkqW8iSWMa3PVTT9ItA1EqQ4077K87tt7oYEDixUvsZoxxyZR7MiXLcpGzQFymHT1lhLLNGFgqIh0eE96977NDSg9UmNf+JkabDqGNpfIfNs7nkz3bPDOpsZNsDAN/WuWgj2ueHN1PGA0dhRnzbufhXw0WhbOdMQ5KSvspwqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609942; c=relaxed/simple; bh=/7rl5GpIaogvwdDJ1vJsDbzXreKacDYhsfh9rHTeMPI=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=cluGpxydFQbokc8DpKLJOtZcdA0FH+pnbYP0Xe1jrMSzYC8vdgU8RH4KsW2oB0VmKzQ3vbSvjuda9j/pDEXQ2jc7ZlfF/R9Q8I7BwoVKYxpr6NxTBdgI5NRv77h/+BhqwHhwtMCWT0Pc8jmJesQ9VU7BH0VTL0qa6rRewYZk/T0= 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 QWCrrCWPyCF6GQZ3brrcy0; Thu, 18 Jan 2024 20:32:11 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3arhTautzh2QZ3brbVKh; Thu, 18 Jan 2024 20:32:11 +0000 X-Authority-Analysis: v=2.4 cv=Ra6Dtnhv c=1 sm=1 tr=0 ts=65a98acb a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=635ygisoJLhA9rX-spYA: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=oU7wIbbZqL92l4POqMbQzxeXbwzfEkd3Gh+VCQJGkjU=; b=OpalyiiC7QHTHbZkVCM7D3oFjy rlRUhyM48O1bIH9g2dzQSIWNoi8NMXkuyqsRo8WQhOp6PxAsSQzVfck5mK8ZjELHiN+tPBJNT/usC 3ab9t478tsWal/KPu5oGREZlw; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3a-002DCj-1U for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:10 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:11 -0700 Subject: [PATCH v2 13/30] Replace search_domain with domain_search_flags MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-13-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3a-002DCj-1U X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 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: MS4xfEjlZR+Jm9LvamJUt+ZKpDzeczcNUyW73QKNWqhvJEcpreZqVnz3F3qyJm+XBgS5/DMI6rG/J1wn7r0kM6pAzyKAp8JXHEHAyCWkTrfQy+QpH1mmEXXZ gm69mU3jm342QbIayi8YsKal9Bt1K2DFyRpQjAGwPJsAm2w3abAh1GnuPp7n+URoHu7nL2llBdcHxMWm/8TR/+/GSsKODUKfos0= X-Spam-Status: No, score=-3022.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, 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 This patch changes gdb to replace search_domain with domain_search_flags everywhere. search_domain is removed. --- gdb/ada-lang.c | 6 +- gdb/compile/compile-cplus-symbols.c | 2 +- gdb/dwarf2/cooked-index.c | 36 ++++++++++ gdb/dwarf2/cooked-index.h | 24 +------ gdb/dwarf2/read-debug-names.c | 122 ++++++++++----------------------- gdb/dwarf2/read-gdb-index.c | 33 +++++---- gdb/dwarf2/read.c | 6 +- gdb/linespec.c | 33 ++++----- gdb/mi/mi-symbol-cmds.c | 33 ++++----- gdb/objfiles.h | 2 +- gdb/psymtab.c | 14 ++-- gdb/psymtab.h | 2 +- gdb/python/py-symbol.c | 2 +- gdb/python/python.c | 2 +- gdb/quick-symbol.h | 2 +- gdb/symfile-debug.c | 12 ++-- gdb/symfile.c | 2 +- gdb/symfile.h | 2 +- gdb/symmisc.c | 2 +- gdb/symtab.c | 130 +++++++++++++++++++----------------- gdb/symtab.h | 36 ++-------- 21 files changed, 221 insertions(+), 282 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index c04c48e2e90..4eea4e6609e 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -5514,7 +5514,7 @@ map_matching_symbols (struct objfile *objfile, global ? SEARCH_GLOBAL_BLOCK : SEARCH_STATIC_BLOCK, - domain, ALL_DOMAIN); + domain, SEARCH_ALL); const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK; for (compunit_symtab *symtab : objfile->compunits ()) @@ -12997,7 +12997,7 @@ ada_add_global_exceptions (compiled_regex *preg, }, NULL, SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, - VARIABLES_DOMAIN); + SEARCH_VAR_DOMAIN); /* Iterate over all objfiles irrespective of scope or linker namespaces so we get all exceptions anywhere in the progspace. */ @@ -13542,7 +13542,7 @@ class ada_language : public language_defn NULL, NULL, SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, - ALL_DOMAIN); + SEARCH_ALL); /* At this point scan through the misc symbol vectors and add each symbol you find to the list. Eventually we want to ignore diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c index e4bbaa9a2b0..dbdabe94e1e 100644 --- a/gdb/compile/compile-cplus-symbols.c +++ b/gdb/compile/compile-cplus-symbols.c @@ -368,7 +368,7 @@ gcc_cplus_convert_symbol (void *datum, symbol_searcher searcher; searcher.find_all_symbols (identifier, current_language, - ALL_DOMAIN, nullptr, nullptr); + SEARCH_ALL, nullptr, nullptr); /* Convert any found symbols. */ for (const auto &it : searcher.matching_symbols ()) diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index e4f112b6ee0..2430dbd40f4 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -199,6 +199,42 @@ test_compare () /* See cooked-index.h. */ +bool +cooked_index_entry::matches (domain_search_flags kind) const +{ + /* Just reject type declarations. */ + if ((flags & IS_TYPE_DECLARATION) != 0) + return false; + + if ((kind & SEARCH_VAR_DOMAIN) != 0 + && (tag == DW_TAG_variable + || tag == DW_TAG_constant + || tag == DW_TAG_enumerator)) + return true; + + if ((kind & SEARCH_STRUCT_DOMAIN) != 0 + && (tag == DW_TAG_structure_type + || tag == DW_TAG_class_type + || tag == DW_TAG_union_type + || tag == DW_TAG_enumeration_type)) + return true; + + if ((kind & SEARCH_MODULE_DOMAIN) != 0 && tag == DW_TAG_module) + return true; + + if ((kind & SEARCH_TYPE_DOMAIN) != 0 && tag_is_type (tag)) + return true; + + if ((kind & SEARCH_FUNCTION_DOMAIN) != 0 + && (tag == DW_TAG_subprogram + || tag == DW_TAG_entry_point)) + return true; + + return false; +} + +/* See cooked-index.h. */ + const char * cooked_index_entry::full_name (struct obstack *storage, bool for_main) const { diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index ebaed04753c..8fc54f9b994 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -160,29 +160,7 @@ struct cooked_index_entry : public allocate_on_obstack } /* Return true if this entry matches KIND. */ - bool matches (enum search_domain kind) const - { - /* Just reject type declarations. */ - if ((flags & IS_TYPE_DECLARATION) != 0) - return false; - - switch (kind) - { - case VARIABLES_DOMAIN: - return (tag == DW_TAG_variable - || tag == DW_TAG_constant - || tag == DW_TAG_enumerator); - case FUNCTIONS_DOMAIN: - return (tag == DW_TAG_subprogram - || tag == DW_TAG_entry_point); - case TYPES_DOMAIN: - return tag_is_type (tag); - case MODULES_DOMAIN: - return tag == DW_TAG_module; - } - - return true; - } + bool matches (domain_search_flags kind) const; /* Construct the fully-qualified name of this entry and return a pointer to it. If allocation is needed, it will be done on diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c index a2a9fd425ae..91aeb70fac8 100644 --- a/gdb/dwarf2/read-debug-names.c +++ b/gdb/dwarf2/read-debug-names.c @@ -92,7 +92,7 @@ struct dwarf2_debug_names_index : public dwarf2_base_index_functions gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain kind) override; + domain_search_flags kind) override; }; quick_symbol_functions_up @@ -526,7 +526,7 @@ class dw2_debug_names_iterator {} dw2_debug_names_iterator (const mapped_debug_names &map, - search_domain search, uint32_t namei, + domain_search_flags search, uint32_t namei, dwarf2_per_objfile *per_objfile, domain_enum domain = UNDEF_DOMAIN) : m_map (map), @@ -564,7 +564,7 @@ class dw2_debug_names_iterator /* The kind of symbol we're looking for. */ const domain_enum m_domain = UNDEF_DOMAIN; - const search_domain m_search = ALL_DOMAIN; + const domain_search_flags m_search = SEARCH_ALL; /* The list of CUs from the index entry of the symbol, or NULL if not found. */ @@ -831,100 +831,46 @@ dw2_debug_names_iterator::next () } } - /* Match dw2_symtab_iter_next, symbol_kind - and debug_names::psymbol_tag. */ - switch (m_domain) + domain_enum domain = UNDEF_DOMAIN; + switch (indexval.dwarf_tag) { - case VAR_DOMAIN: - switch (indexval.dwarf_tag) - { - case DW_TAG_variable: - case DW_TAG_subprogram: - /* Some types are also in VAR_DOMAIN. */ - case DW_TAG_typedef: - case DW_TAG_structure_type: - break; - default: - goto again; - } - break; - case STRUCT_DOMAIN: - switch (indexval.dwarf_tag) - { - case DW_TAG_typedef: - case DW_TAG_structure_type: - break; - default: - goto again; - } + case DW_TAG_variable: + domain = VAR_DOMAIN; break; - case LABEL_DOMAIN: - switch (indexval.dwarf_tag) - { - case 0: - case DW_TAG_variable: - break; - default: - goto again; - } - break; - case MODULE_DOMAIN: - switch (indexval.dwarf_tag) - { - case DW_TAG_module: - break; - default: - goto again; - } - break; - default: + + case DW_TAG_subprogram: + domain = FUNCTION_DOMAIN; break; - } - /* Match dw2_expand_symtabs_matching, symbol_kind and - debug_names::psymbol_tag. */ - switch (m_search) - { - case VARIABLES_DOMAIN: - switch (indexval.dwarf_tag) - { - case DW_TAG_variable: - break; - default: - goto again; - } + case DW_TAG_structure_type: + case DW_TAG_union_type: + case DW_TAG_enumeration_type: + domain = STRUCT_DOMAIN; break; - case FUNCTIONS_DOMAIN: - switch (indexval.dwarf_tag) - { - case DW_TAG_subprogram: - break; - default: - goto again; - } + + case DW_TAG_typedef: + domain = TYPE_DOMAIN; break; - case TYPES_DOMAIN: - switch (indexval.dwarf_tag) - { - case DW_TAG_typedef: - case DW_TAG_structure_type: - break; - default: - goto again; - } + + case DW_TAG_label: + domain = LABEL_DOMAIN; break; - case MODULES_DOMAIN: - switch (indexval.dwarf_tag) - { - case DW_TAG_module: - break; - default: - goto again; - } - default: + + case DW_TAG_module: + domain = MODULE_DOMAIN; break; } + if (! (m_domain == domain + || (m_domain == VAR_DOMAIN + && (domain == TYPE_DOMAIN + || domain == FUNCTION_DOMAIN)))) + goto again; + + domain_search_flags flags = to_search_flags (domain); + if ((flags & m_search) == 0) + goto again; + return per_cu; } @@ -947,7 +893,7 @@ dwarf2_debug_names_index::expand_symtabs_matching gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain kind) + domain_search_flags kind) { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c index 3f10aa748f0..091aa62d61d 100644 --- a/gdb/dwarf2/read-gdb-index.c +++ b/gdb/dwarf2/read-gdb-index.c @@ -147,7 +147,7 @@ struct dwarf2_gdb_index : public dwarf2_base_index_functions gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain kind) override; + domain_search_flags kind) override; }; /* This dumps minimal information about the index. @@ -176,7 +176,7 @@ dw2_expand_marked_cus gdb::function_view file_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - search_domain kind) + domain_search_flags kind) { offset_type vec_len, vec_idx; bool global_seen = false; @@ -227,27 +227,24 @@ dw2_expand_marked_cus continue; } - switch (kind) + domain_search_flags mask = 0; + switch (symbol_kind) { - case VARIABLES_DOMAIN: - if (symbol_kind != GDB_INDEX_SYMBOL_KIND_VARIABLE) - continue; - break; - case FUNCTIONS_DOMAIN: - if (symbol_kind != GDB_INDEX_SYMBOL_KIND_FUNCTION) - continue; + case GDB_INDEX_SYMBOL_KIND_VARIABLE: + mask = SEARCH_VAR_DOMAIN; break; - case TYPES_DOMAIN: - if (symbol_kind != GDB_INDEX_SYMBOL_KIND_TYPE) - continue; + case GDB_INDEX_SYMBOL_KIND_FUNCTION: + mask = SEARCH_FUNCTION_DOMAIN; break; - case MODULES_DOMAIN: - if (symbol_kind != GDB_INDEX_SYMBOL_KIND_OTHER) - continue; + case GDB_INDEX_SYMBOL_KIND_TYPE: + mask = SEARCH_TYPE_DOMAIN; break; - default: + case GDB_INDEX_SYMBOL_KIND_OTHER: + mask = SEARCH_MODULE_DOMAIN; break; } + if ((kind & mask) == 0) + continue; } /* Don't crash on bad data. */ @@ -276,7 +273,7 @@ dwarf2_gdb_index::expand_symtabs_matching gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain kind) + domain_search_flags kind) { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 078edd8c842..292dba3e24e 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1641,7 +1641,7 @@ struct readnow_functions : public dwarf2_base_index_functions gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain kind) override + domain_search_flags kind) override { return true; } @@ -16734,7 +16734,7 @@ struct cooked_index_functions : public dwarf2_base_index_functions gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain kind) override; + domain_search_flags kind) override; struct compunit_symtab *find_pc_sect_compunit_symtab (struct objfile *objfile, struct bound_minimal_symbol msymbol, @@ -16799,7 +16799,7 @@ cooked_index_functions::expand_symtabs_matching gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain kind) + domain_search_flags kind) { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); diff --git a/gdb/linespec.c b/gdb/linespec.c index 2c54ed55d93..1d8cbc58b97 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -387,13 +387,13 @@ static int symbol_to_sal (struct symtab_and_line *result, static void add_matching_symbols_to_info (const char *name, symbol_name_match_type name_match_type, - enum search_domain search_domain, + domain_search_flags domain_search_flags, struct collect_info *info, struct program_space *pspace); static void add_all_symbol_names_from_pspace (struct collect_info *info, struct program_space *pspace, - const std::vector &names, enum search_domain search_domain); + const std::vector &names, domain_search_flags domain_search_flags); static std::vector collect_symtabs_from_filename (const char *file, @@ -1155,7 +1155,7 @@ iterate_over_all_matching_symtabs (struct linespec_state *state, const lookup_name_info &lookup_name, const domain_enum name_domain, - enum search_domain search_domain, + domain_search_flags domain_search_flags, struct program_space *search_pspace, bool include_inline, gdb::function_view callback) { @@ -1174,7 +1174,7 @@ iterate_over_all_matching_symtabs (SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK), UNDEF_DOMAIN, - search_domain); + domain_search_flags); for (compunit_symtab *cu : objfile->compunits ()) { @@ -3331,7 +3331,7 @@ decode_objc (struct linespec_state *self, linespec *ls, const char *arg) return {}; add_all_symbol_names_from_pspace (&info, NULL, symbol_names, - FUNCTIONS_DOMAIN); + SEARCH_FUNCTION_DOMAIN); std::vector values; if (!symbols.empty () || !minimal_symbols.empty ()) @@ -3450,10 +3450,10 @@ lookup_prefix_sym (struct linespec_state *state, if (elt == nullptr) { iterate_over_all_matching_symtabs (state, lookup_name, - STRUCT_DOMAIN, ALL_DOMAIN, + STRUCT_DOMAIN, SEARCH_ALL, NULL, false, collector); iterate_over_all_matching_symtabs (state, lookup_name, - VAR_DOMAIN, ALL_DOMAIN, + VAR_DOMAIN, SEARCH_ALL, NULL, false, collector); } else @@ -3531,12 +3531,12 @@ static void add_all_symbol_names_from_pspace (struct collect_info *info, struct program_space *pspace, const std::vector &names, - enum search_domain search_domain) + domain_search_flags domain_search_flags) { for (const char *iter : names) add_matching_symbols_to_info (iter, symbol_name_match_type::FULL, - search_domain, info, pspace); + domain_search_flags, info, pspace); } static void @@ -3630,7 +3630,7 @@ find_method (struct linespec_state *self, iterate over the symbol tables looking for all matches in this pspace. */ add_all_symbol_names_from_pspace (&info, pspace, result_names, - FUNCTIONS_DOMAIN); + SEARCH_FUNCTION_DOMAIN); superclass_vec.clear (); last_result_len = result_names.size (); @@ -3753,7 +3753,7 @@ symtabs_from_filename (const char *filename, void symbol_searcher::find_all_symbols (const std::string &name, const struct language_defn *language, - enum search_domain search_domain, + domain_search_flags domain_search_flags, std::vector *search_symtabs, struct program_space *search_pspace) { @@ -3775,7 +3775,7 @@ symbol_searcher::find_all_symbols (const std::string &name, info.file_symtabs = search_symtabs; add_matching_symbols_to_info (name.c_str (), symbol_name_match_type::WILD, - search_domain, &info, search_pspace); + domain_search_flags, &info, search_pspace); } /* Look up a function symbol named NAME in symtabs FILE_SYMTABS. Matching @@ -3801,9 +3801,10 @@ find_function_symbols (struct linespec_state *state, find_imps (name, &symbol_names); if (!symbol_names.empty ()) add_all_symbol_names_from_pspace (&info, state->search_pspace, - symbol_names, FUNCTIONS_DOMAIN); + symbol_names, SEARCH_FUNCTION_DOMAIN); else - add_matching_symbols_to_info (name, name_match_type, FUNCTIONS_DOMAIN, + add_matching_symbols_to_info (name, name_match_type, + SEARCH_FUNCTION_DOMAIN, &info, state->search_pspace); } @@ -4322,7 +4323,7 @@ search_minsyms_for_name (struct collect_info *info, static void add_matching_symbols_to_info (const char *name, symbol_name_match_type name_match_type, - enum search_domain search_domain, + domain_search_flags domain_search_flags, struct collect_info *info, struct program_space *pspace) { @@ -4333,7 +4334,7 @@ add_matching_symbols_to_info (const char *name, if (elt == nullptr) { iterate_over_all_matching_symtabs (info->state, lookup_name, - VAR_DOMAIN, search_domain, + VAR_DOMAIN, domain_search_flags, pspace, true, [&] (block_symbol *bsym) { return info->add_symbol (bsym); }); diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c index 758f5974706..37cf2fbcfa2 100644 --- a/gdb/mi/mi-symbol-cmds.c +++ b/gdb/mi/mi-symbol-cmds.c @@ -72,7 +72,7 @@ mi_cmd_symbol_list_lines (const char *command, const char *const *argv, results. */ static void -output_debug_symbol (ui_out *uiout, enum search_domain kind, +output_debug_symbol (ui_out *uiout, domain_search_flags kind, struct symbol *sym, int block) { ui_out_emit_tuple tuple_emitter (uiout, NULL); @@ -81,7 +81,7 @@ output_debug_symbol (ui_out *uiout, enum search_domain kind, uiout->field_unsigned ("line", sym->line ()); uiout->field_string ("name", sym->print_name ()); - if (kind == FUNCTIONS_DOMAIN || kind == VARIABLES_DOMAIN) + if ((kind & (SEARCH_FUNCTION_DOMAIN | SEARCH_VAR_DOMAIN)) != 0) { string_file tmp_stream; type_print (sym->type (), "", &tmp_stream, -1); @@ -113,7 +113,7 @@ output_nondebug_symbol (ui_out *uiout, and then prints the matching [m]symbols in an MI structured format. */ static void -mi_symbol_info (enum search_domain kind, const char *name_regexp, +mi_symbol_info (domain_search_flags kind, const char *name_regexp, const char *type_regexp, bool exclude_minsyms, size_t max_results) { @@ -190,7 +190,7 @@ parse_max_results_option (const char *arg) Processes command line options from ARGV and ARGC. */ static void -mi_info_functions_or_variables (enum search_domain kind, +mi_info_functions_or_variables (domain_search_flags kind, const char *const *argv, int argc) { size_t max_results = SIZE_MAX; @@ -217,7 +217,7 @@ mi_info_functions_or_variables (enum search_domain kind, while (1) { const char *cmd_string - = ((kind == FUNCTIONS_DOMAIN) + = ((kind == SEARCH_FUNCTION_DOMAIN) ? "-symbol-info-functions" : "-symbol-info-variables"); int opt = mi_getopt (cmd_string, argc, argv, opts, &oind, &oarg); if (opt < 0) @@ -253,7 +253,7 @@ typedef std::vector::const_iterator static module_symbol_search_iterator output_module_symbols_in_single_module_and_file (struct ui_out *uiout, module_symbol_search_iterator iter, - const module_symbol_search_iterator end, enum search_domain kind) + const module_symbol_search_iterator end, domain_search_flags kind) { /* The symbol for the module in which the first result resides. */ const symbol *first_module_symbol = iter->first.symbol; @@ -288,7 +288,7 @@ output_module_symbols_in_single_module_and_file static module_symbol_search_iterator output_module_symbols_in_single_module (struct ui_out *uiout, module_symbol_search_iterator iter, - const module_symbol_search_iterator end, enum search_domain kind) + const module_symbol_search_iterator end, domain_search_flags kind) { gdb_assert (iter->first.symbol != nullptr); gdb_assert (iter->second.symbol != nullptr); @@ -316,8 +316,8 @@ output_module_symbols_in_single_module command line options passed to the MI command. */ static void -mi_info_module_functions_or_variables (enum search_domain kind, - const char *const *argv, int argc) +mi_info_module_functions_or_variables (domain_search_flags kind, + const char *const *argv, int argc) { const char *module_regexp = nullptr; const char *regexp = nullptr; @@ -343,7 +343,7 @@ mi_info_module_functions_or_variables (enum search_domain kind, while (1) { const char *cmd_string - = ((kind == FUNCTIONS_DOMAIN) + = ((kind == SEARCH_FUNCTION_DOMAIN) ? "-symbol-info-module-functions" : "-symbol-info-module-variables"); int opt = mi_getopt (cmd_string, argc, argv, opts, &oind, &oarg); @@ -385,7 +385,7 @@ void mi_cmd_symbol_info_functions (const char *command, const char *const *argv, int argc) { - mi_info_functions_or_variables (FUNCTIONS_DOMAIN, argv, argc); + mi_info_functions_or_variables (SEARCH_FUNCTION_DOMAIN, argv, argc); } /* Implement -symbol-info-module-functions command. */ @@ -394,7 +394,7 @@ void mi_cmd_symbol_info_module_functions (const char *command, const char *const *argv, int argc) { - mi_info_module_functions_or_variables (FUNCTIONS_DOMAIN, argv, argc); + mi_info_module_functions_or_variables (SEARCH_FUNCTION_DOMAIN, argv, argc); } /* Implement -symbol-info-module-variables command. */ @@ -403,7 +403,7 @@ void mi_cmd_symbol_info_module_variables (const char *command, const char *const *argv, int argc) { - mi_info_module_functions_or_variables (VARIABLES_DOMAIN, argv, argc); + mi_info_module_functions_or_variables (SEARCH_VAR_DOMAIN, argv, argc); } /* Implement -symbol-inf-modules command. */ @@ -446,7 +446,7 @@ mi_cmd_symbol_info_modules (const char *command, const char *const *argv, } } - mi_symbol_info (MODULES_DOMAIN, regexp, nullptr, true, max_results); + mi_symbol_info (SEARCH_MODULE_DOMAIN, regexp, nullptr, true, max_results); } /* Implement -symbol-info-types command. */ @@ -489,7 +489,8 @@ mi_cmd_symbol_info_types (const char *command, const char *const *argv, } } - mi_symbol_info (TYPES_DOMAIN, regexp, nullptr, true, max_results); + mi_symbol_info (SEARCH_TYPE_DOMAIN | SEARCH_STRUCT_DOMAIN, regexp, nullptr, + true, max_results); } /* Implement -symbol-info-variables command. */ @@ -498,5 +499,5 @@ void mi_cmd_symbol_info_variables (const char *command, const char *const *argv, int argc) { - mi_info_functions_or_variables (VARIABLES_DOMAIN, argv, argc); + mi_info_functions_or_variables (SEARCH_VAR_DOMAIN, argv, argc); } diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 65115ce17f0..e576c4b7087 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -592,7 +592,7 @@ struct objfile gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain kind); + domain_search_flags kind); /* See quick_symbol_functions. */ struct compunit_symtab *find_pc_sect_compunit_symtab diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 4a3a872309d..61d7c3bdc71 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -803,7 +803,7 @@ recursively_search_psymtabs struct objfile *objfile, block_search_flags search_flags, domain_enum domain, - enum search_domain search, + domain_search_flags search, const lookup_name_info &lookup_name, gdb::function_view sym_matcher) { @@ -876,15 +876,15 @@ recursively_search_psymtabs if ((domain == UNDEF_DOMAIN || symbol_matches_domain ((*psym)->ginfo.language (), (*psym)->domain, domain)) - && (search == ALL_DOMAIN - || (search == MODULES_DOMAIN + && (search == SEARCH_ALL + || (search == SEARCH_MODULE_DOMAIN && (*psym)->domain == MODULE_DOMAIN) - || (search == VARIABLES_DOMAIN + || (search == SEARCH_VAR_DOMAIN && (*psym)->aclass != LOC_TYPEDEF && (*psym)->aclass != LOC_BLOCK) - || (search == FUNCTIONS_DOMAIN + || (search == SEARCH_FUNCTION_DOMAIN && (*psym)->aclass == LOC_BLOCK) - || (search == TYPES_DOMAIN + || (search == SEARCH_TYPE_DOMAIN && (*psym)->aclass == LOC_TYPEDEF)) && psymbol_name_matches (*psym, lookup_name) && (sym_matcher == NULL @@ -914,7 +914,7 @@ psymbol_functions::expand_symtabs_matching gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain search) + domain_search_flags search) { /* Clear the search flags. */ for (partial_symtab *ps : partial_symbols (objfile)) diff --git a/gdb/psymtab.h b/gdb/psymtab.h index 2bf423400d1..c4a0d9184f2 100644 --- a/gdb/psymtab.h +++ b/gdb/psymtab.h @@ -634,7 +634,7 @@ struct psymbol_functions : public quick_symbol_functions gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain kind) override; + domain_search_flags kind) override; struct compunit_symtab *find_pc_sect_compunit_symtab (struct objfile *objfile, struct bound_minimal_symbol msymbol, diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index 52a25b632e0..a7d010f6d0c 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -596,7 +596,7 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw) lookup_name_info lookup_name (name, symbol_name_match_type::FULL); expand_symtabs_matching (NULL, lookup_name, NULL, NULL, SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, - ALL_DOMAIN); + SEARCH_ALL); for (objfile *objfile : current_program_space->objfiles ()) { diff --git a/gdb/python/python.c b/gdb/python/python.c index 1d406392bd3..de3a94dfc9a 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -736,7 +736,7 @@ gdbpy_rbreak (PyObject *self, PyObject *args, PyObject *kw) minsyms_p = cmp; } - global_symbol_searcher spec (FUNCTIONS_DOMAIN, regex); + global_symbol_searcher spec (SEARCH_FUNCTION_DOMAIN, regex); SCOPE_EXIT { for (const char *elem : spec.filenames) xfree ((void *) elem); diff --git a/gdb/quick-symbol.h b/gdb/quick-symbol.h index 63b2908b8b2..8646ac199bd 100644 --- a/gdb/quick-symbol.h +++ b/gdb/quick-symbol.h @@ -156,7 +156,7 @@ struct quick_symbol_functions gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain kind) = 0; + domain_search_flags kind) = 0; /* Return the comp unit from OBJFILE that contains PC and SECTION. Return NULL if there is no such compunit. This diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c index b0d2e19295d..38db7777d83 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -223,7 +223,7 @@ objfile::map_symtabs_matching_filename (SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK), UNDEF_DOMAIN, - ALL_DOMAIN)) + SEARCH_ALL)) { retval = false; break; @@ -289,7 +289,7 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain) ? SEARCH_GLOBAL_BLOCK : SEARCH_STATIC_BLOCK, domain, - ALL_DOMAIN)) + SEARCH_ALL)) break; } @@ -344,7 +344,7 @@ objfile::expand_symtabs_for_function (const char *func_name) (SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK), VAR_DOMAIN, - ALL_DOMAIN); + SEARCH_ALL); } void @@ -381,7 +381,7 @@ objfile::expand_symtabs_with_fullname (const char *fullname) (SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK), UNDEF_DOMAIN, - ALL_DOMAIN); + SEARCH_ALL); } bool @@ -392,7 +392,7 @@ objfile::expand_symtabs_matching gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain kind) + domain_search_flags kind) { /* This invariant is documented in quick-functions.h. */ gdb_assert (lookup_name != nullptr || symbol_matcher == nullptr); @@ -404,7 +404,7 @@ objfile::expand_symtabs_matching host_address_to_string (&file_matcher), host_address_to_string (&symbol_matcher), host_address_to_string (&expansion_notify), - search_domain_name (kind)); + domain_name (kind).c_str ()); for (const auto &iter : qf) if (!iter->expand_symtabs_matching (this, file_matcher, lookup_name, diff --git a/gdb/symfile.c b/gdb/symfile.c index 6b9f8055711..065eaf0d518 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -3769,7 +3769,7 @@ expand_symtabs_matching gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - enum search_domain kind) + domain_search_flags kind) { for (objfile *objfile : current_program_space->objfiles ()) if (!objfile->expand_symtabs_matching (file_matcher, diff --git a/gdb/symfile.h b/gdb/symfile.h index 4cb3c38a5bf..6f8b441b39f 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -352,7 +352,7 @@ bool expand_symtabs_matching gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - enum search_domain kind); + domain_search_flags kind); void map_symbol_filenames (gdb::function_view fun, bool need_fullname); diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 5dfb9fca8f0..519df255047 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -920,7 +920,7 @@ maintenance_expand_symtabs (const char *args, int from_tty) NULL, SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, UNDEF_DOMAIN, - ALL_DOMAIN); + SEARCH_ALL); } diff --git a/gdb/symtab.c b/gdb/symtab.c index 779e1ff82fe..7c56dbadf8c 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -313,22 +313,6 @@ domain_name (domain_enum e) } } -/* Return the name of a search_domain . */ - -const char * -search_domain_name (enum search_domain e) -{ - switch (e) - { - case VARIABLES_DOMAIN: return "VARIABLES_DOMAIN"; - case FUNCTIONS_DOMAIN: return "FUNCTIONS_DOMAIN"; - case TYPES_DOMAIN: return "TYPES_DOMAIN"; - case MODULES_DOMAIN: return "MODULES_DOMAIN"; - case ALL_DOMAIN: return "ALL_DOMAIN"; - default: gdb_assert_not_reached ("bad search_domain"); - } -} - /* See symtab.h. */ std::string @@ -4774,7 +4758,7 @@ treg_matches_sym_type_name (const compiled_regex &treg, bool global_symbol_searcher::is_suitable_msymbol - (const enum search_domain kind, const minimal_symbol *msymbol) + (const domain_search_flags kind, const minimal_symbol *msymbol) { switch (msymbol->type ()) { @@ -4782,12 +4766,12 @@ global_symbol_searcher::is_suitable_msymbol case mst_bss: case mst_file_data: case mst_file_bss: - return kind == VARIABLES_DOMAIN; + return (kind & SEARCH_VAR_DOMAIN) != 0; case mst_text: case mst_file_text: case mst_solib_trampoline: case mst_text_gnu_ifunc: - return kind == FUNCTIONS_DOMAIN; + return (kind & SEARCH_FUNCTION_DOMAIN) != 0; default: return false; } @@ -4799,7 +4783,7 @@ bool global_symbol_searcher::expand_symtabs (objfile *objfile, const std::optional &preg) const { - enum search_domain kind = m_kind; + domain_search_flags kind = m_kind; bool found_msymbol = false; auto do_file_match = [&] (const char *filename, bool basenames) @@ -4838,7 +4822,7 @@ global_symbol_searcher::expand_symtabs all objfiles. In large programs (1000s of shared libs) searching all objfiles is not worth the pain. */ if (filenames.empty () - && (kind == VARIABLES_DOMAIN || kind == FUNCTIONS_DOMAIN)) + && (kind & (SEARCH_VAR_DOMAIN | SEARCH_FUNCTION_DOMAIN)) != 0) { for (minimal_symbol *msymbol : objfile->msymbols ()) { @@ -4858,7 +4842,7 @@ global_symbol_searcher::expand_symtabs in the process we will add matching symbols or msymbols to the results list, and that requires that the symbols tables are expanded. */ - if (kind == FUNCTIONS_DOMAIN + if ((kind & SEARCH_FUNCTION_DOMAIN) != 0 ? (find_pc_compunit_symtab (msymbol->value_address (objfile)) == NULL) : (lookup_symbol_in_objfile_from_linkage_name @@ -4883,7 +4867,7 @@ global_symbol_searcher::add_matching_symbols const std::optional &treg, std::set *result_set) const { - enum search_domain kind = m_kind; + domain_search_flags kind = m_kind; /* Add matching symbols (if not already present). */ for (compunit_symtab *cust : objfile->compunits ()) @@ -4916,7 +4900,7 @@ global_symbol_searcher::add_matching_symbols continue; bool matches = false; - if (!matches && kind == VARIABLES_DOMAIN) + if (!matches && (kind & SEARCH_VAR_DOMAIN) != 0) { if (sym->aclass () != LOC_TYPEDEF && sym->aclass () != LOC_UNRESOLVED @@ -4932,7 +4916,7 @@ global_symbol_searcher::add_matching_symbols || treg_matches_sym_type_name (*treg, sym))) matches = true; } - if (!matches && kind == FUNCTIONS_DOMAIN) + if (!matches && (kind & SEARCH_FUNCTION_DOMAIN) != 0) { if (sym->aclass () == LOC_BLOCK && (!treg.has_value () @@ -4940,13 +4924,13 @@ global_symbol_searcher::add_matching_symbols sym))) matches = true; } - if (!matches && kind == TYPES_DOMAIN) + if (!matches && (kind & SEARCH_TYPE_DOMAIN) != 0) { if (sym->aclass () == LOC_TYPEDEF && sym->domain () != MODULE_DOMAIN) matches = true; } - if (!matches && kind == MODULES_DOMAIN) + if (!matches && (kind & SEARCH_MODULE_DOMAIN) != 0) { if (sym->domain () == MODULE_DOMAIN && sym->line () != 0) @@ -4978,7 +4962,7 @@ global_symbol_searcher::add_matching_msymbols (objfile *objfile, const std::optional &preg, std::vector *results) const { - enum search_domain kind = m_kind; + domain_search_flags kind = m_kind; for (minimal_symbol *msymbol : objfile->msymbols ()) { @@ -4995,7 +4979,7 @@ global_symbol_searcher::add_matching_msymbols { /* For functions we can do a quick check of whether the symbol might be found via find_pc_symtab. */ - if (kind != FUNCTIONS_DOMAIN + if ((kind & SEARCH_FUNCTION_DOMAIN) == 0 || (find_pc_compunit_symtab (msymbol->value_address (objfile)) == NULL)) { @@ -5025,8 +5009,6 @@ global_symbol_searcher::search () const std::optional preg; std::optional treg; - gdb_assert (m_kind != ALL_DOMAIN); - if (m_symbol_name_regexp != NULL) { const char *symbol_name_regexp = m_symbol_name_regexp; @@ -5103,11 +5085,13 @@ global_symbol_searcher::search () const user wants to see symbols matching a type regexp, then never give a minimal symbol, as we assume that a minimal symbol does not have a type. */ - if ((found_msymbol || (filenames.empty () && m_kind == VARIABLES_DOMAIN)) + if ((found_msymbol + || (filenames.empty () && (m_kind & SEARCH_VAR_DOMAIN) != 0)) && !m_exclude_minsyms && !treg.has_value ()) { - gdb_assert (m_kind == VARIABLES_DOMAIN || m_kind == FUNCTIONS_DOMAIN); + gdb_assert ((m_kind & (SEARCH_VAR_DOMAIN | SEARCH_FUNCTION_DOMAIN)) + != 0); for (objfile *objfile : current_program_space->objfiles ()) if (!add_matching_msymbols (objfile, preg, &result)) break; @@ -5238,36 +5222,55 @@ print_msymbol_info (struct bound_minimal_symbol msymbol) static void symtab_symbol_info (bool quiet, bool exclude_minsyms, - const char *regexp, enum search_domain kind, + const char *regexp, domain_enum kind, const char *t_regexp, int from_tty) { - static const char * const classnames[] = - {"variable", "function", "type", "module"}; const char *last_filename = ""; int first = 1; - gdb_assert (kind != ALL_DOMAIN); - if (regexp != nullptr && *regexp == '\0') regexp = nullptr; - global_symbol_searcher spec (kind, regexp); + domain_search_flags flags = to_search_flags (kind); + if (kind == TYPE_DOMAIN) + flags |= SEARCH_STRUCT_DOMAIN; + + global_symbol_searcher spec (flags, regexp); spec.set_symbol_type_regexp (t_regexp); spec.set_exclude_minsyms (exclude_minsyms); std::vector symbols = spec.search (); if (!quiet) { + const char *classname; + switch (kind) + { + case VAR_DOMAIN: + classname = "variable"; + break; + case FUNCTION_DOMAIN: + classname = "function"; + break; + case TYPE_DOMAIN: + classname = "type"; + break; + case MODULE_DOMAIN: + classname = "module"; + break; + default: + gdb_assert_not_reached ("invalid domain enum"); + } + if (regexp != NULL) { if (t_regexp != NULL) gdb_printf (_("All %ss matching regular expression \"%s\"" " with type matching regular expression \"%s\":\n"), - classnames[kind], regexp, t_regexp); + classname, regexp, t_regexp); else gdb_printf (_("All %ss matching regular expression \"%s\":\n"), - classnames[kind], regexp); + classname, regexp); } else { @@ -5275,9 +5278,9 @@ symtab_symbol_info (bool quiet, bool exclude_minsyms, gdb_printf (_("All defined %ss" " with type matching regular expression \"%s\" :\n"), - classnames[kind], t_regexp); + classname, t_regexp); else - gdb_printf (_("All defined %ss:\n"), classnames[kind]); + gdb_printf (_("All defined %ss:\n"), classname); } } @@ -5380,7 +5383,7 @@ info_variables_command (const char *args, int from_tty) args = nullptr; symtab_symbol_info - (opts.quiet, opts.exclude_minsyms, args, VARIABLES_DOMAIN, + (opts.quiet, opts.exclude_minsyms, args, VAR_DOMAIN, opts.type_regexp.empty () ? nullptr : opts.type_regexp.c_str (), from_tty); } @@ -5399,7 +5402,7 @@ info_functions_command (const char *args, int from_tty) args = nullptr; symtab_symbol_info - (opts.quiet, opts.exclude_minsyms, args, FUNCTIONS_DOMAIN, + (opts.quiet, opts.exclude_minsyms, args, FUNCTION_DOMAIN, opts.type_regexp.empty () ? nullptr : opts.type_regexp.c_str (), from_tty); } @@ -5442,7 +5445,8 @@ info_types_command (const char *args, int from_tty) (&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp); if (args != nullptr && *args == '\0') args = nullptr; - symtab_symbol_info (opts.quiet, false, args, TYPES_DOMAIN, NULL, from_tty); + symtab_symbol_info (opts.quiet, false, args, TYPE_DOMAIN, nullptr, + from_tty); } /* Command completer for 'info types' command. */ @@ -5474,7 +5478,7 @@ info_modules_command (const char *args, int from_tty) (&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp); if (args != nullptr && *args == '\0') args = nullptr; - symtab_symbol_info (opts.quiet, true, args, MODULES_DOMAIN, NULL, + symtab_symbol_info (opts.quiet, true, args, MODULE_DOMAIN, nullptr, from_tty); } @@ -5517,7 +5521,7 @@ rbreak_command (const char *regexp, int from_tty) } } - global_symbol_searcher spec (FUNCTIONS_DOMAIN, regexp); + global_symbol_searcher spec (SEARCH_FUNCTION_DOMAIN, regexp); if (file_name != nullptr) spec.filenames.push_back (file_name); std::vector symbols = spec.search (); @@ -6015,7 +6019,7 @@ default_collect_symbol_completion_matches_break_on return true; }, SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, - ALL_DOMAIN); + SEARCH_ALL); /* Search upwards from currently selected frame (so that we can complete on local vars). Also catch fields of types defined in @@ -6714,12 +6718,12 @@ static struct cmd_list_element *info_module_cmdlist = NULL; std::vector search_module_symbols (const char *module_regexp, const char *regexp, - const char *type_regexp, search_domain kind) + const char *type_regexp, domain_search_flags kind) { std::vector results; /* Search for all modules matching MODULE_REGEXP. */ - global_symbol_searcher spec1 (MODULES_DOMAIN, module_regexp); + global_symbol_searcher spec1 (SEARCH_MODULE_DOMAIN, module_regexp); spec1.set_exclude_minsyms (true); std::vector modules = spec1.search (); @@ -6765,8 +6769,10 @@ search_module_symbols (const char *module_regexp, const char *regexp, static void info_module_subcommand (bool quiet, const char *module_regexp, const char *regexp, const char *type_regexp, - search_domain kind) + domain_search_flags kind) { + gdb_assert (kind == SEARCH_FUNCTION_DOMAIN || kind == SEARCH_VAR_DOMAIN); + /* Print a header line. Don't build the header line bit by bit as this prevents internationalisation. */ if (!quiet) @@ -6776,12 +6782,12 @@ info_module_subcommand (bool quiet, const char *module_regexp, if (type_regexp == nullptr) { if (regexp == nullptr) - gdb_printf ((kind == VARIABLES_DOMAIN + gdb_printf ((kind == SEARCH_VAR_DOMAIN ? _("All variables in all modules:") : _("All functions in all modules:"))); else gdb_printf - ((kind == VARIABLES_DOMAIN + ((kind == SEARCH_VAR_DOMAIN ? _("All variables matching regular expression" " \"%s\" in all modules:") : _("All functions matching regular expression" @@ -6792,7 +6798,7 @@ info_module_subcommand (bool quiet, const char *module_regexp, { if (regexp == nullptr) gdb_printf - ((kind == VARIABLES_DOMAIN + ((kind == SEARCH_VAR_DOMAIN ? _("All variables with type matching regular " "expression \"%s\" in all modules:") : _("All functions with type matching regular " @@ -6800,7 +6806,7 @@ info_module_subcommand (bool quiet, const char *module_regexp, type_regexp); else gdb_printf - ((kind == VARIABLES_DOMAIN + ((kind == SEARCH_VAR_DOMAIN ? _("All variables matching regular expression " "\"%s\",\n\twith type matching regular " "expression \"%s\" in all modules:") @@ -6816,7 +6822,7 @@ info_module_subcommand (bool quiet, const char *module_regexp, { if (regexp == nullptr) gdb_printf - ((kind == VARIABLES_DOMAIN + ((kind == SEARCH_VAR_DOMAIN ? _("All variables in all modules matching regular " "expression \"%s\":") : _("All functions in all modules matching regular " @@ -6824,7 +6830,7 @@ info_module_subcommand (bool quiet, const char *module_regexp, module_regexp); else gdb_printf - ((kind == VARIABLES_DOMAIN + ((kind == SEARCH_VAR_DOMAIN ? _("All variables matching regular expression " "\"%s\",\n\tin all modules matching regular " "expression \"%s\":") @@ -6837,7 +6843,7 @@ info_module_subcommand (bool quiet, const char *module_regexp, { if (regexp == nullptr) gdb_printf - ((kind == VARIABLES_DOMAIN + ((kind == SEARCH_VAR_DOMAIN ? _("All variables with type matching regular " "expression \"%s\"\n\tin all modules matching " "regular expression \"%s\":") @@ -6847,7 +6853,7 @@ info_module_subcommand (bool quiet, const char *module_regexp, type_regexp, module_regexp); else gdb_printf - ((kind == VARIABLES_DOMAIN + ((kind == SEARCH_VAR_DOMAIN ? _("All variables matching regular expression " "\"%s\",\n\twith type matching regular expression " "\"%s\",\n\tin all modules matching regular " @@ -6962,7 +6968,7 @@ info_module_functions_command (const char *args, int from_tty) (opts.quiet, opts.module_regexp.empty () ? nullptr : opts.module_regexp.c_str (), args, opts.type_regexp.empty () ? nullptr : opts.type_regexp.c_str (), - FUNCTIONS_DOMAIN); + SEARCH_FUNCTION_DOMAIN); } /* Implements the 'info module variables' command. */ @@ -6981,7 +6987,7 @@ info_module_variables_command (const char *args, int from_tty) (opts.quiet, opts.module_regexp.empty () ? nullptr : opts.module_regexp.c_str (), args, opts.type_regexp.empty () ? nullptr : opts.type_regexp.c_str (), - VARIABLES_DOMAIN); + SEARCH_VAR_DOMAIN); } /* Command completer for 'info module ...' sub-commands. */ diff --git a/gdb/symtab.h b/gdb/symtab.h index c02a58367c6..2e55ad78039 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -947,30 +947,6 @@ search_flags_matches (domain_search_flags flags, domain_enum domain) return (flags & to_search_flags (domain)) != 0; } -/* Searching domains, used when searching for symbols. Element numbers are - hardcoded in GDB, check all enum uses before changing it. */ - -enum search_domain -{ - /* Everything in VAR_DOMAIN minus FUNCTIONS_DOMAIN and - TYPES_DOMAIN. */ - VARIABLES_DOMAIN = 0, - - /* All functions -- for some reason not methods, though. */ - FUNCTIONS_DOMAIN = 1, - - /* All defined types */ - TYPES_DOMAIN = 2, - - /* All modules. */ - MODULES_DOMAIN = 3, - - /* Any type. */ - ALL_DOMAIN = 4 -}; - -extern const char *search_domain_name (enum search_domain); - /* An address-class says where to find the value of a symbol. */ enum address_class @@ -2571,13 +2547,11 @@ class global_symbol_searcher public: /* Constructor. */ - global_symbol_searcher (enum search_domain kind, + global_symbol_searcher (domain_search_flags kind, const char *symbol_name_regexp) : m_kind (kind), m_symbol_name_regexp (symbol_name_regexp) { - /* The symbol searching is designed to only find one kind of thing. */ - gdb_assert (m_kind != ALL_DOMAIN); } /* Set the optional regexp that matches against the symbol type. */ @@ -2619,7 +2593,7 @@ class global_symbol_searcher TYPES_DOMAIN - Search all type names. MODULES_DOMAIN - Search all Fortran modules. ALL_DOMAIN - Not valid for this function. */ - enum search_domain m_kind; + domain_search_flags m_kind; /* Regular expression to match against the symbol name. */ const char *m_symbol_name_regexp = nullptr; @@ -2663,7 +2637,7 @@ class global_symbol_searcher std::vector *results) const; /* Return true if MSYMBOL is of type KIND. */ - static bool is_suitable_msymbol (const enum search_domain kind, + static bool is_suitable_msymbol (const domain_search_flags kind, const minimal_symbol *msymbol); }; @@ -2680,7 +2654,7 @@ typedef std::pair module_symbol_search; within the module. */ extern std::vector search_module_symbols (const char *module_regexp, const char *regexp, - const char *type_regexp, search_domain kind); + const char *type_regexp, domain_search_flags kind); /* Convert a global or static symbol SYM (based on BLOCK, which should be either GLOBAL_BLOCK or STATIC_BLOCK) into a string for use in 'info' @@ -2882,7 +2856,7 @@ class symbol_searcher to search all symtabs and program spaces. */ void find_all_symbols (const std::string &name, const struct language_defn *language, - enum search_domain search_domain, + domain_search_flags domain_search_flags, std::vector *search_symtabs, struct program_space *search_pspace); From patchwork Thu Jan 18 20:32:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84382 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 6EE3C385840A for ; Thu, 18 Jan 2024 20:36:41 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id 34249385840B for ; Thu, 18 Jan 2024 20:32:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 34249385840B 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 34249385840B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609939; cv=none; b=k+uBJyYyoZzBAcosnKl/IpoewFhDu+4SnAsvdflltrUYYfmJU9EB68tiKAo06iaoBcFI7n+UFNQ6uCJ3vAs5c1rX9EG2vAjO+4q6gbHrswdPzldKWHgo4NXvzG7+Y7JJ4obtTmXHRFx3OXygyMDztwPI8ZI154rUr9YruDG5lMA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609939; c=relaxed/simple; bh=AuxQEH8z3m7GWlxnPS3+5t44NK1io8aKAyEQOk/xXAk=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=UzchNBPMVP+DvkMygIJuRfVJGuDge9FQfVWny0qJz2G8uj0lLxZZRADxsOUQ2wjksIs1pPWvxh39s/VU2eGoMVkNJuZNidxdUkC3qJu4T15i87hl9/gR924djVj2AZOa7hIaSL8MG7DSqIYzd/jg58z8AjiwkRLfSJ2UZM9WBDo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5007a.ext.cloudfilter.net ([10.0.29.141]) by cmsmtp with ESMTPS id QWgNrIHza8uLRQZ3crw3CD; Thu, 18 Jan 2024 20:32:12 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3brcvQXPwzWQZ3brqpLk; Thu, 18 Jan 2024 20:32:11 +0000 X-Authority-Analysis: v=2.4 cv=T8yf8tGQ c=1 sm=1 tr=0 ts=65a98acb a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=xBr83xsTwwIbWKOzC-sA: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=H7HwQa+5ZZBGzk1TE+V9GuiHS665zCnpUkMdWe6sOuY=; b=p6flsg/14NNYIudPV1otOK/Zgs J/oEElkoyC6cW8Xe/mvaXZ67/gbfjeSP8DezRSZSdkM3fNF3RGVtsKzhO01KawTS+Pq59qbCHn6Ww UNeLw9F3+6E8RTR6PLJdU3RbF; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3a-002DCj-2P for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:10 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:12 -0700 Subject: [PATCH v2 14/30] Remove a check of VAR_DOMAIN MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-14-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3a-002DCj-2P X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 16 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfH1BuLF/b+3XF3/JXDNWWKi2K+mZmnVBUqV5vRE9SQdC6LImQrCLgFsDfrubI5O8Wjmji85DyHJBipzZKNmPIyyCgDnHMsk3xQIj9gojzplt2ZcYtNkr doZmFWdbEzgRpU4zOxSCB/PlGIrihrI5JvCLAaBKduv+KNpjvmYRBtr1ghg6aaVhueQoNLav05K2sRh73E+LUycgh6E3A9ywdb0= X-Spam-Status: No, score=-3022.8 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, 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 completion_list_add_symbol checks that the returned symbol has VAR_DOMAIN, but also checks that its address class is LOC_BLOCK. The domain check is redundant -- only functions can possibly be LOC_BLOCK -- and leaving this in place will cause a regression when combined with a later patch in this series. This patch preemptively removes the redundant check. --- gdb/symtab.c | 1 - 1 file changed, 1 deletion(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index 7c56dbadf8c..76a771b1166 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -5631,7 +5631,6 @@ completion_list_add_symbol (completion_tracker &tracker, the msymbol name and removes the msymbol name from the completion tracker. */ if (sym->language () == language_cplus - && sym->domain () == VAR_DOMAIN && sym->aclass () == LOC_BLOCK) { /* The call to canonicalize returns the empty string if the input From patchwork Thu Jan 18 20:32:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84374 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 D3863385801A for ; Thu, 18 Jan 2024 20:34:38 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta038.useast.a.cloudfilter.net (omta038.useast.a.cloudfilter.net [44.202.169.37]) by sourceware.org (Postfix) with ESMTPS id C401C385840D for ; Thu, 18 Jan 2024 20:32:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C401C385840D 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 C401C385840D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609940; cv=none; b=e2/bootgolqZkX2WLokNyOxce7aRpVtx0GY467qN5X0hYATmGL8js5dl76NUgTSCNNtnay2XnU5uqSzVwDI/YOAnI3sMWNSYKHqvQypDBSEsTnYuvArpAD3+CFiYd0bQcmQjf2ZIC1bPARNUhEOzzitIjNJgEIKsVE7291+4F+4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609940; c=relaxed/simple; bh=xnQLRDoE/MWVdIHjcDTGeOH5bjK0blwgHy/+IFGGQHo=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=mUDwfcJmgQ/sdy0qAt3AbWGPZO4K8a1eD1gQZdF4cPBQHdkRSp3gJ0V6mKhetAnEK+/dFcTE9JcjMHMxHIAAcZpT3UPB4uwBNK5dYCvoMXNOyi5LKcyhN5hRWA/74SIrKyGNGFsmsZ00atJPlpuigo62VwjJg49lJnSWiFcgbbk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5001a.ext.cloudfilter.net ([10.0.29.139]) by cmsmtp with ESMTPS id QXxyrQEer9gG6QZ3crf5xN; Thu, 18 Jan 2024 20:32:12 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3brH2g2RT1bQZ3br8FbE; Thu, 18 Jan 2024 20:32:11 +0000 X-Authority-Analysis: v=2.4 cv=MKVzJeVl c=1 sm=1 tr=0 ts=65a98acb a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=6hCNZdMetuoarO1jANEA: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=hqmIYDaE2uV8q9D+mVUfeGQm9SUmDY3EjikNZRzO7G4=; b=Inm5tXjNZElmMS7STGocZjihwj 8T6l2hQa68UizYzWpwpg7jsnEYInqIvl4D93h35iAL1V+y9sJfMu8P7F/AvWYcAar6Au7hMPYouff 2kyeOwtHY23v2U6RqjXHmfQNK; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3b-002DCj-00 for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:11 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:13 -0700 Subject: [PATCH v2 15/30] Introduce "scripting" domains MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-15-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3b-002DCj-00 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 17 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfDSN/s8ucWcaXBqdP9YnXs+lTZP0T5StGIVJbJ1quevfBSj/FMgQkK1h2CPpaC83Rfkz95ur0db3otTwKdjlGRvio5MRDrSoOKzzYw0ApOYVCN53bBDg 2cjvxBoXbG7d9clGJ/+SWjnNz4M635zOwvo7sSBwt5AgI+Id1IUvafmXUeTdzdOfQEZ5xSjNvOh0yX9XZIdaa0V2YdmJ8t3feYA= X-Spam-Status: No, score=-3022.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, 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 Python and Guile code exposed the internal domain constants both as attributes of symbols and as values to pass to lookup functions. Now, perfect backward compatibility here can't be achieved: some symbols are going to have domain changes by the end of this series. However, it seemed to me that we can preserve lookups using the basic domain values. This patch implements this by exporting the "or"-able search constants with an extra bit set. Then it introduces some functions to convert such constants to domain_search_flags. This will be used by the Python and Guile code, so that both old- and new-style lookups will work properly; and while preserving the idea that the domain constants can be compared to a symbol's domain. --- gdb/symtab.c | 42 ++++++++++++++++++++++++++++++++++++++++++ gdb/symtab.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/gdb/symtab.c b/gdb/symtab.c index 76a771b1166..6d24d2fe9ee 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -330,6 +330,48 @@ domain_name (domain_search_flags flags) /* See symtab.h. */ +domain_search_flags +from_scripting_domain (int val) +{ + if ((val & SCRIPTING_SEARCH_FLAG) == 0) + { + /* VAL should be one of the domain constants. Verify this and + convert it to a search constant. */ + switch (val) + { +#define DOMAIN(X) \ + case X ## _DOMAIN: break; +#include "sym-domains.def" +#undef DOMAIN + default: + error (_("unrecognized domain constant")); + } + domain_search_flags result = to_search_flags ((domain_enum) val); + if (val == VAR_DOMAIN) + { + /* This matches the historical practice. */ + result |= SEARCH_TYPE_DOMAIN | SEARCH_FUNCTION_DOMAIN; + } + return result; + } + else + { + /* VAL is several search constants or'd together. Verify + this. */ + val &= ~SCRIPTING_SEARCH_FLAG; + int check = val; +#define DOMAIN(X) \ + check &= ~ (int) SEARCH_ ## X ## _DOMAIN; +#include "sym-domains.def" +#undef DOMAIN + if (check != 0) + error (_("unrecognized domain constant")); + return (domain_search_flag) val; + } +} + +/* See symtab.h. */ + CORE_ADDR linetable_entry::pc (const struct objfile *objfile) const { diff --git a/gdb/symtab.h b/gdb/symtab.h index 2e55ad78039..b12c0541d6f 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -947,6 +947,37 @@ search_flags_matches (domain_search_flags flags, domain_enum domain) return (flags & to_search_flags (domain)) != 0; } +/* Some helpers for Python and Guile to account for backward + compatibility. Those exposed the domains for lookup as well as + checking attributes of a symbol, so special encoding and decoding + is needed to continue to support both uses. Domain constants must + remain unchanged, so that comparing a symbol's domain against a + constant yields the correct result, so search symbols are + distinguished by adding a flag bit. This way, either sort of + constant can be used for lookup. */ + +/* The flag bit. */ +constexpr int SCRIPTING_SEARCH_FLAG = 0x8000; +static_assert (SCRIPTING_SEARCH_FLAG > SEARCH_ALL); + +/* Convert a domain constant to a "scripting domain". */ +static constexpr inline int +to_scripting_domain (domain_enum val) +{ + return val; +} + +/* Convert a search constant to a "scripting domain". */ +static constexpr inline int +to_scripting_domain (domain_search_flags val) +{ + return SCRIPTING_SEARCH_FLAG | (int) val; +} + +/* Convert from a "scripting domain" constant back to search flags. + Throws an exception if VAL is not one of the allowable values. */ +extern domain_search_flags from_scripting_domain (int val); + /* An address-class says where to find the value of a symbol. */ enum address_class From patchwork Thu Jan 18 20:32:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84383 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 7DA543858292 for ; Thu, 18 Jan 2024 20:36:48 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta038.useast.a.cloudfilter.net (omta038.useast.a.cloudfilter.net [44.202.169.37]) by sourceware.org (Postfix) with ESMTPS id F254B3858414 for ; Thu, 18 Jan 2024 20:32:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F254B3858414 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 F254B3858414 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609943; cv=none; b=oyPQrtFzADqITMsP4EfYWoqDRoak1Kf3ygwbifffmHLcfJSzwpJIh4XydKYhnfkTkJVyPfGPZpqV/HHYysiBNrxa+p6YGVNwerPZORbjNbQDwumumw29bqf5jojXVpcGzq7cYdTfxWuZ+SKOjHUsnCkg5upug5U8S82TosO0n+M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609943; c=relaxed/simple; bh=LLoKorSYOQQ+Dcio4vvdB0LVpL7ffmy5I/UScVUKA4w=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=vRNv7JYzfTWTA1LKy7qmFyRyjxeiTqCg9xA5GYMSKda+29isEjswHt8k7ff16YBA8ElPiv/3dHawqxG0DspQqi3nnI2u7u0J8WKsaj54nQPxPAKDz4UBgarFBrnqN+E1wIWreEUq4TV9wq8pbc6tI3otRz+ARFnnY2fjAixxYMA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5006a.ext.cloudfilter.net ([10.0.29.179]) by cmsmtp with ESMTPS id QW09rPaNc9gG6QZ3crf5xR; Thu, 18 Jan 2024 20:32:12 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3brhZVyim6EQZ3crQzk5; Thu, 18 Jan 2024 20:32:12 +0000 X-Authority-Analysis: v=2.4 cv=Qft1A+Xv c=1 sm=1 tr=0 ts=65a98acc a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=jvYCnkMPVOesT5LiCGEA: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=aXDUM902bHJOu1tlXSFfGlZSlma44jn6KVnHBszg8Nw=; b=IpF64dJAPRywWv4tsZhJNsp6D3 EYV0epZOU8BFBfBxeZaduw0sLmhoJX7j9brby8Hkh8cnUH7xjxSe5P44c8ziVB9v6SjYAxG2cJYBc kth4gejZ80ezxKlvJU2Hft4gK; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3b-002DCj-0x for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:11 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:14 -0700 Subject: [PATCH v2 16/30] Use domain_search_flags in lookup_global_symbol_language MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-16-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3b-002DCj-0x X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 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: MS4xfBwR/rByWeerEUq6fFcC0ibpyRBdL8aD3axkUBUPbQy7ZZg303MdlmvZSV9sdZDGAL121PHQnhu2DldARLjuzGRFFhDCyZwxXOEGnC/9AtOQpBAzqouS o34p+hEk6HiRWlf8+SwF5kgnBmG3DJIT4mxJ24Ebl5qeMQ1IaTTmPPjpVCM9HFLwQZrX+h/jm3IaG82UEU2su7PYrAw+9bIySE8= X-Spam-Status: No, score=-3022.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, 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 This changes quick_symbol_functions::lookup_global_symbol_language to accept domain_search_flags rather than just a domain_enum, and fixes up the fallout. To avoid introducing any regressions, any code passing VAR_DOMAIN now uses SEARCH_VFT. That is, no visible changes should result from this patch. However, it sets the stage to refine some searches later on. --- gdb/ada-exp.y | 13 ++++---- gdb/ada-lang.c | 71 ++++++++++++++++++++++--------------------- gdb/ada-lang.h | 6 ++-- gdb/dwarf2/cooked-index.h | 22 -------------- gdb/dwarf2/read-debug-names.c | 28 ++++++----------- gdb/dwarf2/read-gdb-index.c | 8 ++--- gdb/dwarf2/read.c | 54 +++++++++++++++++++++++++++----- gdb/dwarf2/read.h | 2 +- gdb/language.h | 2 +- gdb/linespec.c | 42 ++++++++++++++----------- gdb/objfiles.h | 5 ++- gdb/psymtab.c | 37 ++++++---------------- gdb/psymtab.h | 3 +- gdb/quick-symbol.h | 10 +++--- gdb/symfile-debug.c | 21 ++++++------- gdb/symfile.c | 5 ++- gdb/symmisc.c | 1 - gdb/symtab.c | 7 ++--- gdb/symtab.h | 4 +-- 19 files changed, 164 insertions(+), 177 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 2500bd086c3..1f439b38aea 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -1265,7 +1265,7 @@ write_object_renaming (struct parser_state *par_state, name = obstack_strndup (&temp_parse_space, renamed_entity, renamed_entity_len); - ada_lookup_encoded_symbol (name, orig_left_context, VAR_DOMAIN, &sym_info); + ada_lookup_encoded_symbol (name, orig_left_context, SEARCH_VFT, &sym_info); if (sym_info.symbol == NULL) error (_("Could not find renamed variable: %s"), ada_decode (name).c_str ()); else if (sym_info.symbol->aclass () == LOC_TYPEDEF) @@ -1334,7 +1334,7 @@ write_object_renaming (struct parser_state *par_state, renaming_expr = end; ada_lookup_encoded_symbol (index_name, orig_left_context, - VAR_DOMAIN, &index_sym_info); + SEARCH_VFT, &index_sym_info); if (index_sym_info.symbol == NULL) error (_("Could not find %s"), index_name); else if (index_sym_info.symbol->aclass () == LOC_TYPEDEF) @@ -1404,7 +1404,7 @@ block_lookup (const struct block *context, const char *raw_name) } std::vector syms - = ada_lookup_symbol_list (name, context, VAR_DOMAIN); + = ada_lookup_symbol_list (name, context, SEARCH_VFT); if (context == NULL && (syms.empty () || syms[0].symbol->aclass () != LOC_BLOCK)) @@ -1483,7 +1483,7 @@ find_primitive_type (struct parser_state *par_state, const char *name) (char *) alloca (strlen (name) + sizeof ("standard__")); strcpy (expanded_name, "standard__"); strcat (expanded_name, name); - sym = ada_lookup_symbol (expanded_name, NULL, VAR_DOMAIN).symbol; + sym = ada_lookup_symbol (expanded_name, NULL, SEARCH_VFT).symbol; if (sym != NULL && sym->aclass () == LOC_TYPEDEF) type = sym->type (); } @@ -1670,7 +1670,8 @@ write_var_or_type (struct parser_state *par_state, encoded_name[tail_index] = terminator; std::vector syms - = ada_lookup_symbol_list (decoded_name.c_str (), block, VAR_DOMAIN); + = ada_lookup_symbol_list (decoded_name.c_str (), block, + SEARCH_VFT); type_sym = select_possible_type_sym (syms); @@ -1876,7 +1877,7 @@ write_name_assoc (struct parser_state *par_state, struct stoken name) std::vector syms = ada_lookup_symbol_list (name.ptr, par_state->expression_context_block, - VAR_DOMAIN); + SEARCH_VFT); if (syms.size () != 1 || syms[0].symbol->aclass () == LOC_TYPEDEF) pstate->push_new (copy_name (name)); diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 4eea4e6609e..a1fac3e8ad3 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -98,12 +98,12 @@ static struct value *make_array_descriptor (struct type *, struct value *); static void ada_add_block_symbols (std::vector &, const struct block *, const lookup_name_info &lookup_name, - domain_enum, struct objfile *); + domain_search_flags, struct objfile *); static void ada_add_all_symbols (std::vector &, const struct block *, const lookup_name_info &lookup_name, - domain_enum, int, int *); + domain_search_flags, int, int *); static int is_nonfunction (const std::vector &); @@ -176,9 +176,6 @@ static LONGEST pos_atr (struct value *); static struct value *val_atr (struct type *, LONGEST); -static struct symbol *standard_lookup (const char *, const struct block *, - domain_enum); - static struct value *ada_search_struct_field (const char *, struct value *, int, struct type *); @@ -335,7 +332,7 @@ struct cache_entry /* The name used to perform the lookup. */ std::string name; /* The namespace used during the lookup. */ - domain_enum domain = UNDEF_DOMAIN; + domain_search_flags domain = 0; /* The symbol returned by the lookup, or NULL if no matching symbol was found. */ struct symbol *sym = nullptr; @@ -349,7 +346,7 @@ struct cache_entry struct cache_entry_search { const char *name; - domain_enum domain; + domain_search_flags domain; hashval_t hash () const { @@ -3751,7 +3748,7 @@ ada_find_operator_symbol (enum exp_opcode op, bool parse_completion, { std::vector candidates = ada_lookup_symbol_list (ada_decoded_op_name (op), - NULL, VAR_DOMAIN); + NULL, SEARCH_VFT); int i = ada_resolve_function (candidates, argvec, nargs, ada_decoded_op_name (op), NULL, @@ -3772,7 +3769,7 @@ ada_resolve_funcall (struct symbol *sym, const struct block *block, innermost_block_tracker *tracker) { std::vector candidates - = ada_lookup_symbol_list (sym->linkage_name (), block, VAR_DOMAIN); + = ada_lookup_symbol_list (sym->linkage_name (), block, SEARCH_VFT); int i; if (candidates.size () == 1) @@ -3838,7 +3835,7 @@ ada_resolve_variable (struct symbol *sym, const struct block *block, innermost_block_tracker *tracker) { std::vector candidates - = ada_lookup_symbol_list (sym->linkage_name (), block, VAR_DOMAIN); + = ada_lookup_symbol_list (sym->linkage_name (), block, SEARCH_VFT); if (std::any_of (candidates.begin (), candidates.end (), @@ -4708,7 +4705,7 @@ ada_clear_symbol_cache (program_space *pspace) SYM. Same principle for BLOCK if not NULL. */ static int -lookup_cached_symbol (const char *name, domain_enum domain, +lookup_cached_symbol (const char *name, domain_search_flags domain, struct symbol **sym, const struct block **block) { htab_t tab = get_ada_pspace_data (current_program_space); @@ -4731,8 +4728,8 @@ lookup_cached_symbol (const char *name, domain_enum domain, in domain DOMAIN, save this result in our symbol cache. */ static void -cache_symbol (const char *name, domain_enum domain, struct symbol *sym, - const struct block *block) +cache_symbol (const char *name, domain_search_flags domain, + struct symbol *sym, const struct block *block) { /* Symbols for builtin types don't have a block. For now don't cache such symbols. */ @@ -4789,7 +4786,7 @@ name_match_type_from_name (const char *lookup_name) static struct symbol * standard_lookup (const char *name, const struct block *block, - domain_enum domain) + domain_search_flags domain) { /* Initialize it just to avoid a GCC false warning. */ struct block_symbol sym = {}; @@ -5192,7 +5189,7 @@ is_package_name (const char *name) /* If it is a function that has not been defined at library level, then we should be able to look it up in the symbols. */ - if (standard_lookup (name, NULL, VAR_DOMAIN) != NULL) + if (standard_lookup (name, NULL, SEARCH_VFT) != NULL) return 0; /* Library-level function names start with "_ada_". See if function @@ -5205,7 +5202,7 @@ is_package_name (const char *name) std::string fun_name = string_printf ("_ada_%s", name); - return (standard_lookup (fun_name.c_str (), NULL, VAR_DOMAIN) == NULL); + return (standard_lookup (fun_name.c_str (), NULL, SEARCH_VFT) == NULL); } /* Return nonzero if SYM corresponds to a renaming entity that is @@ -5365,7 +5362,7 @@ remove_irrelevant_renamings (std::vector *syms, static void ada_add_local_symbols (std::vector &result, const lookup_name_info &lookup_name, - const struct block *block, domain_enum domain) + const struct block *block, domain_search_flags domain) { while (block != NULL) { @@ -5439,7 +5436,7 @@ static int ada_add_block_renamings (std::vector &result, const struct block *block, const lookup_name_info &lookup_name, - domain_enum domain) + domain_search_flags domain) { struct using_direct *renaming; int defns_mark = result.size (); @@ -5504,7 +5501,7 @@ ada_lookup_name (const lookup_name_info &lookup_name) static void map_matching_symbols (struct objfile *objfile, const lookup_name_info &lookup_name, - domain_enum domain, + domain_search_flags domain, int global, match_data &data) { @@ -5514,7 +5511,7 @@ map_matching_symbols (struct objfile *objfile, global ? SEARCH_GLOBAL_BLOCK : SEARCH_STATIC_BLOCK, - domain, SEARCH_ALL); + domain); const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK; for (compunit_symtab *symtab : objfile->compunits ()) @@ -5535,7 +5532,7 @@ map_matching_symbols (struct objfile *objfile, static void add_nonlocal_symbols (std::vector &result, const lookup_name_info &lookup_name, - domain_enum domain, int global) + domain_search_flags domain, int global) { struct match_data data (&result); @@ -5588,7 +5585,7 @@ static void ada_add_all_symbols (std::vector &result, const struct block *block, const lookup_name_info &lookup_name, - domain_enum domain, + domain_search_flags domain, int full_search, int *made_global_lookup_p) { @@ -5668,7 +5665,7 @@ ada_add_all_symbols (std::vector &result, static std::vector ada_lookup_symbol_list_worker (const lookup_name_info &lookup_name, const struct block *block, - domain_enum domain, + domain_search_flags domain, int full_search) { int syms_from_global_search; @@ -5697,7 +5694,7 @@ ada_lookup_symbol_list_worker (const lookup_name_info &lookup_name, std::vector ada_lookup_symbol_list (const char *name, const struct block *block, - domain_enum domain) + domain_search_flags domain) { symbol_name_match_type name_match_type = name_match_type_from_name (name); lookup_name_info lookup_name (name, name_match_type); @@ -5714,7 +5711,7 @@ ada_lookup_symbol_list (const char *name, const struct block *block, void ada_lookup_encoded_symbol (const char *name, const struct block *block, - domain_enum domain, + domain_search_flags domain, struct block_symbol *info) { /* Since we already have an encoded name, wrap it in '<>' to force a @@ -5736,7 +5733,7 @@ ada_lookup_encoded_symbol (const char *name, const struct block *block, struct block_symbol ada_lookup_symbol (const char *name, const struct block *block0, - domain_enum domain) + domain_search_flags domain) { std::vector candidates = ada_lookup_symbol_list (name, block0, domain); @@ -6008,7 +6005,7 @@ static void ada_add_block_symbols (std::vector &result, const struct block *block, const lookup_name_info &lookup_name, - domain_enum domain, struct objfile *objfile) + domain_search_flags domain, struct objfile *objfile) { /* A matching argument symbol, if any. */ struct symbol *arg_sym; @@ -7441,11 +7438,11 @@ ada_find_any_type_symbol (const char *name) { struct symbol *sym; - sym = standard_lookup (name, get_selected_block (NULL), VAR_DOMAIN); + sym = standard_lookup (name, get_selected_block (NULL), SEARCH_VFT); if (sym != NULL && sym->aclass () == LOC_TYPEDEF) return sym; - sym = standard_lookup (name, NULL, STRUCT_DOMAIN); + sym = standard_lookup (name, NULL, SEARCH_STRUCT_DOMAIN); return sym; } @@ -11323,7 +11320,7 @@ get_var_value (const char *name, const char *err_msg) std::vector syms = ada_lookup_symbol_list_worker (lookup_name, get_selected_block (0), - VAR_DOMAIN, 1); + SEARCH_VFT, 1); if (syms.size () != 1) { @@ -11626,7 +11623,7 @@ ada_has_this_exception_support (const struct exception_support_info *einfo) that should be compiled with debugging information. As a result, we expect to find that symbol in the symtabs. */ - sym = standard_lookup (einfo->catch_exception_sym, NULL, VAR_DOMAIN); + sym = standard_lookup (einfo->catch_exception_sym, NULL, SEARCH_VFT); if (sym == NULL) { /* Perhaps we did not find our symbol because the Ada runtime was @@ -11660,7 +11657,7 @@ ada_has_this_exception_support (const struct exception_support_info *einfo) error (_("Symbol \"%s\" is not a function (class = %d)"), sym->linkage_name (), sym->aclass ()); - sym = standard_lookup (einfo->catch_handlers_sym, NULL, VAR_DOMAIN); + sym = standard_lookup (einfo->catch_handlers_sym, NULL, SEARCH_VFT); if (sym == NULL) { struct bound_minimal_symbol msym @@ -12627,7 +12624,7 @@ ada_exception_sal (enum ada_exception_catchpoint_kind ex) /* Then lookup the function on which we will break in order to catch the Ada exceptions requested by the user. */ sym_name = ada_exception_sym_name (ex); - sym = standard_lookup (sym_name, NULL, VAR_DOMAIN); + sym = standard_lookup (sym_name, NULL, SEARCH_VFT); if (sym == NULL) throw_error (NOT_FOUND_ERROR, _("Catchpoint symbol not found: %s"), @@ -13445,7 +13442,7 @@ class ada_language : public language_defn bool iterate_over_symbols (const struct block *block, const lookup_name_info &name, - domain_enum domain, + domain_search_flags domain, gdb::function_view callback) const override { std::vector results @@ -13682,11 +13679,15 @@ class ada_language : public language_defn { struct block_symbol sym; + domain_search_flags flags = to_search_flags (domain); + if (domain == VAR_DOMAIN) + flags |= SEARCH_TYPE_DOMAIN | SEARCH_FUNCTION_DOMAIN; + sym = ada_lookup_symbol (name, (block == nullptr ? nullptr : block->static_block ()), - domain); + flags); if (sym.symbol != NULL) return sym; diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h index 429931b853d..aefd335ff39 100644 --- a/gdb/ada-lang.h +++ b/gdb/ada-lang.h @@ -230,14 +230,14 @@ extern std::string ada_decode (const char *name, bool wrap = true, bool wide = true); extern std::vector ada_lookup_symbol_list - (const char *, const struct block *, domain_enum); + (const char *, const struct block *, domain_search_flags); extern struct block_symbol ada_lookup_symbol (const char *, const struct block *, - domain_enum); + domain_search_flags); extern void ada_lookup_encoded_symbol - (const char *name, const struct block *block, domain_enum domain, + (const char *name, const struct block *block, domain_search_flags domain, struct block_symbol *symbol_info); extern struct bound_minimal_symbol ada_lookup_simple_minsym (const char *, diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index 8fc54f9b994..458e2b7d01e 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -137,28 +137,6 @@ struct cooked_index_entry : public allocate_on_obstack return false; } - /* Return true if this entry matches DOMAIN. */ - bool matches (domain_enum domain) const - { - /* Just reject type declarations. */ - if ((flags & IS_TYPE_DECLARATION) != 0) - return false; - - switch (domain) - { - case LABEL_DOMAIN: - return false; - - case MODULE_DOMAIN: - return tag == DW_TAG_module; - - case COMMON_BLOCK_DOMAIN: - return tag == DW_TAG_common_block; - } - - return true; - } - /* Return true if this entry matches KIND. */ bool matches (domain_search_flags kind) const; diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c index 91aeb70fac8..0e9b1eb878f 100644 --- a/gdb/dwarf2/read-debug-names.c +++ b/gdb/dwarf2/read-debug-names.c @@ -91,8 +91,7 @@ struct dwarf2_debug_names_index : public dwarf2_base_index_functions gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, - domain_search_flags kind) override; + domain_search_flags domain) override; }; quick_symbol_functions_up @@ -518,28 +517,27 @@ class dw2_debug_names_iterator public: dw2_debug_names_iterator (const mapped_debug_names &map, block_search_flags block_index, - domain_enum domain, + domain_search_flags domain, const char *name, dwarf2_per_objfile *per_objfile) - : m_map (map), m_block_index (block_index), m_domain (domain), + : m_map (map), m_block_index (block_index), m_search (domain), m_addr (find_vec_in_debug_names (map, name, per_objfile)), m_per_objfile (per_objfile) {} dw2_debug_names_iterator (const mapped_debug_names &map, domain_search_flags search, uint32_t namei, - dwarf2_per_objfile *per_objfile, - domain_enum domain = UNDEF_DOMAIN) + dwarf2_per_objfile *per_objfile) : m_map (map), - m_domain (domain), m_search (search), m_addr (find_vec_in_debug_names (map, namei, per_objfile)), m_per_objfile (per_objfile) {} dw2_debug_names_iterator (const mapped_debug_names &map, - block_search_flags block_index, domain_enum domain, + block_search_flags block_index, + domain_search_flags domain, uint32_t namei, dwarf2_per_objfile *per_objfile) - : m_map (map), m_block_index (block_index), m_domain (domain), + : m_map (map), m_block_index (block_index), m_search (domain), m_addr (find_vec_in_debug_names (map, namei, per_objfile)), m_per_objfile (per_objfile) {} @@ -563,7 +561,6 @@ class dw2_debug_names_iterator | SEARCH_STATIC_BLOCK); /* The kind of symbol we're looking for. */ - const domain_enum m_domain = UNDEF_DOMAIN; const domain_search_flags m_search = SEARCH_ALL; /* The list of CUs from the index entry of the symbol, or NULL if @@ -861,12 +858,6 @@ dw2_debug_names_iterator::next () break; } - if (! (m_domain == domain - || (m_domain == VAR_DOMAIN - && (domain == TYPE_DOMAIN - || domain == FUNCTION_DOMAIN)))) - goto again; - domain_search_flags flags = to_search_flags (domain); if ((flags & m_search) == 0) goto again; @@ -892,8 +883,7 @@ dwarf2_debug_names_index::expand_symtabs_matching gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, - domain_search_flags kind) + domain_search_flags domain) { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); @@ -927,7 +917,7 @@ dwarf2_debug_names_index::expand_symtabs_matching { /* The name was matched, now expand corresponding CUs that were marked. */ - dw2_debug_names_iterator iter (map, kind, namei, per_objfile, domain); + dw2_debug_names_iterator iter (map, domain, namei, per_objfile); struct dwarf2_per_cu_data *per_cu; while ((per_cu = iter.next ()) != NULL) diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c index 091aa62d61d..d4741166e61 100644 --- a/gdb/dwarf2/read-gdb-index.c +++ b/gdb/dwarf2/read-gdb-index.c @@ -146,8 +146,7 @@ struct dwarf2_gdb_index : public dwarf2_base_index_functions gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, - domain_search_flags kind) override; + domain_search_flags domain) override; }; /* This dumps minimal information about the index. @@ -272,8 +271,7 @@ dwarf2_gdb_index::expand_symtabs_matching gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, - domain_search_flags kind) + domain_search_flags domain) { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); @@ -306,7 +304,7 @@ dwarf2_gdb_index::expand_symtabs_matching [&] (offset_type idx) { if (!dw2_expand_marked_cus (per_objfile, idx, file_matcher, - expansion_notify, search_flags, kind)) + expansion_notify, search_flags, domain)) return false; return true; }, per_objfile); diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 292dba3e24e..877918999b8 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1640,8 +1640,7 @@ struct readnow_functions : public dwarf2_base_index_functions gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, - domain_search_flags kind) override + domain_search_flags domain) override { return true; } @@ -16733,8 +16732,7 @@ struct cooked_index_functions : public dwarf2_base_index_functions gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, - domain_search_flags kind) override; + domain_search_flags domain) override; struct compunit_symtab *find_pc_sect_compunit_symtab (struct objfile *objfile, struct bound_minimal_symbol msymbol, @@ -16759,6 +16757,48 @@ struct cooked_index_functions : public dwarf2_base_index_functions { wait (objfile, false); } + + enum language lookup_global_symbol_language (struct objfile *objfile, + const char *name, + domain_search_flags domain, + bool *symbol_found_p) override + { + *symbol_found_p = false; + + if ((domain & SEARCH_FUNCTION_DOMAIN) == 0) + return language_unknown; + if (!streq (name, "main")) + return language_unknown; + + dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); + struct dwarf2_per_bfd *per_bfd = per_objfile->per_bfd; + if (per_bfd->index_table == nullptr) + return language_unknown; + + /* Expansion of large CUs can be slow. By returning the language of main + here for C and C++, we avoid CU expansion during set_initial_language. + But by doing a symbol lookup in the cooked index, we are forced to wait + for finalization to complete. See PR symtab/30174 for ideas how to + bypass that as well. */ + cooked_index *table + = (gdb::checked_static_cast + (per_bfd->index_table.get ())); + + for (const cooked_index_entry *entry : table->find (name, false)) + { + if (entry->tag != DW_TAG_subprogram) + continue; + + enum language lang = entry->per_cu->lang (); + if (!(lang == language_c || lang == language_cplus)) + continue; + + *symbol_found_p = true; + return lang; + } + + return language_unknown; + } }; dwarf2_per_cu_data * @@ -16798,8 +16838,7 @@ cooked_index_functions::expand_symtabs_matching gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, - domain_search_flags kind) + domain_search_flags domain) { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); @@ -16862,8 +16901,7 @@ cooked_index_functions::expand_symtabs_matching /* See if the symbol matches the type filter. */ if (!entry->matches (search_flags) - || !entry->matches (domain) - || !entry->matches (kind)) + || !entry->matches (domain)) continue; /* We've found the base name of the symbol; now walk its diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 66c6fe3fe87..805a81aad27 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -879,7 +879,7 @@ struct dwarf2_base_index_functions : public quick_symbol_functions enum language lookup_global_symbol_language (struct objfile *objfile, const char *name, - domain_enum domain, + domain_search_flags domain, bool *symbol_found_p) override { *symbol_found_p = false; diff --git a/gdb/language.h b/gdb/language.h index 287faee0cf2..14a1ef6d472 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -369,7 +369,7 @@ struct language_defn used as the definition. */ virtual bool iterate_over_symbols (const struct block *block, const lookup_name_info &name, - domain_enum domain, + domain_search_flags domain, gdb::function_view callback) const { return ::iterate_over_symbols (block, name, domain, callback); diff --git a/gdb/linespec.c b/gdb/linespec.c index 1d8cbc58b97..b9aca3cc6ce 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -350,7 +350,7 @@ struct linespec_parser static void iterate_over_file_blocks (struct symtab *symtab, const lookup_name_info &name, - domain_enum domain, + domain_search_flags domain, gdb::function_view callback); static void initialize_defaults (struct symtab **default_symtab, @@ -1154,8 +1154,7 @@ static void iterate_over_all_matching_symtabs (struct linespec_state *state, const lookup_name_info &lookup_name, - const domain_enum name_domain, - domain_search_flags domain_search_flags, + const domain_search_flags domain, struct program_space *search_pspace, bool include_inline, gdb::function_view callback) { @@ -1173,15 +1172,13 @@ iterate_over_all_matching_symtabs objfile->expand_symtabs_matching (NULL, &lookup_name, NULL, NULL, (SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK), - UNDEF_DOMAIN, - domain_search_flags); + domain); for (compunit_symtab *cu : objfile->compunits ()) { struct symtab *symtab = cu->primary_filetab (); - iterate_over_file_blocks (symtab, lookup_name, name_domain, - callback); + iterate_over_file_blocks (symtab, lookup_name, domain, callback); if (include_inline) { @@ -1193,7 +1190,7 @@ iterate_over_all_matching_symtabs { block = bv->block (i); state->language->iterate_over_symbols - (block, lookup_name, name_domain, + (block, lookup_name, domain, [&] (block_symbol *bsym) { /* Restrict calls to CALLBACK to symbols @@ -1226,7 +1223,8 @@ get_current_search_block (void) static void iterate_over_file_blocks (struct symtab *symtab, const lookup_name_info &name, - domain_enum domain, gdb::function_view callback) + domain_search_flags domain, + gdb::function_view callback) { const struct block *block; @@ -3450,10 +3448,10 @@ lookup_prefix_sym (struct linespec_state *state, if (elt == nullptr) { iterate_over_all_matching_symtabs (state, lookup_name, - STRUCT_DOMAIN, SEARCH_ALL, + SEARCH_STRUCT_DOMAIN, NULL, false, collector); iterate_over_all_matching_symtabs (state, lookup_name, - VAR_DOMAIN, SEARCH_ALL, + SEARCH_VFT, NULL, false, collector); } else @@ -3464,8 +3462,12 @@ lookup_prefix_sym (struct linespec_state *state, gdb_assert (!pspace->executing_startup); set_current_program_space (pspace); - iterate_over_file_blocks (elt, lookup_name, STRUCT_DOMAIN, collector); - iterate_over_file_blocks (elt, lookup_name, VAR_DOMAIN, collector); + iterate_over_file_blocks (elt, lookup_name, + SEARCH_STRUCT_DOMAIN, + collector); + iterate_over_file_blocks (elt, lookup_name, + SEARCH_VFT, + collector); } } @@ -3799,12 +3801,16 @@ find_function_symbols (struct linespec_state *state, /* Try NAME as an Objective-C selector. */ find_imps (name, &symbol_names); + + domain_search_flags flags = SEARCH_FUNCTION_DOMAIN; + if (state->list_mode) + flags = SEARCH_VFT; + if (!symbol_names.empty ()) add_all_symbol_names_from_pspace (&info, state->search_pspace, - symbol_names, SEARCH_FUNCTION_DOMAIN); + symbol_names, flags); else - add_matching_symbols_to_info (name, name_match_type, - SEARCH_FUNCTION_DOMAIN, + add_matching_symbols_to_info (name, name_match_type, flags, &info, state->search_pspace); } @@ -4334,7 +4340,7 @@ add_matching_symbols_to_info (const char *name, if (elt == nullptr) { iterate_over_all_matching_symtabs (info->state, lookup_name, - VAR_DOMAIN, domain_search_flags, + domain_search_flags, pspace, true, [&] (block_symbol *bsym) { return info->add_symbol (bsym); }); @@ -4349,7 +4355,7 @@ add_matching_symbols_to_info (const char *name, program_space *elt_pspace = elt->compunit ()->objfile ()->pspace; gdb_assert (!elt_pspace->executing_startup); set_current_program_space (elt_pspace); - iterate_over_file_blocks (elt, lookup_name, VAR_DOMAIN, + iterate_over_file_blocks (elt, lookup_name, SEARCH_VFT, [&] (block_symbol *bsym) { return info->add_symbol (bsym); }); diff --git a/gdb/objfiles.h b/gdb/objfiles.h index e576c4b7087..64f2b5ef6be 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -591,8 +591,7 @@ struct objfile gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, - domain_search_flags kind); + domain_search_flags domain); /* See quick_symbol_functions. */ struct compunit_symtab *find_pc_sect_compunit_symtab @@ -613,7 +612,7 @@ struct objfile /* See quick_symbol_functions. */ enum language lookup_global_symbol_language (const char *name, - domain_enum domain, + domain_search_flags domain, bool *symbol_found_p); /* Return the relocation offset applied to SECTION. */ diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 61d7c3bdc71..eb031d33f0d 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -42,7 +42,7 @@ static struct partial_symbol *lookup_partial_symbol (struct objfile *, struct partial_symtab *, const lookup_name_info &, int, - domain_enum); + domain_search_flags); static const char *psymtab_to_fullname (struct partial_symtab *ps); @@ -279,7 +279,7 @@ find_pc_sect_psymbol (struct objfile *objfile, enum language psymbol_functions::lookup_global_symbol_language (struct objfile *objfile, const char *name, - domain_enum domain, + domain_search_flags domain, bool *symbol_found_p) { *symbol_found_p = false; @@ -325,7 +325,7 @@ static struct partial_symbol * lookup_partial_symbol (struct objfile *objfile, struct partial_symtab *pst, const lookup_name_info &lookup_name, - int global, domain_enum domain) + int global, domain_search_flags domain) { struct partial_symbol **start, **psym; struct partial_symbol **top, **real_top, **bottom, **center; @@ -385,8 +385,7 @@ lookup_partial_symbol (struct objfile *objfile, while (top <= real_top && symbol_matches_search_name (&(*top)->ginfo, lookup_name)) { - if (symbol_matches_domain ((*top)->ginfo.language (), - (*top)->domain, domain)) + if (search_flags_matches (domain, (*top)->domain)) return *top; top++; } @@ -399,8 +398,7 @@ lookup_partial_symbol (struct objfile *objfile, { for (psym = start; psym < start + length; psym++) { - if (symbol_matches_domain ((*psym)->ginfo.language (), - (*psym)->domain, domain) + if (search_flags_matches (domain, (*psym)->domain) && symbol_matches_search_name (&(*psym)->ginfo, lookup_name)) return *psym; } @@ -802,8 +800,7 @@ recursively_search_psymtabs (struct partial_symtab *ps, struct objfile *objfile, block_search_flags search_flags, - domain_enum domain, - domain_search_flags search, + domain_search_flags domain, const lookup_name_info &lookup_name, gdb::function_view sym_matcher) { @@ -825,7 +822,7 @@ recursively_search_psymtabs continue; r = recursively_search_psymtabs (ps->dependencies[i], - objfile, search_flags, domain, search, + objfile, search_flags, domain, lookup_name, sym_matcher); if (r != 0) { @@ -873,19 +870,7 @@ recursively_search_psymtabs { QUIT; - if ((domain == UNDEF_DOMAIN - || symbol_matches_domain ((*psym)->ginfo.language (), - (*psym)->domain, domain)) - && (search == SEARCH_ALL - || (search == SEARCH_MODULE_DOMAIN - && (*psym)->domain == MODULE_DOMAIN) - || (search == SEARCH_VAR_DOMAIN - && (*psym)->aclass != LOC_TYPEDEF - && (*psym)->aclass != LOC_BLOCK) - || (search == SEARCH_FUNCTION_DOMAIN - && (*psym)->aclass == LOC_BLOCK) - || (search == SEARCH_TYPE_DOMAIN - && (*psym)->aclass == LOC_TYPEDEF)) + if (search_flags_matches (domain, (*psym)->domain) && psymbol_name_matches (*psym, lookup_name) && (sym_matcher == NULL || sym_matcher ((*psym)->ginfo.search_name ()))) @@ -913,8 +898,7 @@ psymbol_functions::expand_symtabs_matching gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, - domain_search_flags search) + domain_search_flags domain) { /* Clear the search flags. */ for (partial_symtab *ps : partial_symbols (objfile)) @@ -956,8 +940,7 @@ psymbol_functions::expand_symtabs_matching if (lookup_name == nullptr || recursively_search_psymtabs (ps, objfile, search_flags, - domain, search, - *psym_lookup_name, + domain, *psym_lookup_name, symbol_matcher)) { compunit_symtab *cust = psymtab_to_symtab (objfile, ps); diff --git a/gdb/psymtab.h b/gdb/psymtab.h index c4a0d9184f2..557a7cf4c08 100644 --- a/gdb/psymtab.h +++ b/gdb/psymtab.h @@ -617,7 +617,7 @@ struct psymbol_functions : public quick_symbol_functions enum language lookup_global_symbol_language (struct objfile *objfile, const char *name, - domain_enum domain, + domain_search_flags domain, bool *symbol_found_p) override; void print_stats (struct objfile *objfile, bool print_bcache) override; @@ -633,7 +633,6 @@ struct psymbol_functions : public quick_symbol_functions gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, domain_search_flags kind) override; struct compunit_symtab *find_pc_sect_compunit_symtab diff --git a/gdb/quick-symbol.h b/gdb/quick-symbol.h index 8646ac199bd..676c3ede373 100644 --- a/gdb/quick-symbol.h +++ b/gdb/quick-symbol.h @@ -96,14 +96,14 @@ struct quick_symbol_functions /* Check to see if the global symbol is defined in a "partial" symbol table of OBJFILE. NAME is the name of the symbol to look for. DOMAIN - indicates what sort of symbol to search for. + indicates what sorts of symbols to search for. If found, sets *symbol_found_p to true and returns the symbol language. defined, or NULL if no such symbol table exists. */ virtual enum language lookup_global_symbol_language (struct objfile *objfile, const char *name, - domain_enum domain, + domain_search_flags domain, bool *symbol_found_p) = 0; /* Print statistics about any indices loaded for OBJFILE. The @@ -134,8 +134,7 @@ struct quick_symbol_functions Otherwise, individual symbols are considered. - If DOMAIN or KIND do not match, the symbol is skipped. - If DOMAIN is UNDEF_DOMAIN, that is treated as a wildcard. + If DOMAIN does not match, the symbol is skipped. If the symbol name does not match LOOKUP_NAME, the symbol is skipped. @@ -155,8 +154,7 @@ struct quick_symbol_functions gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, - domain_search_flags kind) = 0; + domain_search_flags domain) = 0; /* Return the comp unit from OBJFILE that contains PC and SECTION. Return NULL if there is no such compunit. This diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c index 38db7777d83..3f5df13a005 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -222,7 +222,6 @@ objfile::map_symtabs_matching_filename on_expansion, (SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK), - UNDEF_DOMAIN, SEARCH_ALL)) { retval = false; @@ -278,6 +277,10 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain) return true; }; + domain_search_flags flags = to_search_flags (domain); + if (domain == VAR_DOMAIN) + flags |= SEARCH_TYPE_DOMAIN | SEARCH_FUNCTION_DOMAIN; + for (const auto &iter : qf) { if (!iter->expand_symtabs_matching (this, @@ -288,8 +291,7 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain) kind == GLOBAL_BLOCK ? SEARCH_GLOBAL_BLOCK : SEARCH_STATIC_BLOCK, - domain, - SEARCH_ALL)) + flags)) break; } @@ -343,8 +345,7 @@ objfile::expand_symtabs_for_function (const char *func_name) nullptr, (SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK), - VAR_DOMAIN, - SEARCH_ALL); + SEARCH_VFT); } void @@ -380,7 +381,6 @@ objfile::expand_symtabs_with_fullname (const char *fullname) nullptr, (SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK), - UNDEF_DOMAIN, SEARCH_ALL); } @@ -391,8 +391,7 @@ objfile::expand_symtabs_matching gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, - domain_search_flags kind) + domain_search_flags domain) { /* This invariant is documented in quick-functions.h. */ gdb_assert (lookup_name != nullptr || symbol_matcher == nullptr); @@ -404,12 +403,12 @@ objfile::expand_symtabs_matching host_address_to_string (&file_matcher), host_address_to_string (&symbol_matcher), host_address_to_string (&expansion_notify), - domain_name (kind).c_str ()); + domain_name (domain).c_str ()); for (const auto &iter : qf) if (!iter->expand_symtabs_matching (this, file_matcher, lookup_name, symbol_matcher, expansion_notify, - search_flags, domain, kind)) + search_flags, domain)) return false; return true; } @@ -504,7 +503,7 @@ objfile::find_compunit_symtab_by_address (CORE_ADDR address) enum language objfile::lookup_global_symbol_language (const char *name, - domain_enum domain, + domain_search_flags domain, bool *symbol_found_p) { enum language result = language_unknown; diff --git a/gdb/symfile.c b/gdb/symfile.c index 065eaf0d518..17e1a64e77d 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -3769,7 +3769,7 @@ expand_symtabs_matching gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_search_flags kind) + domain_search_flags domain) { for (objfile *objfile : current_program_space->objfiles ()) if (!objfile->expand_symtabs_matching (file_matcher, @@ -3777,8 +3777,7 @@ expand_symtabs_matching symbol_matcher, expansion_notify, search_flags, - UNDEF_DOMAIN, - kind)) + domain)) return false; return true; } diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 519df255047..3659ac687b0 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -919,7 +919,6 @@ maintenance_expand_symtabs (const char *args, int from_tty) NULL, NULL, SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, - UNDEF_DOMAIN, SEARCH_ALL); } diff --git a/gdb/symtab.c b/gdb/symtab.c index 6d24d2fe9ee..a973052f338 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2864,7 +2864,7 @@ basic_lookup_transparent_type (const char *name) bool iterate_over_symbols (const struct block *block, const lookup_name_info &name, - const domain_enum domain, + const domain_search_flags domain, gdb::function_view callback) { for (struct symbol *sym : block_iterator_range (block, &name)) @@ -2886,7 +2886,7 @@ bool iterate_over_symbols_terminated (const struct block *block, const lookup_name_info &name, - const domain_enum domain, + const domain_search_flags domain, gdb::function_view callback) { if (!iterate_over_symbols (block, name, domain, callback)) @@ -4846,7 +4846,6 @@ global_symbol_searcher::expand_symtabs }, NULL, SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, - UNDEF_DOMAIN, kind); /* Here, we search through the minimal symbol tables for functions and @@ -6502,7 +6501,7 @@ find_main_name (void) [&symbol_found_p, pspace] (objfile *obj) { language lang - = obj->lookup_global_symbol_language ("main", VAR_DOMAIN, + = obj->lookup_global_symbol_language ("main", SEARCH_VFT, &symbol_found_p); if (symbol_found_p) { diff --git a/gdb/symtab.h b/gdb/symtab.h index b12c0541d6f..69e3c060213 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -2804,7 +2804,7 @@ typedef bool (symbol_found_callback_ftype) (struct block_symbol *bsym); bool iterate_over_symbols (const struct block *block, const lookup_name_info &name, - const domain_enum domain, + const domain_search_flags domain, gdb::function_view callback); /* Like iterate_over_symbols, but if all calls to CALLBACK return @@ -2814,7 +2814,7 @@ bool iterate_over_symbols (const struct block *block, bool iterate_over_symbols_terminated (const struct block *block, const lookup_name_info &name, - const domain_enum domain, + const domain_search_flags domain, gdb::function_view callback); /* Storage type used by demangle_for_lookup. demangle_for_lookup From patchwork Thu Jan 18 20:32:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84386 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 5E8783858417 for ; Thu, 18 Jan 2024 20:37:17 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta038.useast.a.cloudfilter.net (omta038.useast.a.cloudfilter.net [44.202.169.37]) by sourceware.org (Postfix) with ESMTPS id 41C773858415 for ; Thu, 18 Jan 2024 20:32:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 41C773858415 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 41C773858415 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609945; cv=none; b=v8oj+4WIH8+mGVneihc3BhO7qoswP+IC1IcKeTjzrLMpfJM7V5UWe7vkswPfZ3Yjvyj68qlBdyq3sahge+yPsMOxBy6GegEHZ89ZrNZ6C6EJOUW4ie2LfXY3Dx1nNvTd3cbz53VwwqL36xx6Kzf/vizDUCtDLW2nJ1/pxLVgNhc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609945; c=relaxed/simple; bh=Y7N8Dn5sCp8dYxFuD1JFi1/aPZqC3gy6LNGzS+ZTB9g=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=eR4KcFYwKGXseN7dOdQjsQveTMW3sgeg3LCX3+TbH18umUa0g4210I+a9TgQX9VS/v0Fnn30+tOvpc7p/bvei+Z2JedA+T+gJGCj3Jadw+9GgDWyToB8987s2ClhuDjEIkV8zLLsX89KQ3gxSZ4NVz27MQkp91NzSueUUZe+iFM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6008a.ext.cloudfilter.net ([10.0.30.227]) by cmsmtp with ESMTPS id QXcTrQ7fQ9gG6QZ3crf5xO; Thu, 18 Jan 2024 20:32:13 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3brEcIBZKctQZ3crDY9g; Thu, 18 Jan 2024 20:32:12 +0000 X-Authority-Analysis: v=2.4 cv=a+kjSGeF c=1 sm=1 tr=0 ts=65a98acc a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=KLxg1auYuVWGrs_o9_cA: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=r7MRnxsXnJHMprM3bhyTQXELYEwCvnv7Iwk6KLV6bfg=; b=Xnq5MeA1BW8/hUByRC8W6rWHVD QOV+g60Ilhs2RHnoMDcEYQ+M7GmJ7/6nUP135gMOxXYcH1tCcpqcDQddCox/Xp74FPkspC1FH0XJ4 QjMj3esLSXxhmvSlu3i1MarIQ; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3b-002DCj-1t for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:11 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:15 -0700 Subject: [PATCH v2 17/30] Use domain_search_flags in lookup_symbol et al MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-17-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3b-002DCj-1t X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 19 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfIQermGn4pkYWzpBn8DHiNAtUdWns/m6Waqv1f34ahaC1pfQqMtbHvnAHqmQPWSuPhroHCs7Ub84bZpQDas/C7qSrr5daeJRGzDUoSQM6+MmzN2W00b/ D30Ovu/pd8at4K3V3RjQGiDuPt0dCfBQ/IlOGCaf5QFXoUWTXagwxTQM5HJjzcQCa9GejdRceqGgWHXbYYRcbP2/jcEV5oucXOY= X-Spam-Status: No, score=-3022.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, 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 This changes lookup_symbol and associated APIs to accept domain_search_flags rather than a domain_enum. Note that this introduces some new constants to Python and Guile. I chose to break out the documentation patch for this, because the internals here do not change until a later patch, and it seemed simpler to patch the docs just once, rather than twice. --- gdb/ada-lang.c | 10 +-- gdb/ada-tasks.c | 17 +++-- gdb/alpha-mdebug-tdep.c | 2 +- gdb/ax-gdb.c | 5 +- gdb/block.c | 24 ++++--- gdb/block.h | 15 ++-- gdb/c-exp.y | 19 ++--- gdb/c-lang.c | 2 +- gdb/c-valprint.c | 2 +- gdb/compile/compile-c-symbols.c | 17 ++--- gdb/compile/compile-cplus-symbols.c | 13 ++-- gdb/compile/compile-cplus-types.c | 8 +-- gdb/compile/compile-object-load.c | 6 +- gdb/cp-namespace.c | 51 ++++++------- gdb/cp-support.c | 6 +- gdb/cp-support.h | 8 +-- gdb/d-exp.y | 12 ++-- gdb/d-lang.c | 2 +- gdb/d-lang.h | 9 +-- gdb/d-namespace.c | 24 +++---- gdb/dwarf2/ada-imported.c | 2 +- gdb/dwarf2/loc.c | 2 +- gdb/eval.c | 5 +- gdb/f-exp.y | 8 +-- gdb/f-lang.c | 2 +- gdb/f-lang.h | 2 +- gdb/f-valprint.c | 2 +- gdb/fbsd-tdep.c | 5 +- gdb/frame.c | 3 +- gdb/ft32-tdep.c | 3 +- gdb/gdbtypes.c | 17 +++-- gdb/gnu-v3-abi.c | 2 +- gdb/go-exp.y | 9 +-- gdb/guile/scm-frame.c | 2 +- gdb/guile/scm-symbol.c | 17 +++-- gdb/infrun.c | 2 +- gdb/language.c | 3 +- gdb/language.h | 2 +- gdb/linespec.c | 4 +- gdb/m2-exp.y | 10 +-- gdb/mi/mi-cmd-stack.c | 5 +- gdb/moxie-tdep.c | 3 +- gdb/objc-lang.c | 4 +- gdb/objfiles.h | 2 +- gdb/p-exp.y | 19 ++--- gdb/p-valprint.c | 2 +- gdb/parse.c | 3 +- gdb/printcmd.c | 2 +- gdb/psymtab.c | 4 +- gdb/python/py-frame.c | 3 +- gdb/python/py-objfile.c | 6 +- gdb/python/py-symbol.c | 22 +++--- gdb/rust-lang.c | 7 +- gdb/rust-lang.h | 2 +- gdb/rust-parse.c | 8 +-- gdb/source.c | 5 +- gdb/stack.c | 4 +- gdb/symfile-debug.c | 11 ++- gdb/symfile.c | 4 +- gdb/symtab.c | 138 +++++++++++++++++------------------- gdb/symtab.h | 23 +++--- gdb/valops.c | 14 ++-- gdb/value.c | 6 +- gdb/xstormy16-tdep.c | 3 +- 64 files changed, 342 insertions(+), 312 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index a1fac3e8ad3..a15ea7b725e 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -13675,19 +13675,15 @@ class ada_language : public language_defn struct block_symbol lookup_symbol_nonlocal (const char *name, const struct block *block, - const domain_enum domain) const override + const domain_search_flags domain) const override { struct block_symbol sym; - domain_search_flags flags = to_search_flags (domain); - if (domain == VAR_DOMAIN) - flags |= SEARCH_TYPE_DOMAIN | SEARCH_FUNCTION_DOMAIN; - sym = ada_lookup_symbol (name, (block == nullptr ? nullptr : block->static_block ()), - flags); + domain); if (sym.symbol != NULL) return sym; @@ -13703,7 +13699,7 @@ class ada_language : public language_defn languages, we search the primitive types this late and only after having searched the global symbols without success. */ - if (domain == VAR_DOMAIN) + if ((domain & SEARCH_TYPE_DOMAIN) != 0) { struct gdbarch *gdbarch; diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c index e4aacaf4b6a..fd3f5d1ead9 100644 --- a/gdb/ada-tasks.c +++ b/gdb/ada-tasks.c @@ -520,16 +520,17 @@ ada_get_tcb_types_info (void) C-like) lookups to get the first match. */ struct symbol *atcb_sym = - lookup_symbol_in_language (atcb_name, NULL, STRUCT_DOMAIN, + lookup_symbol_in_language (atcb_name, NULL, SEARCH_STRUCT_DOMAIN, language_c, NULL).symbol; const struct symbol *common_atcb_sym = - lookup_symbol_in_language (common_atcb_name, NULL, STRUCT_DOMAIN, + lookup_symbol_in_language (common_atcb_name, NULL, SEARCH_STRUCT_DOMAIN, language_c, NULL).symbol; const struct symbol *private_data_sym = - lookup_symbol_in_language (private_data_name, NULL, STRUCT_DOMAIN, + lookup_symbol_in_language (private_data_name, NULL, SEARCH_STRUCT_DOMAIN, language_c, NULL).symbol; const struct symbol *entry_call_record_sym = - lookup_symbol_in_language (entry_call_record_name, NULL, STRUCT_DOMAIN, + lookup_symbol_in_language (entry_call_record_name, NULL, + SEARCH_STRUCT_DOMAIN, language_c, NULL).symbol; if (atcb_sym == NULL || atcb_sym->type () == NULL) @@ -537,7 +538,7 @@ ada_get_tcb_types_info (void) /* In Ravenscar run-time libs, the ATCB does not have a dynamic size, so the symbol name differs. */ atcb_sym = lookup_symbol_in_language (atcb_name_fixed, NULL, - STRUCT_DOMAIN, language_c, + SEARCH_STRUCT_DOMAIN, language_c, NULL).symbol; if (atcb_sym == NULL || atcb_sym->type () == NULL) @@ -929,7 +930,8 @@ ada_tasks_inferior_data_sniffer (struct ada_tasks_inferior_data *data) data->known_tasks_addr = msym.value_address (); /* Try to get pointer type and array length from the symtab. */ - sym = lookup_symbol_in_language (KNOWN_TASKS_NAME, NULL, VAR_DOMAIN, + sym = lookup_symbol_in_language (KNOWN_TASKS_NAME, NULL, + SEARCH_VAR_DOMAIN, language_c, NULL).symbol; if (sym != NULL) { @@ -975,7 +977,8 @@ ada_tasks_inferior_data_sniffer (struct ada_tasks_inferior_data *data) data->known_tasks_addr = msym.value_address (); data->known_tasks_length = 1; - sym = lookup_symbol_in_language (KNOWN_TASKS_LIST, NULL, VAR_DOMAIN, + sym = lookup_symbol_in_language (KNOWN_TASKS_LIST, NULL, + SEARCH_VAR_DOMAIN, language_c, NULL).symbol; if (sym != NULL && sym->value_address () != 0) { diff --git a/gdb/alpha-mdebug-tdep.c b/gdb/alpha-mdebug-tdep.c index 1ba8e500e32..7691a53148a 100644 --- a/gdb/alpha-mdebug-tdep.c +++ b/gdb/alpha-mdebug-tdep.c @@ -106,7 +106,7 @@ find_proc_desc (CORE_ADDR pc) symbol reading. */ sym = NULL; else - sym = lookup_symbol (MDEBUG_EFI_SYMBOL_NAME, b, LABEL_DOMAIN, + sym = lookup_symbol (MDEBUG_EFI_SYMBOL_NAME, b, SEARCH_LABEL_DOMAIN, 0).symbol; } diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index deadbc1bc02..a08a5121527 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -1457,7 +1457,8 @@ gen_static_field (struct agent_expr *ax, struct axs_value *value, else { const char *phys_name = type->field (fieldno).loc_physname (); - struct symbol *sym = lookup_symbol (phys_name, 0, VAR_DOMAIN, 0).symbol; + struct symbol *sym = lookup_symbol (phys_name, 0, + SEARCH_VAR_DOMAIN, 0).symbol; if (sym) { @@ -1548,7 +1549,7 @@ gen_maybe_namespace_elt (struct agent_expr *ax, struct axs_value *value, sym = cp_lookup_symbol_namespace (namespace_name, name, block_for_pc (ax->scope), - VAR_DOMAIN); + SEARCH_VAR_DOMAIN); if (sym.symbol == NULL) return 0; diff --git a/gdb/block.c b/gdb/block.c index 4b9307ea794..0bdd0f915c0 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -630,26 +630,32 @@ block_iterator_next (struct block_iterator *iterator) /* See block.h. */ bool -best_symbol (struct symbol *a, const domain_enum domain) +best_symbol (struct symbol *a, const domain_search_flags domain) { - return (a->domain () == domain - && a->aclass () != LOC_UNRESOLVED); + if (a->aclass () == LOC_UNRESOLVED) + return false; + + if ((domain & SEARCH_VAR_DOMAIN) != 0) + return a->domain () == VAR_DOMAIN; + + return a->matches (domain); } /* See block.h. */ struct symbol * -better_symbol (struct symbol *a, struct symbol *b, const domain_enum domain) +better_symbol (struct symbol *a, struct symbol *b, + const domain_search_flags domain) { if (a == NULL) return b; if (b == NULL) return a; - if (a->domain () == domain && b->domain () != domain) + if (a->matches (domain) && !b->matches (domain)) return a; - if (b->domain () == domain && a->domain () != domain) + if (b->matches (domain) && !a->matches (domain)) return b; if (a->aclass () != LOC_UNRESOLVED && b->aclass () == LOC_UNRESOLVED) @@ -675,7 +681,7 @@ better_symbol (struct symbol *a, struct symbol *b, const domain_enum domain) struct symbol * block_lookup_symbol (const struct block *block, const char *name, symbol_name_match_type match_type, - const domain_enum domain) + const domain_search_flags domain) { lookup_name_info lookup_name (name, match_type); @@ -730,7 +736,7 @@ block_lookup_symbol (const struct block *block, const char *name, struct symbol * block_lookup_symbol_primary (const struct block *block, const char *name, - const domain_enum domain) + const domain_search_flags domain) { struct symbol *sym, *other; struct mdict_iterator mdict_iter; @@ -792,7 +798,7 @@ block_lookup_symbol_primary (const struct block *block, const char *name, struct symbol * block_find_symbol (const struct block *block, const lookup_name_info &name, - const domain_enum domain, struct symbol **stub) + const domain_search_flags domain, struct symbol **stub) { /* Verify BLOCK is STATIC_BLOCK or GLOBAL_BLOCK. */ gdb_assert (block->superblock () == NULL diff --git a/gdb/block.h b/gdb/block.h index 5c56518bfce..0c121941f05 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -554,28 +554,29 @@ typedef iterator_range block_iterator_range; /* Return true if symbol A is the best match possible for DOMAIN. */ -extern bool best_symbol (struct symbol *a, const domain_enum domain); +extern bool best_symbol (struct symbol *a, const domain_search_flags domain); /* Return symbol B if it is a better match than symbol A for DOMAIN. Otherwise return A. */ extern struct symbol *better_symbol (struct symbol *a, struct symbol *b, - const domain_enum domain); + const domain_search_flags domain); /* Search BLOCK for symbol NAME in DOMAIN. */ extern struct symbol *block_lookup_symbol (const struct block *block, const char *name, symbol_name_match_type match_type, - const domain_enum domain); + const domain_search_flags domain); /* Search BLOCK for symbol NAME in DOMAIN but only in primary symbol table of BLOCK. BLOCK must be STATIC_BLOCK or GLOBAL_BLOCK. Function is useful if one iterates all global/static blocks of an objfile. */ -extern struct symbol *block_lookup_symbol_primary (const struct block *block, - const char *name, - const domain_enum domain); +extern struct symbol *block_lookup_symbol_primary + (const struct block *block, + const char *name, + const domain_search_flags domain); /* Find symbol NAME in BLOCK and in DOMAIN. This will return a matching symbol whose type is not a "opaque", see TYPE_IS_OPAQUE. @@ -584,7 +585,7 @@ extern struct symbol *block_lookup_symbol_primary (const struct block *block, extern struct symbol *block_find_symbol (const struct block *block, const lookup_name_info &name, - const domain_enum domain, + const domain_search_flags domain, struct symbol **stub); /* Given a vector of pairs, allocate and build an obstack allocated diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 8c0d86f68b5..fb85914805c 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -1087,9 +1087,10 @@ block : block COLONCOLON name std::string copy = copy_name ($3); struct symbol *tem = lookup_symbol (copy.c_str (), $1, - VAR_DOMAIN, NULL).symbol; + SEARCH_FUNCTION_DOMAIN, + nullptr).symbol; - if (!tem || tem->aclass () != LOC_BLOCK) + if (tem == nullptr) error (_("No function \"%s\" in specified context."), copy.c_str ()); $$ = tem->value_block (); } @@ -1113,7 +1114,7 @@ variable: block COLONCOLON name std::string copy = copy_name ($3); struct block_symbol sym = lookup_symbol (copy.c_str (), $1, - VAR_DOMAIN, NULL); + SEARCH_VFT, NULL); if (sym.symbol == 0) error (_("No symbol \"%s\" in specified context."), @@ -1168,7 +1169,7 @@ variable: qualified_name struct block_symbol sym = lookup_symbol (name.c_str (), (const struct block *) NULL, - VAR_DOMAIN, NULL); + SEARCH_VFT, NULL); pstate->push_symbol (name.c_str (), sym); } ; @@ -1833,7 +1834,7 @@ name_not_typename : NAME $$.sym = lookup_symbol ($1.ptr, pstate->expression_context_block, - VAR_DOMAIN, + SEARCH_VFT, &is_a_field_of_this); $$.is_a_field_of_this = is_a_field_of_this.type != NULL; @@ -2969,7 +2970,7 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name) if (lookup_symbol (copy.c_str (), pstate->expression_context_block, - VAR_DOMAIN, + SEARCH_VFT, (par_state->language ()->la_language == language_cplus ? &is_a_field_of_this : NULL)).symbol @@ -3037,7 +3038,7 @@ classify_name (struct parser_state *par_state, const struct block *block, we can refer to it unconditionally below. */ memset (&is_a_field_of_this, 0, sizeof (is_a_field_of_this)); - bsym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN, + bsym = lookup_symbol (copy.c_str (), block, SEARCH_VFT, par_state->language ()->name_of_this () ? &is_a_field_of_this : NULL); @@ -3060,7 +3061,7 @@ classify_name (struct parser_state *par_state, const struct block *block, { struct field_of_this_result inner_is_a_field_of_this; - bsym = lookup_symbol (copy.c_str (), block, STRUCT_DOMAIN, + bsym = lookup_symbol (copy.c_str (), block, SEARCH_STRUCT_DOMAIN, &inner_is_a_field_of_this); if (bsym.symbol != NULL) { @@ -3167,7 +3168,7 @@ classify_inner_name (struct parser_state *par_state, std::string copy = copy_name (yylval.ssym.stoken); /* N.B. We assume the symbol can only be in VAR_DOMAIN. */ yylval.ssym.sym = cp_lookup_nested_symbol (type, copy.c_str (), block, - VAR_DOMAIN); + SEARCH_VFT); /* If no symbol was found, search for a matching base class named COPY. This will allow users to enter qualified names of class members diff --git a/gdb/c-lang.c b/gdb/c-lang.c index 2dfbd05c52f..ce711c4b4f6 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -1014,7 +1014,7 @@ class cplus_language : public language_defn struct block_symbol lookup_symbol_nonlocal (const char *name, const struct block *block, - const domain_enum domain) const override + const domain_search_flags domain) const override { return cp_lookup_symbol_nonlocal (this, name, block, domain); } diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 1731f0302a8..8911a169604 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -205,7 +205,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype, { const char *search_name = msymbol.minsym->search_name (); wsym = lookup_symbol_search_name (search_name, NULL, - VAR_DOMAIN).symbol; + SEARCH_VAR_DOMAIN).symbol; } if (wsym) diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index f55438d9ccb..a8f4ca16225 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -210,7 +210,7 @@ convert_one_symbol (compile_c_instance *context, static void convert_symbol_sym (compile_c_instance *context, const char *identifier, - struct block_symbol sym, domain_enum domain) + struct block_symbol sym, domain_search_flags domain) { int is_local_symbol; @@ -325,19 +325,19 @@ gcc_convert_symbol (void *datum, { compile_c_instance *context = static_cast (datum); - domain_enum domain; + domain_search_flags domain; int found = 0; switch (request) { case GCC_C_ORACLE_SYMBOL: - domain = VAR_DOMAIN; + domain = SEARCH_VFT; break; case GCC_C_ORACLE_TAG: - domain = STRUCT_DOMAIN; + domain = SEARCH_STRUCT_DOMAIN; break; case GCC_C_ORACLE_LABEL: - domain = LABEL_DOMAIN; + domain = SEARCH_LABEL_DOMAIN; break; default: gdb_assert_not_reached ("Unrecognized oracle request."); @@ -355,7 +355,7 @@ gcc_convert_symbol (void *datum, convert_symbol_sym (context, identifier, sym, domain); found = 1; } - else if (domain == VAR_DOMAIN) + else if (request == GCC_C_ORACLE_SYMBOL) { struct bound_minimal_symbol bmsym; @@ -398,8 +398,9 @@ gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context, struct symbol *sym; /* We only need global functions here. */ - sym = lookup_symbol (identifier, NULL, VAR_DOMAIN, NULL).symbol; - if (sym != NULL && sym->aclass () == LOC_BLOCK) + sym = lookup_symbol (identifier, nullptr, SEARCH_FUNCTION_DOMAIN, + nullptr).symbol; + if (sym != nullptr) { if (compile_debug) gdb_printf (gdb_stdlog, diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c index dbdabe94e1e..9d8e801ba3a 100644 --- a/gdb/compile/compile-cplus-symbols.c +++ b/gdb/compile/compile-cplus-symbols.c @@ -227,7 +227,7 @@ convert_one_symbol (compile_cplus_instance *instance, static void convert_symbol_sym (compile_cplus_instance *instance, const char *identifier, struct block_symbol sym, - domain_enum domain) + domain_search_flags domain) { /* If we found a symbol and it is not in the static or global scope, then we should first convert any static or global scope @@ -355,12 +355,12 @@ gcc_cplus_convert_symbol (void *datum, This will find variables in the current scope. */ struct block_symbol sym - = lookup_symbol (identifier, instance->block (), VAR_DOMAIN, nullptr); + = lookup_symbol (identifier, instance->block (), SEARCH_VFT, nullptr); if (sym.symbol != nullptr) { found = true; - convert_symbol_sym (instance, identifier, sym, VAR_DOMAIN); + convert_symbol_sym (instance, identifier, sym, SEARCH_VFT); } /* Then use linespec.c's multi-symbol search. This should find @@ -378,7 +378,7 @@ gcc_cplus_convert_symbol (void *datum, { found = true; convert_symbol_sym (instance, identifier, it, - it.symbol->domain ()); + to_search_flags (it.symbol->domain ())); } } @@ -437,9 +437,10 @@ gcc_cplus_symbol_address (void *datum, struct gcc_cp_context *gcc_context, try { struct symbol *sym - = lookup_symbol (identifier, nullptr, VAR_DOMAIN, nullptr).symbol; + = lookup_symbol (identifier, nullptr, SEARCH_FUNCTION_DOMAIN, + nullptr).symbol; - if (sym != nullptr && sym->aclass () == LOC_BLOCK) + if (sym != nullptr) { if (compile_debug) gdb_printf (gdb_stdlog, diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c index 90ce3f15e14..c8a25515359 100644 --- a/gdb/compile/compile-cplus-types.c +++ b/gdb/compile/compile-cplus-types.c @@ -154,7 +154,7 @@ type_name_to_scope (const char *type_name, const struct block *block) /* Look up the resulting name. */ struct block_symbol bsymbol - = lookup_symbol (lookup_name.c_str (), block, VAR_DOMAIN, nullptr); + = lookup_symbol (lookup_name.c_str (), block, SEARCH_VFT, nullptr); if (bsymbol.symbol != nullptr) { @@ -384,7 +384,7 @@ compile_cplus_instance::new_scope (const char *type_name, struct type *type) scope_component comp = { decl_name (type->name ()).get (), - lookup_symbol (type->name (), block (), VAR_DOMAIN, nullptr) + lookup_symbol (type->name (), block (), SEARCH_VFT, nullptr) }; scope.push_back (comp); } @@ -617,7 +617,7 @@ compile_cplus_convert_struct_or_union_members const char *physname = type->field (i).loc_physname (); struct block_symbol sym = lookup_symbol (physname, instance->block (), - VAR_DOMAIN, nullptr); + SEARCH_VFT, nullptr); if (sym.symbol == nullptr) { @@ -729,7 +729,7 @@ compile_cplus_convert_struct_or_union_methods (compile_cplus_instance *instance, gcc_type method_type; struct block_symbol sym = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (methods, j), - instance->block (), VAR_DOMAIN, nullptr); + instance->block (), SEARCH_VFT, nullptr); if (sym.symbol == nullptr) { diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c index b2cc3a1a042..e26f0f46048 100644 --- a/gdb/compile/compile-object-load.c +++ b/gdb/compile/compile-object-load.c @@ -437,7 +437,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile, gdb_val_sym = block_lookup_symbol (block, COMPILE_I_EXPR_VAL, symbol_name_match_type::SEARCH_NAME, - VAR_DOMAIN); + SEARCH_VFT); if (gdb_val_sym == NULL) continue; @@ -463,7 +463,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile, gdb_ptr_type_sym = block_lookup_symbol (block, COMPILE_I_EXPR_PTR_TYPE, symbol_name_match_type::SEARCH_NAME, - VAR_DOMAIN); + SEARCH_VFT); if (gdb_ptr_type_sym == NULL) error (_("No \"%s\" symbol found"), COMPILE_I_EXPR_PTR_TYPE); gdb_ptr_type = gdb_ptr_type_sym->type (); @@ -652,7 +652,7 @@ compile_object_load (const compile_file_names &file_names, func_sym = lookup_global_symbol_from_objfile (objfile, GLOBAL_BLOCK, GCC_FE_WRAPPER_FUNCTION, - VAR_DOMAIN).symbol; + SEARCH_VFT).symbol; if (func_sym == NULL) error (_("Cannot find function \"%s\" in compiled module \"%s\"."), GCC_FE_WRAPPER_FUNCTION, objfile_name (objfile)); diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index a573b1410d3..593340af350 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -42,7 +42,7 @@ static struct block_symbol const char *nested_name, const char *concatenated_name, const struct block *block, - const domain_enum domain, + const domain_search_flags domain, int basic_lookup, int is_in_anonymous); static struct type *cp_lookup_transparent_type_loop (const char *name, @@ -129,7 +129,7 @@ cp_is_in_anonymous (const char *symbol_name) static struct block_symbol cp_basic_lookup_symbol (const char *name, const struct block *block, - const domain_enum domain, int is_in_anonymous) + const domain_search_flags domain, int is_in_anonymous) { struct block_symbol sym; @@ -172,7 +172,7 @@ cp_basic_lookup_symbol (const char *name, const struct block *block, static struct block_symbol cp_lookup_bare_symbol (const struct language_defn *langdef, const char *name, const struct block *block, - const domain_enum domain, int search) + const domain_search_flags domain, int search) { struct block_symbol sym; @@ -192,7 +192,7 @@ cp_lookup_bare_symbol (const struct language_defn *langdef, shared libraries we could search all of them only to find out the builtin type isn't defined in any of them. This is common for types like "void". */ - if (langdef != NULL && domain == VAR_DOMAIN) + if (langdef != nullptr && (domain & SEARCH_TYPE_DOMAIN) != 0) { struct gdbarch *gdbarch; @@ -251,7 +251,7 @@ cp_lookup_bare_symbol (const struct language_defn *langdef, static struct block_symbol cp_search_static_and_baseclasses (const char *name, const struct block *block, - const domain_enum domain, + const domain_search_flags domain, unsigned int prefix_len, int is_in_anonymous) { @@ -273,9 +273,9 @@ cp_search_static_and_baseclasses (const char *name, symbol_matches_domain (which should be replaced with something else, but it's what we have today). */ block_symbol scope_sym = lookup_symbol_in_static_block (scope.c_str (), - block, VAR_DOMAIN); + block, SEARCH_VFT); if (scope_sym.symbol == NULL) - scope_sym = lookup_global_symbol (scope.c_str (), block, VAR_DOMAIN); + scope_sym = lookup_global_symbol (scope.c_str (), block, SEARCH_VFT); if (scope_sym.symbol == NULL) return {}; @@ -285,9 +285,9 @@ cp_search_static_and_baseclasses (const char *name, static variable. E.g., "print 'function()::static_var'". */ if ((scope_type->code () == TYPE_CODE_FUNC || scope_type->code () == TYPE_CODE_METHOD) - && domain == VAR_DOMAIN) + && (domain & SEARCH_VAR_DOMAIN) != 0) return lookup_symbol (nested, scope_sym.symbol->value_block (), - VAR_DOMAIN, NULL); + domain, NULL); /* Look for a symbol named NESTED in this class/namespace. The caller is assumed to have already have done a basic lookup of NAME. @@ -308,7 +308,7 @@ cp_search_static_and_baseclasses (const char *name, static struct block_symbol cp_lookup_symbol_in_namespace (const char *the_namespace, const char *name, const struct block *block, - const domain_enum domain, int search) + const domain_search_flags domain, int search) { char *concatenated_name = NULL; int is_in_anonymous; @@ -382,7 +382,7 @@ static void cp_lookup_symbol_via_imports (const char *scope, const char *name, const struct block *block, - const domain_enum domain, + const domain_search_flags domain, const int search_scope_first, const int declaration_only, const int search_parents, @@ -503,7 +503,7 @@ static struct block_symbol cp_lookup_symbol_via_imports (const char *scope, const char *name, const struct block *block, - const domain_enum domain, + const domain_search_flags domain, const int declaration_only, const int search_parents) { @@ -560,13 +560,14 @@ struct block_symbol cp_lookup_symbol_imports_or_template (const char *scope, const char *name, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { struct symbol *function = block->function (); symbol_lookup_debug_printf ("cp_lookup_symbol_imports_or_template (%s, %s, %s, %s)", - scope, name, host_address_to_string (block), domain_name (domain)); + scope, name, host_address_to_string (block), + domain_name (domain).c_str ()); if (function != NULL && function->language () == language_cplus) { @@ -646,7 +647,7 @@ cp_lookup_symbol_imports_or_template (const char *scope, static struct block_symbol cp_lookup_symbol_via_all_imports (const char *scope, const char *name, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { struct block_symbol sym; @@ -671,13 +672,13 @@ struct block_symbol cp_lookup_symbol_namespace (const char *scope, const char *name, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { struct block_symbol sym; symbol_lookup_debug_printf ("cp_lookup_symbol_namespace (%s, %s, %s, %s)", scope, name, host_address_to_string (block), - domain_name (domain)); + domain_name (domain).c_str ()); /* First, try to find the symbol in the given namespace. */ sym = cp_lookup_symbol_in_namespace (scope, name, block, domain, 1); @@ -711,7 +712,7 @@ static struct block_symbol lookup_namespace_scope (const struct language_defn *langdef, const char *name, const struct block *block, - const domain_enum domain, + const domain_search_flags domain, const char *scope, int scope_len) { @@ -768,14 +769,15 @@ struct block_symbol cp_lookup_symbol_nonlocal (const struct language_defn *langdef, const char *name, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { struct block_symbol sym; const char *scope = block == nullptr ? "" : block->scope (); symbol_lookup_debug_printf ("cp_lookup_symbol_non_local (%s, %s (scope %s), %s)", - name, host_address_to_string (block), scope, domain_name (domain)); + name, host_address_to_string (block), scope, + domain_name (domain).c_str ()); /* First, try to find the symbol in the given namespace, and all containing namespaces. */ @@ -826,7 +828,8 @@ cp_find_type_baseclass_by_name (struct type *parent_type, const char *name) static struct block_symbol find_symbol_in_baseclass (struct type *parent_type, const char *name, - const struct block *block, const domain_enum domain, + const struct block *block, + const domain_search_flags domain, int is_in_anonymous) { int i; @@ -869,7 +872,7 @@ cp_lookup_nested_symbol_1 (struct type *container_type, const char *nested_name, const char *concatenated_name, const struct block *block, - const domain_enum domain, + const domain_search_flags domain, int basic_lookup, int is_in_anonymous) { struct block_symbol sym; @@ -933,7 +936,7 @@ struct block_symbol cp_lookup_nested_symbol (struct type *parent_type, const char *nested_name, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { /* type_name_or_error provides better error reporting using the original type. */ @@ -948,7 +951,7 @@ cp_lookup_nested_symbol (struct type *parent_type, symbol_lookup_debug_printf ("cp_lookup_nested_symbol (%s, %s, %s, %s)", type_name != NULL ? type_name : "unnamed", nested_name, host_address_to_string (block), - domain_name (domain)); + domain_name (domain).c_str ()); } switch (parent_type->code ()) diff --git a/gdb/cp-support.c b/gdb/cp-support.c index 3ce2f131b25..9a59d7632a1 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -151,7 +151,7 @@ inspect_type (struct demangle_parse_info *info, try { - sym = lookup_symbol (name, 0, VAR_DOMAIN, 0).symbol; + sym = lookup_symbol (name, 0, SEARCH_VFT, 0).symbol; } catch (const gdb_exception &except) { @@ -505,7 +505,7 @@ replace_typedefs (struct demangle_parse_info *info, try { sym = lookup_symbol (local_name.get (), 0, - VAR_DOMAIN, 0).symbol; + SEARCH_VFT, 0).symbol; } catch (const gdb_exception &except) { @@ -1500,7 +1500,7 @@ cp_lookup_rtti_type (const char *name, const struct block *block) /* Use VAR_DOMAIN here as NAME may be a typedef. PR 18141, 18417. Classes "live" in both STRUCT_DOMAIN and VAR_DOMAIN. */ - rtti_sym = lookup_symbol (name, block, VAR_DOMAIN, NULL).symbol; + rtti_sym = lookup_symbol (name, block, SEARCH_VFT, NULL).symbol; if (rtti_sym == NULL) { diff --git a/gdb/cp-support.h b/gdb/cp-support.h index a50b111bab8..f95b6f0f0e2 100644 --- a/gdb/cp-support.h +++ b/gdb/cp-support.h @@ -141,25 +141,25 @@ extern struct block_symbol cp_lookup_symbol_nonlocal (const struct language_defn *langdef, const char *name, const struct block *block, - const domain_enum domain); + const domain_search_flags domain); extern struct block_symbol cp_lookup_symbol_namespace (const char *the_namespace, const char *name, const struct block *block, - const domain_enum domain); + const domain_search_flags domain); extern struct block_symbol cp_lookup_symbol_imports_or_template (const char *scope, const char *name, const struct block *block, - const domain_enum domain); + const domain_search_flags domain); extern struct block_symbol cp_lookup_nested_symbol (struct type *parent_type, const char *nested_name, const struct block *block, - const domain_enum domain); + const domain_search_flags domain); struct type *cp_lookup_transparent_type (const char *name); diff --git a/gdb/d-exp.y b/gdb/d-exp.y index 6f7beae0dac..620d900709c 100644 --- a/gdb/d-exp.y +++ b/gdb/d-exp.y @@ -444,7 +444,7 @@ PrimaryExpression: /* Handle VAR, which could be local or global. */ sym = lookup_symbol (copy.c_str (), pstate->expression_context_block, - VAR_DOMAIN, &is_a_field_of_this); + SEARCH_VFT, &is_a_field_of_this); if (sym.symbol && sym.symbol->aclass () != LOC_TYPEDEF) { if (symbol_read_needs_frame (sym.symbol)) @@ -493,7 +493,7 @@ PrimaryExpression: sym = lookup_symbol (name.c_str (), (const struct block *) NULL, - VAR_DOMAIN, NULL); + SEARCH_VFT, NULL); pstate->push_symbol (name.c_str (), sym); } else @@ -1337,7 +1337,7 @@ classify_name (struct parser_state *par_state, const struct block *block) std::string copy = copy_name (yylval.sval); - sym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN, &is_a_field_of_this); + sym = lookup_symbol (copy.c_str (), block, SEARCH_VFT, &is_a_field_of_this); if (sym.symbol && sym.symbol->aclass () == LOC_TYPEDEF) { yylval.tsym.type = sym.symbol->type (); @@ -1346,9 +1346,11 @@ classify_name (struct parser_state *par_state, const struct block *block) else if (sym.symbol == NULL) { /* Look-up first for a module name, then a type. */ - sym = lookup_symbol (copy.c_str (), block, MODULE_DOMAIN, NULL); + sym = lookup_symbol (copy.c_str (), block, SEARCH_MODULE_DOMAIN, + nullptr); if (sym.symbol == NULL) - sym = lookup_symbol (copy.c_str (), block, STRUCT_DOMAIN, NULL); + sym = lookup_symbol (copy.c_str (), block, SEARCH_STRUCT_DOMAIN, + nullptr); if (sym.symbol != NULL) { diff --git a/gdb/d-lang.c b/gdb/d-lang.c index 5b0307d44ac..6af57062ef9 100644 --- a/gdb/d-lang.c +++ b/gdb/d-lang.c @@ -171,7 +171,7 @@ class d_language : public language_defn struct block_symbol lookup_symbol_nonlocal (const char *name, const struct block *block, - const domain_enum domain) const override + const domain_search_flags domain) const override { return d_lookup_symbol_nonlocal (this, name, block, domain); } diff --git a/gdb/d-lang.h b/gdb/d-lang.h index 1747ad90f24..ecf194d8155 100644 --- a/gdb/d-lang.h +++ b/gdb/d-lang.h @@ -69,10 +69,11 @@ extern const struct builtin_d_type *builtin_d_type (struct gdbarch *); /* Defined in d-namespace.c */ -extern struct block_symbol d_lookup_symbol_nonlocal (const struct language_defn *, - const char *, - const struct block *, - const domain_enum); +extern struct block_symbol d_lookup_symbol_nonlocal + (const struct language_defn *, + const char *, + const struct block *, + const domain_search_flags); extern struct block_symbol d_lookup_nested_symbol (struct type *, const char *, const struct block *); diff --git a/gdb/d-namespace.c b/gdb/d-namespace.c index c110cbda057..3f8f7d8c24e 100644 --- a/gdb/d-namespace.c +++ b/gdb/d-namespace.c @@ -78,7 +78,7 @@ d_entire_prefix_len (const char *name) static struct block_symbol d_lookup_symbol (const struct language_defn *langdef, const char *name, const struct block *block, - const domain_enum domain, int search) + const domain_search_flags domain, int search) { struct block_symbol sym; @@ -88,7 +88,7 @@ d_lookup_symbol (const struct language_defn *langdef, /* If we didn't find a definition for a builtin type in the static block, such as "ucent" which is a specialist type, search for it now. */ - if (langdef != NULL && domain == VAR_DOMAIN) + if (langdef != nullptr && (domain & SEARCH_TYPE_DOMAIN) != 0) { struct gdbarch *gdbarch; @@ -166,7 +166,7 @@ d_lookup_symbol (const struct language_defn *langdef, static struct block_symbol d_lookup_symbol_in_module (const char *module, const char *name, const struct block *block, - const domain_enum domain, int search) + const domain_search_flags domain, int search) { char *concatenated_name = NULL; @@ -198,7 +198,7 @@ d_lookup_symbol_in_module (const char *module, const char *name, static struct block_symbol lookup_module_scope (const struct language_defn *langdef, const char *name, const struct block *block, - const domain_enum domain, const char *scope, + const domain_search_flags domain, const char *scope, int scope_len) { char *module; @@ -261,7 +261,7 @@ find_symbol_in_baseclass (struct type *parent_type, const char *name, /* Search this particular base class. */ sym = d_lookup_symbol_in_module (base_name, name, block, - VAR_DOMAIN, 0); + SEARCH_VFT, 0); if (sym.symbol != NULL) break; @@ -270,14 +270,14 @@ find_symbol_in_baseclass (struct type *parent_type, const char *name, what we want is possibly there. */ std::string concatenated_name = std::string (base_name) + "." + name; sym = lookup_symbol_in_static_block (concatenated_name.c_str (), block, - VAR_DOMAIN); + SEARCH_VFT); if (sym.symbol != NULL) break; /* Nope. We now have to search all static blocks in all objfiles, even if block != NULL, because there's no guarantees as to which symtab the symbol we want is in. */ - sym = lookup_static_symbol (concatenated_name.c_str (), VAR_DOMAIN); + sym = lookup_static_symbol (concatenated_name.c_str (), SEARCH_VFT); if (sym.symbol != NULL) break; @@ -320,7 +320,7 @@ d_lookup_nested_symbol (struct type *parent_type, const char *parent_name = type_name_or_error (saved_parent_type); struct block_symbol sym = d_lookup_symbol_in_module (parent_name, nested_name, - block, VAR_DOMAIN, 0); + block, SEARCH_VFT, 0); char *concatenated_name; if (sym.symbol != NULL) @@ -337,7 +337,7 @@ d_lookup_nested_symbol (struct type *parent_type, xsnprintf (concatenated_name, size, "%s.%s", parent_name, nested_name); - sym = lookup_static_symbol (concatenated_name, VAR_DOMAIN); + sym = lookup_static_symbol (concatenated_name, SEARCH_VFT); if (sym.symbol != NULL) return sym; @@ -361,7 +361,7 @@ d_lookup_nested_symbol (struct type *parent_type, static struct block_symbol d_lookup_symbol_imports (const char *scope, const char *name, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { struct using_direct *current; struct block_symbol sym; @@ -473,7 +473,7 @@ d_lookup_symbol_imports (const char *scope, const char *name, static struct block_symbol d_lookup_symbol_module (const char *scope, const char *name, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { struct block_symbol sym; @@ -509,7 +509,7 @@ struct block_symbol d_lookup_symbol_nonlocal (const struct language_defn *langdef, const char *name, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { struct block_symbol sym; const char *scope = block == nullptr ? "" : block->scope (); diff --git a/gdb/dwarf2/ada-imported.c b/gdb/dwarf2/ada-imported.c index 7654c05742e..21f81bbcdea 100644 --- a/gdb/dwarf2/ada-imported.c +++ b/gdb/dwarf2/ada-imported.c @@ -103,7 +103,7 @@ ada_alias_get_block_value (const struct symbol *sym) { const char *name = get_imported_name (sym); block_symbol real_symbol = lookup_global_symbol (name, nullptr, - VAR_DOMAIN); + SEARCH_VFT); if (real_symbol.symbol == nullptr) error (_("could not find alias '%s' for function '%s'"), name, sym->print_name ()); diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 062bd12909f..f832507341a 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -625,7 +625,7 @@ func_get_frame_base_dwarf_block (struct symbol *framefunc, CORE_ADDR pc, value * compute_var_value (const char *name) { - struct block_symbol sym = lookup_symbol (name, nullptr, VAR_DOMAIN, + struct block_symbol sym = lookup_symbol (name, nullptr, SEARCH_VAR_DOMAIN, nullptr); if (sym.symbol != nullptr) return value_of_variable (sym.symbol, sym.block); diff --git a/gdb/eval.c b/gdb/eval.c index 495effe2d03..b25b10f342a 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -730,7 +730,7 @@ scope_operation::evaluate_funcall (struct type *expect_type, function = cp_lookup_symbol_namespace (type->name (), name.c_str (), get_selected_block (0), - VAR_DOMAIN).symbol; + SEARCH_FUNCTION_DOMAIN).symbol; if (function == NULL) error (_("No symbol \"%s\" in namespace \"%s\"."), name.c_str (), type->name ()); @@ -1105,7 +1105,8 @@ eval_op_func_static_var (struct type *expect_type, struct expression *exp, { CORE_ADDR addr = func->address (); const block *blk = block_for_pc (addr); - struct block_symbol sym = lookup_symbol (var, blk, VAR_DOMAIN, NULL); + struct block_symbol sym = lookup_symbol (var, blk, SEARCH_VAR_DOMAIN, + nullptr); if (sym.symbol == NULL) error (_("No symbol \"%s\" in specified context."), var); return evaluate_var_value (noside, sym.block, sym.symbol); diff --git a/gdb/f-exp.y b/gdb/f-exp.y index 7e45069c67e..faa53ba9dd0 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -1640,11 +1640,11 @@ yylex (void) { std::string tmp = copy_name (yylval.sval); struct block_symbol result; - const domain_enum lookup_domains[] = + const domain_search_flags lookup_domains[] = { - STRUCT_DOMAIN, - VAR_DOMAIN, - MODULE_DOMAIN + SEARCH_STRUCT_DOMAIN, + SEARCH_VFT, + SEARCH_MODULE_DOMAIN }; int hextype; diff --git a/gdb/f-lang.c b/gdb/f-lang.c index c35c73a0eb7..d573c4f2fbb 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -1715,7 +1715,7 @@ f_language::search_name_hash (const char *name) const struct block_symbol f_language::lookup_symbol_nonlocal (const char *name, const struct block *block, - const domain_enum domain) const + const domain_search_flags domain) const { return cp_lookup_symbol_nonlocal (this, name, block, domain); } diff --git a/gdb/f-lang.h b/gdb/f-lang.h index 3126146c607..c2034258513 100644 --- a/gdb/f-lang.h +++ b/gdb/f-lang.h @@ -142,7 +142,7 @@ class f_language : public language_defn struct block_symbol lookup_symbol_nonlocal (const char *name, const struct block *block, - const domain_enum domain) const override; + const domain_search_flags domain) const override; /* See language.h. */ diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index f15ae7e8fb6..19bcd746208 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -552,7 +552,7 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream, value field before printing its value. */ struct block_symbol sym = lookup_symbol (field_name, get_selected_block (nullptr), - VAR_DOMAIN, nullptr); + SEARCH_VFT, nullptr); if (sym.symbol == nullptr) error (_("failed to find symbol for name list component %s"), field_name); diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index 5bcd5a744f1..d8fae0786f8 100644 --- a/gdb/fbsd-tdep.c +++ b/gdb/fbsd-tdep.c @@ -1960,8 +1960,9 @@ fbsd_fetch_rtld_offsets (struct gdbarch *gdbarch, struct fbsd_pspace_data *data) { /* Fetch offsets from debug symbols in rtld. */ struct symbol *obj_entry_sym - = lookup_symbol_in_language ("Struct_Obj_Entry", NULL, STRUCT_DOMAIN, - language_c, NULL).symbol; + = lookup_symbol_in_language ("Struct_Obj_Entry", nullptr, + SEARCH_STRUCT_DOMAIN, + language_c, nullptr).symbol; if (obj_entry_sym == NULL) error (_("Unable to find Struct_Obj_Entry symbol")); data->off_linkmap = lookup_struct_elt (obj_entry_sym->type (), diff --git a/gdb/frame.c b/gdb/frame.c index d95d63eb0f6..03f3c50cb8d 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -2559,7 +2559,8 @@ inside_main_func (frame_info_ptr this_frame) /* In some language (for example Fortran) there will be no minimal symbol with the name of the main function. In this case we should search the full symbols to see if we can find a match. */ - struct block_symbol bs = lookup_symbol (name, NULL, VAR_DOMAIN, 0); + struct block_symbol bs = lookup_symbol (name, nullptr, + SEARCH_VFT, nullptr); /* We might have found some unrelated symbol. For example, the Rust compiler can emit both a subprogram and a namespace with diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c index 9484f9e843f..069d40f56fb 100644 --- a/gdb/ft32-tdep.c +++ b/gdb/ft32-tdep.c @@ -297,7 +297,8 @@ ft32_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) plg_end = ft32_analyze_prologue (func_addr, func_end, &cache, gdbarch); /* Found a function. */ - sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL).symbol; + sym = lookup_symbol (func_name, nullptr, SEARCH_FUNCTION_DOMAIN, + nullptr).symbol; /* Don't use line number debug info for assembly source files. */ if ((sym != NULL) && sym->language () != language_asm) { diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 1dc68a99104..f4eff650799 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1655,7 +1655,7 @@ lookup_typename (const struct language_defn *language, { struct symbol *sym; - sym = lookup_symbol_in_language (name, block, VAR_DOMAIN, + sym = lookup_symbol_in_language (name, block, SEARCH_VFT, language->la_language, NULL).symbol; if (sym != NULL && sym->aclass () == LOC_TYPEDEF) { @@ -1699,7 +1699,7 @@ lookup_struct (const char *name, const struct block *block) { struct symbol *sym; - sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol; + sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, 0).symbol; if (sym == NULL) { @@ -1722,7 +1722,7 @@ lookup_union (const char *name, const struct block *block) struct symbol *sym; struct type *t; - sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol; + sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, 0).symbol; if (sym == NULL) error (_("No union type named %s."), name); @@ -1745,7 +1745,7 @@ lookup_enum (const char *name, const struct block *block) { struct symbol *sym; - sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol; + sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, 0).symbol; if (sym == NULL) { error (_("No enum type named %s."), name); @@ -1772,7 +1772,8 @@ lookup_template_type (const char *name, struct type *type, nam += type->name (); nam += " >"; /* FIXME, extra space still introduced in gcc? */ - symbol *sym = lookup_symbol (nam.c_str (), block, VAR_DOMAIN, 0).symbol; + symbol *sym = lookup_symbol (nam.c_str (), block, + SEARCH_STRUCT_DOMAIN, 0).symbol; if (sym == NULL) { @@ -2994,7 +2995,8 @@ check_typedef (struct type *type) stub_noname_complaint (); return make_qualified_type (type, instance_flags, NULL); } - sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0).symbol; + sym = lookup_symbol (name, nullptr, SEARCH_STRUCT_DOMAIN, + nullptr).symbol; if (sym) type->set_target_type (sym->type ()); else /* TYPE_CODE_UNDEF */ @@ -3084,7 +3086,8 @@ check_typedef (struct type *type) stub_noname_complaint (); return make_qualified_type (type, instance_flags, NULL); } - sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0).symbol; + sym = lookup_symbol (name, nullptr, SEARCH_STRUCT_DOMAIN, + nullptr).symbol; if (sym) { /* Same as above for opaque types, we can replace the stub diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index de6d21ae2c3..faefe925943 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -1079,7 +1079,7 @@ gnuv3_get_typeid_type (struct gdbarch *gdbarch) struct symbol *typeinfo; struct type *typeinfo_type; - typeinfo = lookup_symbol ("std::type_info", NULL, STRUCT_DOMAIN, + typeinfo = lookup_symbol ("std::type_info", NULL, SEARCH_STRUCT_DOMAIN, NULL).symbol; if (typeinfo == NULL) { diff --git a/gdb/go-exp.y b/gdb/go-exp.y index 0b17ea42ff3..a3afbbb8514 100644 --- a/gdb/go-exp.y +++ b/gdb/go-exp.y @@ -1293,7 +1293,8 @@ package_name_p (const char *name, const struct block *block) struct symbol *sym; struct field_of_this_result is_a_field_of_this; - sym = lookup_symbol (name, block, STRUCT_DOMAIN, &is_a_field_of_this).symbol; + sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, + &is_a_field_of_this).symbol; if (sym && sym->aclass () == LOC_TYPEDEF @@ -1335,7 +1336,7 @@ classify_packaged_name (const struct block *block) std::string copy = copy_name (yylval.sval); - sym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN, &is_a_field_of_this); + sym = lookup_symbol (copy.c_str (), block, SEARCH_VFT, &is_a_field_of_this); if (sym.symbol) { @@ -1378,7 +1379,7 @@ classify_name (struct parser_state *par_state, const struct block *block) /* TODO: What about other types? */ - sym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN, &is_a_field_of_this); + sym = lookup_symbol (copy.c_str (), block, SEARCH_VFT, &is_a_field_of_this); if (sym.symbol) { @@ -1403,7 +1404,7 @@ classify_name (struct parser_state *par_state, const struct block *block) strlen (current_package_name.get ()), copy.c_str (), copy.size ()); - sym = lookup_symbol (sval.ptr, block, VAR_DOMAIN, + sym = lookup_symbol (sval.ptr, block, SEARCH_VFT, &is_a_field_of_this); if (sym.symbol) { diff --git a/gdb/guile/scm-frame.c b/gdb/guile/scm-frame.c index 60bacdd7320..b133e8de11d 100644 --- a/gdb/guile/scm-frame.c +++ b/gdb/guile/scm-frame.c @@ -937,7 +937,7 @@ gdbscm_frame_read_var (SCM self, SCM symbol_scm, SCM rest) if (block == NULL) block = get_frame_block (frame_info_ptr (frame), NULL); - lookup_sym = lookup_symbol (var_name.get (), block, VAR_DOMAIN, + lookup_sym = lookup_symbol (var_name.get (), block, SEARCH_VFT, NULL); var = lookup_sym.symbol; block = lookup_sym.block; diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c index bf5fe24f23d..7061ff58872 100644 --- a/gdb/guile/scm-symbol.c +++ b/gdb/guile/scm-symbol.c @@ -617,7 +617,8 @@ gdbscm_lookup_symbol (SCM name_scm, SCM rest) gdbscm_gdb_exception except {}; try { - symbol = lookup_symbol (name, block, (domain_enum) domain, + domain_search_flags flags = from_scripting_domain (domain); + symbol = lookup_symbol (name, block, flags, &is_a_field_of_this).symbol; } catch (const gdb_exception &ex) @@ -654,7 +655,8 @@ gdbscm_lookup_global_symbol (SCM name_scm, SCM rest) try { - symbol = lookup_global_symbol (name, NULL, (domain_enum) domain).symbol; + domain_search_flags flags = from_scripting_domain (domain); + symbol = lookup_global_symbol (name, NULL, flags).symbol; } catch (const gdb_exception &ex) { @@ -696,14 +698,15 @@ static const scheme_integer_constant symbol_integer_constants[] = #undef X #define DOMAIN(X) \ - { "SYMBOL_" #X "_DOMAIN", X ## _DOMAIN }, + { "SYMBOL_" #X "_DOMAIN", to_scripting_domain (X ## _DOMAIN) }, \ + { "SEARCH_" #X "_DOMAIN", to_scripting_domain (SEARCH_ ## X ## _DOMAIN) }, #include "sym-domains.def" #undef DOMAIN - /* These were never correct. */ - { "SYMBOL_VARIABLES_DOMAIN", VAR_DOMAIN }, - { "SYMBOL_FUNCTIONS_DOMAIN", VAR_DOMAIN }, - { "SYMBOL_TYPES_DOMAIN", VAR_DOMAIN }, + /* Historical. */ + { "SYMBOL_VARIABLES_DOMAIN", to_scripting_domain (SEARCH_VAR_DOMAIN) }, + { "SYMBOL_FUNCTIONS_DOMAIN", to_scripting_domain (SEARCH_FUNCTION_DOMAIN) }, + { "SYMBOL_TYPES_DOMAIN", to_scripting_domain (SEARCH_TYPE_DOMAIN) }, END_INTEGER_CONSTANTS }; diff --git a/gdb/infrun.c b/gdb/infrun.c index 3f0f69be098..87939579111 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -8799,7 +8799,7 @@ insert_exception_resume_breakpoint (struct thread_info *tp, struct breakpoint *bp; vsym = lookup_symbol_search_name (sym->search_name (), - b, VAR_DOMAIN); + b, SEARCH_VAR_DOMAIN); value = read_var_value (vsym.symbol, vsym.block, frame); /* If the value was optimized out, revert to the old behavior. */ if (! value->optimized_out ()) diff --git a/gdb/language.c b/gdb/language.c index 038559a34bf..d6f6831c190 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -944,7 +944,8 @@ language_arch_info::bool_type () const { struct symbol *sym; - sym = lookup_symbol (m_bool_type_name, NULL, VAR_DOMAIN, NULL).symbol; + sym = lookup_symbol (m_bool_type_name, nullptr, SEARCH_TYPE_DOMAIN, + nullptr).symbol; if (sym != nullptr) { struct type *type = sym->type (); diff --git a/gdb/language.h b/gdb/language.h index 14a1ef6d472..5bef965c2c8 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -513,7 +513,7 @@ struct language_defn virtual struct block_symbol lookup_symbol_nonlocal (const char *name, const struct block *block, - const domain_enum domain) const; + const domain_search_flags domain) const; /* Return an expression that can be used for a location watchpoint. TYPE is a pointer type that points to the memory diff --git a/gdb/linespec.c b/gdb/linespec.c index b9aca3cc6ce..4e43bf28a67 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -3923,7 +3923,7 @@ find_label_symbols_in_block (const struct block *block, for (struct symbol *sym : block_iterator_range (block)) { - if (sym->matches (LABEL_DOMAIN) + if (sym->domain () == LABEL_DOMAIN && cmp (sym->search_name (), name, name_len) == 0) { result->push_back ({sym, block}); @@ -3934,7 +3934,7 @@ find_label_symbols_in_block (const struct block *block, else { struct block_symbol label_sym - = lookup_symbol (name, block, LABEL_DOMAIN, 0); + = lookup_symbol (name, block, SEARCH_LABEL_DOMAIN, 0); if (label_sym.symbol != NULL) { diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y index 67252ef5684..ce5a399477d 100644 --- a/gdb/m2-exp.y +++ b/gdb/m2-exp.y @@ -494,7 +494,7 @@ fblock : BLOCKNAME { struct symbol *sym = lookup_symbol (copy_name ($1).c_str (), pstate->expression_context_block, - VAR_DOMAIN, 0).symbol; + SEARCH_VFT, 0).symbol; $$ = sym;} ; @@ -503,7 +503,7 @@ fblock : BLOCKNAME fblock : block COLONCOLON BLOCKNAME { struct symbol *tem = lookup_symbol (copy_name ($3).c_str (), $1, - VAR_DOMAIN, 0).symbol; + SEARCH_VFT, 0).symbol; if (!tem || tem->aclass () != LOC_BLOCK) error (_("No function \"%s\" in specified context."), copy_name ($3).c_str ()); @@ -528,7 +528,7 @@ variable: DOLLAR_VARIABLE variable: block COLONCOLON NAME { struct block_symbol sym = lookup_symbol (copy_name ($3).c_str (), $1, - VAR_DOMAIN, 0); + SEARCH_VFT, 0); if (sym.symbol == 0) error (_("No symbol \"%s\" in specified context."), @@ -549,7 +549,7 @@ variable: NAME sym = lookup_symbol (name.c_str (), pstate->expression_context_block, - VAR_DOMAIN, + SEARCH_VFT, &is_a_field_of_this); pstate->push_symbol (name.c_str (), sym); @@ -927,7 +927,7 @@ yylex (void) if (lookup_symtab (tmp.c_str ())) return BLOCKNAME; sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block, - VAR_DOMAIN, 0).symbol; + SEARCH_VFT, 0).symbol; if (sym && sym->aclass () == LOC_BLOCK) return BLOCKNAME; if (lookup_typename (pstate->language (), diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index 3cd9e097458..d80739b1f39 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -636,8 +636,9 @@ list_args_or_locals (const frame_print_options &fp_opts, struct frame_arg arg, entryarg; if (sym->is_argument ()) - sym2 = lookup_symbol_search_name (sym->search_name (), - block, VAR_DOMAIN).symbol; + sym2 = (lookup_symbol_search_name + (sym->search_name (), + block, SEARCH_VAR_DOMAIN).symbol); else sym2 = sym; gdb_assert (sym2 != NULL); diff --git a/gdb/moxie-tdep.c b/gdb/moxie-tdep.c index 223cf09a561..4a80355ada5 100644 --- a/gdb/moxie-tdep.c +++ b/gdb/moxie-tdep.c @@ -226,7 +226,8 @@ moxie_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) plg_end = moxie_analyze_prologue (func_addr, func_end, &cache, gdbarch); /* Found a function. */ - sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL).symbol; + sym = lookup_symbol (func_name, nullptr, + SEARCH_FUNCTION_DOMAIN, nullptr).symbol; /* Don't use line number debug info for assembly source files. */ if (sym && sym->language () != language_asm) diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index 10eb73a95cb..2424e1e8530 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -87,7 +87,7 @@ lookup_struct_typedef (const char *name, const struct block *block, int noerr) { struct symbol *sym; - sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol; + sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, 0).symbol; if (sym == NULL) { @@ -1129,7 +1129,7 @@ find_imps (const char *method, std::vector *symbol_names) add the selector itself as a symbol, if it exists. */ if (selector_case && !symbol_names->empty ()) { - struct symbol *sym = lookup_symbol (selector, NULL, VAR_DOMAIN, + struct symbol *sym = lookup_symbol (selector, NULL, SEARCH_VFT, 0).symbol; if (sym != NULL) diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 64f2b5ef6be..98e2355f7a9 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -562,7 +562,7 @@ struct objfile contains !TYPE_OPAQUE symbol prefer its compunit. If it contains only TYPE_OPAQUE symbol(s), return at least that compunit. */ struct compunit_symtab *lookup_symbol (block_enum kind, const char *name, - domain_enum domain); + domain_search_flags domain); /* See quick_symbol_functions. */ void print_stats (bool print_bcache); diff --git a/gdb/p-exp.y b/gdb/p-exp.y index 2b5eb6f3026..ea7eb8c8d7e 100644 --- a/gdb/p-exp.y +++ b/gdb/p-exp.y @@ -629,9 +629,10 @@ block : block COLONCOLON name std::string copy = copy_name ($3); struct symbol *tem = lookup_symbol (copy.c_str (), $1, - VAR_DOMAIN, NULL).symbol; + SEARCH_FUNCTION_DOMAIN, + nullptr).symbol; - if (!tem || tem->aclass () != LOC_BLOCK) + if (tem == nullptr) error (_("No function \"%s\" in specified context."), copy.c_str ()); $$ = tem->value_block (); } @@ -642,7 +643,7 @@ variable: block COLONCOLON name std::string copy = copy_name ($3); sym = lookup_symbol (copy.c_str (), $1, - VAR_DOMAIN, NULL); + SEARCH_VFT, NULL); if (sym.symbol == 0) error (_("No symbol \"%s\" in specified context."), copy.c_str ()); @@ -672,7 +673,7 @@ variable: qualified_name struct block_symbol sym = lookup_symbol (name.c_str (), nullptr, - VAR_DOMAIN, nullptr); + SEARCH_VFT, nullptr); pstate->push_symbol (name.c_str (), sym); } ; @@ -1400,7 +1401,7 @@ yylex (void) static const char this_name[] = "this"; if (lookup_symbol (this_name, pstate->expression_context_block, - VAR_DOMAIN, NULL).symbol) + SEARCH_VFT, NULL).symbol) { free (uptokstart); return THIS; @@ -1440,7 +1441,7 @@ yylex (void) sym = NULL; else sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block, - VAR_DOMAIN, &is_a_field_of_this).symbol; + SEARCH_VFT, &is_a_field_of_this).symbol; /* second chance uppercased (as Free Pascal does). */ if (!sym && is_a_field_of_this.type == NULL && !is_a_field) { @@ -1456,7 +1457,7 @@ yylex (void) sym = NULL; else sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block, - VAR_DOMAIN, &is_a_field_of_this).symbol; + SEARCH_VFT, &is_a_field_of_this).symbol; } /* Third chance Capitalized (as GPC does). */ if (!sym && is_a_field_of_this.type == NULL && !is_a_field) @@ -1479,7 +1480,7 @@ yylex (void) sym = NULL; else sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block, - VAR_DOMAIN, &is_a_field_of_this).symbol; + SEARCH_VFT, &is_a_field_of_this).symbol; } if (is_a_field || (is_a_field_of_this.type != NULL)) @@ -1576,7 +1577,7 @@ yylex (void) cur_sym = lookup_symbol (ncopy, pstate->expression_context_block, - VAR_DOMAIN, NULL).symbol; + SEARCH_VFT, NULL).symbol; if (cur_sym) { if (cur_sym->aclass () == LOC_TYPEDEF) diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index 076ee08ab6e..2372cdf83eb 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -253,7 +253,7 @@ pascal_language::value_print_inner (struct value *val, { const char *search_name = msymbol.minsym->search_name (); wsym = lookup_symbol_search_name (search_name, NULL, - VAR_DOMAIN).symbol; + SEARCH_VFT).symbol; } if (wsym) diff --git a/gdb/parse.c b/gdb/parse.c index 9209e3d8fa2..4b0eeaf5330 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -225,7 +225,8 @@ parser_state::push_dollar (struct stoken str) /* On some systems, such as HP-UX and hppa-linux, certain system routines have names beginning with $ or $$. Check for those, first. */ - sym = lookup_symbol (copy.c_str (), NULL, VAR_DOMAIN, NULL); + sym = lookup_symbol (copy.c_str (), nullptr, + SEARCH_VAR_DOMAIN | SEARCH_FUNCTION_DOMAIN, nullptr); if (sym.symbol) { push_new (sym); diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 7a638ab8b89..813b5e642ef 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1582,7 +1582,7 @@ info_address_command (const char *exp, int from_tty) if (exp == 0) error (_("Argument required.")); - sym = lookup_symbol (exp, get_selected_block (&context_pc), VAR_DOMAIN, + sym = lookup_symbol (exp, get_selected_block (&context_pc), SEARCH_VFT, &is_a_field_of_this).symbol; if (sym == NULL) { diff --git a/gdb/psymtab.c b/gdb/psymtab.c index eb031d33f0d..cb7a397afb1 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1507,7 +1507,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty) sym = block_lookup_symbol (b, psym->ginfo.search_name (), symbol_name_match_type::SEARCH_NAME, - psym->domain); + to_search_flags (psym->domain)); if (!sym) { gdb_printf ("Static symbol `"); @@ -1522,7 +1522,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty) { sym = block_lookup_symbol (b, psym->ginfo.search_name (), symbol_name_match_type::SEARCH_NAME, - psym->domain); + to_search_flags (psym->domain)); if (!sym) { gdb_printf ("Global symbol `"); diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c index 95f15e00436..a1061fc0d72 100644 --- a/gdb/python/py-frame.c +++ b/gdb/python/py-frame.c @@ -532,7 +532,8 @@ frapy_read_var (PyObject *self, PyObject *args, PyObject *kw) if (!block) block = get_frame_block (frame, NULL); - lookup_sym = lookup_symbol (var_name.get (), block, VAR_DOMAIN, NULL); + lookup_sym = lookup_symbol (var_name.get (), block, + SEARCH_VFT, nullptr); var = lookup_sym.symbol; block = lookup_sym.block; } diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c index a3e55ffa3eb..ffdb7be4a9a 100644 --- a/gdb/python/py-objfile.c +++ b/gdb/python/py-objfile.c @@ -479,8 +479,9 @@ objfpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw) try { + domain_search_flags flags = from_scripting_domain (domain); struct symbol *sym = lookup_global_symbol_from_objfile - (obj->objfile, GLOBAL_BLOCK, symbol_name, (domain_enum) domain).symbol; + (obj->objfile, GLOBAL_BLOCK, symbol_name, flags).symbol; if (sym == nullptr) Py_RETURN_NONE; @@ -513,8 +514,9 @@ objfpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw) try { + domain_search_flags flags = from_scripting_domain (domain); struct symbol *sym = lookup_global_symbol_from_objfile - (obj->objfile, STATIC_BLOCK, symbol_name, (domain_enum) domain).symbol; + (obj->objfile, STATIC_BLOCK, symbol_name, flags).symbol; if (sym == nullptr) Py_RETURN_NONE; diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index a7d010f6d0c..2fb68377bad 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -432,8 +432,8 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw) try { - symbol = lookup_symbol (name, block, (domain_enum) domain, - &is_a_field_of_this).symbol; + domain_search_flags flags = from_scripting_domain (domain); + symbol = lookup_symbol (name, block, flags, &is_a_field_of_this).symbol; } catch (const gdb_exception &except) { @@ -481,7 +481,8 @@ gdbpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw) try { - symbol = lookup_global_symbol (name, NULL, (domain_enum) domain).symbol; + domain_search_flags flags = from_scripting_domain (domain); + symbol = lookup_global_symbol (name, NULL, flags).symbol; } catch (const gdb_exception &except) { @@ -542,13 +543,14 @@ gdbpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw) try { + domain_search_flags flags = from_scripting_domain (domain); + if (block != nullptr) symbol - = lookup_symbol_in_static_block (name, block, - (domain_enum) domain).symbol; + = lookup_symbol_in_static_block (name, block, flags).symbol; if (symbol == nullptr) - symbol = lookup_static_symbol (name, (domain_enum) domain).symbol; + symbol = lookup_static_symbol (name, flags).symbol; } catch (const gdb_exception &except) { @@ -592,6 +594,8 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw) try { + domain_search_flags flags = from_scripting_domain (domain); + /* Expand any symtabs that contain potentially matching symbols. */ lookup_name_info lookup_name (name, symbol_name_match_type::FULL); expand_symtabs_matching (NULL, lookup_name, NULL, NULL, @@ -613,7 +617,7 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw) if (block != nullptr) { symbol *symbol = lookup_symbol_in_static_block - (name, block, (domain_enum) domain).symbol; + (name, block, flags).symbol; if (symbol != nullptr) { @@ -675,7 +679,9 @@ gdbpy_initialize_symbols (void) #define DOMAIN(X) \ if (PyModule_AddIntConstant (gdb_module, "SYMBOL_" #X "_DOMAIN", \ - X ## _DOMAIN) < 0) \ + to_scripting_domain (X ## _DOMAIN)) < 0 \ + || PyModule_AddIntConstant (gdb_module, "SEARCH_" #X "_DOMAIN", \ + to_scripting_domain (SEARCH_ ## X ## _DOMAIN)) < 0) \ return -1; #include "sym-domains.def" #undef DOMAIN diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index ff1769c7296..11c7f13417d 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1563,7 +1563,8 @@ rust_structop::evaluate_funcall (struct type *expect_type, const struct block *block = get_selected_block (0); struct block_symbol sym = lookup_symbol (name.c_str (), block, - VAR_DOMAIN, NULL); + SEARCH_VFT, + nullptr); if (sym.symbol == NULL) error (_("Could not find function named '%s'"), name.c_str ()); @@ -1699,7 +1700,7 @@ rust_language::is_string_type_p (struct type *type) const struct block_symbol rust_language::lookup_symbol_nonlocal (const char *name, const struct block *block, - const domain_enum domain) const + const domain_search_flags domain) const { struct block_symbol result = {}; @@ -1707,7 +1708,7 @@ rust_language::lookup_symbol_nonlocal symbol_lookup_debug_printf ("rust_lookup_symbol_non_local (%s, %s (scope %s), %s)", name, host_address_to_string (block), scope, - domain_name (domain)); + domain_name (domain).c_str ()); /* Look up bare names in the block's scope. */ std::string scopedname; diff --git a/gdb/rust-lang.h b/gdb/rust-lang.h index d2270e66b4a..e76a63ee037 100644 --- a/gdb/rust-lang.h +++ b/gdb/rust-lang.h @@ -151,7 +151,7 @@ class rust_language : public language_defn struct block_symbol lookup_symbol_nonlocal (const char *name, const struct block *block, - const domain_enum domain) const override; + const domain_search_flags domain) const override; /* See language.h. */ diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c index 277a0793ea9..af1b76f738a 100644 --- a/gdb/rust-parse.c +++ b/gdb/rust-parse.c @@ -308,7 +308,7 @@ struct rust_parser void update_innermost_block (struct block_symbol sym); struct block_symbol lookup_symbol (const char *name, const struct block *block, - const domain_enum domain); + const domain_search_flags domain); struct type *rust_lookup_type (const char *name); /* Clear some state. This is only used for testing. */ @@ -431,7 +431,7 @@ munge_name_and_block (const char **name, const struct block **block) struct block_symbol rust_parser::lookup_symbol (const char *name, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { struct block_symbol result; @@ -454,7 +454,7 @@ rust_parser::rust_lookup_type (const char *name) const struct block *block = pstate->expression_context_block; munge_name_and_block (&name, &block); - result = ::lookup_symbol (name, block, STRUCT_DOMAIN, NULL); + result = ::lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, NULL); if (result.symbol != NULL) { update_innermost_block (result); @@ -1221,7 +1221,7 @@ rust_parser::name_to_operation (const std::string &name) { struct block_symbol sym = lookup_symbol (name.c_str (), pstate->expression_context_block, - VAR_DOMAIN); + SEARCH_VFT); if (sym.symbol != nullptr && sym.symbol->aclass () != LOC_TYPEDEF) return make_operation (sym); diff --git a/gdb/source.c b/gdb/source.c index 2c3bf91923b..2c465a1251f 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -316,8 +316,9 @@ select_source_symtab () /* Make the default place to list be the function `main' if one exists. */ - block_symbol bsym = lookup_symbol (main_name (), 0, VAR_DOMAIN, 0); - if (bsym.symbol != nullptr && bsym.symbol->aclass () == LOC_BLOCK) + block_symbol bsym = lookup_symbol (main_name (), nullptr, + SEARCH_FUNCTION_DOMAIN, nullptr); + if (bsym.symbol != nullptr) { symtab_and_line sal = find_function_start_sal (bsym.symbol, true); if (sal.symtab == NULL) diff --git a/gdb/stack.c b/gdb/stack.c index 2de3e361c61..fac0279472e 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -818,7 +818,7 @@ print_frame_args (const frame_print_options &fp_opts, struct symbol *nsym; nsym = lookup_symbol_search_name (sym->search_name (), - b, VAR_DOMAIN).symbol; + b, SEARCH_VAR_DOMAIN).symbol; gdb_assert (nsym != NULL); if (nsym->aclass () == LOC_REGISTER && !nsym->is_argument ()) @@ -2472,7 +2472,7 @@ iterate_over_block_arg_vars (const struct block *b, struct symbol *sym2 = lookup_symbol_search_name (sym->search_name (), - b, VAR_DOMAIN).symbol; + b, SEARCH_VAR_DOMAIN).symbol; cb (sym->print_name (), sym2); } } diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c index 3f5df13a005..30b02531b9c 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -240,7 +240,8 @@ objfile::map_symtabs_matching_filename } struct compunit_symtab * -objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain) +objfile::lookup_symbol (block_enum kind, const char *name, + domain_search_flags domain) { struct compunit_symtab *retval = nullptr; @@ -248,7 +249,7 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain) gdb_printf (gdb_stdlog, "qf->lookup_symbol (%s, %d, \"%s\", %s)\n", objfile_debug_name (this), kind, name, - domain_name (domain)); + domain_name (domain).c_str ()); lookup_name_info lookup_name (name, symbol_name_match_type::FULL); @@ -277,10 +278,6 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain) return true; }; - domain_search_flags flags = to_search_flags (domain); - if (domain == VAR_DOMAIN) - flags |= SEARCH_TYPE_DOMAIN | SEARCH_FUNCTION_DOMAIN; - for (const auto &iter : qf) { if (!iter->expand_symtabs_matching (this, @@ -291,7 +288,7 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain) kind == GLOBAL_BLOCK ? SEARCH_GLOBAL_BLOCK : SEARCH_STATIC_BLOCK, - flags)) + domain)) break; } diff --git a/gdb/symfile.c b/gdb/symfile.c index 17e1a64e77d..9d5ce7f6ad2 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1697,8 +1697,8 @@ set_initial_language_callback () { const char *name = main_name (); struct symbol *sym - = lookup_symbol_in_language (name, NULL, VAR_DOMAIN, default_lang, - NULL).symbol; + = lookup_symbol_in_language (name, nullptr, SEARCH_FUNCTION_DOMAIN, + default_lang, nullptr).symbol; if (sym != NULL) lang = sym->language (); diff --git a/gdb/symtab.c b/gdb/symtab.c index a973052f338..5735786ac44 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -85,7 +85,7 @@ static struct block_symbol lookup_symbol_aux (const char *name, symbol_name_match_type match_type, const struct block *block, - const domain_enum domain, + const domain_search_flags domain, enum language language, struct field_of_this_result *); @@ -93,13 +93,14 @@ static struct block_symbol lookup_local_symbol (const char *name, symbol_name_match_type match_type, const struct block *block, - const domain_enum domain, + const domain_search_flags domain, enum language language); static struct block_symbol lookup_symbol_in_objfile (struct objfile *objfile, enum block_enum block_index, - const char *name, const domain_enum domain); + const char *name, + const domain_search_flags domain); static void set_main_name (program_space *pspace, const char *name, language lang); @@ -171,14 +172,14 @@ struct symbol_cache_slot lookup was saved in the cache, but cache space is pretty cheap. */ const struct objfile *objfile_context; + /* The domain that was searched for initially. This must exactly + match. */ + domain_search_flags domain; + union { struct block_symbol found; - struct - { - char *name; - domain_enum domain; - } not_found; + char *name; } value; }; @@ -188,7 +189,7 @@ static void symbol_cache_clear_slot (struct symbol_cache_slot *slot) { if (slot->state == SYMBOL_SLOT_NOT_FOUND) - xfree (slot->value.not_found.name); + xfree (slot->value.name); slot->state = SYMBOL_SLOT_UNUSED; } @@ -1243,19 +1244,14 @@ matching_obj_sections (struct obj_section *obj_first, static unsigned int hash_symbol_entry (const struct objfile *objfile_context, - const char *name, domain_enum domain) + const char *name, domain_search_flags domain) { unsigned int hash = (uintptr_t) objfile_context; if (name != NULL) hash += htab_hash_string (name); - /* Because of symbol_matches_domain we need VAR_DOMAIN and STRUCT_DOMAIN - to map to the same slot. */ - if (domain == STRUCT_DOMAIN) - hash += VAR_DOMAIN * 7; - else - hash += domain * 7; + hash += domain * 7; return hash; } @@ -1265,10 +1261,9 @@ hash_symbol_entry (const struct objfile *objfile_context, static int eq_symbol_entry (const struct symbol_cache_slot *slot, const struct objfile *objfile_context, - const char *name, domain_enum domain) + const char *name, domain_search_flags domain) { const char *slot_name; - domain_enum slot_domain; if (slot->state == SYMBOL_SLOT_UNUSED) return 0; @@ -1276,16 +1271,11 @@ eq_symbol_entry (const struct symbol_cache_slot *slot, if (slot->objfile_context != objfile_context) return 0; + domain_search_flags slot_domain = slot->domain; if (slot->state == SYMBOL_SLOT_NOT_FOUND) - { - slot_name = slot->value.not_found.name; - slot_domain = slot->value.not_found.domain; - } + slot_name = slot->value.name; else - { - slot_name = slot->value.found.symbol->search_name (); - slot_domain = slot->value.found.symbol->domain (); - } + slot_name = slot->value.found.symbol->search_name (); /* NULL names match. */ if (slot_name == NULL && name == NULL) @@ -1301,18 +1291,18 @@ eq_symbol_entry (const struct symbol_cache_slot *slot, the first time through. If the slot records a found symbol, then this means using the symbol name comparison function of the symbol's language with symbol->search_name (). See - dictionary.c. It also means using symbol_matches_domain for - found symbols. See block.c. + dictionary.c. If the slot records a not-found symbol, then require a precise match. We could still be lax with whitespace like strcmp_iw though. */ + if (slot_domain != domain) + return 0; + if (slot->state == SYMBOL_SLOT_NOT_FOUND) { if (strcmp (slot_name, name) != 0) return 0; - if (slot_domain != domain) - return 0; } else { @@ -1321,9 +1311,6 @@ eq_symbol_entry (const struct symbol_cache_slot *slot, if (!symbol_matches_search_name (sym, lookup_name)) return 0; - - if (!symbol_matches_domain (sym->language (), slot_domain, domain)) - return 0; } } else @@ -1443,7 +1430,7 @@ set_symbol_cache_size_handler (const char *args, int from_tty, static struct block_symbol symbol_cache_lookup (struct symbol_cache *cache, struct objfile *objfile_context, enum block_enum block, - const char *name, domain_enum domain, + const char *name, domain_search_flags domain, struct block_symbol_cache **bsc_ptr, struct symbol_cache_slot **slot_ptr) { @@ -1474,7 +1461,7 @@ symbol_cache_lookup (struct symbol_cache *cache, block == GLOBAL_BLOCK ? "Global" : "Static", slot->state == SYMBOL_SLOT_NOT_FOUND ? " (not found)" : "", name, - domain_name (domain)); + domain_name (domain).c_str ()); ++bsc->hits; if (slot->state == SYMBOL_SLOT_NOT_FOUND) return SYMBOL_LOOKUP_FAILED; @@ -1485,7 +1472,7 @@ symbol_cache_lookup (struct symbol_cache *cache, symbol_lookup_debug_printf ("%s block symbol cache miss for %s, %s", block == GLOBAL_BLOCK ? "Global" : "Static", - name, domain_name (domain)); + name, domain_name (domain).c_str ()); ++bsc->misses; return {}; } @@ -1500,7 +1487,8 @@ symbol_cache_mark_found (struct block_symbol_cache *bsc, struct symbol_cache_slot *slot, struct objfile *objfile_context, struct symbol *symbol, - const struct block *block) + const struct block *block, + domain_search_flags domain) { if (bsc == NULL) return; @@ -1513,6 +1501,7 @@ symbol_cache_mark_found (struct block_symbol_cache *bsc, slot->objfile_context = objfile_context; slot->value.found.symbol = symbol; slot->value.found.block = block; + slot->domain = domain; } /* Mark symbol NAME, DOMAIN as not found in SLOT. @@ -1523,7 +1512,7 @@ static void symbol_cache_mark_not_found (struct block_symbol_cache *bsc, struct symbol_cache_slot *slot, struct objfile *objfile_context, - const char *name, domain_enum domain) + const char *name, domain_search_flags domain) { if (bsc == NULL) return; @@ -1534,8 +1523,8 @@ symbol_cache_mark_not_found (struct block_symbol_cache *bsc, } slot->state = SYMBOL_SLOT_NOT_FOUND; slot->objfile_context = objfile_context; - slot->value.not_found.name = xstrdup (name); - slot->value.not_found.domain = domain; + slot->value.name = xstrdup (name); + slot->domain = domain; } /* Flush the symbol cache of PSPACE. */ @@ -1620,8 +1609,8 @@ symbol_cache_dump (const struct symbol_cache *cache) case SYMBOL_SLOT_NOT_FOUND: gdb_printf (" [%4u] = %s, %s %s (not found)\n", i, host_address_to_string (slot->objfile_context), - slot->value.not_found.name, - domain_name (slot->value.not_found.domain)); + slot->value.name, + domain_name (slot->domain).c_str ()); break; case SYMBOL_SLOT_FOUND: { @@ -1984,7 +1973,8 @@ search_name_hash (enum language language, const char *search_name) struct block_symbol lookup_symbol_in_language (const char *name, const struct block *block, - const domain_enum domain, enum language lang, + const domain_search_flags domain, + enum language lang, struct field_of_this_result *is_a_field_of_this) { SYMBOL_LOOKUP_SCOPED_DEBUG_ENTER_EXIT; @@ -2002,7 +1992,7 @@ lookup_symbol_in_language (const char *name, const struct block *block, struct block_symbol lookup_symbol (const char *name, const struct block *block, - domain_enum domain, + domain_search_flags domain, struct field_of_this_result *is_a_field_of_this) { return lookup_symbol_in_language (name, block, domain, @@ -2014,7 +2004,7 @@ lookup_symbol (const char *name, const struct block *block, struct block_symbol lookup_symbol_search_name (const char *search_name, const struct block *block, - domain_enum domain) + domain_search_flags domain) { return lookup_symbol_aux (search_name, symbol_name_match_type::SEARCH_NAME, block, domain, language_asm, NULL); @@ -2039,7 +2029,7 @@ lookup_language_this (const struct language_defn *lang, sym = block_lookup_symbol (block, lang->name_of_this (), symbol_name_match_type::SEARCH_NAME, - VAR_DOMAIN); + SEARCH_VFT); if (sym != NULL) { symbol_lookup_debug_printf_v @@ -2108,7 +2098,7 @@ check_field (struct type *type, const char *name, static struct block_symbol lookup_symbol_aux (const char *name, symbol_name_match_type match_type, const struct block *block, - const domain_enum domain, enum language language, + const domain_search_flags domain, enum language language, struct field_of_this_result *is_a_field_of_this) { SYMBOL_LOOKUP_SCOPED_DEBUG_ENTER_EXIT; @@ -2127,7 +2117,7 @@ lookup_symbol_aux (const char *name, symbol_name_match_type match_type, objfile != NULL ? objfile_debug_name (objfile) : "NULL"); symbol_lookup_debug_printf ("domain name = \"%s\", language = \"%s\")", - domain_name (domain), language_str (language)); + domain_name (domain).c_str (), language_str (language)); } /* Make sure we do something sensible with is_a_field_of_this, since @@ -2157,7 +2147,7 @@ lookup_symbol_aux (const char *name, symbol_name_match_type match_type, /* Don't do this check if we are searching for a struct. It will not be found by check_field, but will be found by other means. */ - if (is_a_field_of_this != NULL && domain != STRUCT_DOMAIN) + if (is_a_field_of_this != NULL && (domain & SEARCH_STRUCT_DOMAIN) == 0) { result = lookup_language_this (langdef, block); @@ -2213,7 +2203,7 @@ static struct block_symbol lookup_local_symbol (const char *name, symbol_name_match_type match_type, const struct block *block, - const domain_enum domain, + const domain_search_flags domain, enum language language) { if (block == nullptr) @@ -2258,7 +2248,7 @@ lookup_local_symbol (const char *name, struct symbol * lookup_symbol_in_block (const char *name, symbol_name_match_type match_type, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { struct symbol *sym; @@ -2271,7 +2261,7 @@ lookup_symbol_in_block (const char *name, symbol_name_match_type match_type, ("lookup_symbol_in_block (%s, %s (objfile %s), %s)", name, host_address_to_string (block), objfile != nullptr ? objfile_debug_name (objfile) : "NULL", - domain_name (domain)); + domain_name (domain).c_str ()); } sym = block_lookup_symbol (block, name, match_type, domain); @@ -2292,7 +2282,7 @@ struct block_symbol lookup_global_symbol_from_objfile (struct objfile *main_objfile, enum block_enum block_index, const char *name, - const domain_enum domain) + const domain_search_flags domain) { gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK); @@ -2316,7 +2306,7 @@ lookup_global_symbol_from_objfile (struct objfile *main_objfile, static struct block_symbol lookup_symbol_in_objfile_symtabs (struct objfile *objfile, enum block_enum block_index, const char *name, - const domain_enum domain) + const domain_search_flags domain) { gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK); @@ -2324,7 +2314,7 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile, ("lookup_symbol_in_objfile_symtabs (%s, %s, %s, %s)", objfile_debug_name (objfile), block_index == GLOBAL_BLOCK ? "GLOBAL_BLOCK" : "STATIC_BLOCK", - name, domain_name (domain)); + name, domain_name (domain).c_str ()); struct block_symbol other; other.symbol = NULL; @@ -2383,7 +2373,7 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile, static struct block_symbol lookup_symbol_in_objfile_from_linkage_name (struct objfile *objfile, const char *linkage_name, - domain_enum domain) + domain_search_flags domain) { enum language lang = current_language->la_language; struct objfile *main_objfile; @@ -2435,7 +2425,7 @@ Internal: %s symbol `%s' found in %s psymtab but not in symtab.\n\ static struct block_symbol lookup_symbol_via_quick_fns (struct objfile *objfile, enum block_enum block_index, const char *name, - const domain_enum domain) + const domain_search_flags domain) { struct compunit_symtab *cust; const struct blockvector *bv; @@ -2446,7 +2436,7 @@ lookup_symbol_via_quick_fns (struct objfile *objfile, ("lookup_symbol_via_quick_fns (%s, %s, %s, %s)", objfile_debug_name (objfile), block_index == GLOBAL_BLOCK ? "GLOBAL_BLOCK" : "STATIC_BLOCK", - name, domain_name (domain)); + name, domain_name (domain).c_str ()); cust = objfile->lookup_symbol (block_index, name, domain); if (cust == NULL) @@ -2477,7 +2467,7 @@ lookup_symbol_via_quick_fns (struct objfile *objfile, struct block_symbol language_defn::lookup_symbol_nonlocal (const char *name, const struct block *block, - const domain_enum domain) const + const domain_search_flags domain) const { struct block_symbol result; @@ -2495,7 +2485,7 @@ language_defn::lookup_symbol_nonlocal (const char *name, shared libraries we could search all of them only to find out the builtin type isn't defined in any of them. This is common for types like "void". */ - if (domain == VAR_DOMAIN) + if ((domain & SEARCH_TYPE_DOMAIN) != 0) { struct gdbarch *gdbarch; @@ -2518,7 +2508,7 @@ language_defn::lookup_symbol_nonlocal (const char *name, struct block_symbol lookup_symbol_in_static_block (const char *name, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { if (block == nullptr) return {}; @@ -2538,7 +2528,7 @@ lookup_symbol_in_static_block (const char *name, ("lookup_symbol_in_static_block (%s, %s (objfile %s), %s)", name, host_address_to_string (block), objfile != nullptr ? objfile_debug_name (objfile) : "NULL", - domain_name (domain)); + domain_name (domain).c_str ()); } sym = lookup_symbol_in_block (name, @@ -2557,7 +2547,7 @@ lookup_symbol_in_static_block (const char *name, static struct block_symbol lookup_symbol_in_objfile (struct objfile *objfile, enum block_enum block_index, - const char *name, const domain_enum domain) + const char *name, const domain_search_flags domain) { struct block_symbol result; @@ -2567,7 +2557,7 @@ lookup_symbol_in_objfile (struct objfile *objfile, enum block_enum block_index, objfile_debug_name (objfile), block_index == GLOBAL_BLOCK ? "GLOBAL_BLOCK" : "STATIC_BLOCK", - name, domain_name (domain)); + name, domain_name (domain).c_str ()); result = lookup_symbol_in_objfile_symtabs (objfile, block_index, name, domain); @@ -2598,7 +2588,7 @@ static struct block_symbol lookup_global_or_static_symbol (const char *name, enum block_enum block_index, struct objfile *objfile, - const domain_enum domain) + const domain_search_flags domain) { struct symbol_cache *cache = get_symbol_cache (current_program_space); struct block_symbol result; @@ -2632,7 +2622,8 @@ lookup_global_or_static_symbol (const char *name, objfile); if (result.symbol != NULL) - symbol_cache_mark_found (bsc, slot, objfile, result.symbol, result.block); + symbol_cache_mark_found (bsc, slot, objfile, result.symbol, result.block, + domain); else symbol_cache_mark_not_found (bsc, slot, objfile, name, domain); @@ -2642,7 +2633,7 @@ lookup_global_or_static_symbol (const char *name, /* See symtab.h. */ struct block_symbol -lookup_static_symbol (const char *name, const domain_enum domain) +lookup_static_symbol (const char *name, const domain_search_flags domain) { return lookup_global_or_static_symbol (name, STATIC_BLOCK, nullptr, domain); } @@ -2652,7 +2643,7 @@ lookup_static_symbol (const char *name, const domain_enum domain) struct block_symbol lookup_global_symbol (const char *name, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { /* If a block was passed in, we want to search the corresponding global block first. This yields "more expected" behavior, and is @@ -2761,7 +2752,7 @@ basic_lookup_transparent_type_quick (struct objfile *objfile, const struct block *block; struct symbol *sym; - cust = objfile->lookup_symbol (block_index, name, STRUCT_DOMAIN); + cust = objfile->lookup_symbol (block_index, name, SEARCH_STRUCT_DOMAIN); if (cust == NULL) return NULL; @@ -2769,7 +2760,7 @@ basic_lookup_transparent_type_quick (struct objfile *objfile, block = bv->block (block_index); lookup_name_info lookup_name (name, symbol_name_match_type::FULL); - sym = block_find_symbol (block, lookup_name, STRUCT_DOMAIN, nullptr); + sym = block_find_symbol (block, lookup_name, SEARCH_STRUCT_DOMAIN, nullptr); if (sym == nullptr) error_in_psymtab_expansion (block_index, name, cust); gdb_assert (!TYPE_IS_OPAQUE (sym->type ())); @@ -2794,7 +2785,8 @@ basic_lookup_transparent_type_1 (struct objfile *objfile, { bv = cust->blockvector (); block = bv->block (block_index); - sym = block_find_symbol (block, lookup_name, STRUCT_DOMAIN, nullptr); + sym = block_find_symbol (block, lookup_name, SEARCH_STRUCT_DOMAIN, + nullptr); if (sym != nullptr) { gdb_assert (!TYPE_IS_OPAQUE (sym->type ())); @@ -4888,7 +4880,7 @@ global_symbol_searcher::expand_symtabs (msymbol->value_address (objfile)) == NULL) : (lookup_symbol_in_objfile_from_linkage_name (objfile, msymbol->linkage_name (), - VAR_DOMAIN) + SEARCH_VFT) .symbol == NULL)) found_msymbol = true; } @@ -5026,7 +5018,7 @@ global_symbol_searcher::add_matching_msymbols { if (lookup_symbol_in_objfile_from_linkage_name (objfile, msymbol->linkage_name (), - VAR_DOMAIN).symbol == NULL) + SEARCH_VFT).symbol == NULL) { /* Matching msymbol, add it to the results list. */ if (results->size () < m_max_search_results) diff --git a/gdb/symtab.h b/gdb/symtab.h index 69e3c060213..340ad170ece 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -2099,7 +2099,7 @@ struct field_of_this_result extern struct block_symbol lookup_symbol_in_language (const char *, const struct block *, - const domain_enum, + const domain_search_flags, enum language, struct field_of_this_result *); @@ -2107,7 +2107,7 @@ extern struct block_symbol extern struct block_symbol lookup_symbol (const char *, const struct block *, - const domain_enum, + const domain_search_flags, struct field_of_this_result *); /* Find the definition for a specified symbol search name in domain @@ -2119,9 +2119,10 @@ extern struct block_symbol lookup_symbol (const char *, pointer, or NULL if no symbol is found. The symbol's section is fixed up if necessary. */ -extern struct block_symbol lookup_symbol_search_name (const char *search_name, - const struct block *block, - domain_enum domain); +extern struct block_symbol lookup_symbol_search_name + (const char *search_name, + const struct block *block, + domain_search_flags domain); /* Some helper functions for languages that need to write their own lookup_symbol_nonlocal functions. */ @@ -2133,13 +2134,13 @@ extern struct block_symbol lookup_symbol_search_name (const char *search_name, extern struct block_symbol lookup_symbol_in_static_block (const char *name, const struct block *block, - const domain_enum domain); + const domain_search_flags domain); /* Search all static file-level symbols for NAME from DOMAIN. Upon success fixes up the symbol's section if necessary. */ -extern struct block_symbol lookup_static_symbol (const char *name, - const domain_enum domain); +extern struct block_symbol lookup_static_symbol + (const char *name, const domain_search_flags domain); /* Lookup a symbol in all files' global blocks. @@ -2155,7 +2156,7 @@ extern struct block_symbol lookup_static_symbol (const char *name, extern struct block_symbol lookup_global_symbol (const char *name, const struct block *block, - const domain_enum domain); + const domain_search_flags domain); /* Lookup a symbol in block BLOCK. Upon success fixes up the symbol's section if necessary. */ @@ -2164,7 +2165,7 @@ extern struct symbol * lookup_symbol_in_block (const char *name, symbol_name_match_type match_type, const struct block *block, - const domain_enum domain); + const domain_search_flags domain); /* Look up the `this' symbol for LANG in BLOCK. Return the symbol if found, or NULL if not found. */ @@ -2711,7 +2712,7 @@ extern struct block_symbol lookup_global_symbol_from_objfile (struct objfile *main_objfile, enum block_enum block_index, const char *name, - const domain_enum domain); + const domain_search_flags domain); /* Return 1 if the supplied producer string matches the ARM RealView compiler (armcc). */ diff --git a/gdb/valops.c b/gdb/valops.c index 93e2dfedad0..e2694f0c32b 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -118,15 +118,9 @@ find_function_in_inferior (const char *name, struct objfile **objf_p) { struct block_symbol sym; - sym = lookup_symbol (name, 0, VAR_DOMAIN, 0); + sym = lookup_symbol (name, nullptr, SEARCH_TYPE_DOMAIN, nullptr); if (sym.symbol != NULL) { - if (sym.symbol->aclass () != LOC_BLOCK) - { - error (_("\"%s\" exists in this program but is not a function."), - name); - } - if (objf_p) *objf_p = sym.symbol->objfile (); @@ -3708,7 +3702,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, { struct symbol *s = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j), - 0, VAR_DOMAIN, 0).symbol; + 0, SEARCH_FUNCTION_DOMAIN, 0).symbol; if (s == NULL) return NULL; @@ -3739,7 +3733,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, { struct symbol *s = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j), - 0, VAR_DOMAIN, 0).symbol; + 0, SEARCH_FUNCTION_DOMAIN, 0).symbol; if (s == NULL) return NULL; @@ -3819,7 +3813,7 @@ value_maybe_namespace_elt (const struct type *curtype, struct value *result; sym = cp_lookup_symbol_namespace (namespace_name, name, - get_selected_block (0), VAR_DOMAIN); + get_selected_block (0), SEARCH_VFT); if (sym.symbol == NULL) return NULL; diff --git a/gdb/value.c b/gdb/value.c index 4ec9babcce8..ccaef9fd80f 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -2922,7 +2922,8 @@ value_static_field (struct type *type, int fieldno) { const char *phys_name = type->field (fieldno).loc_physname (); /* type->field (fieldno).name (); */ - struct block_symbol sym = lookup_symbol (phys_name, 0, VAR_DOMAIN, 0); + struct block_symbol sym = lookup_symbol (phys_name, nullptr, + SEARCH_VAR_DOMAIN, nullptr); if (sym.symbol == NULL) { @@ -3113,7 +3114,8 @@ value_fn_field (struct value **arg1p, struct fn_field *f, struct symbol *sym; struct bound_minimal_symbol msym; - sym = lookup_symbol (physname, 0, VAR_DOMAIN, 0).symbol; + sym = lookup_symbol (physname, nullptr, SEARCH_FUNCTION_DOMAIN, + nullptr).symbol; if (sym == nullptr) { msym = lookup_bound_minimal_symbol (physname); diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c index 71339c502d2..b19c9491fd0 100644 --- a/gdb/xstormy16-tdep.c +++ b/gdb/xstormy16-tdep.c @@ -423,7 +423,8 @@ xstormy16_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) return plg_end; /* Found a function. */ - sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL).symbol; + sym = lookup_symbol (func_name, NULL, SEARCH_FUNCTION_DOMAIN, + nullptr).symbol; /* Don't use line number debug info for assembly source files. */ if (sym && sym->language () != language_asm) { From patchwork Thu Jan 18 20:32:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84380 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 433D238582B2 for ; Thu, 18 Jan 2024 20:35:49 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta36.uswest2.a.cloudfilter.net (omta36.uswest2.a.cloudfilter.net [35.89.44.35]) by sourceware.org (Postfix) with ESMTPS id 7D7A03858412 for ; Thu, 18 Jan 2024 20:32:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7D7A03858412 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 7D7A03858412 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609942; cv=none; b=JgdoDbGV6fBrw2j3U6hzduxQFSFh62/K9W2e5K7GPjqbpuv1ZHjtVNl2GKwErb1tNZdCXcclOFiOSYp+rj815gkzBCPCa6Zpf6dv796GDz554ZGS7Ydl9EpSNfYgLxnj3QNW13HqfjqBVfJAtst9E1ivlbkg/viTEXJhveCsjQ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609942; c=relaxed/simple; bh=ykwwFmUNVGZXCNs+p5V1OixzUg+4yBa3Ol43eebjOVQ=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=pgq8LI25HYUJj9lzmGnY8cQzFknYddpVYnXwgD4I7/oBgL+F/zGaVaL7Kl97ECAK9N09qT4gNhbIb0XN2bOGzegDJI36YdIbukT8rLpUIhzep8R2ZPv+z6ktrxl1kprCuAFdljWHRA7J6oC1lnqjI4hC8z03cyAfeOdfBOb0K/E= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5001a.ext.cloudfilter.net ([10.0.29.139]) by cmsmtp with ESMTPS id QTsDrBhvaCF6GQZ3drrczC; Thu, 18 Jan 2024 20:32:13 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3crH2h2RT1bQZ3cr8Fc6; Thu, 18 Jan 2024 20:32:12 +0000 X-Authority-Analysis: v=2.4 cv=MKVzJeVl c=1 sm=1 tr=0 ts=65a98acc a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=lk1wNYbFhmqovUGGJqEA: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=kFRHRV3OSQyAz5pQ8bW034pnuT8Hq8F1RdnBgOyof0s=; b=SkdCR8ou7UESEhBFyhGpN3iW+L o9P6gWULzAe0o5C8nzbj67Cb2aa3flG8ncs9Np+CzRl8//8CD2HtuBIWCOXG9IPTYDvYeqNEDN/0U YASwz7aTzd8pQvsmVSfdsydQY; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3b-002DCj-31 for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:11 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:16 -0700 Subject: [PATCH v2 18/30] Remove some obsolete Python constants MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-18-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3b-002DCj-31 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 20 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfMjtirMgPsiJu5LV29oYzkVU+PnPmtL5x8cCvuuV059LI2yid+X+x2X9hqaPIoKIZLj0N6ZTM39G5N3U50rK1pXFNU3GoEvDSKSmg4Gu1smb9K4geeFo S+sw+0KRmFdJx1KOXzA8N2Ugx9Q+zYSGLXB5T78Qpb/Y2FGTGOVL6DM3IIspnLC1X/tbynX4yl3506akxQhq1fkz3u29x0Wgx+4= X-Spam-Status: No, score=-3022.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, 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 Python code has exported some constants, but they are no longer documented, and were never useful. This patch removes them. --- gdb/python/py-symbol.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index 2fb68377bad..db8df891b29 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -686,20 +686,6 @@ gdbpy_initialize_symbols (void) #include "sym-domains.def" #undef DOMAIN - /* These remain defined for compatibility, but as they were never - correct, they are no longer documented. Eventually we can remove - them. These exist because at one time, enum search_domain and - enum domain_enum_tag were combined -- but different values were - used differently. Here we try to give them values that will make - sense if they are passed to gdb.lookup_symbol. */ - if (PyModule_AddIntConstant (gdb_module, "SYMBOL_VARIABLES_DOMAIN", - VAR_DOMAIN) < 0 - || PyModule_AddIntConstant (gdb_module, "SYMBOL_FUNCTIONS_DOMAIN", - VAR_DOMAIN) < 0 - || PyModule_AddIntConstant (gdb_module, "SYMBOL_TYPES_DOMAIN", - VAR_DOMAIN) < 0) - return -1; - return gdb_pymodule_addobject (gdb_module, "Symbol", (PyObject *) &symbol_object_type); } From patchwork Thu Jan 18 20:32:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84379 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 78E6A3858431 for ; Thu, 18 Jan 2024 20:35: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 C10EB3858410 for ; Thu, 18 Jan 2024 20:32:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C10EB3858410 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 C10EB3858410 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=1705609942; cv=none; b=XOC0UYiznJxZdcJWh0N3iJnbZhI7dNAkatbZMCc+vRgom7jeRPGUAK/bXsxST+fY3oSoV5LQZRkiFWzmz+c4Zh0bJFkO4wfN0nQDEE/ezb4wcsKG5ulmGqyoIwIyO683MAFyISoYoGudpi1huy9uDyw764X2H2jVyxf9tQODhPc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609942; c=relaxed/simple; bh=BRR1cAuGkCaa6TfpUWmKsUtTiNUBE8QZn5gsTaylwoQ=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=AXAv0dIlipbSPfBtoAXVeEugiZRiiJMSD0teRt6C4E+SJKqdCVF49GFd378aLZPiZjbdm44IJX9Uq9wu2iP3fOWBY3/L1+LDbhs4N5JuJOd1lzqiiz+4eql8pq6C7HQLyimuPHZr5B5SxLIcNpRWaVDQS0d2fFMxi6GcFfqw5ww= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6010a.ext.cloudfilter.net ([10.0.30.248]) by cmsmtp with ESMTPS id QYpHracYP80oiQZ3dr0O8I; Thu, 18 Jan 2024 20:32:13 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3crjZMffPByQZ3crj6MB; Thu, 18 Jan 2024 20:32:12 +0000 X-Authority-Analysis: v=2.4 cv=T+af8tGQ c=1 sm=1 tr=0 ts=65a98acc a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=erOdZxmXbWm6VKJsYvcA: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=CJJAFlCKkXkZQ2UXPhAVv4SW0X37Os7TpHu3fx6dN0M=; b=QlGqSnxMtZHRUWKJIsOEFtMBjx YKmsG9QJx2X6hEaZMMB4oktdkP9BTidTECw3+IDl+U6f/c+dyeXfrN/+p1RkfU+JmEJ+8NgdzsqO3 Reu95tTGK3LUWUCRzlCIuzSsA; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3c-002DCj-0c for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:12 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:17 -0700 Subject: [PATCH v2 19/30] Remove old symbol_matches_domain MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-19-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3c-002DCj-0c X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 21 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfCNDDLYGE4STEO/YNi2fhQrw8k0M2KGgugSd352owN9H7j6H9PlRjT7xmsylByyhTfDHjVMovkv9sEOaJll2KGdt4aepBUpTy87b2oGrSWZWy27HpnI1 gNZhY7wQ3SsElVmV2dKHFkovKkdMh4+Wg1F3KpkCyp4d71A19tmWwL5ncIIEGpeRBnlmRQqmXEVOrUQbnxRgyyOdkNCo/gL+8Jk= X-Spam-Status: No, score=-3022.8 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 Nothing calls the variant of symbol_matches_domain that accepts a domain_enum for searching, so this patch removes it and the corresponding symbol::matches. --- gdb/symtab.c | 20 -------------------- gdb/symtab.h | 11 ----------- 2 files changed, 31 deletions(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index 5735786ac44..b8588355921 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2676,26 +2676,6 @@ lookup_global_symbol (const char *name, return bs; } -bool -symbol_matches_domain (enum language symbol_language, - domain_enum symbol_domain, - domain_enum domain) -{ - /* For C++ "struct foo { ... }" also defines a typedef for "foo". - Similarly, any Ada type declaration implicitly defines a typedef. */ - if (symbol_language == language_cplus - || symbol_language == language_d - || symbol_language == language_ada - || symbol_language == language_rust) - { - if ((domain == VAR_DOMAIN || domain == STRUCT_DOMAIN) - && symbol_domain == STRUCT_DOMAIN) - return true; - } - /* For all other languages, strict match is required. */ - return (symbol_domain == domain); -} - /* See symtab.h. */ bool diff --git a/gdb/symtab.h b/gdb/symtab.h index 340ad170ece..8624006746d 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1242,10 +1242,6 @@ enum symbol_subclass_kind extern gdb::array_view symbol_impls; -bool symbol_matches_domain (enum language symbol_language, - domain_enum symbol_domain, - domain_enum domain); - /* This structure is space critical. See space comments at the top. */ struct symbol : public general_symbol_info, public allocate_on_obstack @@ -1292,13 +1288,6 @@ struct symbol : public general_symbol_info, public allocate_on_obstack return this->impl ().aclass; } - /* Call symbol_matches_domain on this symbol, using the symbol's - domain. */ - bool matches (domain_enum d) const - { - return symbol_matches_domain (language (), domain (), d); - } - /* Return true if this symbol's domain matches FLAGS. */ bool matches (domain_search_flags flags) const; From patchwork Thu Jan 18 20:32:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84389 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 0A94F385829F for ; Thu, 18 Jan 2024 20:38:01 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta36.uswest2.a.cloudfilter.net (omta36.uswest2.a.cloudfilter.net [35.89.44.35]) by sourceware.org (Postfix) with ESMTPS id 4B94F385842B for ; Thu, 18 Jan 2024 20:32:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4B94F385842B 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 4B94F385842B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609955; cv=none; b=OHjJATWkruZGbfIhoaDQlYtcGqMd7mGFTEwtkzOmCt23pW9vG4Y67wq0312cVNz6PDFOCZ4S4PrANsjTzUlYWQzkIfqrfJKEnDQREl2PJhPPxvk6cPgQllbBZ12nBJfUzcdgNJVyVhAo3/fu0PKoCDnQdxks1URaliTwnBGUHvo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609955; c=relaxed/simple; bh=SDvU6EVfbma7qfSmGbmrQ9f1kcz1hXqq+8l0v9yoR+w=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=saMekQ04xY/lZHwTQS/BVJ1rtfGWAjFWoMXtXcf9ccSmGmxce432nXTRmYKgT8CQXVwSvqef9kPyJ06aBgTzJ8Ij8WPn2F4OtMgqTsaYC5lRqN2cG1Siz0Q2O65ekN9yamzPdwI2nMzN/Ny2oFf/mOD795UyoI+7PUJXiWcjLs8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5005a.ext.cloudfilter.net ([10.0.29.234]) by cmsmtp with ESMTPS id QVkKrCM6ECF6GQZ3errcze; Thu, 18 Jan 2024 20:32:14 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3crzg5sfs4hQZ3drwysk; Thu, 18 Jan 2024 20:32:13 +0000 X-Authority-Analysis: v=2.4 cv=Q6TBXq6a c=1 sm=1 tr=0 ts=65a98acd a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=CCpqsmhAAAAA:8 a=-1PRDyB1VGpGU6LbscAA:9 a=QEXdDO2ut3YA:10 a=ul9cdbp4aOFLsgKbc677:22 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=9LAIkv/yJLgg+fZQ0TpoB8ONbL4rfz5MOz+QcKIuZE0=; b=wnOQwOOSFZHKDJ7Hc3+cU7O0Nd X+gwZFcTXnJCj7z4rFBg+j3onzmi/fN6jVIHDCjGbqSOfEeppvJmslBHqANVsjW1cJlBgunOc1Drl W5FEF6IYBFc9Fu/GjFp+5Mgtt; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3c-002DCj-1T for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:12 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:18 -0700 Subject: [PATCH v2 20/30] Use the new symbol domains MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-20-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3c-002DCj-1T X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 22 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfH58z1OMBYNn/edq93zqRhzXWv/EM0i2ej/XAryRYKNPt2cprouC1qupylSNO8c+KL5bDD5ByXWjl7xuAixz7u+kJzIrTwnVliU/LDVgPDNeWY5t48GQ cXVdjSOTtkPVZceoIeyS5ToaPKtg5NRU26V5OiOPeGrjyVDU0N4wXZz6VE8EM1a+H+jMhp9zA1sDr3RkSzbqtlDYi1ts312U0NU= X-Spam-Status: No, score=-3022.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, 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 This patch changes the DWARF reader to use the new symbol domains. It also adjusts many bits of associated code to adapt to this change. The cooked index and the .debug_names index now share some code here -- the long term goal here is to bring these two pieces of code into sync, since really they do more or less the same job, just with slightly differing inputs. The non-DWARF readers are updated on a best-effort basis. This is somewhat simpler since most of them only support C and C++. I have no way to test a few of these. I went back and forth a few times on how to handle the "tag" situation. The basic problem is that C has a special namespace for tags, which is separate from the type namespace. Other languages don't do this. So, the question is, should a DW_TAG_structure_type end up in the tag domain, or the type domain, or should it be language-dependent? I settled on making it language-dependent using a thought experiment. Suppose there was a Rust compiler that only emitted nameless DW_TAG_structure_type objects, and specified all structure type names using DW_TAG_typedef. This DWARF would be correct, in that it faithfully represents the source language -- but would not work with a purely struct-domain implementation in gdb. Therefore gdb would be wrong. Now, this approach is a little tricky for C++, which uses tags but also enters a typedef for them. I notice that some other readers -- like stabsread -- actually emit a typedef symbol as well. And, I think this is a reasonable approach. It uses more memory, but it makes the internals simpler. However, DWARF never did this for whatever reason, and so in the interest of keeping the series slightly shorter, I've left some C++-specific hacks in place here. Note that this patch includes language_minimal as a language that uses tags. I did this to avoid regressing gdb.dwarf2/debug-names-tu.exp, which doesn't specify the language for a type unit. Arguably this test case is wrong. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30164 --- gdb/ada-tasks.c | 10 +-- gdb/coffread.c | 5 +- gdb/ctfread.c | 2 +- gdb/dwarf2/cooked-index.c | 26 +------- gdb/dwarf2/index-write.c | 7 +-- gdb/dwarf2/read-debug-names.c | 40 +++--------- gdb/dwarf2/read-gdb-index.c | 2 +- gdb/dwarf2/read.c | 31 +++++++-- gdb/dwarf2/tag.h | 79 +++++++++++++++++++++++ gdb/gdbtypes.c | 24 ++++--- gdb/go-exp.y | 2 +- gdb/jit.c | 2 +- gdb/language.c | 2 +- gdb/mdebugread.c | 4 +- gdb/rust-parse.c | 2 +- gdb/stabsread.c | 8 +-- gdb/sym-domains.def | 4 +- gdb/symtab.c | 104 ++++++++++--------------------- gdb/testsuite/gdb.ada/info_auto_lang.exp | 4 +- gdb/testsuite/gdb.ada/ptype-o.exp | 2 +- gdb/testsuite/gdb.fortran/info-types.exp | 2 +- gdb/xcoffread.c | 9 +-- 22 files changed, 197 insertions(+), 174 deletions(-) diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c index fd3f5d1ead9..8ae94dcdbab 100644 --- a/gdb/ada-tasks.c +++ b/gdb/ada-tasks.c @@ -520,17 +520,17 @@ ada_get_tcb_types_info (void) C-like) lookups to get the first match. */ struct symbol *atcb_sym = - lookup_symbol_in_language (atcb_name, NULL, SEARCH_STRUCT_DOMAIN, + lookup_symbol_in_language (atcb_name, NULL, SEARCH_TYPE_DOMAIN, language_c, NULL).symbol; const struct symbol *common_atcb_sym = - lookup_symbol_in_language (common_atcb_name, NULL, SEARCH_STRUCT_DOMAIN, + lookup_symbol_in_language (common_atcb_name, NULL, SEARCH_TYPE_DOMAIN, language_c, NULL).symbol; const struct symbol *private_data_sym = - lookup_symbol_in_language (private_data_name, NULL, SEARCH_STRUCT_DOMAIN, + lookup_symbol_in_language (private_data_name, NULL, SEARCH_TYPE_DOMAIN, language_c, NULL).symbol; const struct symbol *entry_call_record_sym = lookup_symbol_in_language (entry_call_record_name, NULL, - SEARCH_STRUCT_DOMAIN, + SEARCH_TYPE_DOMAIN, language_c, NULL).symbol; if (atcb_sym == NULL || atcb_sym->type () == NULL) @@ -538,7 +538,7 @@ ada_get_tcb_types_info (void) /* In Ravenscar run-time libs, the ATCB does not have a dynamic size, so the symbol name differs. */ atcb_sym = lookup_symbol_in_language (atcb_name_fixed, NULL, - SEARCH_STRUCT_DOMAIN, language_c, + SEARCH_TYPE_DOMAIN, language_c, NULL).symbol; if (atcb_sym == NULL || atcb_sym->type () == NULL) diff --git a/gdb/coffread.c b/gdb/coffread.c index 30a38035c52..abb1c1880d6 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -1473,7 +1473,7 @@ patch_opaque_types (struct symtab *s) but search the whole chain, as there may be several syms from different files with the same name. */ if (real_sym->aclass () == LOC_TYPEDEF - && real_sym->domain () == VAR_DOMAIN + && real_sym->domain () == TYPE_DOMAIN && real_sym->type ()->code () == TYPE_CODE_PTR && real_sym->type ()->target_type ()->length () != 0) { @@ -1544,6 +1544,7 @@ process_coff_symbol (struct coff_symbol *cs, if (ISFCN (cs->c_type)) { + sym->set_domain (FUNCTION_DOMAIN); sym->set_value_longest (sym->value_longest () + objfile->text_section_offset ()); sym->set_type @@ -1626,7 +1627,7 @@ process_coff_symbol (struct coff_symbol *cs, case C_TPDEF: sym->set_aclass_index (LOC_TYPEDEF); - sym->set_domain (VAR_DOMAIN); + sym->set_domain (TYPE_DOMAIN); /* If type has no name, give it one. */ if (sym->type ()->name () == 0) diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 50bac18232e..cbb8c3f2b8a 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -505,7 +505,7 @@ new_symbol (struct ctf_context *ccp, struct type *type, ctf_id_t tid) case CTF_K_INTEGER: case CTF_K_FLOAT: sym->set_aclass_index (LOC_TYPEDEF); - sym->set_domain (VAR_DOMAIN); + sym->set_domain (TYPE_DOMAIN); break; case CTF_K_POINTER: break; diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index 2430dbd40f4..3800c3aa800 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -206,31 +206,7 @@ cooked_index_entry::matches (domain_search_flags kind) const if ((flags & IS_TYPE_DECLARATION) != 0) return false; - if ((kind & SEARCH_VAR_DOMAIN) != 0 - && (tag == DW_TAG_variable - || tag == DW_TAG_constant - || tag == DW_TAG_enumerator)) - return true; - - if ((kind & SEARCH_STRUCT_DOMAIN) != 0 - && (tag == DW_TAG_structure_type - || tag == DW_TAG_class_type - || tag == DW_TAG_union_type - || tag == DW_TAG_enumeration_type)) - return true; - - if ((kind & SEARCH_MODULE_DOMAIN) != 0 && tag == DW_TAG_module) - return true; - - if ((kind & SEARCH_TYPE_DOMAIN) != 0 && tag_is_type (tag)) - return true; - - if ((kind & SEARCH_FUNCTION_DOMAIN) != 0 - && (tag == DW_TAG_subprogram - || tag == DW_TAG_entry_point)) - return true; - - return false; + return tag_matches_domain (tag, kind, per_cu->lang ()); } /* See cooked-index.h. */ diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index 081046d4237..15356c72cb2 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -1314,11 +1314,10 @@ write_cooked_index (cooked_index *table, || entry->tag == DW_TAG_constant || entry->tag == DW_TAG_enumerator) kind = GDB_INDEX_SYMBOL_KIND_VARIABLE; - else if (entry->tag == DW_TAG_module - || entry->tag == DW_TAG_common_block) - kind = GDB_INDEX_SYMBOL_KIND_OTHER; - else + else if (tag_is_type (entry->tag)) kind = GDB_INDEX_SYMBOL_KIND_TYPE; + else + kind = GDB_INDEX_SYMBOL_KIND_OTHER; symtab->add_index_entry (name, (entry->flags & IS_STATIC) != 0, kind, it->second); diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c index 0e9b1eb878f..d7709bb91cb 100644 --- a/gdb/dwarf2/read-debug-names.c +++ b/gdb/dwarf2/read-debug-names.c @@ -20,6 +20,7 @@ #include "defs.h" #include "read-debug-names.h" #include "dwarf2/aranges.h" +#include "dwarf2/tag.h" #include "complaints.h" #include "cp-support.h" @@ -828,38 +829,13 @@ dw2_debug_names_iterator::next () } } - domain_enum domain = UNDEF_DOMAIN; - switch (indexval.dwarf_tag) - { - case DW_TAG_variable: - domain = VAR_DOMAIN; - break; - - case DW_TAG_subprogram: - domain = FUNCTION_DOMAIN; - break; - - case DW_TAG_structure_type: - case DW_TAG_union_type: - case DW_TAG_enumeration_type: - domain = STRUCT_DOMAIN; - break; - - case DW_TAG_typedef: - domain = TYPE_DOMAIN; - break; - - case DW_TAG_label: - domain = LABEL_DOMAIN; - break; - - case DW_TAG_module: - domain = MODULE_DOMAIN; - break; - } - - domain_search_flags flags = to_search_flags (domain); - if ((flags & m_search) == 0) + /* We have to use language_cplus here, first because the CU's + language isn't set yet, and then second because C++ is the main + special case, and so this choice will match a superset of other + languages. This hack can go away once the .debug_names writer is + fixed to be more corrects. */ + if (!tag_matches_domain ((dwarf_tag) indexval.dwarf_tag, m_search, + language_cplus)) goto again; return per_cu; diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c index d4741166e61..bf4f828b007 100644 --- a/gdb/dwarf2/read-gdb-index.c +++ b/gdb/dwarf2/read-gdb-index.c @@ -236,7 +236,7 @@ dw2_expand_marked_cus mask = SEARCH_FUNCTION_DOMAIN; break; case GDB_INDEX_SYMBOL_KIND_TYPE: - mask = SEARCH_TYPE_DOMAIN; + mask = SEARCH_TYPE_DOMAIN | SEARCH_STRUCT_DOMAIN; break; case GDB_INDEX_SYMBOL_KIND_OTHER: mask = SEARCH_MODULE_DOMAIN; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 877918999b8..24459a0d166 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -5780,9 +5780,7 @@ fixup_go_packaging (struct dwarf2_cu *cu) sym = new (&objfile->objfile_obstack) symbol; sym->set_language (language_go, &objfile->objfile_obstack); sym->compute_and_set_names (saved_package_name, false, objfile->per_bfd); - /* This is not VAR_DOMAIN because we want a way to ensure a lookup of, - e.g., "main" finds the "main" module and not C's main(). */ - sym->set_domain (STRUCT_DOMAIN); + sym->set_domain (TYPE_DOMAIN); sym->set_aclass_index (LOC_TYPEDEF); sym->set_type (type); @@ -19052,7 +19050,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, /* Default assumptions. Use the passed type or decode it from the die. */ - sym->set_domain (VAR_DOMAIN); + sym->set_domain (UNDEF_DOMAIN); sym->set_aclass_index (LOC_OPTIMIZED_OUT); if (type != NULL) sym->set_type (type); @@ -19104,6 +19102,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, case DW_TAG_entry_point: /* SYMBOL_BLOCK_VALUE (sym) will be filled in later by finish_block. */ + sym->set_domain (FUNCTION_DOMAIN); sym->set_aclass_index (LOC_BLOCK); /* DW_TAG_entry_point provides an additional entry_point to an existing sub_program. Therefore, we inherit the "external" @@ -19118,6 +19117,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, case DW_TAG_subprogram: /* SYMBOL_BLOCK_VALUE (sym) will be filled in later by finish_block. */ + sym->set_domain (FUNCTION_DOMAIN); sym->set_aclass_index (LOC_BLOCK); attr2 = dwarf2_attr (die, DW_AT_external, cu); if ((attr2 != nullptr && attr2->as_boolean ()) @@ -19162,6 +19162,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, case DW_TAG_inlined_subroutine: /* SYMBOL_BLOCK_VALUE (sym) will be filled in later by finish_block. */ + sym->set_domain (FUNCTION_DOMAIN); sym->set_aclass_index (LOC_BLOCK); sym->set_is_inlined (1); list_to_add = cu->list_in_scope; @@ -19172,6 +19173,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, case DW_TAG_constant: case DW_TAG_variable: case DW_TAG_member: + sym->set_domain (VAR_DOMAIN); /* Compilation with minimal debug info may result in variables with missing type entries. Change the misleading `void' type to something sensible. */ @@ -19320,6 +19322,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, when we do not have enough information to show inlined frames; pretend it's a local variable in that case so that the user can still see it. */ + sym->set_domain (VAR_DOMAIN); struct context_stack *curr = cu->get_builder ()->get_current_context_stack (); if (curr != nullptr && curr->name != nullptr) @@ -19358,11 +19361,25 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, sym->set_aclass_index (LOC_STATIC); sym->set_domain (VAR_DOMAIN); } - else + else if (cu->lang () == language_c + || cu->lang () == language_cplus + || cu->lang () == language_objc + || cu->lang () == language_opencl + || cu->lang () == language_minimal) { + /* These languages have a tag namespace. Note that + there's a special hack for C++ in the matching code, + so we don't need to enter a separate typedef for the + tag. */ sym->set_aclass_index (LOC_TYPEDEF); sym->set_domain (STRUCT_DOMAIN); } + else + { + /* Other languages don't have a tag namespace. */ + sym->set_aclass_index (LOC_TYPEDEF); + sym->set_domain (TYPE_DOMAIN); + } /* NOTE: carlton/2003-11-10: C++ class symbols shouldn't really ever be static objects: otherwise, if you try @@ -19406,10 +19423,11 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, case DW_TAG_subrange_type: case DW_TAG_generic_subrange: sym->set_aclass_index (LOC_TYPEDEF); - sym->set_domain (VAR_DOMAIN); + sym->set_domain (TYPE_DOMAIN); list_to_add = cu->list_in_scope; break; case DW_TAG_enumerator: + sym->set_domain (VAR_DOMAIN); attr = dwarf2_attr (die, DW_AT_const_value, cu); if (attr != nullptr) { @@ -19427,6 +19445,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, break; case DW_TAG_imported_declaration: case DW_TAG_namespace: + sym->set_domain (TYPE_DOMAIN); sym->set_aclass_index (LOC_TYPEDEF); list_to_add = cu->get_builder ()->get_global_symbols (); break; diff --git a/gdb/dwarf2/tag.h b/gdb/dwarf2/tag.h index 2fae4cced78..2ceae5393b5 100644 --- a/gdb/dwarf2/tag.h +++ b/gdb/dwarf2/tag.h @@ -21,6 +21,7 @@ #define GDB_DWARF2_TAG_H #include "dwarf2.h" +#include "symtab.h" /* Return true if TAG represents a type, false otherwise. */ @@ -64,4 +65,82 @@ tag_is_type (dwarf_tag tag) } } +/* Return true if the given DWARF tag matches the specified search + domain flags. LANG may affect the result, due to the "C++ tag + hack". */ + +static inline bool +tag_matches_domain (dwarf_tag tag, domain_search_flags search, language lang) +{ + domain_search_flags flags = 0; + switch (tag) + { + case DW_TAG_variable: + case DW_TAG_enumerator: + case DW_TAG_constant: + flags = SEARCH_VAR_DOMAIN; + break; + + case DW_TAG_subprogram: + case DW_TAG_entry_point: + flags = SEARCH_FUNCTION_DOMAIN; + break; + + case DW_TAG_structure_type: + case DW_TAG_class_type: + case DW_TAG_union_type: + case DW_TAG_enumeration_type: + { + if (lang == language_c + || lang == language_objc + || lang == language_opencl + || lang == language_minimal) + flags = SEARCH_STRUCT_DOMAIN; + else if (lang == language_cplus) + flags = SEARCH_STRUCT_DOMAIN | SEARCH_TYPE_DOMAIN; + else + flags = SEARCH_TYPE_DOMAIN; + } + break; + + case DW_TAG_padding: + case DW_TAG_array_type: + case DW_TAG_pointer_type: + case DW_TAG_reference_type: + case DW_TAG_string_type: + case DW_TAG_subroutine_type: + case DW_TAG_ptr_to_member_type: + case DW_TAG_set_type: + case DW_TAG_subrange_type: + case DW_TAG_base_type: + case DW_TAG_const_type: + case DW_TAG_packed_type: + case DW_TAG_template_type_param: + case DW_TAG_volatile_type: + case DW_TAG_restrict_type: + case DW_TAG_interface_type: + case DW_TAG_namespace: + case DW_TAG_unspecified_type: + case DW_TAG_shared_type: + case DW_TAG_rvalue_reference_type: + case DW_TAG_coarray_type: + case DW_TAG_dynamic_type: + case DW_TAG_atomic_type: + case DW_TAG_immutable_type: + case DW_TAG_typedef: + flags = SEARCH_TYPE_DOMAIN; + break; + + case DW_TAG_label: + flags = SEARCH_LABEL_DOMAIN; + break; + + case DW_TAG_module: + flags = SEARCH_MODULE_DOMAIN; + break; + } + + return (flags & search) != 0; +} + #endif /* GDB_DWARF2_TAG_H */ diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index f4eff650799..970a9e4a4a5 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -2988,15 +2988,19 @@ check_typedef (struct type *type) return make_qualified_type (type, instance_flags, NULL); name = type->name (); - /* FIXME: shouldn't we look in STRUCT_DOMAIN and/or - VAR_DOMAIN as appropriate? */ if (name == NULL) { stub_noname_complaint (); return make_qualified_type (type, instance_flags, NULL); } - sym = lookup_symbol (name, nullptr, SEARCH_STRUCT_DOMAIN, - nullptr).symbol; + domain_search_flag flag + = ((type->language () == language_c + || type->language () == language_objc + || type->language () == language_opencl + || type->language () == language_minimal) + ? SEARCH_STRUCT_DOMAIN + : SEARCH_TYPE_DOMAIN); + sym = lookup_symbol (name, nullptr, flag, nullptr).symbol; if (sym) type->set_target_type (sym->type ()); else /* TYPE_CODE_UNDEF */ @@ -3077,8 +3081,6 @@ check_typedef (struct type *type) else if (type->is_stub () && !currently_reading_symtab) { const char *name = type->name (); - /* FIXME: shouldn't we look in STRUCT_DOMAIN and/or VAR_DOMAIN - as appropriate? */ struct symbol *sym; if (name == NULL) @@ -3086,8 +3088,14 @@ check_typedef (struct type *type) stub_noname_complaint (); return make_qualified_type (type, instance_flags, NULL); } - sym = lookup_symbol (name, nullptr, SEARCH_STRUCT_DOMAIN, - nullptr).symbol; + domain_search_flag flag + = ((type->language () == language_c + || type->language () == language_objc + || type->language () == language_opencl + || type->language () == language_minimal) + ? SEARCH_STRUCT_DOMAIN + : SEARCH_TYPE_DOMAIN); + sym = lookup_symbol (name, nullptr, flag, nullptr).symbol; if (sym) { /* Same as above for opaque types, we can replace the stub diff --git a/gdb/go-exp.y b/gdb/go-exp.y index a3afbbb8514..2e56e4bff61 100644 --- a/gdb/go-exp.y +++ b/gdb/go-exp.y @@ -1293,7 +1293,7 @@ package_name_p (const char *name, const struct block *block) struct symbol *sym; struct field_of_this_result is_a_field_of_this; - sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, + sym = lookup_symbol (name, block, SEARCH_TYPE_DOMAIN, &is_a_field_of_this).symbol; if (sym diff --git a/gdb/jit.c b/gdb/jit.c index 7960d32acd1..f1dbf39f73f 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -581,7 +581,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) new_block->set_end (gdb_block_iter.end); /* The name. */ - block_name->set_domain (VAR_DOMAIN); + block_name->set_domain (FUNCTION_DOMAIN); block_name->set_aclass_index (LOC_BLOCK); block_name->set_symtab (filetab); block_name->set_type (lookup_function_type (block_type)); diff --git a/gdb/language.c b/gdb/language.c index d6f6831c190..c5bbc319963 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -974,7 +974,7 @@ language_arch_info::type_and_symbol::alloc_type_symbol symbol->set_is_objfile_owned (0); symbol->set_section_index (0); symbol->set_type (type); - symbol->set_domain (VAR_DOMAIN); + symbol->set_domain (TYPE_DOMAIN); symbol->set_aclass_index (LOC_TYPEDEF); return symbol; } diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 13c9401d171..4748b0cd7aa 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -753,7 +753,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, break; } s = new_symbol (name); - s->set_domain (VAR_DOMAIN); + s->set_domain (FUNCTION_DOMAIN); s->set_aclass_index (LOC_BLOCK); s->set_section_index (section_index); /* Type of the return value. */ @@ -1297,7 +1297,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, if (has_opaque_xref (cur_fdr, sh)) break; s = new_symbol (name); - s->set_domain (VAR_DOMAIN); + s->set_domain (TYPE_DOMAIN); s->set_aclass_index (LOC_TYPEDEF); s->set_value_block (top_stack->cur_block); s->set_type (t); diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c index af1b76f738a..66263b91bdc 100644 --- a/gdb/rust-parse.c +++ b/gdb/rust-parse.c @@ -454,7 +454,7 @@ rust_parser::rust_lookup_type (const char *name) const struct block *block = pstate->expression_context_block; munge_name_and_block (&name, &block); - result = ::lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, NULL); + result = ::lookup_symbol (name, block, SEARCH_TYPE_DOMAIN, nullptr); if (result.symbol != NULL) { update_innermost_block (result); diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 071290fbe12..025cb2120d1 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -940,7 +940,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, /* A static function definition. */ sym->set_type (read_type (&p, objfile)); sym->set_aclass_index (LOC_BLOCK); - sym->set_domain (VAR_DOMAIN); + sym->set_domain (FUNCTION_DOMAIN); add_symbol_to_list (sym, get_file_symbols ()); /* fall into process_function_types. */ @@ -1011,7 +1011,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, /* A global function definition. */ sym->set_type (read_type (&p, objfile)); sym->set_aclass_index (LOC_BLOCK); - sym->set_domain (VAR_DOMAIN); + sym->set_domain (FUNCTION_DOMAIN); add_symbol_to_list (sym, get_global_symbols ()); goto process_function_types; @@ -1209,7 +1209,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, sym->set_aclass_index (LOC_TYPEDEF); sym->set_value_longest (valu); - sym->set_domain (VAR_DOMAIN); + sym->set_domain (TYPE_DOMAIN); /* C++ vagaries: we may have a type which is derived from a base type which did not have its name defined when the derived class was output. We fill in the derived class's @@ -1328,7 +1328,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, *typedef_sym = *sym; typedef_sym->set_aclass_index (LOC_TYPEDEF); typedef_sym->set_value_longest (valu); - typedef_sym->set_domain (VAR_DOMAIN); + typedef_sym->set_domain (TYPE_DOMAIN); if (sym->type ()->name () == 0) sym->type ()->set_name (obconcat (&objfile->objfile_obstack, sym->linkage_name (), diff --git a/gdb/sym-domains.def b/gdb/sym-domains.def index cea25a5f5b3..7545631063b 100644 --- a/gdb/sym-domains.def +++ b/gdb/sym-domains.def @@ -47,7 +47,9 @@ DOMAIN (LABEL) DOMAIN (COMMON_BLOCK) /* TYPE_DOMAIN is for types and typedefs. Note that tags are not - found here, see STRUCT_DOMAIN above. */ + found here, see STRUCT_DOMAIN above. If a language does not have a + tag namespace, then all types (including structures, etc) are + here. */ DOMAIN (TYPE) diff --git a/gdb/symtab.c b/gdb/symtab.c index b8588355921..30b12d6f4eb 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2681,32 +2681,10 @@ lookup_global_symbol (const char *name, bool symbol::matches (domain_search_flags flags) const { - if (language () != language_c - && language () != language_objc - && language () != language_opencl) - { - /* Only C languages distinguish tag and type namespaces. */ - if ((flags & SEARCH_TYPE_DOMAIN) != 0) - flags |= SEARCH_STRUCT_DOMAIN; - } - - if ((flags & SEARCH_FUNCTION_DOMAIN) != 0 - && domain () == VAR_DOMAIN - && aclass () == LOC_BLOCK) - return true; - - if ((flags & SEARCH_VAR_DOMAIN) != 0 - && domain () == VAR_DOMAIN) - return true; - - if ((flags & SEARCH_TYPE_DOMAIN) != 0 - && domain () == VAR_DOMAIN - && aclass () == LOC_TYPEDEF) - return true; - - if ((flags & SEARCH_STRUCT_DOMAIN) != 0 - && domain () == STRUCT_DOMAIN) - return true; + /* C++ has a typedef for every tag, and the types are in the struct + domain. */ + if (language () == language_cplus && (flags & SEARCH_TYPE_DOMAIN) != 0) + flags |= SEARCH_STRUCT_DOMAIN; return search_flags_matches (flags, m_domain); } @@ -4908,59 +4886,42 @@ global_symbol_searcher::add_matching_symbols filenames, false)))) continue; + if (!sym->matches (kind)) + continue; + if (preg.has_value () && !preg->exec (sym->natural_name (), 0, nullptr, 0) == 0) continue; - bool matches = false; - if (!matches && (kind & SEARCH_VAR_DOMAIN) != 0) + if (((sym->domain () == VAR_DOMAIN + || sym->domain () == FUNCTION_DOMAIN) + && treg.has_value () + && !treg_matches_sym_type_name (*treg, sym))) + continue; + + if ((kind & SEARCH_VAR_DOMAIN) != 0) { - if (sym->aclass () != LOC_TYPEDEF - && sym->aclass () != LOC_UNRESOLVED - && sym->aclass () != LOC_BLOCK + if (sym->aclass () == LOC_UNRESOLVED /* LOC_CONST can be used for more than just enums, e.g., c++ static const members. We only want to skip enums here. */ - && !(sym->aclass () == LOC_CONST - && (sym->type ()->code () - == TYPE_CODE_ENUM)) - && (!treg.has_value () - || treg_matches_sym_type_name (*treg, sym))) - matches = true; - } - if (!matches && (kind & SEARCH_FUNCTION_DOMAIN) != 0) - { - if (sym->aclass () == LOC_BLOCK - && (!treg.has_value () - || treg_matches_sym_type_name (*treg, - sym))) - matches = true; - } - if (!matches && (kind & SEARCH_TYPE_DOMAIN) != 0) - { - if (sym->aclass () == LOC_TYPEDEF - && sym->domain () != MODULE_DOMAIN) - matches = true; - } - if (!matches && (kind & SEARCH_MODULE_DOMAIN) != 0) - { - if (sym->domain () == MODULE_DOMAIN - && sym->line () != 0) - matches = true; + || (sym->aclass () == LOC_CONST + && (sym->type ()->code () == TYPE_CODE_ENUM))) + continue; } - if (matches) + if (sym->domain () == MODULE_DOMAIN && sym->line () == 0) + continue; + + if (result_set->size () < m_max_search_results) { - if (result_set->size () < m_max_search_results) - { - /* Match, insert if not already in the results. */ - symbol_search ss (block, sym); - if (result_set->find (ss) == result_set->end ()) - result_set->insert (ss); - } - else - return false; + /* Match, insert if not already in the results. */ + symbol_search ss (block, sym); + if (result_set->find (ss) == result_set->end ()) + result_set->insert (ss); } + else + return false; } } } @@ -5123,12 +5084,12 @@ symbol_to_info_string (struct symbol *sym, int block) gdb_assert (block == GLOBAL_BLOCK || block == STATIC_BLOCK); if (block == STATIC_BLOCK - && sym->domain () == VAR_DOMAIN - && sym->aclass () != LOC_TYPEDEF) + && (sym->domain () == VAR_DOMAIN + || sym->domain () == FUNCTION_DOMAIN)) str += "static "; /* Typedef that is not a C++ class. */ - if (sym->domain () == VAR_DOMAIN && sym->aclass () == LOC_TYPEDEF) + if (sym->domain () == TYPE_DOMAIN) { string_file tmp_stream; @@ -5147,7 +5108,8 @@ symbol_to_info_string (struct symbol *sym, int block) str += tmp_stream.string (); } /* variable, func, or typedef-that-is-c++-class. */ - else if (sym->domain () == VAR_DOMAIN || sym->domain () == STRUCT_DOMAIN) + else if (sym->domain () == VAR_DOMAIN || sym->domain () == STRUCT_DOMAIN + || sym->domain () == FUNCTION_DOMAIN) { string_file tmp_stream; diff --git a/gdb/testsuite/gdb.ada/info_auto_lang.exp b/gdb/testsuite/gdb.ada/info_auto_lang.exp index dc92659670b..cb2a5a7a172 100644 --- a/gdb/testsuite/gdb.ada/info_auto_lang.exp +++ b/gdb/testsuite/gdb.ada/info_auto_lang.exp @@ -65,8 +65,8 @@ set type_in_c(ada_syntax) [multi_line \ "${decimal}: record" \ " some_component_in_c: int;" \ "end record" ] -set type_in_ada(c_syntax) "${decimal}: struct global_pack__some_type_in_ada;" -set type_in_ada(ada_syntax) "${decimal}: global_pack.some_type_in_ada;" +set type_in_ada(c_syntax) "${decimal}: struct global_pack__some_type_in_ada" +set type_in_ada(ada_syntax) "${decimal}: global_pack.some_type_in_ada" set var_in_c(c_syntax) "${decimal}: some_type_in_c some_struct_in_c;" set var_in_c(ada_syntax) "${decimal}: some_struct_in_c: some_type_in_c;" diff --git a/gdb/testsuite/gdb.ada/ptype-o.exp b/gdb/testsuite/gdb.ada/ptype-o.exp index 1a2817da6bc..f7782199d58 100644 --- a/gdb/testsuite/gdb.ada/ptype-o.exp +++ b/gdb/testsuite/gdb.ada/ptype-o.exp @@ -43,5 +43,5 @@ foreach_with_prefix scenario {all minimal} { # crash. set exp ".*" } - gdb_test "ptype/o struct prog__rec" $exp + gdb_test "ptype/o prog__rec" $exp } diff --git a/gdb/testsuite/gdb.fortran/info-types.exp b/gdb/testsuite/gdb.fortran/info-types.exp index ab1d8947729..52ce7ace89d 100644 --- a/gdb/testsuite/gdb.fortran/info-types.exp +++ b/gdb/testsuite/gdb.fortran/info-types.exp @@ -44,7 +44,7 @@ GDBInfoSymbols::check_header "All defined types:" GDBInfoSymbols::check_optional_entry "${srcfile}" "" "${character1}" GDBInfoSymbols::check_entry "${srcfile}" "" "${integer4}" GDBInfoSymbols::check_entry "${srcfile}" "" "${logical4}" -GDBInfoSymbols::check_entry "${srcfile}" "$decimal" "Type m1t1;" +GDBInfoSymbols::check_entry "${srcfile}" "$decimal" "Type m1t1" GDBInfoSymbols::check_entry "${srcfile}" "" "${real4}" # The emission of the 'Type s1' at global scope is actually not expected. The diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index d161ad34c2f..589208cda68 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -1491,6 +1491,7 @@ process_xcoff_symbol (struct xcoff_symbol *cs, struct objfile *objfile) sym->set_linkage_name (SYMNAME_ALLOC (name, symname_alloced)); sym->set_type (builtin_type (objfile)->nodebug_text_symbol); + sym->set_domain (FUNCTION_DOMAIN); sym->set_aclass_index (LOC_BLOCK); sym2 = new (&objfile->objfile_obstack) symbol (*sym); @@ -2546,7 +2547,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, /* Also a typedef with the same name. */ pst->add_psymbol (std::string_view (namestring, p - namestring), - true, VAR_DOMAIN, LOC_TYPEDEF, -1, + true, TYPE_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, unrelocated_addr (0), psymtab_language, @@ -2561,7 +2562,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, { pst->add_psymbol (std::string_view (namestring, p - namestring), - true, VAR_DOMAIN, LOC_TYPEDEF, -1, + true, TYPE_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, unrelocated_addr (0), psymtab_language, @@ -2661,7 +2662,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, } pst->add_psymbol (std::string_view (namestring, p - namestring), - true, VAR_DOMAIN, LOC_BLOCK, + true, FUNCTION_DOMAIN, LOC_BLOCK, SECT_OFF_TEXT (objfile), psymbol_placement::STATIC, unrelocated_addr (symbol.n_value), @@ -2688,7 +2689,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, pst->add_psymbol (std::string_view (namestring, p - namestring), - true, VAR_DOMAIN, LOC_BLOCK, + true, FUNCTION_DOMAIN, LOC_BLOCK, SECT_OFF_TEXT (objfile), psymbol_placement::GLOBAL, unrelocated_addr (symbol.n_value), From patchwork Thu Jan 18 20:32:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84388 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 93C563858436 for ; Thu, 18 Jan 2024 20:37:23 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id 82E783858417 for ; Thu, 18 Jan 2024 20:32:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 82E783858417 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 82E783858417 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609945; cv=none; b=aWWCOqE139YKHbBD8P0144laC8qpBlICOwDDh2ctvXjPioL9xxre38YOgFAma9QG5vhI/dvytULEDrrCrZy4TW4Q+YgApQrAJXwhAHbF4tCsoKSdVww0bJk7FWUV4DWXBWUUv9zSmm+thL7Jl1jheM58DEOH4n7xnM06fYZBipQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609945; c=relaxed/simple; bh=j/h92J9c7lNEf72sJTDEy1avS47PTYYr8ZbrZlvFXU4=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=GM2NqwTIZoQFJ3tkqWAmkhiYMCrIxfvMh/HLENjOkSCYt1M46wqxYKPA4DGc+LB52UIwsQrGvGntH+Fct/k2ev7Cu5vPEGPsVyyMiNxoYym4x0tb64EgIE9CxON9HThRe19kPSXIUn8u7D8vYH69eLd12LPr9HqIP1FoKVZj8KQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6001a.ext.cloudfilter.net ([10.0.30.140]) by cmsmtp with ESMTPS id QWnIrNP6ZMVQiQZ3drEcTW; Thu, 18 Jan 2024 20:32:13 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3crX5VIWRcnQZ3drSBiW; Thu, 18 Jan 2024 20:32:13 +0000 X-Authority-Analysis: v=2.4 cv=OPo0YAWB c=1 sm=1 tr=0 ts=65a98acd a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=zUfXEgyxzIi75vXqr1wA: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=oSFDRUDkOpa6OPBbyBijvvXpny1ZR7YXBAsRKkDJVVk=; b=BQJi8uzkfjIhC6sTEcbASYHep5 gsnEl4+ufry6wHYuE+kIWFfqZ2VE3tnaySIU9J41oGcrOaw9IBhHd2STJpfRgB88tHLmqiL0kjc4b YKmT1ft4+Q/87L+f4UW+4EcS3; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3c-002DCj-2N for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:12 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:19 -0700 Subject: [PATCH v2 21/30] Simplify some symbol searches in Ada code MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-21-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3c-002DCj-2N X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 23 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfJuruXcD7ZKmfUM/lT2GBVhiph4CK5dT6o/ZYRgqZXJErfBzSv22ZCY0L2zFlLKLRRyh7cJ5ZgLc+CCf5TcSOUlESjZU33ac/bmqA8nK+UMkH9HymtfU yvTdVvfVkntjNUY8kg4JgGJM6YHtJDIpt/EECaHB4efrJhY/epS4Chemq0daiMkN6KdsR6tJS6ukc3eQvpXTRD8ncLQpDkfa9iY= X-Spam-Status: No, score=-3022.8 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 This changes some of the Ada code to simplify symbol searches. For example, if a function is being looked for, the search is narrowed to use SEARCH_FUNCTION_DOMAIN rather than SEARCH_VFT. In one spot, a search of the "struct" domain is removed, because Ada does not have a tag domain. --- gdb/ada-exp.y | 4 ++-- gdb/ada-lang.c | 10 ++-------- gdb/dwarf2/ada-imported.c | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 1f439b38aea..ab936ae4733 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -1404,7 +1404,7 @@ block_lookup (const struct block *context, const char *raw_name) } std::vector syms - = ada_lookup_symbol_list (name, context, SEARCH_VFT); + = ada_lookup_symbol_list (name, context, SEARCH_FUNCTION_DOMAIN); if (context == NULL && (syms.empty () || syms[0].symbol->aclass () != LOC_BLOCK)) @@ -1483,7 +1483,7 @@ find_primitive_type (struct parser_state *par_state, const char *name) (char *) alloca (strlen (name) + sizeof ("standard__")); strcpy (expanded_name, "standard__"); strcat (expanded_name, name); - sym = ada_lookup_symbol (expanded_name, NULL, SEARCH_VFT).symbol; + sym = ada_lookup_symbol (expanded_name, NULL, SEARCH_TYPE_DOMAIN).symbol; if (sym != NULL && sym->aclass () == LOC_TYPEDEF) type = sym->type (); } diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index a15ea7b725e..f1d01ec7aa3 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -7436,14 +7436,8 @@ field_alignment (struct type *type, int f) static struct symbol * ada_find_any_type_symbol (const char *name) { - struct symbol *sym; - - sym = standard_lookup (name, get_selected_block (NULL), SEARCH_VFT); - if (sym != NULL && sym->aclass () == LOC_TYPEDEF) - return sym; - - sym = standard_lookup (name, NULL, SEARCH_STRUCT_DOMAIN); - return sym; + return standard_lookup (name, get_selected_block (nullptr), + SEARCH_TYPE_DOMAIN); } /* Find a type named NAME. Ignores ambiguity. This routine will look diff --git a/gdb/dwarf2/ada-imported.c b/gdb/dwarf2/ada-imported.c index 21f81bbcdea..1a0bc1d528e 100644 --- a/gdb/dwarf2/ada-imported.c +++ b/gdb/dwarf2/ada-imported.c @@ -103,7 +103,7 @@ ada_alias_get_block_value (const struct symbol *sym) { const char *name = get_imported_name (sym); block_symbol real_symbol = lookup_global_symbol (name, nullptr, - SEARCH_VFT); + SEARCH_FUNCTION_DOMAIN); if (real_symbol.symbol == nullptr) error (_("could not find alias '%s' for function '%s'"), name, sym->print_name ()); From patchwork Thu Jan 18 20:32:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84384 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 21AC63858286 for ; Thu, 18 Jan 2024 20:36:57 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id C96313858418 for ; Thu, 18 Jan 2024 20:32:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C96313858418 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 C96313858418 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609945; cv=none; b=Sht1EyYu/Q3tUnrFqGlEgDocmDshNxFGjkhEhcOCAO7kf/36FYISRZXV5Bk5+ePJGygo+T9wbm5ir7nYol5687pP8LrF8YpBsl5xYvxS8+54Z7i8vprRQmGJVABuPNZGSCVlGftgAkcERyNKigHgGCC+wE5qJWuqX9iaGGnFDHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609945; c=relaxed/simple; bh=+43odcif+hBkHl0XeTKiXdWu5bIEmDoOIedK5xGYXk4=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=DeSrQHWQHZRMhLq24O/uYceh8HJSV4QHs+Ut0xa6RzNoRdgZUwBvPvemg3kWC1k3gq1n49ajXA9U8h6R24lYDfzx8Jmw0uudWyyTZZMX8lRE/HqEEEFQ7wFJ3xLJB/1XT5x6XLOOznDu48jfbbGdAiEj4l8fMdQZqobXmJsN+Zw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5002a.ext.cloudfilter.net ([10.0.29.215]) by cmsmtp with ESMTPS id QNmlrKebGMVQiQZ3erEcTv; Thu, 18 Jan 2024 20:32:14 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3dr6xzNBnVCQZ3drv2Ts; Thu, 18 Jan 2024 20:32:13 +0000 X-Authority-Analysis: v=2.4 cv=H+TIfsUi c=1 sm=1 tr=0 ts=65a98acd a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=fapS_FOKSIiKDB77OEMA: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=OSYLl9iNMSFianRAQsmsnoMPXGUY+0o0zjqteEkxphw=; b=gRBw/sKJ7620qAg5MsNReOj1C6 /TcGrr+MbQapOdpDpjt1ZIPB+7ZcsryvfRdx5XgY4WowAL9b0o9Wd1YuIiwi2xERTyltgLB7dMVqo QVadZ2zyamCelPkSO/DnUht3W; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3c-002DCj-3A for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:13 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:20 -0700 Subject: [PATCH v2 22/30] Simplify some symbol searches in linespec.c MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-22-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3c-002DCj-3A X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 24 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfIlw4WD+Og/1fTsRNLMbCHxEOlpFJp4arqMiJ16TC3MTkIPkt/Yiwl4CgSMfJ8AeVrOy8xT8l7U6iiqHA1DmS64uUpWyYkd95IqhnC09ANRoCE+KOnqE 6ckgJopyIl8Wqg46Z2b6s1xzkNgNl6c+W8bMlyibm4iqGqhPUro8v57Su9WfEaMWa1+v1zumdUuZZEYOeW4bSJKLdr3UweESytc= X-Spam-Status: No, score=-3022.8 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 This simplifies some symbol searches in linespec.c. In particular, two separate searches here can now be combined into one, due to the new use of flags. Arguably the STRUCT_DOMAIN searches should perhaps not even be done. Only C really has these, and C doesn't have member functions. However, it seems relatively harmless -- and clearly compatible -- to leave this in. --- gdb/linespec.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/gdb/linespec.c b/gdb/linespec.c index 4e43bf28a67..b5bbd8c433c 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -3446,14 +3446,9 @@ lookup_prefix_sym (struct linespec_state *state, for (const auto &elt : file_symtabs) { if (elt == nullptr) - { - iterate_over_all_matching_symtabs (state, lookup_name, - SEARCH_STRUCT_DOMAIN, - NULL, false, collector); - iterate_over_all_matching_symtabs (state, lookup_name, - SEARCH_VFT, - NULL, false, collector); - } + iterate_over_all_matching_symtabs (state, lookup_name, + SEARCH_STRUCT_DOMAIN | SEARCH_VFT, + NULL, false, collector); else { /* Program spaces that are executing startup should have @@ -3463,10 +3458,7 @@ lookup_prefix_sym (struct linespec_state *state, gdb_assert (!pspace->executing_startup); set_current_program_space (pspace); iterate_over_file_blocks (elt, lookup_name, - SEARCH_STRUCT_DOMAIN, - collector); - iterate_over_file_blocks (elt, lookup_name, - SEARCH_VFT, + SEARCH_STRUCT_DOMAIN | SEARCH_VFT, collector); } } From patchwork Thu Jan 18 20:32:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84391 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 7E1503858291 for ; Thu, 18 Jan 2024 20:38:05 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta38.uswest2.a.cloudfilter.net (omta38.uswest2.a.cloudfilter.net [35.89.44.37]) by sourceware.org (Postfix) with ESMTPS id E0E05385841B for ; Thu, 18 Jan 2024 20:32:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E0E05385841B 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 E0E05385841B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609945; cv=none; b=xL5+X0T8uBl3qKDobzpCmtAyM/fBiqS/B7TsmzdM9Ij5yQVKwXrLYu6P1czP2u5omn72xPNP1Lj7IBQVvvEtXXltaahh4Ccej3fOjm3tMihXa+Oc+zADQtLOdV+au1+K7FHKNts1p6rpLls7uvTinphpH9+ktB9s3hjAPDmNF+Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609945; c=relaxed/simple; bh=NEpjo5AVlRCjNyZP2Mqs5RG0klOSoT/lExOQHWcRpGw=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=kqsNi+/aynZySMDgO1z3ckkQPNIUgmwFZeLail7B3/6Xp0CqbaaI5QqsLNgrNbBFLifK3oyFp+jXml09BLLL7qKO60FrdcvwJysaxV3v7AddAeGHdjSW4ZrWqfDoF8IvjFCxcx0vT8xPmgRhZr05UhVxY4hsWx9GSBPs3RFGsRA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6005a.ext.cloudfilter.net ([10.0.30.201]) by cmsmtp with ESMTPS id QXALrgtY5oMN9QZ3erOoD7; Thu, 18 Jan 2024 20:32:14 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3drrF531UTRQZ3drmni1; Thu, 18 Jan 2024 20:32:13 +0000 X-Authority-Analysis: v=2.4 cv=ZOXEJF3b c=1 sm=1 tr=0 ts=65a98ace a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=8Veq67EhIFtdNKN4G4AA: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=eRUpzvGvYplLNEDvAdWrg9i5mP+BYYqJy217Wc/N+fE=; b=KrGi8BsDd7Qvaj5hTvL0xGfVJe Ha4/A+eTj42vOihTX9wfS2JfSv5/XCZ+0VSfGaGu6NO9faq5Sm9a3al+1DiZ68S/2AzfZEAOgK4eD JEaJRObw3WK2Ec5fHuFZYz/Tk; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3d-002DCj-0j for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:13 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:21 -0700 Subject: [PATCH v2 23/30] Only search for "main" as a function MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-23-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3d-002DCj-0j X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 25 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfIyC6IsZIs0EZsK5f7D48d8yYona144k/h5/ijur6eot5eTiMSq1gvk0aQfd7Z/RPEvTj/yDm0kbzgZnZr7S6B11mfCqPH+xEeYRxaka7Cn5dLJOYN4Q OTOsLSaTLIC2QlaJd7YJl87OtEDdGGSna3vInb7Ml67d4ew4+A+CNKqBxtW6vlRhjLvWQzABLuPpZI9Wx43MVkTlT8kQ0eUSxGU= X-Spam-Status: No, score=-3022.8 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 This changes find_main_name to restrict its search to the function domain. --- gdb/symtab.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index 30b12d6f4eb..517e843244b 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -6435,7 +6435,8 @@ find_main_name (void) [&symbol_found_p, pspace] (objfile *obj) { language lang - = obj->lookup_global_symbol_language ("main", SEARCH_VFT, + = obj->lookup_global_symbol_language ("main", + SEARCH_FUNCTION_DOMAIN, &symbol_found_p); if (symbol_found_p) { From patchwork Thu Jan 18 20:32:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84381 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 C0ECB3858414 for ; Thu, 18 Jan 2024 20:36:04 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta034.useast.a.cloudfilter.net (omta034.useast.a.cloudfilter.net [44.202.169.33]) by sourceware.org (Postfix) with ESMTPS id 108D7385841C for ; Thu, 18 Jan 2024 20:32:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 108D7385841C 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 108D7385841C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609945; cv=none; b=iPLfdC0WYnuoclvaExs3WHlSLnYzf2aRfCa3ySs98NyA81lBDfl4j/8f0AciIxh5gyCbYeoIij+olOBlBuRv6nNxL8on9cD2nzAArfqwWEcATkd9f+54xZOcRqTkONqqjEGtRb5p0Ha0ODXRVzAb1yKbeJmx9m8JF6SZX0G2oJg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609945; c=relaxed/simple; bh=U/vR3RFgLAsxvPDe8+rdqA/7azZmgY6LoJp4r9PbbPE=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=Lycb/nzz0jgwjJnyF2F+zVePgH5jVOqStbOUkkdBKMhSMziyUip71jYjVFX/yWU/lYFPCGB1ZRhX3cmpja3kjqzBBKcLqDmsCXSxdd7sTpbu5HkcWwNmI5vNeEK1BONh3Px+GtN5bjyCfH8w/blvcda7Qh9qyRMUpy8nWqTX0bQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5001a.ext.cloudfilter.net ([10.0.29.139]) by cmsmtp with ESMTPS id QWAgr6g0fAxAkQZ3vrR5dh; Thu, 18 Jan 2024 20:32:31 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3drH2ieRT1bQZ3er8Fdd; Thu, 18 Jan 2024 20:32:14 +0000 X-Authority-Analysis: v=2.4 cv=MKVzJeVl c=1 sm=1 tr=0 ts=65a98ace a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=1eGJtVPQ-MQg7gw_q08A: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=ijwFGFLWuIuGaw/dsE/CpHOYkL79oRjGyZTxQTtPkro=; b=PxYuLi50XRxEG3ZNfHEe+gS14t 3ac2HL7Hre3V1zgVCzWQc74BhzlquxmNmAVWxlp+YZr0fsUSV5XYkoAsGjYH2SEVvfknj6rJMWrXs s4DCHQ0BNQZ0XFXC1Q5AB8S/S; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3d-002DCj-1b for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:13 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:22 -0700 Subject: [PATCH v2 24/30] Only look for functions in expand_symtabs_for_function MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-24-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3d-002DCj-1b X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 26 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfEImbup/rEPcrm/c5YR1rdclawfQubXCAAP+mdODQ7P3nFyw33u0HsPcVo0eHYpt62/LLNZlXGzEGBI566VGQVDqfZSIPiTnKBT1p6GuCqlPQKJpGj72 OFecHFHuMu/6KBacbmY2sQG+WeH5f8DczrIefWzaMovxAlCFt/cJEA5EaWWK47T3a6yZmKVlqcZNXMXZKdQzyUrWGQBDIJyMp8M= X-Spam-Status: No, score=-3022.8 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, 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 This changes expand_symtabs_for_function to only look in the function domain. --- gdb/symfile-debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c index 30b02531b9c..96cdfeeb7ed 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -342,7 +342,7 @@ objfile::expand_symtabs_for_function (const char *func_name) nullptr, (SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK), - SEARCH_VFT); + SEARCH_FUNCTION_DOMAIN); } void From patchwork Thu Jan 18 20:32:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84385 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 74803385840C for ; Thu, 18 Jan 2024 20:36:57 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta034.useast.a.cloudfilter.net (omta034.useast.a.cloudfilter.net [44.202.169.33]) by sourceware.org (Postfix) with ESMTPS id 5A5803858CD1 for ; Thu, 18 Jan 2024 20:32:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5A5803858CD1 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 5A5803858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609947; cv=none; b=JNzem/8gR8BiqCPRdyvwpbaaJyjc5t9G93mSEdvOY25j6WvRX5X2Yaw8ULLzwuhwXv0/pSzlHsGvWDMeUoL5p8/tq3wi/AYCwJdtFebN/gIGN7f/5oAPVzZulBNGtdTBClLTYMMQCQFV7Gmgj8YoYYc2JZ4+/bsh2u7Xxi+QpoY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609947; c=relaxed/simple; bh=sNPy3xMq3aj/X1OtV0BGbOVO11Q5WbCMCb3cVkVc6XM=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=SpzNArBP/NB6gzzcyaXn6Fwtx6h+DWRg3OY7VcZLhAm5EJZSQSkYJxktRzNGtGc2pQ2gGY2oKz01Jsalhk2pl30WxXb/soc/t34y2pgNUrugUUbKWxmDekzbpbWYi5zIUraW3Y59ZkvbRCkktDr7ic57W/U2I8+t/aFphDYRpkw= 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 QYyCr7bw8AxAkQZ3vrR5dz; Thu, 18 Jan 2024 20:32:31 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3errY8Sl5UwQZ3erg4p2; Thu, 18 Jan 2024 20:32:14 +0000 X-Authority-Analysis: v=2.4 cv=daKTYFbe c=1 sm=1 tr=0 ts=65a98ace a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=5czC0i5-_6mFZ_pGFLkA: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=ja94WEoqwbj5eEZ6JI3OG+hXEUss4G/rhRhhSPO/EcM=; b=RiE8WK/XlDK321/EdH2hRAKAIV GOhgC+qmipAzXn9RN3pC/5E/8pV3w4qGGoG9Hqw3x91R9K1Lk10g43cSZOaVEv5ZGpY2N7B+Lh/n2 1s5CLNuF9CDYpUAbyOMbjoGl2; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3d-002DCj-2Q for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:13 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:23 -0700 Subject: [PATCH v2 25/30] Use a function-domain search in inside_main_func MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-25-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3d-002DCj-2Q X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 27 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfJfcZ0r5r1F9KI7fklmsqjqyQjGfIMqBtdfTQGPfNDITteEjjmVe3rPawqBbweoEOQGLGyt7nruXWjRtzYpTWS5Q325kdrYApOjRlQCRLNwUW5Wmw/53 xbLlcJS0gdcA4Y9Xrzr9cHspuVYRgHSEMPjr8fPY+bhnSy3HIZpLnsLyPs2J4/JR7QPUU6WkexR5fB5SxL4mAlApZpgj7OKiQdg= X-Spam-Status: No, score=-3022.9 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, 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 This changes inside_main_func to search only for functions. --- gdb/frame.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/gdb/frame.c b/gdb/frame.c index 03f3c50cb8d..7d586eef244 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -2560,13 +2560,9 @@ inside_main_func (frame_info_ptr this_frame) symbol with the name of the main function. In this case we should search the full symbols to see if we can find a match. */ struct block_symbol bs = lookup_symbol (name, nullptr, - SEARCH_VFT, nullptr); + SEARCH_FUNCTION_DOMAIN, nullptr); - /* We might have found some unrelated symbol. For example, the - Rust compiler can emit both a subprogram and a namespace with - the same name in the same scope; and due to how gdb's symbol - tables currently work, we can't request the one we'd - prefer. */ + /* This lookup should always yield a block-valued symbol. */ if (bs.symbol != nullptr && bs.symbol->aclass () == LOC_BLOCK) { const struct block *block = bs.symbol->value_block (); From patchwork Thu Jan 18 20:32:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84390 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 1D7203858283 for ; Thu, 18 Jan 2024 20:38:05 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta034.useast.a.cloudfilter.net (omta034.useast.a.cloudfilter.net [44.202.169.33]) by sourceware.org (Postfix) with ESMTPS id 374A43858427 for ; Thu, 18 Jan 2024 20:32:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 374A43858427 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 374A43858427 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609947; cv=none; b=FEq2XkBxNY6YzwOAziP8CnEJYta3b9R8KUvmPptdnTTCp286TVGWT8ZE1Gv9bydRcPxPs4gUyjsmukbKKkMQvRyOsb+/tNqHXLgr9T2rxRBvYfxToyGiT2UrTuxSWLoz8JWbRmhb71ASckC2B5Frtu9jKDC3Wa77aMUgIM4QAY8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609947; c=relaxed/simple; bh=ZnsEjaCtnpKqP1dze7NBCQN1OD8KYE47gRYGZMizjLI=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=mUh6kUEvZIg8+5HJHh2/zXWeNrdMzZhGGUZFc83knMxA1jZGnETA5Pj4258ERg9EGYwwN4Cp+ZvjsllHSbCI8mGks/13rz3xI/gUhi2X4UIMhQiwV+UtppuGYYC2Nd/2TQub1IBIhUl0zj1aDRfhUX8p/fPJ5M4noSWm2C8r7S8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6010a.ext.cloudfilter.net ([10.0.30.248]) by cmsmtp with ESMTPS id QYaDr7U9nAxAkQZ3vrR5di; Thu, 18 Jan 2024 20:32:31 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3erjZP3fPByQZ3erj6OM; Thu, 18 Jan 2024 20:32:14 +0000 X-Authority-Analysis: v=2.4 cv=T+af8tGQ c=1 sm=1 tr=0 ts=65a98ace a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=DXojhDegXKjf2IFW-d0A: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=j50eceDe+7hSgH8QTJcDU6SrLByBDCzJ9RifaAO78pA=; b=nFZZTv5ieDukjwAYk/druM4A4X 6QXUiifmzUp29cYh1GU2RwA3ijJcKvDW9E4uELn3cp7oKBcwWsv4XUTYCK4SKwfTiKHZFyiTP17GD +mNcaN2z3YfPCBeQjZs3C3OPC; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3d-002DCj-3B for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:14 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:24 -0700 Subject: [PATCH v2 26/30] Only search types in cp_lookup_rtti_type MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-26-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3d-002DCj-3B X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 28 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfEh6lU2S8Qc9Dvukjix0nXcjZUFgwGDWNnrnV3lthZ/RGIXprbi6XPeAZmOKARMUp/PQrAFQjwYmR/bQmIh7dZg74TxUEF50ArP7uku88/JebVgGN4eQ hrAh+RQcpru9L4kq26TaPyFB7xiHy9HfNwk8PNPd/Kdoj51zjcvA2UFR+nGqOProYp18p6Vf1L33OoQ4XcAIuOl5WlyFGwOo2Lk= X-Spam-Status: No, score=-3022.9 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, 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 This changes cp_lookup_rtti_type to only search for types -- not functions or variables. Due to the symbol-matching hack, this could just use SEARCH_TYPE_DOMAIN, but I think it's better to be clear; also I hold on to some hope that perhaps the hack can someday be removed. --- gdb/cp-support.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gdb/cp-support.c b/gdb/cp-support.c index 9a59d7632a1..6b7c2f5a062 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -1498,9 +1498,9 @@ cp_lookup_rtti_type (const char *name, const struct block *block) struct symbol * rtti_sym; struct type * rtti_type; - /* Use VAR_DOMAIN here as NAME may be a typedef. PR 18141, 18417. - Classes "live" in both STRUCT_DOMAIN and VAR_DOMAIN. */ - rtti_sym = lookup_symbol (name, block, SEARCH_VFT, NULL).symbol; + rtti_sym = lookup_symbol (name, block, + SEARCH_TYPE_DOMAIN | SEARCH_STRUCT_DOMAIN, + nullptr).symbol; if (rtti_sym == NULL) { From patchwork Thu Jan 18 20:32:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84387 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 A202838582A8 for ; Thu, 18 Jan 2024 20:37:22 +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 2FF913858422 for ; Thu, 18 Jan 2024 20:32:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2FF913858422 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 2FF913858422 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=1705609947; cv=none; b=OSVHPNWi/U0vMZcD7KxUd0W1h7TXsWaaBCwhDSgxLanJ+V4nmlIqeFmNmi45vXCdo3SKJiinLIhsQg1OOIA8lq7jaJ5gUqU9VkM7lT0fqzJeGgXr0QfZRUPKic0Tt9N33lzkk9sKuCzYnIgVNr9WaB73IR38dWe7H7gpbhozxPE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609947; c=relaxed/simple; bh=D7moOlxRGgY6neOUVWR1IIWVNRRrOOcsQS2GKYCMVas=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=MuobV1oNq8nLyYSAHDzMdh3Rg9Lyw0ATs6O0SE+sSYn5zS+qWj90KJSsy8hUqkIYcapXD2y7L2elJN1umEFrDJBW2lUiNpoVpXueteoYqWzUyIKXcuwfmAjd2KoLZhxT3uwJIu9YGXzZeQ5habx2y0bB6k+1dCMGgng1hxgKLU0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6002a.ext.cloudfilter.net ([10.0.30.222]) by cmsmtp with ESMTPS id QTR0rRIzGTHHuQZ3er9Wzt; Thu, 18 Jan 2024 20:32:15 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3ersCKnD6lhQZ3erjjY9; Thu, 18 Jan 2024 20:32:14 +0000 X-Authority-Analysis: v=2.4 cv=LNR1/ba9 c=1 sm=1 tr=0 ts=65a98ace a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=CCpqsmhAAAAA:8 a=cYCz3hqAlafZEMwgip4A:9 a=QEXdDO2ut3YA:10 a=ul9cdbp4aOFLsgKbc677:22 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=3tQIfZ/iXxh8mHadK1C4FzNNkDXdyhxya7a7ZsFLciI=; b=aHFY9YGTC5mjeqM/81nk+RVc6q Yw3n3MHdf3z76PjiqmgveFuxL+h3H18SDPPeELEQ0pVRuWUHG6P52r8fiJCUqW8uDXFgagvWUgO5U IeJRkSPFQ9PJTTWka0R/SR2Uz; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3e-002DCj-0k for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:14 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:25 -0700 Subject: [PATCH v2 27/30] Only search types in lookup_typename MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-27-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3e-002DCj-0k X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 29 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfHqjiEwPF2msSW9kqMEfBFiGoBvEV96I1zVvcOUVnbuaokvbpYR9gMLxtSBNUphDbMcoLLXlWCt9epgfGc0KvxLUB9C8ZsQdcFEJpytAF6ynCMO+3cHd HcP6PFpGs9GFxB701tlTnGivOKHzYj1GGZ1xWywEvvHXWH6gRTKPmDV/URWLjjXu4Xb5SZH75ps018Jik01GyX5MkTQHrAEwmuk= X-Spam-Status: No, score=-3022.9 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, 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 This changes lookup_typename to only look for types. The check for LOC_TYPEDEF can now also be removed, because only types will appear in TYPE_DOMAIN. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=24870 --- gdb/gdbtypes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 970a9e4a4a5..a48c4c8abf2 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1655,9 +1655,9 @@ lookup_typename (const struct language_defn *language, { struct symbol *sym; - sym = lookup_symbol_in_language (name, block, SEARCH_VFT, + sym = lookup_symbol_in_language (name, block, SEARCH_TYPE_DOMAIN, language->la_language, NULL).symbol; - if (sym != NULL && sym->aclass () == LOC_TYPEDEF) + if (sym != nullptr) { struct type *type = sym->type (); /* Ensure the length of TYPE is valid. */ From patchwork Thu Jan 18 20:32:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84392 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 B3BE33858291 for ; Thu, 18 Jan 2024 20:38:43 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta038.useast.a.cloudfilter.net (omta038.useast.a.cloudfilter.net [44.202.169.37]) by sourceware.org (Postfix) with ESMTPS id 9F0613858283 for ; Thu, 18 Jan 2024 20:32:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9F0613858283 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 9F0613858283 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609947; cv=none; b=LHcYjMhu6wScjsx0clIvGSAobBhf5EIZgDQu178Dbv965m+oXcQwex+dl6wOXUC+LFl6qpD8bgbEP2hKESmY5HS1Gd/RVBVQzDpmsGlZ9FbB5j+3KLMEM0vz7e+RNeVLJUGhoVUhGsVnqvvfiYF2tzIk/GKeUPorApj3KvKo82g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609947; c=relaxed/simple; bh=VVlcwxdIU8464VONUN7Cna1yYiHJWxgkMe+v8fTBIfw=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=JEbx0okbSG7IAXULDnn9ZEeoR6Wz7VR/cGFfqlTY31DzaBdc0dFXP/uqvJzrLPPRA/Tog5BMowMymK00bqDgp3FkG4sksR8V6rgeZfzuYt0Q8dbKnc+jK/T60NtQ67ezUwQ1bm/FrFUJ2yIoKAKUcRWD2bAMdR8vv4mxHzsYcpU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6010a.ext.cloudfilter.net ([10.0.30.248]) by cmsmtp with ESMTPS id QPBtrNNfO9gG6QZ3frf5z8; Thu, 18 Jan 2024 20:32:15 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3erjZPYfPByQZ3erj6Ov; Thu, 18 Jan 2024 20:32:15 +0000 X-Authority-Analysis: v=2.4 cv=T+af8tGQ c=1 sm=1 tr=0 ts=65a98acf a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=nqHERdTwHaLE-7x9c5UA: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=MO+IFBhExHWWXMyZ6HwsehL3Ww3lZtrMnvbcSNUDT1s=; b=VbuP3MDxzdg5lLt+zl33O/Srsk GW3z6bZDBbPSNZoSnluMzwtKkA4DpylXkDmvEVBmILMkzA+5ZnBrMHP73j11foGSvTT/6SvPl/y41 oiO9YlFOJxA9BrvrbZu1SF/jZ; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3e-002DCj-1X for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:14 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:26 -0700 Subject: [PATCH v2 28/30] Only search for functions in rust_structop::evaluate_funcall MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-28-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3e-002DCj-1X X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 30 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfJ4zLZKMyR0M1VOe0UGfv05Y+J2PoNWEo8KiAVXNag4kk3iFdIqGWvixGzQH83JKlZGKUBVCwMG9PfQ/jhjWUiK/LDxnfvknX97PvpbVRltJ0WosjIlZ 236srkPK9qwrGiNqtNkgo8Ziugbed/UaO9lUmIPhde6Jwap4OMArIjIo9/tycocqSn3Fb61Bg8jLbyXY4EjfIO5P+o11LYgFzbQ= X-Spam-Status: No, score=-3022.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, 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 This changes rust_structop::evaluate_funcall to only search for functions. --- gdb/rust-lang.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 11c7f13417d..e0b5a887a23 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1563,7 +1563,7 @@ rust_structop::evaluate_funcall (struct type *expect_type, const struct block *block = get_selected_block (0); struct block_symbol sym = lookup_symbol (name.c_str (), block, - SEARCH_VFT, + SEARCH_FUNCTION_DOMAIN, nullptr); if (sym.symbol == NULL) error (_("Could not find function named '%s'"), name.c_str ()); From patchwork Thu Jan 18 20:32:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84393 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 00990385840D for ; Thu, 18 Jan 2024 20:38:47 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id C8F6C3858286 for ; Thu, 18 Jan 2024 20:32:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C8F6C3858286 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 C8F6C3858286 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609952; cv=none; b=VnOiZOl7ePieA8Jpq0lWrCkL6xHSfcX9j1g+fwuqDm8SHB0lpER0PN74MQ/0QwgAPeNIrwECxLRNSA7wk3UXKy5jMmjWyGZT88fMDwGvFzlkoAc6bzn27xfjtkllc0Ta1mztcRpzP6wCXiwDnSMQDaK9ae0H7CA665bLN74JC0U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609952; c=relaxed/simple; bh=ABJbJcUDHmf0XlsZlHl4ZfN61QbUHa8FY6Iv9N4ygok=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=HZpVp5lN4gNwIPFamOkMmWrGgFTYQjOHMwrgybOibtlKycixpJA+WDj+cC/NO8Xg8uGvdDUK2LI0oAN/dNU0iu7oiIEL0RqKNIPerzFdPtzco26n5jKVyNOgDmRTMgJdnjm2/od5HykWZzqzjXfsudLQNQRmZpea3kjCvmAJpLQ= 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 QPLXrG21e8uLRQZ3frw3EP; Thu, 18 Jan 2024 20:32:15 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3erhTg1tzh2QZ3frbVP2; Thu, 18 Jan 2024 20:32:15 +0000 X-Authority-Analysis: v=2.4 cv=Ra6Dtnhv c=1 sm=1 tr=0 ts=65a98acf a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=ABg-ZwUhIPAXn4CSIH0A: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=MS6FMHWSJTJI/fkCAVZytNPXAy4koF9/7L00r2XSxRs=; b=k0gauXqkA8XhIL9XpMOMb25Nry sLtd7QOg5VdsyGfOITVGe83bC1rzaA6T/CAcjqaBdiDKj+oORjH1NudEs4QRuiGk4HvrKc2Z+vzsZ mwq/URjTogWNv9hG2dj7jZq+Q; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3e-002DCj-2K for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:14 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:27 -0700 Subject: [PATCH v2 29/30] Refine search in cp_search_static_and_baseclasses MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-29-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3e-002DCj-2K X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 31 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfFBdZgFq+sciiwNlvVKMAWcR1w+3NSWFRfaznGvnRDdY13GlIP2qzeTS7O5duZqSAxLQb9wLN1UXCBqk5mWToSr9c9zNsLaV7yHthKrMpjt6zfRSs9h6 3klWAShnUzqu3Gua36kbK2pkzsF7hS2ziPj3h6ISveQB4/2rCwGrtxlSnn8YUkAOF8saSCbZ2I61c7U0ac1dlDfwjJTQvuwJXuY= X-Spam-Status: No, score=-3022.9 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, 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 This changes cp_search_static_and_baseclasses to only search for types, functions, and modules. The latter two cases were discovered by regression testing. I found it somewhat surprising the Fortran name lookup ends up in this code, but did not attempt to change this. --- gdb/cp-namespace.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index 593340af350..41ab52de54a 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -268,14 +268,19 @@ cp_search_static_and_baseclasses (const char *name, const char *nested = name + prefix_len + 2; /* Lookup the scope symbol. If none is found, there is nothing more - that can be done. SCOPE could be a namespace, so always look in - VAR_DOMAIN. This works for classes too because of - symbol_matches_domain (which should be replaced with something - else, but it's what we have today). */ - block_symbol scope_sym = lookup_symbol_in_static_block (scope.c_str (), - block, SEARCH_VFT); + that can be done. SCOPE could be a namespace, a class, or even a + function. This code is also used by Fortran, so modules are + included in the search as well. */ + block_symbol scope_sym + = lookup_symbol_in_static_block (scope.c_str (), block, + SEARCH_TYPE_DOMAIN + | SEARCH_FUNCTION_DOMAIN + | SEARCH_MODULE_DOMAIN); if (scope_sym.symbol == NULL) - scope_sym = lookup_global_symbol (scope.c_str (), block, SEARCH_VFT); + scope_sym = lookup_global_symbol (scope.c_str (), block, + SEARCH_TYPE_DOMAIN + | SEARCH_FUNCTION_DOMAIN + | SEARCH_MODULE_DOMAIN); if (scope_sym.symbol == NULL) return {}; From patchwork Thu Jan 18 20:32:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84394 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 D4BE3385840A for ; Thu, 18 Jan 2024 20:39:44 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id 89F733858412 for ; Thu, 18 Jan 2024 20:38:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 89F733858412 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 89F733858412 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705610293; cv=none; b=DYChojQt0nZ2nb5DFC/hMVogUdCOibMBseDez+kE14rDZBfuyciltVs/tJD0m6dYNpQP/zQ+hxUCG0E+aG+N5XP6yLsjZIvGyNRjq6SuKdG0cS6eNlSlp18nOmfjapjdVajCkYzZh3tYilAItrgAdgb1Q9SMESPA5STPDuKFjpU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705610293; c=relaxed/simple; bh=ld4/bGCG3GvzfuEuzGnJkSqHTjWJF8Af0jYYReJQHpo=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=IyDzh3GmI36g9Dh2ObYbXHomXhJqShIyqJWbDRAQ/LY7fydZ2CskkRHirCvdo1xekzSRKePaPe+QeTG98IoVm7AxiLVWzraz3DotO937CdlQX40hU/NcMKRSlM9zGrzlKwYReyRBw9cpK9TT94w7NdOKBN/hJMrF0q2SCtnrdHI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5010a.ext.cloudfilter.net ([10.0.29.199]) by cmsmtp with ESMTPS id QQ7vrLFqoMVQiQZ9NrEfdW; Thu, 18 Jan 2024 20:38:09 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ9Mr3eMjbhW6QZ9MrsaRO; Thu, 18 Jan 2024 20:38:09 +0000 X-Authority-Analysis: v=2.4 cv=aLPjFJxm c=1 sm=1 tr=0 ts=65a98c31 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=mDV3o1hIAAAA:8 a=7s7ocBhQw26AErY8W1oA:9 a=QEXdDO2ut3YA:10 a=_FVE-zBwftR9WsbkzFJk:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To: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=rZErj0sQ4ueRyfbqxoR6mTVM0CdJx25QTSwG97kSMQo=; b=uY5FjyZA9rfvLV6KUgxHVclho/ bbMLorGReLIRKaM1CYS/3iBRWZXs7rwORkRrOpTzSuIQ5rONzQe3bAyfPQRmZ3ydgT8uDsp/bD5tu HlgdsLL36E4tBn/oJDi+6vPKl; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 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 1rQZ3f-002DCj-0a; Thu, 18 Jan 2024 13:32:15 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:28 -0700 Subject: [PATCH v2 30/30] Document new Python and Guile constants MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-30-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> To: gdb-patches@sourceware.org Cc: Eli Zaretskii 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.68.157 X-Source-L: No X-Exim-ID: 1rQZ3f-002DCj-0a X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 37 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfL8euQzDkS07pCktwo6zLIDOBLqj8EpbjRrKOk5JoRo4/yf4cXEHEpfJjtQf9ZoyPVkziO/sSDqSykOl7OZxrA2N3h4djlE8fDtVf9RcZINptw1ZGmjf 6RZsouq4txrUoN7Y3bcS6mMWzsmbYlcA49rQ+bRujXjGNWi0hGiLpmCLH7JMCStwl5bKsf+y+LS6Wos8az6/tGLJ4ULY5DXyLy8= X-Spam-Status: No, score=-3022.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, 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 This documents the new Python and Guile constants introduced earlier in this series. Reviewed-By: Eli Zaretskii --- gdb/NEWS | 12 ++++++++++++ gdb/doc/guile.texi | 13 +++++++++++++ gdb/doc/python.texi | 30 +++++++++++++++++++++++++++--- 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index bab300e36b8..2638b3e0d9c 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -108,6 +108,11 @@ show remote thread-options-packet object, these will be stored in the object's new InferiorThread.__dict__ attribute. + ** New constants gdb.SYMBOL_TYPE_DOMAIN, gdb.SYMBOL_FUNCTION_DOMAIN, + and gdb.SEARCH_*_DOMAIN corresponding to all the existing symbol + domains. Symbol lookup can now search in multiple domains at + once, and can also narrowly search for just a type or function. + * Debugger Adapter Protocol changes ** GDB now emits the "process" event. @@ -121,6 +126,13 @@ show remote thread-options-packet ** The "set debug dap-log-file" command is now documented. This command was available in GDB 14 but not documented. +* Guile API + + ** New constants SYMBOL_TYPE_DOMAIN, SYMBOL_FUNCTION_DOMAIN, and + SEARCH_*_DOMAIN corresponding to all the existing symbol domains. + Symbol lookup can now search in multiple domains at once, and can + also narrowly search for just a type or function. + * New remote packets New stop reason: clone diff --git a/gdb/doc/guile.texi b/gdb/doc/guile.texi index 271b672fdc6..483a96fb592 100644 --- a/gdb/doc/guile.texi +++ b/gdb/doc/guile.texi @@ -2802,6 +2802,14 @@ in the symbol information or in @value{GDBN}'s handling of symbols. This domain contains variables, function names, typedef names and enum type values. +@item SYMBOL_FUNCTION_DOMAIN +This domain contains functions. + +@item SYMBOL_TYPE_DOMAIN +This domain contains types. In a C-like language, types using a tag +will not appear here; in other languages, all types are in this +domain. + @item SYMBOL_STRUCT_DOMAIN This domain holds struct, union and enum type names. @@ -2822,6 +2830,11 @@ This domain contains all types. The available address class categories in @code{} are represented as constants in the @code{gdb} module: +When searching for a symbol, the desired domain constant can be passed +verbatim to the lookup function. For more complex searches, there is +a corresponding set of constants using a @samp{SEARCH_} prefix. These +may be or'd together to form a search constant. + @vtable @code @item SYMBOL_LOC_UNDEF If this is returned by address class, it indicates an error either in diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index 71431878dd3..906775c5711 100644 --- a/gdb/doc/python.texi +++ b/gdb/doc/python.texi @@ -6214,12 +6214,22 @@ in the symbol information or in @value{GDBN}'s handling of symbols. @vindex SYMBOL_VAR_DOMAIN @item gdb.SYMBOL_VAR_DOMAIN -This domain contains variables, function names, typedef names and enum -type values. +This domain contains variables. + +@vindex SYMBOL_FUNCTION_DOMAIN +@item gdb.SYMBOL_FUNCTION_DOMAIN +This domain contains functions. + +@vindex SYMBOL_TYPE_DOMAIN +@item gdb.SYMBOL_TYPE_DOMAIN +This domain contains types. In a C-like language, types using a tag +will not appear here; in other languages, all types are in this +domain. @vindex SYMBOL_STRUCT_DOMAIN @item gdb.SYMBOL_STRUCT_DOMAIN -This domain holds struct, union and enum type names. +This domain holds struct, union and enum tag names. This domain is +only used for C-like languages. @vindex SYMBOL_LABEL_DOMAIN @item gdb.SYMBOL_LABEL_DOMAIN @@ -6234,6 +6244,20 @@ This domain contains names of Fortran module types. This domain contains names of Fortran common blocks. @end vtable +When searching for a symbol, the desired domain constant can be passed +verbatim to the lookup function. For example: +@smallexample +symbol = gdb.lookup_symbol ("name", domain=gdb.SYMBOL_VAR_DOMAIN) +@end smallexample + +For more complex searches, there is a corresponding set of constants +using a @samp{SEARCH_} prefix. These may be or'd together to form a +search constant, e.g.: +@smallexample +symbol = gdb.lookup_symbol ("name", + domain=gdb.SEARCH_VAR_DOMAIN | gdb.SEARCH_TYPE_DOMAIN) +@end smallexample + The available address class categories in @code{gdb.Symbol} are represented as constants in the @code{gdb} module: