From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id sewzKi++6WnhQTUAWB0awg (envelope-from ) for ; Thu, 23 Apr 2026 02:37:35 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=eO3T+isd; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=yr0Re/1P; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=eO3T+isd; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=yr0Re/1P; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id A72281E0BA; Thu, 23 Apr 2026 02:37: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=-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 094A11E067 for ; Thu, 23 Apr 2026 02:37:35 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 4230A4BBCDB1 for ; Thu, 23 Apr 2026 06:37:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4230A4BBCDB1 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=eO3T+isd; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=yr0Re/1P; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=eO3T+isd; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=yr0Re/1P Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 1A0424BBC0FC for ; Thu, 23 Apr 2026 06:35:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1A0424BBC0FC Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1A0424BBC0FC Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776926151; cv=none; b=uzPk/qFm46p2EbXnTpON4VOjFNa2lVdvZ0A0j/2DbEtMqUxVy7HzJ9wBY4baIVMFd22Zcj24TfX71U8YMqGryERc3qswS1Jc5oknRIMFg1v9fvvy+aRhKK9DABQpzU203WP+HbbWXKK33KpnPVmpJZZ1G8Qs5SFzD3Ru0MNZyKI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776926151; c=relaxed/simple; bh=+U4NCUeKkKif0I5Zf24nxWL23y6rGs+1tt4Kiw/22M8=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=FBUjyC7uyTkxPX+1lErkwddidrRiJ0xTOohnM6adbyuxdg1M+zffeecCOItl87AIRfo20Y0iKUmFksn/1Q+B8O1KaxdbrDvCaPTCGxxovH2Ahm+2Jrwu5iXyFu9Sg0j8iFdnqzwYQJF96tiBD1MGjHu7dOUm6oe4g2EEI4/fG0w= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1A0424BBC0FC Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id B83B75BD73 for ; Thu, 23 Apr 2026 06:35:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776926132; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t8uxhdte6Uz9vkGprtiB9zk5OcdiuW+2NdKZmSAseRw=; b=eO3T+isdN+wXUaLOvamffPHZ8lXYC4P+gcRpkAssgzFipmE+vhKZg/IB07HsiviSAbHziV 32X3SUKsGLxUeSYzEtU2a9SuTme8a+WIpSn0+q7BJKpRlcn0afw9PBetSB2tSUVRA2sBAV HHY/+snflhKrF6DcJ3suHWxkz6YagfM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776926132; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t8uxhdte6Uz9vkGprtiB9zk5OcdiuW+2NdKZmSAseRw=; b=yr0Re/1P0PbVaK+RgJcNzlJAkVSvDGgMBXFaqgIo0Fr4vE/eGVhc1KYGD4yq8ozOipKj1s Gy8BDJV3i1zeCYCA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=eO3T+isd; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="yr0Re/1P" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776926132; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t8uxhdte6Uz9vkGprtiB9zk5OcdiuW+2NdKZmSAseRw=; b=eO3T+isdN+wXUaLOvamffPHZ8lXYC4P+gcRpkAssgzFipmE+vhKZg/IB07HsiviSAbHziV 32X3SUKsGLxUeSYzEtU2a9SuTme8a+WIpSn0+q7BJKpRlcn0afw9PBetSB2tSUVRA2sBAV HHY/+snflhKrF6DcJ3suHWxkz6YagfM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776926132; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t8uxhdte6Uz9vkGprtiB9zk5OcdiuW+2NdKZmSAseRw=; b=yr0Re/1P0PbVaK+RgJcNzlJAkVSvDGgMBXFaqgIo0Fr4vE/eGVhc1KYGD4yq8ozOipKj1s Gy8BDJV3i1zeCYCA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 1C72C593B5 for ; Thu, 23 Apr 2026 06:35:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id CE+eBbS96WnpAgAAD6G6ig (envelope-from ) for ; Thu, 23 Apr 2026 06:35:32 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 6/7] [gdb] Add block::function_blocks Date: Thu, 23 Apr 2026 08:35:29 +0200 Message-ID: <20260423063530.1074175-7-tdevries@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423063530.1074175-1-tdevries@suse.de> References: <20260423063530.1074175-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_NONE(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim, suse.de:mid, imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns] X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: B83B75BD73 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 a function block::function_blocks that can be used to transform: ... while (block != NULL) { ... if (block->function () != nullptr) break; block = block->superblock (); } ... into: ... for (auto b : block::function_blocks (block)) { ... } ... I'm not sure about the name. It might suggest that it iterates over all function blocks, but that's not the case, it only does so for the inner function. I considered function block::inner_function_blocks instead, but it seems a bit awkward. --- gdb/block.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/gdb/block.h b/gdb/block.h index 4a1db79d7ed..53cc5435576 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -127,7 +127,34 @@ struct block : public allocate_on_obstack } }; + /* Variant of next_iterator using the superblock field instead of next. */ + struct function_block_iterator : base_next_iterator + { + typedef function_block_iterator self_type; + + explicit function_block_iterator (value_type item) + : base_next_iterator (item->is_global_block () || item->is_static_block () + ? nullptr : item) + { + } + + function_block_iterator () = default; + + self_type &operator++ () + { + if (this->m_item->function () != nullptr) + { + this->m_item = nullptr; + return *this; + } + + this->m_item = this->m_item->superblock (); + return *this; + } + }; + using superblock_range = iterator_range; + using function_block_range = iterator_range; /* Return this block's start address. */ CORE_ADDR start () const @@ -334,6 +361,13 @@ struct block : public allocate_on_obstack return superblock_range (std::move (begin)); } + function_block_range function_blocks () const + { + function_block_range::iterator begin (this); + + return function_block_range (std::move (begin)); + } + static superblock_range super_blocks (const block *b) { if (b == nullptr) @@ -342,6 +376,14 @@ struct block : public allocate_on_obstack return b->super_blocks (); } + static function_block_range function_blocks (const block *b) + { + if (b == nullptr) + return function_block_range (); + + return b->function_blocks (); + } + /* Return true if block A is lexically nested within this block, or if A and this block have the same pc range. Return false otherwise. If ALLOW_NESTED is true, then block A is considered -- 2.51.0