From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id eZrJLY+SuGnFlSwAWB0awg (envelope-from ) for ; Mon, 16 Mar 2026 19:30:23 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=HZwQ76Ue; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id B6C0F1E0BC; Mon, 16 Mar 2026 19:30:23 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 4E0BF1E08C for ; Mon, 16 Mar 2026 19:30:23 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 931DF4BA23D0 for ; Mon, 16 Mar 2026 23:30:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 931DF4BA23D0 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=HZwQ76Ue Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id A326B4BA23D0 for ; Mon, 16 Mar 2026 23:29:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A326B4BA23D0 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A326B4BA23D0 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1773703769; cv=none; b=ckHQR69+73T4dS4EQUOcBuJmlPgGfnvELgiibyPCN4pPdTn7pkyacCPtCzpB6mpKPfKQvmNBlXozRgGqmQt0cgB4rUY/iD9xr2oPOwHX7R7QJcBinqVc78np9+kaoAk7DU/oum6Sqdq2etz+3AJC75aYPEyO11akluDKcAM7iyw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1773703769; c=relaxed/simple; bh=sG7+FsTsCWrkWTZlAr+nKhiz7V9bhBQOciEam1Tc7q0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=sMS1Qw8/JcOAjxcaTi3K6mKv0SGr9bicK6M6nAJEx09WcbUR7tVxZTYX+bBJpnjDjvoZC9mEnFODIDYEyqc5uhT0IljtHMEPV6RGw9XAJPwaRSK/TFKKdgddVIHSvA7W5lZYx3EtEhJgzLuf5XqC3ROS6HJEuTIKaAK3PJAWoSw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A326B4BA23D0 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 62GNTN10240303 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 16 Mar 2026 19:29:27 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 62GNTN10240303 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=oct2025; t=1773703768; bh=QEFXSbL8ftRKpVxhMHoTykEeBYsySFKd3GytKLdRZ0M=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=HZwQ76UeMdE/Tkwtbpr6uShI+HpF7WtTsYGHyNof6TpvMksrtnZgMfqjcPGNziqqY auPb/n/9Ibi3fwa5oBcvXNBgbzpTJBTGA5N6nE5VNqEkfbJsXztKP3nPQ27R0mpU7B Sczy8sNAnYH1iDAuKeUXXU67aoRXUgCh38G40g6iXDRhxZUJYicLhzahpwDgz8yd4i AQ4vhRSa+9nB0u6qz8rzA5CewBMLIVoeuspM/i9fxif+dagPiPJZzs+T67cYrecqrJ sIE8uQsj8qDdCWgMt5LgoaiDz5c3gmSQNWwk1ACwjCXkAZ/5fQ+Fr4FHaeRLDizPnm rqpmVF9jHDahw== Received: by simark.ca (Postfix) id 819D81E0CA; Mon, 16 Mar 2026 19:20:52 -0400 (EDT) From: simon.marchi@polymtl.ca To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 4/8] gdb/dwarf: add dwo_file::find_tus Date: Mon, 16 Mar 2026 19:19:22 -0400 Message-ID: <20260316232042.368080-5-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260316232042.368080-1-simon.marchi@polymtl.ca> References: <20260316232042.368080-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 16 Mar 2026 23:29:23 +0000 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~public-inbox=simark.ca@sourceware.org From: Simon Marchi Add this little helper to make finding a TU a bit simpler. I always find the STL way of doing things cryptic, so I think that hiding it in small helper methods makes the code clearer. A subsequent patch will add more uses of it Change-Id: Ibfb20d0e44c65d2ff729f3e0980ec4435f223aef --- gdb/dwarf2/read.c | 18 ++++++++++++++---- gdb/dwarf2/read.h | 5 +++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 3a0602b4ac08..fd1c37ad8e89 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -266,6 +266,18 @@ struct loclists_rnglists_header unsigned int offset_entry_count; }; +/* See read.h. */ + +dwo_unit * +dwo_file::find_tu (ULONGEST signature) const +{ + auto it = this->tus.find (signature); + if (it == this->tus.end ()) + return nullptr; + + return it->get (); +} + /* include/dwarf2.h defines the DWP section codes. It defines a max value but it doesn't define a min value, which we use for error checking, so provide one. */ @@ -2342,12 +2354,10 @@ lookup_dwo_signatured_type (struct dwarf2_cu *cu, ULONGEST sig) /* Note: cu->dwo_unit is the dwo_unit that references this TU, not the dwo_unit of the TU itself. */ dwo_file *dwo_file = cu->dwo_unit->dwo_file; - auto it = dwo_file->tus.find (sig); - if (it == dwo_file->tus.end ()) + dwo_unit *dwo_entry = dwo_file->find_tu (sig); + if (dwo_entry == nullptr) return nullptr; - dwo_unit *dwo_entry = it->get (); - /* If the global table doesn't have an entry for this TU, add one. */ if (sig_type_it == per_bfd->signatured_types.end ()) { diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 5a46786e4f3f..5c61e91870b4 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -585,6 +585,11 @@ struct dwo_file dwo_file () = default; DISABLE_COPY_AND_ASSIGN (dwo_file); + /* Look for a type unit with signature SIGNATURE in this dwo_file. + + Return nullptr if not found. */ + dwo_unit *find_tu (ULONGEST signature) const; + /* The DW_AT_GNU_dwo_name or DW_AT_dwo_name attribute. For virtual DWO files the name is constructed from the section offsets of abbrev,line,loc,str_offsets so that we combine virtual DWO files -- 2.53.0