From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id sTUwOqD4AWraIDAAWB0awg (envelope-from ) for ; Mon, 11 May 2026 11:41:20 -0400 Received: by simark.ca (Postfix, from userid 112) id EC0B51E0C3; Mon, 11 May 2026 11:41:20 -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.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2, 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 9D7211E067 for ; Mon, 11 May 2026 11:41:20 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 709E14BB1C0F for ; Mon, 11 May 2026 15:41:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 709E14BB1C0F Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id C4FD74B99F42 for ; Mon, 11 May 2026 15:40:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C4FD74B99F42 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C4FD74B99F42 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778514055; cv=none; b=Ln2TWu/Mgz0H2Lv6wi3e48IIMxEij6nNNf6uC2YwoTU41pujjQ12Moxs3OCdUhVfmowlHMX6KFO4xJlER+H+bJfESBYQ887yQjVORmdEdIs/50ktt73rBYnwe6SD2jhcJW6GxlR+8fE8Uy8p+TAlUdkKBfM6j0dmBEQeyrk/KAg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778514055; c=relaxed/simple; bh=un09JqtLym/8rSueNVaONqPwl/8QHGW0t/8SDNm60Qw=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=haR/Cj9by/r7uSbd3SvftuOZQqXzw1pADchOLsxDlGKrKSZWqFGX/wm62E7i47XO+vVl+fKIJRU18+QDV4P+0i83om7QBbAG1kVTyleY2RI7Xr36PsPuHxwMovpIubl1dCspEpqIKgZTOIdXazDefMquSLPWCzAE0XZxccZEsXk= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C4FD74B99F42 Received: by simark.ca (Postfix) id 687591E0CA; Mon, 11 May 2026 11:40:54 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi , Tom Tromey Subject: [PATCH v3 3/7] gdb/dwarf: add dwo_file::find_tus Date: Mon, 11 May 2026 11:40:29 -0400 Message-ID: <20260511154053.142576-4-simon.marchi@efficios.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260511154053.142576-1-simon.marchi@efficios.com> References: <20260511154053.142576-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 Approved-By: Tom Tromey --- gdb/dwarf2/dwo.h | 11 +++++++++++ gdb/dwarf2/read.c | 6 ++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/gdb/dwarf2/dwo.h b/gdb/dwarf2/dwo.h index 025932b1e969..47d7bdde7925 100644 --- a/gdb/dwarf2/dwo.h +++ b/gdb/dwarf2/dwo.h @@ -121,6 +121,17 @@ 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 + { + if (auto it = this->tus.find (signature); it != this->tus.end ()) + return it->get (); + + return nullptr; + } + /* 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 diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 4d797b0e29b9..9cb7b83cc339 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2311,12 +2311,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 ()) { -- 2.54.0