From patchwork Mon Apr 8 21:11:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 88201 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 41C843846062 for ; Mon, 8 Apr 2024 21:12:19 +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 A650C3858CD1 for ; Mon, 8 Apr 2024 21:11:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A650C3858CD1 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 A650C3858CD1 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=1712610704; cv=none; b=scFaQrKcUm+zsnWUk7PXquCJ01Nno/XVeHVtk9AsbhVMSRH5IbscWTvQo3r1QW070Mii53JJ5/yro5IBGRGvyxI8PHehOO2V9OeyWQEyLSe5eGVrymgR0ClclM3HpI9SNWb1abrcuWrhF9EdsIUcNJX/rYvuOi0SjY4IBBFFvqA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712610704; c=relaxed/simple; bh=R4GseACGFcr/OkRwyoadRIY7+xmjmis8Wc5JE4WC9MI=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=BrnMzRt+T1ZbRluL6FMlO/PgcqXK7GVe8QjmfG6BgoYGtK+sT5RgZF2GSxJ49/k9CuONqrpoBJGX+UeFpd7kr8MekfFfzYnaJ2nWdyfB6Mf2y8HZ1ZugoU4u56VdGMOVKhck3oXvLvsm0ouKvtMqcpzObzoD4xad7e5Gyafp24o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6009a.ext.cloudfilter.net ([10.0.30.184]) by cmsmtp with ESMTPS id ticzrmG33PM1htwHFrqiSK; Mon, 08 Apr 2024 21:11:41 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id twHFrnUIhnNCOtwHFrgmSQ; Mon, 08 Apr 2024 21:11:41 +0000 X-Authority-Analysis: v=2.4 cv=DKCJ4TNb c=1 sm=1 tr=0 ts=66145d8d a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=raytVjVEu-sA:10 a=Qbun_eYptAEA:10 a=Td9QFZFMXtiXauygS9YA:9 a=QEXdDO2ut3YA:10 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=Hyg1ASTb+Dl6Pkj77tVYPrFImN8cA/0E5N8IP2/7kfM=; b=pviqriVGdS5ZuTa18BhwreZJqe C5WLHpXcGG8vADmzq8rgQLNWW32CzmBX2Xs4nv3S6VZg8RQb9LIvBI6yvrZV3bzatwK5Bt8n9ZU0T Aqn8cvMteZm+9TMiCJG7TwQz2; Received: from 97-122-82-115.hlrn.qwest.net ([97.122.82.115]:54230 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 1rtwHF-001uXf-07; Mon, 08 Apr 2024 15:11:41 -0600 From: Tom Tromey Date: Mon, 08 Apr 2024 15:11:37 -0600 Subject: [PATCH gdb/symtab v2 1/7] Refactor condition in scan_attributes MIME-Version: 1.0 Message-Id: <20240408-die-map-madness-v2-1-6741626d544d@tromey.com> References: <20240408-die-map-madness-v2-0-6741626d544d@tromey.com> In-Reply-To: <20240408-die-map-madness-v2-0-6741626d544d@tromey.com> To: gdb-patches@sourceware.org Cc: Tom de Vries 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.82.115 X-Source-L: No X-Exim-ID: 1rtwHF-001uXf-07 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-82-115.hlrn.qwest.net ([192.168.0.21]) [97.122.82.115]:54230 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: MS4xfDdj4ryVgLgj9UDNh+9BthUnwSyYTgiUo+BWguCqQR01G/1Ry4cRGpo0lGqT+zs/n1CgMsXoeF+nvcxQKx975fxWlxS4l1yOrf9sOrS24AfUnytQmN42 yI3A5UDlPjCbEnpv4Fbg52DWAvHN2NDwJo6oEYomPxNoyDz3IPAcCijdQ9QLKI9ii+2HMs5k0J1OmbowsasBlOK5tmcq7gZD5LQ= X-Spam-Status: No, score=-3021.5 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 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 From: Tom de Vries In scan_attributes there's code: ... if (new_reader->cu == reader->cu && new_info_ptr > watermark_ptr && *parent_entry == nullptr) ... else if (*parent_entry == nullptr) ... ... that uses the "*parent_entry == nullptr" condition twice. Make this somewhat more readable by factoring out the condition: ... if (*parent_entry == nullptr) { if (new_reader->cu == reader->cu && new_info_ptr > watermark_ptr) ... else ... } ... This also allows us to factor out "form_addr (origin_offset, origin_is_dwz)". Tested on x86_64-linux. --- gdb/dwarf2/read.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 9e37011ddf0..7b306d8594c 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -16267,15 +16267,17 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu, const gdb_byte *new_info_ptr = (new_reader->buffer + to_underlying (origin_offset)); - if (new_reader->cu == reader->cu - && new_info_ptr > watermark_ptr - && *parent_entry == nullptr) - *maybe_defer = form_addr (origin_offset, origin_is_dwz); - else if (*parent_entry == nullptr) + if (*parent_entry == nullptr) { - CORE_ADDR lookup = form_addr (origin_offset, origin_is_dwz); - void *obj = m_die_range_map.find (lookup); - *parent_entry = static_cast (obj); + CORE_ADDR addr = form_addr (origin_offset, origin_is_dwz); + if (new_reader->cu == reader->cu + && new_info_ptr > watermark_ptr) + *maybe_defer = addr; + else + { + void *obj = m_die_range_map.find (addr); + *parent_entry = static_cast (obj); + } } unsigned int bytes_read; From patchwork Mon Apr 8 21:11:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 88202 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 658E23846411 for ; Mon, 8 Apr 2024 21:12:23 +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 BF5103858CDA for ; Mon, 8 Apr 2024 21:11:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BF5103858CDA 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 BF5103858CDA 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=1712610704; cv=none; b=p8GL9FEJkJzMOdnerB2nTHThi3mLAcPuoYwvuqaHGcwEeccNrWw+ckU9/nASsgLNUR3+wRZuP+pnoZHT2612EMdES6KWHdTZ7yhxBNYPR3z12E4JbA+XOiOUN60eTQSKzspeR1us9LFCnH7MMf+UigwTkQDW0luy0HJhjL7U9z4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712610704; c=relaxed/simple; bh=z/qRhqhU7sOBh2EuB5XiZqCt0iSSR/hPK+yQAdJdgrw=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=E7ktSCvd2AXh5tBQnqGi0tJs0i9sJuPMYvzVf5kOglUgRUMWsFEWwAwX4vF0YNvnELsU+CJX2FFZ051grXnTBpE2UPlOIAtIr3Ujw3zj5xoTIUn6hX6ibosf9fLPijGKZ9ShyE9f8TP1XJJOonkxX1mT/YMA3MLKy6sTeX1CQVU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6004a.ext.cloudfilter.net ([10.0.30.197]) by cmsmtp with ESMTPS id trCnrYgAatf2QtwHFrySf0; Mon, 08 Apr 2024 21:11:41 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id twHFr7oOVuv6XtwHFrNuCl; Mon, 08 Apr 2024 21:11:41 +0000 X-Authority-Analysis: v=2.4 cv=YbZ25BRf c=1 sm=1 tr=0 ts=66145d8d a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=raytVjVEu-sA:10 a=Qbun_eYptAEA:10 a=AMDE52p7lMkdf-nf6v4A: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=UsqE4FQuCtSj99I/gbMUXstpjRF0Vs2vIowVJjbM6PY=; b=HuAzTeYMmDr2KA3GILt4b5GrVY ZyfrPZZA5R6N4fOi5Ep0KOaQ3mk/gQ3J4nTu6v6jE2rdEq3PeKr3nCgIkfgl5LEhEmz/Q3AF6hRbb +wB/AS7fJqJ20zcVNuFT69JOr; Received: from 97-122-82-115.hlrn.qwest.net ([97.122.82.115]:54230 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 1rtwHF-001uXf-0a for gdb-patches@sourceware.org; Mon, 08 Apr 2024 15:11:41 -0600 From: Tom Tromey Date: Mon, 08 Apr 2024 15:11:38 -0600 Subject: [PATCH v2 2/7] Change handling of DW_TAG_enumeration_type in DWARF scanner MIME-Version: 1.0 Message-Id: <20240408-die-map-madness-v2-2-6741626d544d@tromey.com> References: <20240408-die-map-madness-v2-0-6741626d544d@tromey.com> In-Reply-To: <20240408-die-map-madness-v2-0-6741626d544d@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.82.115 X-Source-L: No X-Exim-ID: 1rtwHF-001uXf-0a X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-82-115.hlrn.qwest.net ([192.168.0.21]) [97.122.82.115]:54230 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: MS4xfHN4hX+eVoISEQ0VN68ttL2FI+o59Ny5LqkjKuNlo2RFOrvLlR+c2N/cO4pu/y/i7kgHTxffmnR46HABWLeW5KxaWFdzyCImikY6qOTEXe1xEANYR39g l8punp1p1ULsju//tBmacSoctFfeNUQ0VEV2TjJp5EseanjOHE90agloYPUxkC70oI7P2mMv+BSbw12qFmqG+dbda3XJ76wcwg0= X-Spam-Status: No, score=-3021.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Currently the DWARF scanner will enter enumeration constants into the same namespace as the DW_TAG_enumeration_type itself. This is the right thing to do, but the implementation may result in strange entries being added to the addrmap that maps DIE ranges to entries. This came up when debugging an earlier version of this series; and while I don't think this should impact the current series, it seems better to clean this up anyway. In the new code, rather than pass the "wrong" scope down through recursive calls to the scanner, the correct scope is always passed, and then the parent handling is done when creating the enumerator entry. --- gdb/dwarf2/read.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 7b306d8594c..b54b381aef3 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -16469,6 +16469,12 @@ cooked_indexer::index_dies (cutu_reader *reader, flags &= ~IS_STATIC; flags |= parent_entry->flags & IS_STATIC; } + /* If the parent is an enum, but not an enum class, then use the + grandparent instead. */ + if (this_parent_entry != nullptr + && this_parent_entry->tag == DW_TAG_enumeration_type + && !is_enum_class) + this_parent_entry = this_parent_entry->get_parent (); if (abbrev->tag == DW_TAG_namespace && m_language == language_cplus @@ -16531,15 +16537,7 @@ cooked_indexer::index_dies (cutu_reader *reader, break; case DW_TAG_enumeration_type: - /* We need to recurse even for an anonymous enumeration. - Which scope we record as the parent scope depends on - whether we're reading an "enum class". If so, we use - the enum itself as the parent, yielding names like - "enum_class::enumerator"; otherwise we inject the - names into our own parent scope. */ - info_ptr = recurse (reader, info_ptr, - is_enum_class ? this_entry : parent_entry, - fully); + info_ptr = recurse (reader, info_ptr, this_entry, fully); continue; case DW_TAG_module: From patchwork Mon Apr 8 21:11:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 88204 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 44E16384646C for ; Mon, 8 Apr 2024 21:12: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 DC84A3858408 for ; Mon, 8 Apr 2024 21:11:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DC84A3858408 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 DC84A3858408 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=1712610704; cv=none; b=iChmrkBRIwcrdtT5ALO5aSyYjUflalGJUW7SkoEtj0YnCqhyUdLlY5DCaaL67FrCa/XUTtNiC4JMwz+qHoJKPUXdXw89kqdrPYe6DjvlrPP9lPS8vU7Gqkauhc4nh6V+NgqDGSqoPpIo3m2QdFV2QYGd/aFK2ZA6ZrDboKxJwJs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712610704; c=relaxed/simple; bh=ocXt6XkxBRJVDtsnn4FmvvaWTL7JUy6zdCjPIUKTR9I=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=tWic0jCfGLDU03sQElKcCMw/tLLpxsR8r1PXetzJ8sU++e3iDvUr/diEp3bYftl714D2GMemD5oUAu1uJNaydGvMiMEiXlA18u6kybduUAC3StH2jzqzkRIn4pGYcHW2r69Jb21KdMlXfY/7hN+kQ/0r6/ktQEtLDGTI2IJxipE= 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 trADriY6Ts4yTtwHGr7OE4; Mon, 08 Apr 2024 21:11:42 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id twHFrqYLssT9BtwHFr9SXn; Mon, 08 Apr 2024 21:11:42 +0000 X-Authority-Analysis: v=2.4 cv=LIutQ4W9 c=1 sm=1 tr=0 ts=66145d8e a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=raytVjVEu-sA:10 a=Qbun_eYptAEA:10 a=rxEfz5amTwgwtFEVBNsA: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=Kb/XCMxHFNuknDnYx65GjK8JnjZSen0Tji2nHWjH9H4=; b=T8g6y9tBZnEcwwBIqKbnaGNhdR hai5XVjwTjjFSKAA9lhfOpJegaiBsloMRgbKN1/jlLsCu2RM8TtBpP2NxrQMZiNgAdtWLAg3HcjKE TcdKjnbks3x5LER1eFD7Z2htW; Received: from 97-122-82-115.hlrn.qwest.net ([97.122.82.115]:54230 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 1rtwHF-001uXf-19 for gdb-patches@sourceware.org; Mon, 08 Apr 2024 15:11:41 -0600 From: Tom Tromey Date: Mon, 08 Apr 2024 15:11:39 -0600 Subject: [PATCH v2 3/7] Add move operators for addrmap MIME-Version: 1.0 Message-Id: <20240408-die-map-madness-v2-3-6741626d544d@tromey.com> References: <20240408-die-map-madness-v2-0-6741626d544d@tromey.com> In-Reply-To: <20240408-die-map-madness-v2-0-6741626d544d@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.82.115 X-Source-L: No X-Exim-ID: 1rtwHF-001uXf-19 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-82-115.hlrn.qwest.net ([192.168.0.21]) [97.122.82.115]:54230 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: MS4xfDgF/WoRjQVsYhwWCvNZekJEZadzQiikhHgCn1y6yQUYKy5BL39qY2uYbSS3ubgVfS9a2owlbtIJja/xG2FNsABQHYznhkt5klZ1dPuUc8lAYOokJlPL yTmkYUX6qZdVSB5ctgaWwG1Qat57lUbAW0NqDybemSpNNbu5JChwb/RZopNalKUUc9q1ZdVnrWbFcyHiZwhBYkfWATxqhuSkilo= X-Spam-Status: No, score=-3021.5 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 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 subsequent patch needs to move an addrmap. This patch adds the necessary support. It also changes addrmap_fixed to take a 'const' addrmap_mutable. This is fine according to the contract of addrmap_mutable; but it did require a compensating const_cast in the implementation. --- gdb/addrmap.c | 12 +++++++----- gdb/addrmap.h | 19 ++++++++++++++++++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/gdb/addrmap.c b/gdb/addrmap.c index 0c60c0c2ceb..c6e037330ec 100644 --- a/gdb/addrmap.c +++ b/gdb/addrmap.c @@ -250,12 +250,13 @@ addrmap_mutable::do_find (CORE_ADDR addr) const } -addrmap_fixed::addrmap_fixed (struct obstack *obstack, addrmap_mutable *mut) +addrmap_fixed::addrmap_fixed (struct obstack *obstack, + const addrmap_mutable *mut) { size_t transition_count = 0; /* Count the number of transitions in the tree. */ - mut->foreach ([&] (CORE_ADDR start, void *obj) + mut->foreach ([&] (CORE_ADDR start, const void *obj) { ++transition_count; return 0; @@ -273,10 +274,10 @@ addrmap_fixed::addrmap_fixed (struct obstack *obstack, addrmap_mutable *mut) /* Copy all entries from the splay tree to the array, in order of increasing address. */ - mut->foreach ([&] (CORE_ADDR start, void *obj) + mut->foreach ([&] (CORE_ADDR start, const void *obj) { transitions[num_transitions].addr = start; - transitions[num_transitions].value = obj; + transitions[num_transitions].value = const_cast (obj); ++num_transitions; return 0; }); @@ -344,7 +345,8 @@ addrmap_mutable::addrmap_mutable () addrmap_mutable::~addrmap_mutable () { - splay_tree_delete (tree); + if (tree != nullptr) + splay_tree_delete (tree); } diff --git a/gdb/addrmap.h b/gdb/addrmap.h index ed52e3cd990..5378b753760 100644 --- a/gdb/addrmap.h +++ b/gdb/addrmap.h @@ -85,9 +85,14 @@ struct addrmap_fixed final : public addrmap, { public: - addrmap_fixed (struct obstack *obstack, addrmap_mutable *mut); + addrmap_fixed (struct obstack *obstack, const addrmap_mutable *mut); DISABLE_COPY_AND_ASSIGN (addrmap_fixed); + /* It's fine to use the default move operators, because this addrmap + does not own the storage for the elements. */ + addrmap_fixed (addrmap_fixed &&other) = default; + addrmap_fixed &operator= (addrmap_fixed &&) = default; + void relocate (CORE_ADDR offset) override; private: @@ -124,6 +129,18 @@ struct addrmap_mutable final : public addrmap ~addrmap_mutable (); DISABLE_COPY_AND_ASSIGN (addrmap_mutable); + addrmap_mutable (addrmap_mutable &&other) + : tree (other.tree) + { + other.tree = nullptr; + } + + addrmap_mutable &operator= (addrmap_mutable &&other) + { + std::swap (tree, other.tree); + return *this; + } + /* In the mutable address map MAP, associate the addresses from START to END_INCLUSIVE that are currently associated with NULL with OBJ instead. Addresses mapped to an object other than NULL are left From patchwork Mon Apr 8 21:11:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 88205 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 678A83846401 for ; Mon, 8 Apr 2024 21:12:57 +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 D9AB53858C39 for ; Mon, 8 Apr 2024 21:11:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D9AB53858C39 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 D9AB53858C39 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=1712610705; cv=none; b=FF3j224ZoReufxFjRF3uWZp2TDpJsy9zGwcSSxVSNFXTFHUrpGREOTWZQC6wOX8XAORaGQPm9SIVLYjSHGUYdFpDrj4EqeYRyH0xWL1wqqee6jr7kEzZnBnzVQwk3RpUbv0Gf+eOXQhXsidzsYyabDnxcZBeJ6ZTGE5KSv0b+uw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712610705; c=relaxed/simple; bh=TMA7t4zIQJxDM+1e6DbswdbwH5Y/0HHeSFP2EU0owns=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=M6CO/zEKS2XP1nW1Cw/GnB0iuaeF8qrDPMYpcppv3lwWRoKN6Y4pXf/Fk6VzxumSNiQ2RY5aaHrr5fAMMz8igQ6VVJDz+KNfJjm7Shc5gJ1zyiXfztl6qR8EQlQcYTrTzH0PhxWUNUQY3a4glwkULbZLZGfkBerhjoqBgLXynV0= 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 tiTor8a3TQr4StwHGrdAZ3; Mon, 08 Apr 2024 21:11:42 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id twHFrvFFa9zHMtwHGrEL4z; Mon, 08 Apr 2024 21:11:42 +0000 X-Authority-Analysis: v=2.4 cv=fo4XZ04f c=1 sm=1 tr=0 ts=66145d8e a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=raytVjVEu-sA:10 a=Qbun_eYptAEA:10 a=mDV3o1hIAAAA:8 a=Q54NkQ1-krxB2HtNLs4A: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=E9KMlcvKu50N4mMwQf2R+E8nexowdKPIB3p7R4ePsDg=; b=aKR37cUMMYhA7f+1s2hmfPYUft 4RVTC49p7kitsd2FodEspfTZJ9bQhcFj2cubch2FATS4V5G/Za4mkNHkjACmTzlasmewiQqticBd8 tfP4OzR0f6fuIyOAhJA3/eNsz; Received: from 97-122-82-115.hlrn.qwest.net ([97.122.82.115]:54230 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 1rtwHF-001uXf-1i; Mon, 08 Apr 2024 15:11:41 -0600 From: Tom Tromey Date: Mon, 08 Apr 2024 15:11:40 -0600 Subject: [PATCH v2 4/7] Introduce class parent_map for DIE range map MIME-Version: 1.0 Message-Id: <20240408-die-map-madness-v2-4-6741626d544d@tromey.com> References: <20240408-die-map-madness-v2-0-6741626d544d@tromey.com> In-Reply-To: <20240408-die-map-madness-v2-0-6741626d544d@tromey.com> To: gdb-patches@sourceware.org Cc: Tom de Vries 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.82.115 X-Source-L: No X-Exim-ID: 1rtwHF-001uXf-1i X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-82-115.hlrn.qwest.net ([192.168.0.21]) [97.122.82.115]:54230 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: MS4xfEtXcCYdL7LJqgL6gedX2HTgvJs61IJPEHHQtQSmTFLWLDkBfu2ExdTMNDvVdg+Rz+C4iVt/U60RrDC/k3Dy4VIXFpIWlAyPW5dy28mEBGgdKajl82UM dTGgg13EZzKdBoHUbhjaUACr/btIuVRDgLy0akiChndHcCTg95LSicjCcx4ynbouM8bJ9dcZ0k1ZBP+NPZIjlFGvYxvQajTS1sQ= X-Spam-Status: No, score=-3021.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This changes the DIE range map from a raw addrmap to a custom class. A new type is used to represent the ranges, in an attempt to gain a little type safety as well. Note that the new code includes a map-of-maps type. This is not used yet, but will be used in the next patch. Co-Authored-By: Tom de Vries --- gdb/dwarf2/cooked-index.h | 7 +-- gdb/dwarf2/parent-map.h | 132 ++++++++++++++++++++++++++++++++++++++++++++++ gdb/dwarf2/read.c | 46 +++++++--------- 3 files changed, 154 insertions(+), 31 deletions(-) diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index 7ff609b9d73..6400750b587 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -35,6 +35,7 @@ #include "dwarf2/read.h" #include "dwarf2/tag.h" #include "dwarf2/abbrev-cache.h" +#include "dwarf2/parent-map.h" #include "gdbsupport/range-chain.h" #include "gdbsupport/task-group.h" #include "complaints.h" @@ -72,7 +73,7 @@ DEF_ENUM_FLAGS_TYPE (enum cooked_index_flag_enum, cooked_index_flag); union cooked_index_entry_ref { - cooked_index_entry_ref (CORE_ADDR deferred_) + cooked_index_entry_ref (parent_map::addr_type deferred_) { deferred = deferred_; } @@ -83,7 +84,7 @@ union cooked_index_entry_ref } const cooked_index_entry *resolved; - CORE_ADDR deferred; + parent_map::addr_type deferred; }; /* Return a string representation of FLAGS. */ @@ -221,7 +222,7 @@ struct cooked_index_entry : public allocate_on_obstack } /* Return deferred parent entry. */ - CORE_ADDR get_deferred_parent () const + parent_map::addr_type get_deferred_parent () const { gdb_assert ((flags & IS_PARENT_DEFERRED) != 0); return m_parent_entry.deferred; diff --git a/gdb/dwarf2/parent-map.h b/gdb/dwarf2/parent-map.h new file mode 100644 index 00000000000..f070d505356 --- /dev/null +++ b/gdb/dwarf2/parent-map.h @@ -0,0 +1,132 @@ +/* DIE indexing + + Copyright (C) 2024 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 . */ + +#ifndef GDB_DWARF2_PARENT_MAP_H +#define GDB_DWARF2_PARENT_MAP_H + +#include + +class cooked_index_entry; + +/* A class that handles mapping from a DIE range to a parent + entry. + + The generated DWARF can sometimes have the declaration for a method + in a class (or perhaps namespace) scope, with the definition + appearing outside this scope... just one of the many bad things + about DWARF. In order to handle this situation, we defer certain + entries until the end of scanning, at which point we'll know the + containing context of all the DIEs that we might have scanned. */ +class parent_map +{ +public: + + parent_map () = default; + ~parent_map () = default; + + /* Move only. */ + DISABLE_COPY_AND_ASSIGN (parent_map); + parent_map (parent_map &&) = default; + parent_map &operator= (parent_map &&) = default; + + /* A reasonably opaque type that is used here to combine a section + offset and the 'dwz' flag into a single value. */ + enum addr_type : CORE_ADDR { }; + + /* Turn a section offset into a value that can be used in a parent + map. */ + static addr_type form_addr (sect_offset offset, bool is_dwz) + { + CORE_ADDR value = to_underlying (offset); + if (is_dwz) + value |= ((CORE_ADDR) 1) << (8 * sizeof (CORE_ADDR) - 1); + return addr_type (value); + } + + /* Add a new entry to this map. DIEs from START to END, inclusive, + are mapped to PARENT. */ + void add_entry (addr_type start, addr_type end, + const cooked_index_entry *parent) + { + gdb_assert (parent != nullptr); + m_map.set_empty (start, end, (void *) parent); + } + + /* Look up an entry in this map. */ + const cooked_index_entry *find (addr_type search) const + { + return static_cast (m_map.find (search)); + } + + /* Return a fixed addrmap that is equivalent to this map. */ + addrmap_fixed *to_fixed (struct obstack *obstack) const + { + return new (obstack) addrmap_fixed (obstack, &m_map); + } + +private: + + /* An addrmap that maps from section offsets to cooked_index_entry *. */ + addrmap_mutable m_map; +}; + +/* Keep a collection of parent_map objects, and allow for lookups + across all of them. */ +class parent_map_map +{ +public: + + parent_map_map () = default; + ~parent_map_map () = default; + + DISABLE_COPY_AND_ASSIGN (parent_map_map); + + /* Add a parent_map to this map. */ + void add_map (const parent_map &map) + { + m_maps.push_back (map.to_fixed (&m_storage)); + } + + /* Look up an entry in this map. */ + const cooked_index_entry *find (parent_map::addr_type search) const + { + for (const auto &iter : m_maps) + { + const cooked_index_entry *result + = static_cast (iter->find (search)); + if (result != nullptr) + return result; + } + return nullptr; + } + +private: + + /* Storage for the convert maps. */ + auto_obstack m_storage; + + /* While conceptually this class is a combination of parent_maps, in + practice it is just a number of fixed maps. This is important + because we want to allow concurrent lookups, but a mutable + addrmap is based on a splay-tree, which is not thread-safe, even + for nominally read-only lookups. */ + std::vector m_maps; +}; + +#endif /* GDB_DWARF2_PARENT_MAP_H */ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index b54b381aef3..6332ffb5767 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -94,6 +94,7 @@ #include "split-name.h" #include "gdbsupport/thread-pool.h" #include "run-on-main-thread.h" +#include "dwarf2/parent-map.h" /* When == 1, print basic high level tracing messages. When > 1, be more verbose. @@ -4473,16 +4474,6 @@ class cooked_indexer private: - /* A helper function to turn a section offset into an address that - can be used in an addrmap. */ - CORE_ADDR form_addr (sect_offset offset, bool is_dwz) - { - CORE_ADDR value = to_underlying (offset); - if (is_dwz) - value |= ((CORE_ADDR) 1) << (8 * sizeof (CORE_ADDR) - 1); - return value; - } - /* A helper function to scan the PC bounds of READER and record them in the storage's addrmap. */ void check_bounds (cutu_reader *reader); @@ -4520,7 +4511,7 @@ class cooked_indexer cooked_index_flag *flags, sect_offset *sibling_offset, const cooked_index_entry **parent_entry, - CORE_ADDR *maybe_defer, + parent_map::addr_type *maybe_defer, bool *is_enum_class, bool for_specification); @@ -4548,10 +4539,9 @@ class cooked_indexer /* The language that we're assuming when reading. */ enum language m_language; - /* An addrmap that maps from section offsets (see the form_addr - method) to newly-created entries. See m_deferred_entries to - understand this. */ - addrmap_mutable m_die_range_map; + /* Map from DIE ranges to newly-created entries. See + m_deferred_entries to understand this. */ + parent_map m_die_range_map; /* The generated DWARF can sometimes have the declaration for a method in a class (or perhaps namespace) scope, with the @@ -16096,7 +16086,7 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu, cooked_index_flag *flags, sect_offset *sibling_offset, const cooked_index_entry **parent_entry, - CORE_ADDR *maybe_defer, + parent_map::addr_type *maybe_defer, bool *is_enum_class, bool for_specification) { @@ -16269,15 +16259,13 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu, if (*parent_entry == nullptr) { - CORE_ADDR addr = form_addr (origin_offset, origin_is_dwz); + parent_map::addr_type addr + = parent_map::form_addr (origin_offset, origin_is_dwz); if (new_reader->cu == reader->cu && new_info_ptr > watermark_ptr) *maybe_defer = addr; else - { - void *obj = m_die_range_map.find (addr); - *parent_entry = static_cast (obj); - } + *parent_entry = m_die_range_map.find (addr); } unsigned int bytes_read; @@ -16402,11 +16390,13 @@ cooked_indexer::recurse (cutu_reader *reader, { /* Both start and end are inclusive, so use both "+ 1" and "- 1" to limit the range to the children of parent_entry. */ - CORE_ADDR start = form_addr (parent_entry->die_offset + 1, - reader->cu->per_cu->is_dwz); - CORE_ADDR end = form_addr (sect_offset (info_ptr - 1 - reader->buffer), + parent_map::addr_type start + = parent_map::form_addr (parent_entry->die_offset + 1, + reader->cu->per_cu->is_dwz); + parent_map::addr_type end + = parent_map::form_addr (sect_offset (info_ptr - 1 - reader->buffer), reader->cu->per_cu->is_dwz); - m_die_range_map.set_empty (start, end, (void *) parent_entry); + m_die_range_map.add_entry (start, end, parent_entry); } return info_ptr; @@ -16448,7 +16438,7 @@ cooked_indexer::index_dies (cutu_reader *reader, const char *name = nullptr; const char *linkage_name = nullptr; - CORE_ADDR defer = 0; + parent_map::addr_type defer {}; cooked_index_flag flags = IS_STATIC; sect_offset sibling {}; const cooked_index_entry *this_parent_entry = parent_entry; @@ -16592,8 +16582,8 @@ cooked_indexer::make_index (cutu_reader *reader) for (const auto &entry : m_deferred_entries) { - void *obj = m_die_range_map.find (entry->get_deferred_parent ()); - cooked_index_entry *parent = static_cast (obj); + const cooked_index_entry *parent + = m_die_range_map.find (entry->get_deferred_parent ()); entry->resolve_parent (parent); } } From patchwork Mon Apr 8 21:11:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 88207 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 0E2FE385E448 for ; Mon, 8 Apr 2024 21:13:26 +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 37A06385840D for ; Mon, 8 Apr 2024 21:11:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 37A06385840D 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 37A06385840D 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=1712610709; cv=none; b=m/fGm1ZuvIlZ/toqAAwSi2iAKay4DfKuHAxmhOxYCwGP7ZHcp6u20mCjkaQo9nqDeT3capdTcos8UwRxJh3djXaUA1C5frQgoeKo3MB9HFFYuPwh78qUic7vgLmX43Cox4WU3RCdE7Ov0x6SypGKhx6a0mSsM3cYrfDfICTQ0Bs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712610709; c=relaxed/simple; bh=2ELopapbz9pTAaFJ97ajhMFZJCZd1PwX3QnoQALksNs=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=lblq9Zo/0QrgYNJHmI3yUE6evFLlSs7LRr7RJVoVBcPwKfD7ebBHsjT30NAyexSFln+zjLBWQBcbopcVGZ4Pz1wbfLOI5Hc2oZRgiGLptJN/7n6Flv7ornc6RDgQdzAvlhtumsEfPvtMc6iSkA7jlhnx4AcOZPzauHMg5iRTsvU= 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 tr6drAsoPQr4StwHHrdAZP; Mon, 08 Apr 2024 21:11:43 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id twHFrmjrEGDo0twHGrQR0u; Mon, 08 Apr 2024 21:11:42 +0000 X-Authority-Analysis: v=2.4 cv=I+uuR8gg c=1 sm=1 tr=0 ts=66145d8e a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=raytVjVEu-sA:10 a=Qbun_eYptAEA:10 a=CCpqsmhAAAAA:8 a=Q-bJrc6Cx20q2ANe5GgA: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=92bsv54c4K5cgtfOel9VTZEjs0AGq5qrDqB6C98UKkA=; b=eWBjv9oHlFtb50eOjd7cPsAwEb F+XbnkNF0nk/92qF2VhtzSetwfNUBWZ8Mw3UZP5tMFwunjheK36wiZsnMUCcBBKns+hqIVUMH0cmu QVmrTOk/8ZV4dPEQaMj0H62xc; Received: from 97-122-82-115.hlrn.qwest.net ([97.122.82.115]:54230 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 1rtwHF-001uXf-2A for gdb-patches@sourceware.org; Mon, 08 Apr 2024 15:11:41 -0600 From: Tom Tromey Date: Mon, 08 Apr 2024 15:11:41 -0600 Subject: [PATCH v2 5/7] Correctly handle DIE parent computations MIME-Version: 1.0 Message-Id: <20240408-die-map-madness-v2-5-6741626d544d@tromey.com> References: <20240408-die-map-madness-v2-0-6741626d544d@tromey.com> In-Reply-To: <20240408-die-map-madness-v2-0-6741626d544d@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.82.115 X-Source-L: No X-Exim-ID: 1rtwHF-001uXf-2A X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-82-115.hlrn.qwest.net ([192.168.0.21]) [97.122.82.115]:54230 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: MS4xfCkz0l6unhmQSu02spPNnEGwQkRu5zBzgqamxtTUZ03VsCPfGDRSjrmZsXRLSTEiGdr2iKDyD4TtXHcSVxWn252jLLapO8A5JzcrwRKjsg3I04RNGPv9 a5S1Y4uJDwJpjGzqSumoE5JSwgjDSplM19OBAyXHx9ITW/qkTWWH5way8aQq0XgdS50dWPxygZVtyEyG3AcUWreZ4pj8lZPIyPo= X-Spam-Status: No, score=-3021.5 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 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 Tom de Vries pointed out that the combination of sharding, multi-threading, and per-CU "racing" means that sometimes a cross-CU DIE reference might not be correctly resolved. However, it's important to handle this correctly, due to some unfortunate aspects of DWARF. This patch implements this by arranging to preserve each worker's DIE map through the end of index finalization. The extra data is discarded when finalization is done. This approach also allows the parent name resolution to be sharded, by integrating it into the existing entry finalization loop. In an earlier review, I remarked that addrmap couldn't be used here. However, I was mistaken. A *mutable* addrmap cannot be used, as those are based on splay trees and restructure the tree even during lookups (and thus aren't thread-safe). A fixed addrmap, on the other hand, is just a vector and is thread-safe. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30846 --- gdb/dwarf2/cooked-index.c | 14 +++++++--- gdb/dwarf2/cooked-index.h | 49 +++++++++++++++++++++++++++-------- gdb/dwarf2/read-debug-names.c | 7 +++-- gdb/dwarf2/read.c | 60 +++++++++++++++++++------------------------ 4 files changed, 80 insertions(+), 50 deletions(-) diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index 66822b575ca..eb1b1df8d74 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -330,7 +330,7 @@ cooked_index_shard::handle_gnat_encoded_entry (cooked_index_entry *entry, /* See cooked-index.h. */ void -cooked_index_shard::finalize () +cooked_index_shard::finalize (const parent_map_map *parent_maps) { auto hash_name_ptr = [] (const void *p) { @@ -371,6 +371,13 @@ cooked_index_shard::finalize () for (cooked_index_entry *entry : m_entries) { + if ((entry->flags & IS_PARENT_DEFERRED) != 0) + { + const cooked_index_entry *new_parent + = parent_maps->find (entry->get_deferred_parent ()); + entry->resolve_parent (new_parent); + } + /* Note that this code must be kept in sync with language_requires_canonicalization. */ gdb_assert (entry->canonical == nullptr); @@ -630,7 +637,8 @@ cooked_index::wait (cooked_state desired_state, bool allow_quit) } void -cooked_index::set_contents (vec_type &&vec, deferred_warnings *warn) +cooked_index::set_contents (vec_type &&vec, deferred_warnings *warn, + const parent_map_map *parent_maps) { gdb_assert (m_vector.empty ()); m_vector = std::move (vec); @@ -652,7 +660,7 @@ cooked_index::set_contents (vec_type &&vec, deferred_warnings *warn) for (auto &idx : m_vector) { auto this_index = idx.get (); - finalizers.add_task ([=] () { this_index->finalize (); }); + finalizers.add_task ([=] () { this_index->finalize (parent_maps); }); } finalizers.start (); diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index 6400750b587..d245570e34d 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -351,9 +351,9 @@ class cooked_index_shard /* Finalize the index. This should be called a single time, when the index has been fully populated. It enters all the entries - into the internal table. This may be invoked in a worker - thread. */ - void finalize (); + into the internal table and fixes up all missing parent links. + This may be invoked in a worker thread. */ + void finalize (const parent_map_map *parent_maps); /* Storage for the entries. */ auto_obstack m_storage; @@ -419,6 +419,19 @@ class cooked_index_storage return &m_addrmap; } + /* Return the parent_map that is currently being created. */ + parent_map *get_parent_map () + { + return &m_parent_map; + } + + /* Return the parent_map that is currently being created. Ownership + is passed to the caller. */ + parent_map release_parent_map () + { + return std::move (m_parent_map); + } + private: /* Hash function for a cutu_reader. */ @@ -434,6 +447,9 @@ class cooked_index_storage /* The index shard that is being constructed. */ std::unique_ptr m_index; + /* Parent map for each CU that is read. */ + parent_map m_parent_map; + /* A writeable addrmap being constructed by this scanner. */ addrmap_mutable m_addrmap; }; @@ -508,13 +524,17 @@ class cooked_index_worker { } /* Each thread returns a tuple holding a cooked index, any collected - complaints, and a vector of errors that should be printed. The - latter is done because GDB's I/O system is not thread-safe. - run_on_main_thread could be used, but that would mean the - messages are printed after the prompt, which looks weird. */ + complaints, a vector of errors that should be printed, and a + vector of parent maps. + + The errors are retained because GDB's I/O system is not + thread-safe. run_on_main_thread could be used, but that would + mean the messages are printed after the prompt, which looks + weird. */ using result_type = std::tuple, complaint_collection, - std::vector>; + std::vector, + parent_map>; /* The per-objfile object. */ dwarf2_per_objfile *m_per_objfile; @@ -527,6 +547,10 @@ class cooked_index_worker This is enforced in the cooked_index_worker constructor. */ deferred_warnings m_warnings; + /* A map of all parent maps. Used during finalization to fix up + parent relationships. */ + parent_map_map m_all_parents_map; + #if CXX_STD_THREAD /* Current state of this object. */ cooked_state m_state = cooked_state::INITIAL; @@ -618,9 +642,12 @@ class cooked_index : public dwarf_scanner_base /* Called by cooked_index_worker to set the contents of this index and transition to the MAIN_AVAILABLE state. WARN is used to - collect any warnings that may arise when writing to the - cache. */ - void set_contents (vec_type &&vec, deferred_warnings *warn); + collect any warnings that may arise when writing to the cache. + PARENT_MAPS is used when resolving pending parent links. + PARENT_MAPS may be NULL if there are no IS_PARENT_DEFERRED + entries in VEC. */ + void set_contents (vec_type &&vec, deferred_warnings *warn, + const parent_map_map *parent_maps); /* A range over a vector of subranges. */ using range = range_chain; diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c index a3547cde7aa..eebe5a91095 100644 --- a/gdb/dwarf2/read-debug-names.c +++ b/gdb/dwarf2/read-debug-names.c @@ -345,13 +345,16 @@ cooked_index_debug_names::do_reading () = create_quick_file_names_table (per_bfd->all_units.size ()); m_results.emplace_back (nullptr, complaint_handler.release (), - std::move (exceptions)); + std::move (exceptions), + parent_map ()); std::vector> indexes; indexes.push_back (std::move (m_map.shard)); cooked_index *table = (gdb::checked_static_cast (per_bfd->index_table.get ())); - table->set_contents (std::move (indexes), &m_warnings); + /* Note that this code never uses IS_PARENT_DEFERRED, so it is safe + to pass nullptr here. */ + table->set_contents (std::move (indexes), &m_warnings, nullptr); bfd_thread_cleanup (); } diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 6332ffb5767..2a723bb947f 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -4463,7 +4463,8 @@ class cooked_indexer enum language language) : m_index_storage (storage), m_per_cu (per_cu), - m_language (language) + m_language (language), + m_die_range_map (storage->get_parent_map ()) { } @@ -4539,18 +4540,8 @@ class cooked_indexer /* The language that we're assuming when reading. */ enum language m_language; - /* Map from DIE ranges to newly-created entries. See - m_deferred_entries to understand this. */ - parent_map m_die_range_map; - - /* The generated DWARF can sometimes have the declaration for a - method in a class (or perhaps namespace) scope, with the - definition appearing outside this scope... just one of the many - bad things about DWARF. In order to handle this situation, we - defer certain entries until the end of scanning, at which point - we'll know the containing context of all the DIEs that we might - have scanned. This vector stores these deferred entries. */ - std::vector m_deferred_entries; + /* Map from DIE ranges to newly-created entries. */ + parent_map *m_die_range_map; }; /* Subroutine of dwarf2_build_psymtabs_hard to simplify it. @@ -4893,7 +4884,8 @@ cooked_index_debug_info::process_cus (size_t task_number, unit_iterator first, m_results[task_number] = result_type (thread_storage.release (), complaint_handler.release (), - std::move (errors)); + std::move (errors), + std::move (thread_storage.release_parent_map ())); } void @@ -4903,7 +4895,10 @@ cooked_index_debug_info::done_reading () can only be dealt with on the main thread. */ std::vector> indexes; for (auto &one_result : m_results) - indexes.push_back (std::move (std::get<0> (one_result))); + { + indexes.push_back (std::move (std::get<0> (one_result))); + m_all_parents_map.add_map (std::get<3> (one_result)); + } /* This has to wait until we read the CUs, we need the list of DWOs. */ process_skeletonless_type_units (m_per_objfile, &m_index_storage); @@ -4911,11 +4906,14 @@ cooked_index_debug_info::done_reading () indexes.push_back (m_index_storage.release ()); indexes.shrink_to_fit (); + m_all_parents_map.add_map (m_index_storage.release_parent_map ()); + dwarf2_per_bfd *per_bfd = m_per_objfile->per_bfd; cooked_index *table = (gdb::checked_static_cast (per_bfd->index_table.get ())); - table->set_contents (std::move (indexes), &m_warnings); + table->set_contents (std::move (indexes), &m_warnings, + &m_all_parents_map); } void @@ -16259,13 +16257,17 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu, if (*parent_entry == nullptr) { + /* We only perform immediate lookups of parents for DIEs + from earlier in this CU. This avoids any problem + with a NULL result when when we see a reference to a + DIE in another CU that we may or may not have + imported locally. */ parent_map::addr_type addr = parent_map::form_addr (origin_offset, origin_is_dwz); - if (new_reader->cu == reader->cu - && new_info_ptr > watermark_ptr) + if (new_reader->cu != reader->cu || new_info_ptr > watermark_ptr) *maybe_defer = addr; else - *parent_entry = m_die_range_map.find (addr); + *parent_entry = m_die_range_map->find (addr); } unsigned int bytes_read; @@ -16396,7 +16398,7 @@ cooked_indexer::recurse (cutu_reader *reader, parent_map::addr_type end = parent_map::form_addr (sect_offset (info_ptr - 1 - reader->buffer), reader->cu->per_cu->is_dwz); - m_die_range_map.add_entry (start, end, parent_entry); + m_die_range_map->add_entry (start, end, parent_entry); } return info_ptr; @@ -16481,13 +16483,10 @@ cooked_indexer::index_dies (cutu_reader *reader, if (name != nullptr) { if (defer != 0) - { - this_entry - = m_index_storage->add (this_die, abbrev->tag, - flags | IS_PARENT_DEFERRED, name, - defer, m_per_cu); - m_deferred_entries.push_back (this_entry); - } + this_entry + = m_index_storage->add (this_die, abbrev->tag, + flags | IS_PARENT_DEFERRED, name, + defer, m_per_cu); else this_entry = m_index_storage->add (this_die, abbrev->tag, flags, name, @@ -16579,13 +16578,6 @@ cooked_indexer::make_index (cutu_reader *reader) if (!reader->comp_unit_die->has_children) return; index_dies (reader, reader->info_ptr, nullptr, false); - - for (const auto &entry : m_deferred_entries) - { - const cooked_index_entry *parent - = m_die_range_map.find (entry->get_deferred_parent ()); - entry->resolve_parent (parent); - } } dwarf2_per_cu_data * From patchwork Mon Apr 8 21:11:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 88203 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 E0A6A3861021 for ; Mon, 8 Apr 2024 21:12:35 +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 06C3B385840B for ; Mon, 8 Apr 2024 21:11:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 06C3B385840B 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 06C3B385840B 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=1712610706; cv=none; b=qjXvgBGZLk8po8Tj4gfNPzFlJd7zyFIFYkuUOE2vJsGQiuC/SFpMFdwixKc7npvcsx3wZ5qmmnXgjkskuyx/nTTEcR7rPNT3Q0fp/TIv25hXmcq+EXVXMguVOcVfO73QAQCqrAfcz1L58DVxD17eWhsjKxE07PBQ+DWwGTFkrLI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712610706; c=relaxed/simple; bh=eOb9ju1ueAm7O5fsk/IM3dyg0PkuIOo9vfolQNzTZyw=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=UUqMuUz5jzBw+bUu7GsMxPPD4nDNWX4ULw8kuzzmIRS5d2tFkmKnmF5JLj6ryTbsId5i4xYXe3YYJaY4tu8JOO74tpmRRw5OWXEMrsUpBJwP6RUGqaqvRva2ik8WdNwL9SoEnmUI1lQYpOpzNRnV44hqc4P9hu7Ml2AOqwSTmeQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6007a.ext.cloudfilter.net ([10.0.30.247]) by cmsmtp with ESMTPS id tKdLrPfcFl9dRtwHGreYnH; Mon, 08 Apr 2024 21:11:42 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id twHGrsIXGVdentwHGrF2pK; Mon, 08 Apr 2024 21:11:42 +0000 X-Authority-Analysis: v=2.4 cv=M4FLKTws c=1 sm=1 tr=0 ts=66145d8e a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=raytVjVEu-sA:10 a=Qbun_eYptAEA:10 a=CCpqsmhAAAAA:8 a=mDV3o1hIAAAA:8 a=FynSyykwWHE-Aet8Js8A:9 a=QEXdDO2ut3YA:10 a=ul9cdbp4aOFLsgKbc677:22 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=V/JY53WNHTJwdloozXtOWAWTmIFTovQ4XtlWqxPdZ2A=; b=FR4CG41LEDt6lYPC3t7c5mA3Rd N54vqNEE4BOs9YdQUlrjJxZvs5o7hVdory8avW2jf/NV+uUSYn2CZz6HMhMWokjD/ox3PEHxTNVCP /FE688t+Iq74mfMUzFh1w8SOn; Received: from 97-122-82-115.hlrn.qwest.net ([97.122.82.115]:54230 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 1rtwHF-001uXf-2m; Mon, 08 Apr 2024 15:11:41 -0600 From: Tom Tromey Date: Mon, 08 Apr 2024 15:11:42 -0600 Subject: [PATCH gdb/testsuite v2 6/7] Add gdb.dwarf2/forward-spec-inter-cu.exp MIME-Version: 1.0 Message-Id: <20240408-die-map-madness-v2-6-6741626d544d@tromey.com> References: <20240408-die-map-madness-v2-0-6741626d544d@tromey.com> In-Reply-To: <20240408-die-map-madness-v2-0-6741626d544d@tromey.com> To: gdb-patches@sourceware.org Cc: Tom de Vries 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.82.115 X-Source-L: No X-Exim-ID: 1rtwHF-001uXf-2m X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-82-115.hlrn.qwest.net ([192.168.0.21]) [97.122.82.115]:54230 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: MS4xfIsgW1f5eASRDSHkXLG5gTnmejyqZ7ibUXvAtwhXQfAsG6AT6G+wIBFh2JHDcfIJ7Ifatf1OVSqvJLn+1sUC8ZlEZdsNEK1Kutz2bAutp848xPnPkOPf LEKaKb8X6wAFsEsQYE8KrmFXvVy5TCBLNx4f8EehRDoEo/GgVTMFFIwVf0y9ffldlep5R+ruhwDDPb1LMO2Rr1434+mroT3NeJU= X-Spam-Status: No, score=-3021.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org From: Tom de Vries Add a regression test for PR symtab/30846. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30846 --- gdb/testsuite/gdb.dwarf2/forward-spec-inter-cu.exp | 103 +++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/gdb/testsuite/gdb.dwarf2/forward-spec-inter-cu.exp b/gdb/testsuite/gdb.dwarf2/forward-spec-inter-cu.exp new file mode 100644 index 00000000000..d8367b0a162 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/forward-spec-inter-cu.exp @@ -0,0 +1,103 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# 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 . + +# Check that the DWARF reader works with a a DW_AT_specification that +# refers to a later DIE. Inter-cu variant of forward-spec.exp. + +load_lib dwarf.exp + +# This test can only be run on targets which support DWARF-2 and use gas. +require dwarf2_support + +standard_testfile main.c -debug.S + +# Set up the DWARF for the test. +set asm_file [standard_output_file $srcfile2] +Dwarf::assemble $asm_file { + global srcfile + + declare_labels spec + + cu {} { + DW_TAG_compile_unit { + {DW_AT_language @DW_LANG_C_plus_plus} + } { + # The new indexer has special code to compute the full + # name of an object that uses a specification that appears + # later in the DWARF. + DW_TAG_variable { + {DW_AT_specification %$spec} + {DW_AT_location { + DW_OP_const1u 23 + DW_OP_stack_value + } SPECIAL_expr} + } + } + } + + cu {} { + DW_TAG_compile_unit { + {DW_AT_language @DW_LANG_C_plus_plus} + } { + declare_labels myint + + myint: DW_TAG_base_type { + {DW_AT_byte_size 4 DW_FORM_sdata} + {DW_AT_encoding @DW_ATE_signed} + {DW_AT_name myint} + } + + DW_TAG_namespace { + {DW_AT_name ns} + } { + spec: DW_TAG_variable { + {DW_AT_name v} + {DW_AT_type :$myint} + {DW_AT_declaration 1 DW_FORM_flag_present} + } + } + } + } +} + +if {[build_executable "failed to build executable" ${testfile} \ + [list $srcfile $asm_file] {nodebug}]} { + return -1 +} + +set eol "\r\n" +set ws "\[ \t\]" + +set worker_threads_list {} + +# Exercises the intra-shard case. +lappend worker_threads_list 0 + +# Might exercise the inter-shard case. +lappend worker_threads_list default + +foreach_with_prefix worker_threads $worker_threads_list { + + clean_restart + + if { $worker_threads != "default" } { + gdb_test_no_output "maint set worker-threads $worker_threads" + } + + gdb_load $binfile + + gdb_test "maint print objfiles" "$eol$ws+qualified:$ws+ns::v$eol.*" \ + "v has parent ns" +} From patchwork Mon Apr 8 21:11:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 88206 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 C595D384604F for ; Mon, 8 Apr 2024 21:13:01 +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 776E43858410 for ; Mon, 8 Apr 2024 21:11:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 776E43858410 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 776E43858410 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=1712610708; cv=none; b=IGhrkuLH9pieUrm9d2+UsHbryFVsjChlqGHz4+yw1OgQauODAfuHZ6Kr8GpUTGWaeAtwSs0/sHodRZrB2JFhSeqqac6jDq5Yji1wzhAx2l3+vGnMWi4MDwzr4yqztpbt2mjEKW8ymzCeaQkWQe32bEZIfEPYwA1beEb3C1QGbX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712610708; c=relaxed/simple; bh=h1GOVH1TqadzWnkGb7/HAJ4mxF99dIRjRwJjgUuosUc=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=hLaupO8yztiFWppYL2sDckR9tLPzk/epk0ELJdbkawoKd4Yly8+XWrPODVGggdkrTPPK2cnO+Qz27QhGGh9scIP65utsa6GJLa8+VhssW6UoyxmoBe7Crux8lTQt4eQVhqI3Z5dZ+yJkUq6+B06NJ7OUDznOllko6gMNNpCbFYc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6009a.ext.cloudfilter.net ([10.0.30.184]) by cmsmtp with ESMTPS id ticzrmG32PM1htwHGrqiSi; Mon, 08 Apr 2024 21:11:42 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id twHGrnUJLnNCOtwHGrgmT1; Mon, 08 Apr 2024 21:11:42 +0000 X-Authority-Analysis: v=2.4 cv=DKCJ4TNb c=1 sm=1 tr=0 ts=66145d8e a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=raytVjVEu-sA:10 a=Qbun_eYptAEA:10 a=CCpqsmhAAAAA:8 a=mDV3o1hIAAAA:8 a=FynSyykwWHE-Aet8Js8A:9 a=QEXdDO2ut3YA:10 a=ul9cdbp4aOFLsgKbc677:22 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=iWA9YJzDNq/XeTqF4B3WKn4TYyfysvqgBhh56X/ZtYs=; b=UoQO+u12eUOnxujFdChytFHV2j 4l2MFmTQPdA3KIAPvBisklJf9guzVyCuwOoJL0Oc88JLRPXVn0n6MmpqstjrlsfF9Zs5WRuRK2bdU QHjOk2I3XAxnOQIFaMLgUnhnL; Received: from 97-122-82-115.hlrn.qwest.net ([97.122.82.115]:54230 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 1rtwHG-001uXf-0F; Mon, 08 Apr 2024 15:11:42 -0600 From: Tom Tromey Date: Mon, 08 Apr 2024 15:11:43 -0600 Subject: [PATCH gdb/testsuite v2 7/7] Add gdb.dwarf2/backward-spec-inter-cu.exp MIME-Version: 1.0 Message-Id: <20240408-die-map-madness-v2-7-6741626d544d@tromey.com> References: <20240408-die-map-madness-v2-0-6741626d544d@tromey.com> In-Reply-To: <20240408-die-map-madness-v2-0-6741626d544d@tromey.com> To: gdb-patches@sourceware.org Cc: Tom de Vries 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.82.115 X-Source-L: No X-Exim-ID: 1rtwHG-001uXf-0F X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-82-115.hlrn.qwest.net ([192.168.0.21]) [97.122.82.115]:54230 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: MS4xfAiZ2ymWT59ZSGy+rzKuxSp/2t+jWuDi8Zmbi4mdT24qIUpULUwTf4yg+cSo+DkmiTQM/mddl6LCSPONAYYAu3DD6VMKpzOx+olqw9umtN97FYgS8RnG sAvDxVwNJPypRJ5A4/0anNU/Pi6JXJXZ2Crcmda3yFdk+hd6CKL2yQMv8oOFAsnvpLhYotXsWVxf8xJmmQK63nJB1Z93dqV1v9o= X-Spam-Status: No, score=-3021.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_SHORT, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org From: Tom de Vries Add another regression test for PR symtab/30846. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30846 --- .../gdb.dwarf2/backward-spec-inter-cu.exp | 103 +++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/gdb/testsuite/gdb.dwarf2/backward-spec-inter-cu.exp b/gdb/testsuite/gdb.dwarf2/backward-spec-inter-cu.exp new file mode 100644 index 00000000000..59b3db50dbb --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/backward-spec-inter-cu.exp @@ -0,0 +1,103 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# 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 . + +# Check that the DWARF reader works with a a DW_AT_specification that +# refers to an earlier DIE. Inter-cu variant of forward-spec.exp. + +load_lib dwarf.exp + +# This test can only be run on targets which support DWARF-2 and use gas. +require dwarf2_support + +standard_testfile main.c -debug.S + +# Set up the DWARF for the test. +set asm_file [standard_output_file $srcfile2] +Dwarf::assemble $asm_file { + global srcfile + + declare_labels spec + + cu {} { + DW_TAG_compile_unit { + {DW_AT_language @DW_LANG_C_plus_plus} + } { + declare_labels myint + + myint: DW_TAG_base_type { + {DW_AT_byte_size 4 DW_FORM_sdata} + {DW_AT_encoding @DW_ATE_signed} + {DW_AT_name myint} + } + + DW_TAG_namespace { + {DW_AT_name ns} + } { + spec: DW_TAG_variable { + {DW_AT_name v} + {DW_AT_type :$myint} + {DW_AT_declaration 1 DW_FORM_flag_present} + } + } + } + } + + cu {} { + DW_TAG_compile_unit { + {DW_AT_language @DW_LANG_C_plus_plus} + } { + # The new indexer has special code to compute the full + # name of an object that uses a specification that appears + # later in the DWARF. + DW_TAG_variable { + {DW_AT_specification %$spec} + {DW_AT_location { + DW_OP_const1u 23 + DW_OP_stack_value + } SPECIAL_expr} + } + } + } +} + +if {[build_executable "failed to build executable" ${testfile} \ + [list $srcfile $asm_file] {nodebug}]} { + return -1 +} + +set eol "\r\n" +set ws "\[ \t\]" + +set worker_threads_list {} + +# Exercises the intra-shard case. +lappend worker_threads_list 0 + +# Might exercise the inter-shard case. +lappend worker_threads_list default + +foreach_with_prefix worker_threads $worker_threads_list { + + clean_restart + + if { $worker_threads != "default" } { + gdb_test_no_output "maint set worker-threads $worker_threads" + } + + gdb_load $binfile + + gdb_test "maint print objfiles" "$eol$ws+qualified:$ws+ns::v$eol.*" \ + "v has parent ns" +}