From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id O2C3Bas8/mnwWCQAWB0awg (envelope-from ) for ; Fri, 08 May 2026 15:42:35 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=CPBL3ZpY; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 04FC61E067; Fri, 08 May 2026 15:42:35 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=no 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 482D91E067 for ; Fri, 08 May 2026 15:42:34 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B1D154BA2E0B for ; Fri, 8 May 2026 19:42:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B1D154BA2E0B Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=CPBL3ZpY Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id 506ED4BA2E04 for ; Fri, 8 May 2026 19:41:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 506ED4BA2E04 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 506ED4BA2E04 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778269319; cv=none; b=W/DYDv0iibCnr6wvKPTGpz8NUxh7gfmNI2Ujsns9Lk+MkAKHRyPFPTAfiPx2DS10rwvM1K0a3xZjYeqsL84hU3Glnrp1llmRCa0tW1H1blNuaRj7Gub6iVqyaWoDCzhmy9ErY+KAz0z2hYbLRiu7enU8yS0W+MVcNPw/BSiJFjE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778269319; c=relaxed/simple; bh=ehMKthhICROsDFhsXaVaP+ZKEAvsZESZEjd+GedKF7I=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=NMJFEQrM7YHf4/tGaDWGc+p8mbVLKkOQlip9Lc05yO11wIgNyDsEtMTz90pOHo+I6T4EQK11VtuD3GCjd26PfWWyUeHp5zWYTVCtKEd3B15/t+x/6FkdPBKdhEmQ4aONyN6QbpoZHF/LQuyHv28tUPkUacHgpVv9iGXZF38oKiw= ARC-Authentication-Results: i=1; sourceware.org; dkim=policy (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=CPBL3ZpY reason="signing key too small" DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 506ED4BA2E04 Received: from eig-obgw-5007b.ext.cloudfilter.net ([10.0.29.167]) by cmsmtp with ESMTPS id L4egwUEfUrDqVLR5CwY4x2; Fri, 08 May 2026 19:41:58 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id LR5BwPTBzHcweLR5BwVKHP; Fri, 08 May 2026 19:41:58 +0000 X-Authority-Analysis: v=2.4 cv=Paj/hjhd c=1 sm=1 tr=0 ts=69fe3c86 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=NGcC8JguVDcA:10 a=ItBw4LHWJt0A:10 a=CcdR0sj4d0BwbvLgdyAA:9 a=O8hF6Hzn-FEA:10 a=DCx65vhANUyCzuf5D8fC:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To :Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=XUN4YrTRA9JlXn9cm16dJVLJUlRBS/d7VwcO5SXUNtY=; b=CPBL3ZpYcszaOf3oWyHkB8MxL6 lOKgiPrdxcQkNNfQ4CKAxNyK9uKpSuLopnuIxlNg4WKeaWmLJuP0RIz9u/whdlG+IeZEMlzAi5rYB 06uKiNcTSCGwRn/tRSfGQLUcJ; Received: from 75-166-225-82.hlrn.qwest.net ([75.166.225.82]:36286 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.99.2) (envelope-from ) id 1wLR5B-00000001JxB-0u8R; Fri, 08 May 2026 13:41:57 -0600 From: Tom Tromey To: Tom de Vries Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 08/10] [gdb] Use block::block_and_superblocks In-Reply-To: <20260501124504.2233495-9-tdevries@suse.de> (Tom de Vries's message of "Fri, 1 May 2026 14:45:02 +0200") References: <20260501124504.2233495-1-tdevries@suse.de> <20260501124504.2233495-9-tdevries@suse.de> X-Attribution: Tom Date: Fri, 08 May 2026 13:41:56 -0600 Message-ID: <87ik8xn0xn.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.225.82 X-Source-L: No X-Exim-ID: 1wLR5B-00000001JxB-0u8R X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-225-82.hlrn.qwest.net (bapiya) [75.166.225.82]:36286 X-Source-Auth: tom+tromey.com X-Email-Count: 7 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfKdV7IHWN9r1PCQeXLF1L6QSYSx8MxP6PzLnoKW3UHme9OxqcWUroj0B/ysz/FqSE5cwNoCugsn9FvV4cyNOAG5JWofBSy30094C+EVOlxAXkb8pZyDk lDWlxvXEPTbGT9R5eBHyX8vCMixRau6VcsO/NTjF3O+kMOxuooskvl1QXmopdw77qFLdNVdzDKxeSNewFfBeyXBfk4EoF93vCOQ= 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 >>>>> "Tom" == Tom de Vries writes: Tom> diff --git a/gdb/blockframe.c b/gdb/blockframe.c Tom> index 8aafa6ffe57..5c981748cbc 100644 Tom> --- a/gdb/blockframe.c Tom> +++ b/gdb/blockframe.c Tom> @@ -69,13 +69,14 @@ get_frame_block (const frame_info_ptr &frame, CORE_ADDR *addr_in_block) Tom> inline_count = frame_inlined_callees (frame); Tom> - while (inline_count > 0) Tom> + auto range = bl->block_and_superblocks (); Tom> + for (auto b = range.begin (); b != range.end (); ++b, bl = *b) Tom> { Tom> - if (bl->inlined_p ()) Tom> - inline_count--; Tom> + if (inline_count <= 0) Tom> + break; Tom> - bl = bl->superblock (); Tom> - gdb_assert (bl != NULL); Tom> + if ((*b)->inlined_p ()) Tom> + inline_count--; Tom> } Tom> return bl; I think this particular change is less clear than the code it replaces. Tom> diff --git a/gdb/dwarf2/line-program.c b/gdb/dwarf2/line-program.c Tom> index b9da1b4799f..227ec01aec9 100644 Tom> --- a/gdb/dwarf2/line-program.c Tom> +++ b/gdb/dwarf2/line-program.c Tom> @@ -373,21 +373,15 @@ dwarf_find_and_extend_inline_block_range (dwarf2_cu *cu, Tom> the child of a non-inline block. This is new inline block is our Tom> candidate for extending. */ Tom> struct block *block = nullptr; Tom> - for (const struct block *b = it->second; Tom> - b != nullptr; Tom> - b = b->superblock ()) Tom> - { Tom> - if (b->function () != nullptr && b->inlined_p ()) Tom> - { Tom> - if (b->superblock () != nullptr Tom> - && b->superblock ()->function () != nullptr Tom> - && !b->superblock ()->inlined_p ()) Tom> - { Tom> - block = const_cast (b); Tom> - break; Tom> - } Tom> - } Tom> - } Tom> + for (auto b : block::block_and_superblocks (it->second)) Tom> + if (b->inlined_p () Tom> + && b->superblock () != nullptr Tom> + && b->superblock ()->function () != nullptr Tom> + && !b->superblock ()->inlined_p ()) Tom> + { Tom> + block = const_cast (b); Tom> + break; Tom> + } It took me a while to figure out why you removed the check of 'function', but it's because inlined_p already does this check. It's helpful to call out this kind of change or to put it in a separate patch. Tom> --- a/gdb/infrun.c Tom> +++ b/gdb/infrun.c Tom> @@ -8261,13 +8261,15 @@ process_event_stop_test (struct execution_control_state *ecs) Tom> const struct block *prev Tom> = block_for_pc (ecs->event_thread->control.step_frame_id.code_addr); Tom> const struct block *curr = block_for_pc (ecs->event_thread->stop_pc ()); Tom> - while (curr != nullptr && !curr->contains (prev)) Tom> + for (auto b : block::block_and_superblocks (curr)) Tom> { This code would be clearer if 'curr' were eliminated entirely. In this case I had to go see if it was used after the loop. Tom> + auto range = block::block_and_superblocks (cur_block); Tom> + for (auto b = range.begin (); b != range.end (); ++b, cur_block = *b) This is another case where the result is harder to reason about that the earlier code. Maybe it could be salvaged somehow by assigning at the breaks, not sure. Tom> diff --git a/gdb/symmisc.c b/gdb/symmisc.c Tom> index 89374bd8a2f..f882f3add17 100644 Tom> --- a/gdb/symmisc.c Tom> +++ b/gdb/symmisc.c Tom> @@ -961,11 +961,10 @@ block_depth (const struct block *block) Tom> { Tom> int i = 0; Tom> - while ((block = block->superblock ()) != NULL) Tom> - { Tom> - i++; Tom> - } Tom> - return i; Tom> + for (auto b [[maybe_unused]]: block::block_and_superblocks (block)) Tom> + i++; Tom> + Tom> + return i - 1; Can this just be std::count? Also this doesn't have to handle the case where the initial block is nullptr. Tom> + auto range = block::block_and_superblocks (bl); Tom> + for (auto b = range.begin (); b != range.end (); ++b, bl = *b) Like the earlier ones. I don't think multiple assignments like this make it clearer or easier to work with. Tom