From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id WS1oA8um6GmYjTMAWB0awg (envelope-from ) for ; Wed, 22 Apr 2026 06:45:31 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=vrany.io header.i=@vrany.io header.a=rsa-sha256 header.s=protonmail3 header.b=tibLXOj5; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 0959C1E0C3; Wed, 22 Apr 2026 06:45:31 -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 DD39B1E067 for ; Wed, 22 Apr 2026 06:45:29 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id C3F0D409EB68 for ; Wed, 22 Apr 2026 10:45:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C3F0D409EB68 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=vrany.io header.i=@vrany.io header.a=rsa-sha256 header.s=protonmail3 header.b=tibLXOj5 Received: from mail-4398.protonmail.ch (mail-4398.protonmail.ch [185.70.43.98]) by sourceware.org (Postfix) with ESMTPS id 258AB48FE201 for ; Wed, 22 Apr 2026 10:30:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 258AB48FE201 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=vrany.io Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrany.io ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 258AB48FE201 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=185.70.43.98 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776853811; cv=none; b=WGvj2ltmHOvfj+v/e7vSZ4NkPz87AGTftFDvqYbwdeJdtF6U6pIHFpu4ZWmIiBfmR3tiRGvpxdEufcHjivHH9uuEXBEO8fIg/U0ctRpvQDm/P7b5NYrK/bvg8blm/YMssqm7qvNhm1ZWjgVCdqdRV5GLaNwY80dNXNE5CQbpAg4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776853811; c=relaxed/simple; bh=aKmDlFaR8mAq5SzV4JlsR/DVQ9NPlCDN2Oh7lrr6+98=; h=DKIM-Signature:Date:To:From:Subject:Message-ID:MIME-Version; b=Y62rYlFVUZEqAMe+97Sz6tvScgwLrd+k3JbARBOF27/zIglN0bypYk0Z4SozviXvqQu94Ubd47nDqoNGtjvWhkzXeY5pe79y8EhfgwhxH5Moo4sm1b92Q4/Yd3WRelyoTD32WxIuKUl+piItiSHTZ8phxshv9YXVNv65KdqjtLg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 258AB48FE201 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrany.io; s=protonmail3; t=1776853809; x=1777113009; bh=fKorN/ZqGeefw5xo6ClLlf7TdbPX8kr6TPGW+EBt2IQ=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=tibLXOj5PVvneeWLuC8Lpi7MNcuXMJARxeADhrJNVTXOw5kjUVSBPWvVBz1gXgrwf TFjLfvarqhlVsHyGa0IZTqFlYAzMY1NuL1RHjrKFTX94wQGkLFQ3uPSHfPViWBLMUk FItoO6Tgy7Ewz1cC8UrNy3rkCsz+wL5XF52CBAI4qtxjGGt/zVA34fJ+b3Fh0ktvsb L17aaytIMKQaYaiKFwqn8QllY2xN96B3T+pPcnayAoV4gTQ51VAkgqqMOpATPmQCl0 KZS93BI36RCzq3oMebzQFure3MStYgEHNgj64980H2Qrue7oAmBf6457ZLCljLy2Gl bLL6VeA1UMOig== Date: Wed, 22 Apr 2026 10:30:05 +0000 To: gdb-patches@sourceware.org From: Jan Vrany Cc: Jan Vrany Subject: [PATCH v3 4/7] gdb: update blockvector::lookup to handle non-contiguous blocks Message-ID: <20260422102923.1185738-5-jan@vrany.io> In-Reply-To: <20260304165914.3209106-1-jan.vrany@labware.com> References: <20260304165914.3209106-1-jan.vrany@labware.com> Feedback-ID: 40767693:user:proton X-Pm-Message-ID: 007a72cda1b817813c2b38c7053d1538b2ec5446 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 This commit updates blockvector::lookup to handle non-contiguous without help of addrmap. It introduces a new method, block::contains(CORE_ADDR), to check whether given block contains given address. This new method is then used in blockvector::lookup instead of simply using block's start and end addresses. For this to work, it is essential that blocks' start address is the same as start address of lowest range and similarly blocks' end address same as end address of highest range. Therefore this commit also adds assert to DWARF reader to ensure that. A unit test for non-contiguous blocks will come later in this series. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D33829 --- gdb/block.c | 24 +++++++++++++++++++++++- gdb/block.h | 4 ++++ gdb/dwarf2/read.c | 10 ++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/gdb/block.c b/gdb/block.c index dc00327048f..b266ec38ea4 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -85,6 +85,25 @@ block::contains (const struct block *a, bool allow_neste= d) const =20 /* See block.h. */ =20 +bool +block::contains (const CORE_ADDR addr) const +{ + if (addr >=3D start () && addr < end ()) + { + if (is_contiguous ()) +=09return true; + + for (auto range : ranges ()) +=09{ +=09 if (range.start () <=3D addr && addr < range.end ()) +=09 return true; +=09} + } + return false; +} + +/* See block.h. */ + struct symbol * block::linkage_function () const { @@ -857,7 +876,10 @@ blockvector::lookup (CORE_ADDR addr) const if (b->start () > addr) =09return nullptr; if (b->end () > addr) -=09return b; +=09{ +=09 if (b->contains (addr)) +=09 return b; +=09} bot--; } =20 diff --git a/gdb/block.h b/gdb/block.h index 091120ae2b8..34bafb962d7 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -315,6 +315,10 @@ struct block : public allocate_on_obstack =20 bool contains (const struct block *a, bool allow_nested =3D false) const= ; =20 + /* Return true if block contains address ADDR. Return false otherwise. = */ + + bool contains (const CORE_ADDR addr) const; + /* Relocate this block and all contained blocks. OBJFILE is the objfile holding this block, and OFFSETS is the relocation offsets to use. */ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 7352bc605ed..5cee71bb8e3 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -9289,6 +9289,9 @@ dwarf2_record_block_ranges (struct die_info *die, str= uct block *block, =09 if (die->tag !=3D DW_TAG_compile_unit) =09 ranges_offset +=3D cu->gnu_ranges_base; =20 +=09 CORE_ADDR lo =3D std::numeric_limits::max (); +=09 CORE_ADDR hi =3D std::numeric_limits::min (); + =09 std::vector rangevec; =09 dwarf2_ranges_process (ranges_offset, cu, die->tag, =09=09=09=09 [&] (unrelocated_addr start, @@ -9296,10 +9299,17 @@ dwarf2_record_block_ranges (struct die_info *die, s= truct block *block, =09 { =09 CORE_ADDR abs_start =3D per_objfile->relocate (start); =09 CORE_ADDR abs_end =3D per_objfile->relocate (end); + +=09 lo =3D std::min (lo, abs_start); +=09 hi =3D std::max (hi, abs_end); + =09 dwarf2_maybe_record_inline_function (cu, block, end); =09 rangevec.emplace_back (abs_start, abs_end); =09 }); =20 +=09 gdb_assert (rangevec.size () =3D=3D 0 || block->start () =3D=3D lo); +=09 gdb_assert (rangevec.size () =3D=3D 0 || block->end () =3D=3D hi); + =09 block->set_ranges (make_blockranges (objfile, rangevec)); =09} } --=20 2.53.0