From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MPLQBAGp82mpxAYAWB0awg (envelope-from ) for ; Thu, 30 Apr 2026 15:09:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1777576192; bh=KVqf0afIA0e/SNj8DqOZtouplEmREgVv6CMy2I+xFF4=; h=Date:Subject:From:To:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=kj/PucieFODEOLNia3vxF8l/u2nbivTTrASOs83bmcj2qhtD90pYSPBYwauEd6tfY qnaOVKgXuWlhaBoTdcT+6+ld5DEEueoQlU5Np56vz4gDru9cNzz5zcILKZDwGN+pqE 6bN+u8bgmA4UDLkwfPe2R8t942wh/DwAIfOPKOfY= Received: by simark.ca (Postfix, from userid 112) id E4DB71E067; Thu, 30 Apr 2026 15:09:52 -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_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 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=cmufj009; dkim-atps=neutral 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 ECDC41E067 for ; Thu, 30 Apr 2026 15:09:51 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 64AD742D3769 for ; Thu, 30 Apr 2026 19:09:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 64AD742D3769 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=cmufj009 Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id E781E4BB58FC for ; Thu, 30 Apr 2026 19:09:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E781E4BB58FC Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E781E4BB58FC 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=1777576168; cv=none; b=rxK8OWQ9Bgq9d6q9omsatTsVifCjYI+YdKmIrxWY3lxkvuvsAjTIpydTMB6fGpQhE+lYVOoyp6BFsqa/fIKDNtNpsB9DVle+VUxffNzbqfhqCK5b3bxd6tqD6sjd/vEaClhuEJ3qXdK2btyo4ceyzUNXjuGKBh9DDG+N7oD2MDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777576168; c=relaxed/simple; bh=KVqf0afIA0e/SNj8DqOZtouplEmREgVv6CMy2I+xFF4=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:From:To; b=HD7bro7ghpIcy/PxWntONVpiBR0CSp5NV5354d1LIw/QE2HPgH3CC/DnGfO1SG2ENAYw9znd1bXuaP1QYDti8MxyUtmCCbnta4Iuo2NM8lSZGFlgadU8Qvmp1udiAGOhbwVtNiRcwKbDWQuV+tsmbks9jn7JcCnQ8ZmTcBqyVtw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E781E4BB58FC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1777576166; bh=KVqf0afIA0e/SNj8DqOZtouplEmREgVv6CMy2I+xFF4=; h=Date:Subject:From:To:References:In-Reply-To:From; b=cmufj009tdA6kSb+XF9l6zar7KuLQgR7UVO7EvZOA8wdh7Yx/A230UO/6CyuIB1Nh rTObBshbDv4qP/vGhxTJhFsrB+SG/8j+DYGX8serfw9Vmdb4wwM133UFnNsN5E3ocf VBNo67xAWhC4r5NKDRu9EKI0me2pavKhIBjRsqvI= Received: by simark.ca (Postfix) id 311141E067; Thu, 30 Apr 2026 15:09:25 -0400 (EDT) Message-ID: Date: Thu, 30 Apr 2026 15:09:24 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/7] [gdbsupport] Factor out base_next_iterator From: Simon Marchi To: Tom de Vries , gdb-patches@sourceware.org References: <20260423063530.1074175-1-tdevries@suse.de> <20260423063530.1074175-4-tdevries@suse.de> <52ebd2ce-a27b-4cf6-81f4-ad3fa3537ee1@simark.ca> Content-Language: fr In-Reply-To: <52ebd2ce-a27b-4cf6-81f4-ad3fa3537ee1@simark.ca> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 On 4/30/26 12:24 PM, Simon Marchi wrote: > Rather than copy paste what I mean here, I pushed what I think it could > look like to the users/simark/next-iterator branch. > > https://sourceware.org/git/?p=binutils-gdb.git;a=shortlog;h=refs/heads/users/simark/next-iterator > https://sourceware.org/cgit/binutils-gdb/log/?h=users/simark/next-iterator > > But just to illustrate here is how the function block iterator and > range are implemented: > > /* Iterator and range type to iterate over this block and its superblocks > within a function. */ > > struct function_block_incrementer > { > const block *operator() (const block &b) const noexcept > { > /* If the current item is the function-defining block, we're done. */ > if (b.function () != nullptr) > return nullptr; > > return b.superblock (); > } > }; > > using function_block_iterator > = base_next_iterator; > using function_block_range = iterator_range; Just a note: in your version, if you pass a global or static block to function_block_iterator, it sets the item to nullptr right away, so you iterate on nothing. I couldn't do that in my version, so I chose to assert that the block isn't global or static, which puts the responsibillity on the caller not to call this on a global or static block. The only caller is in ada-lang.c, it passes the result of get_frame_block(). I guess that a block from a frame is always in a function (is not the global or static block), but if that assumption isn't true, then a check would be needed in the caller. Simon