From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id GZ3mLI1A4WkT2hwAWB0awg (envelope-from ) for ; Thu, 16 Apr 2026 16:03:25 -0400 Received: by simark.ca (Postfix, from userid 112) id B487C1E04F; Thu, 16 Apr 2026 16:03:25 -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_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 631C11E04F for ; Thu, 16 Apr 2026 16:03:25 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id E87034C515FA for ; Thu, 16 Apr 2026 20:03:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E87034C515FA Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id F29864BB58BE for ; Thu, 16 Apr 2026 20:03:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F29864BB58BE 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 F29864BB58BE Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776369781; cv=none; b=P0hcwl36UGixaZm69mKa1oPWIARSBhSEf2acdVL29+8iExRhEsSamBl5/CJTvs9maq6u7W4n4NQc/4E67fvmdDbyNmaeSuJ7+OT+686TboxBvh7kKaeJWSw9ppgLNG/1xegZlItVQd/nL/O0MQloX6V9oCzkRK8XE/xeRy59NBQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776369781; c=relaxed/simple; bh=RC3v1oaT4UWJug2tuHqLCdHXRnJ3MNZgON+kXkiXwbk=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=KHdjRYdauICzcvYiDCtKB9CnJqwxiWbp54Zmu5TRBB+L2p5iHMWgla0CPwpYDYMOWfH9aFkIQcVbWubKijHSrPRZffGlT0EnZ3Vsh2F6zm8AdgYEKiAmMpPrMzgRRqkYvedFmt2db/6nHFskYY4RQb6hYC8fer9vUSvQcWAXcAc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F29864BB58BE Received: by simark.ca (Postfix) id 7F1531E0D1; Thu, 16 Apr 2026 16:02:59 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH v2 4/8] gdb/dwarf: add dwo_file::find_tus Date: Thu, 16 Apr 2026 15:59:07 -0400 Message-ID: <20260416200256.386186-5-simon.marchi@efficios.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260416200256.386186-1-simon.marchi@efficios.com> References: <20260316232042.368080-1-simon.marchi@polymtl.ca> <20260416200256.386186-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 --- 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 b627966a0c99..575b2383b20a 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. */ @@ -2352,12 +2364,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 dfe1e671b9c8..17a158defcae 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -622,6 +622,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