From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id +TqiKtRlqGmERxQAWB0awg (envelope-from ) for ; Wed, 04 Mar 2026 12:03:16 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=labware.com header.i=@labware.com header.a=rsa-sha256 header.s=mimecast20220511 header.b=lyZF98QK; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id A88571E0DD; Wed, 04 Mar 2026 12:03:16 -0500 (EST) 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 BF82E1E089 for ; Wed, 04 Mar 2026 12:03:15 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 574B74BA23C5 for ; Wed, 4 Mar 2026 17:03:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 574B74BA23C5 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=labware.com header.i=@labware.com header.a=rsa-sha256 header.s=mimecast20220511 header.b=lyZF98QK Received: from us-smtp-delivery-114.mimecast.com (us-smtp-delivery-114.mimecast.com [170.10.129.114]) by sourceware.org (Postfix) with ESMTP id 1AF834BA2E18 for ; Wed, 4 Mar 2026 17:00:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1AF834BA2E18 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=labware.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=labware.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1AF834BA2E18 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.114 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772643616; cv=none; b=jNIeCBbIAYPMBsen9skpUiD2bwGVHcL+WAOqYpK98Vpvg7F/5MR9l2py6jv/UlIXA7ZQug4ZQ6CrVX/GekGwGYCAL1/Qhd1a6rdK7afvjb2JwfeZdxUa1wNYs8Q6+kygO5QqJniM2X2a+NfxnEUEKyVMvyuhBTgkcln9NhzC6bg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772643616; c=relaxed/simple; bh=AKEC+YPsaWA/IE6SzDMGAu5Gec8zeh8wzvzT0V8KG34=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=SliUp7Dy4u//zZlighOzjMpVPaEiBy3UHXFob/EbdESrhsdGG8hmjjslQAp/KRQ8Aa7dZpCSxrVu0cia8hPqSQqiihQocCulAMEGwog3veT3Me3zMbObQpMmItRU+ZEj96DvH+VKzOEZXIqOr6KUIz5jvWspjVWW2Y8BXsGvt/g= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1AF834BA2E18 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=labware.com; s=mimecast20220511; t=1772643615; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7o8DVf2uHM/sinwuEoM8KREkYuWeRtHDmOH5bXW7M3o=; b=lyZF98QKark6Kq5OVnPwBRJa+WqrYXSX9YZhIIX+DVAD4I6fUs+E2UmrSoOlVrxX0utUyr 68ZufO9yrE/zVpg0g0MJ403UMn6HGMYgBmUgVCs3agVFKGJ9Ji/6h6TLhP/EmiWab3a8S+ xza5GJhSJen+Gn1pE2D/nEC1DafYhYk= Received: from PH8PR06CU001.outbound.protection.outlook.com (mail-westus3azon11022101.outbound.protection.outlook.com [40.107.209.101]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-455-N-8pWb64PxeR97IvyHriAg-1; Wed, 04 Mar 2026 12:00:12 -0500 X-MC-Unique: N-8pWb64PxeR97IvyHriAg-1 X-Mimecast-MFC-AGG-ID: N-8pWb64PxeR97IvyHriAg_1772643612 Received: from SA1PR17MB5365.namprd17.prod.outlook.com (2603:10b6:806:1d8::11) by IA3PR17MB7264.namprd17.prod.outlook.com (2603:10b6:208:51c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9654.22; Wed, 4 Mar 2026 17:00:10 +0000 Received: from SA1PR17MB5365.namprd17.prod.outlook.com ([fe80::9a:538a:fa42:730e]) by SA1PR17MB5365.namprd17.prod.outlook.com ([fe80::9a:538a:fa42:730e%3]) with mapi id 15.20.9654.022; Wed, 4 Mar 2026 17:00:10 +0000 From: Jan Vrany To: gdb-patches@sourceware.org CC: Jan Vrany Subject: [PATCH v2 4/7] gdb: update blockvector::lookup to handle non-contiguous blocks Date: Wed, 4 Mar 2026 16:59:11 +0000 Message-ID: <20260304165914.3209106-5-jan.vrany@labware.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260304165914.3209106-1-jan.vrany@labware.com> References: <20260304165914.3209106-1-jan.vrany@labware.com> X-ClientProxiedBy: LO3P265CA0009.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:bb::14) To SA1PR17MB5365.namprd17.prod.outlook.com (2603:10b6:806:1d8::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR17MB5365:EE_|IA3PR17MB7264:EE_ X-MS-Office365-Filtering-Correlation-Id: 771f8418-c50d-47cf-3ae8-08de7a0f7ed1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014 X-Microsoft-Antispam-Message-Info: y25hexh+HppLXir0oZ+7LQXKWuUQcDFuhUyOyC149WbsphGs+jXVIpiQw5xMfcvxmOMDTfal9SVI9N7kW8QOQ23R6yNr+lofkXFD70NYXd6/s5/+27Gy4nbq4+jYhR0RfpKGytZNJpfAT8830nenEcWaIYMbViZzib/se6s02fKujgqRB4iZgLB4N1TrXCbckHBkP16NVNxLOoDjqmoua8Jfng+pvv4/AVX8F5dKr6rUEPF83KaoqsEkqva6ut4yKX03bLOpoHklRjiRamg6AeMRhQaf8H45LFjxufuqw/ZLTIjkbUxfKE9hZQzAA8V1JmUh0RpHGZefQjcl+S0GOsGd+ezWGXMt4mJ6jZT8egaXEgCy0wkPnk/wgwkSe/hPDCnx11dT3Y0/u99+6pO0T83tfqvG1UX2fBqO8x8D9NkR8fwOQLL8mj4/jZNVuuAOxUIf2kv4n1QCLI0AWdj2t7xfX1IOFg4xWTW5qfryjUIrmzB8fFtup6mdqWkImcGq9+ZPykoeWTONqz/vQTeV8ZTa7UbytJC10rvM9E21/6O0tUwrPDf2yBUCnhuXh847KVlQltrgt8n0VzBMgJAUwkXPaYrKORC8C5m3JHpMybHtrgANlKqmXlavQEVaDb/KVNwuehpRbBJzkYzIpMPcHQencIkSRGYfeE2S/HLP4bQbM+Sb9btWWKfz+bxy3fPxgW1GyF8NU79CKNwnJ+ROtNTENUygwRXVT1I5q7MPtCU= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA1PR17MB5365.namprd17.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1102 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?lDMwwYiWqMdVfVvK5mWO3qD/TACg+hixZoNJJ9iRvwrkwnvu47/qx7N0BJtw?= =?us-ascii?Q?ige+BBTJWSv/fYkX6zyW3KBmrPqNsy4s2DWccSiPScWNxb4Q9qaaCkCZDWH9?= =?us-ascii?Q?eqMSfkMiEmm0rZWDX+lBz5My4PtGR3eSHN+jxRgCzlUvzqbi4fYaT17W0nC1?= =?us-ascii?Q?VwK09x/5YlR/tpypW0EDXu3Al+ktoucMcgYmlHvH0Td2rAqfP33SjVhCnHv6?= =?us-ascii?Q?Vo0PwNYd20ST0Zpj8znb6CFOeD+NbDR5SAkDXN+jZdQRJ51oZdT6KWtUTdr1?= =?us-ascii?Q?At7IExDFnFwBHPejF1KlVvoXW/Ae+zjvVkH5q4xCMG8ku/eh0VByF0coeALd?= =?us-ascii?Q?YIJLGybbAiHzpl3QfgJKEmH9S6AvZQsQ8daK8pga+yhkFjBfsuRPfRsV7qYd?= =?us-ascii?Q?K3ZKTt9DRE0E1nsN4z/npUfFr+LQ7KDch8IpA/MKeQ2L5rTJVf14j8oWALbe?= =?us-ascii?Q?batANpAWdrK1N3SKcfHnB0uBOW3pHBYFDV24jQehKgyPxDHOivWoYT+urM2y?= =?us-ascii?Q?ifzvOD1NjlOiQCTFG7dGLWulk2A5vBm8FrBHHdWlyue6gP7w62Xwk3ibCkge?= =?us-ascii?Q?3zwVX7967xWH/MssImcj8wLMvUImtAisVoH9OBV1gx1SS0uTp605WcfW75hv?= =?us-ascii?Q?t3TwdzPQtFf6m+Pu1EPYvrTp/vsi1T4dq0bAoo3pgNRpVHv1ySI6y4XI6ZyF?= =?us-ascii?Q?KzWGt1HxHkeElGoK7SbuwQHWY88FVAg8T6TWxMFW8H2NhimRztjSSTD0sxDu?= =?us-ascii?Q?cVXud00l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ascii?Q?RQDqwRrSdGS5UsI2LU1B4ivaQ6Q5/uBPfDRNMuCSo9wr4b9H8FKRtb4Q0wS3?= =?us-ascii?Q?yaGjoSi5Bg=3D=3D?= X-OriginatorOrg: labware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 771f8418-c50d-47cf-3ae8-08de7a0f7ed1 X-MS-Exchange-CrossTenant-AuthSource: SA1PR17MB5365.namprd17.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2026 17:00:10.4775 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b5db0322-1aa0-4c0a-859c-ad0f96966f4c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QDGN5l5Egh+bACTUADlq7p5ZEmiL97m5RyTZeLBqz+bYhE0CHvomVS/EhRx/km1KmxK594kheA/VkH1dxLCdVA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA3PR17MB7264 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: GOIq-JzDS6eC8oVtTwSCMnvcSDdaPsP2pG7hyBjYHhI_1772643612 X-Mimecast-Originator: labware.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=WINDOWS-1252 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 730e4580a5b..b964674865b 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 b84ca12c35a..59cabbd620d 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 7c6f54449ba..c9b6bebdb86 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -9410,6 +9410,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 blockvec; =09 dwarf2_ranges_process (ranges_offset, cu, die->tag, =09=09=09=09 [&] (unrelocated_addr start, @@ -9417,10 +9420,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 blockvec.emplace_back (abs_start, abs_end); =09 }); =20 +=09 gdb_assert (blockvec.size () =3D=3D 0 || block->start () =3D=3D lo); +=09 gdb_assert (blockvec.size () =3D=3D 0 || block->end () =3D=3D hi); + =09 block->set_ranges (make_blockranges (objfile, blockvec)); =09} } --=20 2.51.0