From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id sbsyLzKh9GkT9ggAWB0awg (envelope-from ) for ; Fri, 01 May 2026 08:48:50 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=rSrzP575; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=tReRvU0l; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=rSrzP575; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=tReRvU0l; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id BC4771E067; Fri, 01 May 2026 08:48:50 -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.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,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 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 7D9F41E067 for ; Fri, 01 May 2026 08:48:49 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 219F146A9CED for ; Fri, 1 May 2026 12:48:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 219F146A9CED Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=rSrzP575; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=tReRvU0l; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=rSrzP575; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=tReRvU0l 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 DEA384A9A89F for ; Fri, 1 May 2026 12:45:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DEA384A9A89F 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 DEA384A9A89F 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=1777639551; cv=none; b=LcJ8UTYTNUjFihLWIVcTezydoDv27TCbuPjDetoGAV/isv7j8VRSVJrFoCjsioZYr2HDdKsQ90Ksi9gKkat+sxWkLJ8gWYFbfE5wm54Dvwa12Ub6EtL+E9lpItzBBAmwAuhUWDSMhwFwslC1UVrn0qZIgTKGVCDFQ0c3XhcxsnY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777639551; c=relaxed/simple; bh=naK7SbCVhEwIGeCl1FrpHt6I+rTkNquzVI6H/Mv+b8k=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=wrCRbX70KPNFBpyU9AknOj6VJEFMKNhIWWK4hwlf9X1zrvkIqlrrhKpSkbwzxvvbfEU3ydrieDau/l4o+636B0fgbhsQuy79v3zhjdjEh539833LJj2Hha744wJRcDOpjrUkzjlGjXYnguXH1vyFidcLpwu9f2yvAsyprsFxVHE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DEA384A9A89F Received: from imap1.dmz-prg2.suse.org (unknown [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 C1A855BD70 for ; Fri, 1 May 2026 12:45:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1777639506; 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=R26ZoB5OhEKXg3vGWcFIeTXlVj5uxnUyvUdQkGrQH7M=; b=rSrzP575xn1LCtKwwyMUmkMDsytxz9e3JqEdSGEqUhWEzzyutZ/l/DjzzbmKk6fD6gM2mV BkfvvQ/ECZIgvnkWl4TGCJJErOG8+uGyDLgbAUcngie0DSSgWX0MYYGXWLuIGomtbwlcDk +Ew/cbfSt/+H6d7RvCknYJUQiStwNNM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1777639506; 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=R26ZoB5OhEKXg3vGWcFIeTXlVj5uxnUyvUdQkGrQH7M=; b=tReRvU0ljVdb7QNSSccG/PnGomIGmsdStTuexH19suBBKIcVhJYU0A1K4BU0QwONmpqdIq 9qPu+Z8GFlV1aKCA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1777639506; 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=R26ZoB5OhEKXg3vGWcFIeTXlVj5uxnUyvUdQkGrQH7M=; b=rSrzP575xn1LCtKwwyMUmkMDsytxz9e3JqEdSGEqUhWEzzyutZ/l/DjzzbmKk6fD6gM2mV BkfvvQ/ECZIgvnkWl4TGCJJErOG8+uGyDLgbAUcngie0DSSgWX0MYYGXWLuIGomtbwlcDk +Ew/cbfSt/+H6d7RvCknYJUQiStwNNM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1777639506; 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=R26ZoB5OhEKXg3vGWcFIeTXlVj5uxnUyvUdQkGrQH7M=; b=tReRvU0ljVdb7QNSSccG/PnGomIGmsdStTuexH19suBBKIcVhJYU0A1K4BU0QwONmpqdIq 9qPu+Z8GFlV1aKCA== 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 A768B593B1 for ; Fri, 1 May 2026 12:45:06 +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 kDnEJlKg9Gn5ZwAAD6G6ig (envelope-from ) for ; Fri, 01 May 2026 12:45:06 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 08/10] [gdb] Use block::block_and_superblocks Date: Fri, 1 May 2026 14:45:02 +0200 Message-ID: <20260501124504.2233495-9-tdevries@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260501124504.2233495-1-tdevries@suse.de> References: <20260501124504.2233495-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_TLS_ALL(0.00)[] 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 uses of block::block_and_superblocks. --- gdb/ada-lang.c | 18 ++++------ gdb/blockframe.c | 11 +++--- gdb/compile/compile-object-load.c | 8 +++-- gdb/cp-namespace.c | 6 ++-- gdb/cp-support.c | 8 ++--- gdb/d-namespace.c | 6 ++-- gdb/dwarf2/line-program.c | 24 +++++-------- gdb/infrun.c | 10 +++--- gdb/inline-frame.c | 45 +++++++++++------------- gdb/linespec.c | 7 ++-- gdb/symmisc.c | 9 +++-- gdb/symtab.c | 58 ++++++++++++++++++------------- 12 files changed, 101 insertions(+), 109 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 71a338ce17e..6eb928b445d 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -5402,17 +5402,15 @@ ada_add_local_symbols (std::vector &result, const lookup_name_info &lookup_name, const struct block *block, domain_search_flags domain) { - while (block != NULL) + for (auto b : block::block_and_superblocks (block)) { - ada_add_block_symbols (result, block, lookup_name, domain, NULL); + ada_add_block_symbols (result, b, lookup_name, domain, nullptr); /* If we found a non-function match, assume that's the one. We only check this when finding a function boundary, so that we can accumulate all results from intervening blocks first. */ - if (block->function () != nullptr && is_nonfunction (result)) + if (b->function () != nullptr && is_nonfunction (result)) return; - - block = block->superblock (); } } @@ -13825,9 +13823,7 @@ class ada_language : public language_defn /* Search upwards from currently selected frame (so that we can complete on local vars. */ - for (const block *b = get_selected_block (0); - b != nullptr; - b = b->superblock ()) + for (auto b : block::block_and_superblocks (get_selected_block (0))) { if (b->is_static_block ()) surrounding_static_block = b; /* For elmin of dups */ @@ -13852,9 +13848,9 @@ class ada_language : public language_defn auto callback = [&] (compunit_symtab *s) { QUIT; - for (const block *b = s->blockvector ()->static_block (); - b != nullptr; - b = b->superblock ()) + const struct block *static_block + = s->blockvector ()->static_block (); + for (auto b : block::block_and_superblocks (static_block)) { /* Don't do this block twice. */ if (b == surrounding_static_block) diff --git a/gdb/blockframe.c b/gdb/blockframe.c index 8aafa6ffe57..5c981748cbc 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -69,13 +69,14 @@ get_frame_block (const frame_info_ptr &frame, CORE_ADDR *addr_in_block) inline_count = frame_inlined_callees (frame); - while (inline_count > 0) + auto range = bl->block_and_superblocks (); + for (auto b = range.begin (); b != range.end (); ++b, bl = *b) { - if (bl->inlined_p ()) - inline_count--; + if (inline_count <= 0) + break; - bl = bl->superblock (); - gdb_assert (bl != NULL); + if ((*b)->inlined_p ()) + inline_count--; } return bl; diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c index 4ea924582fb..32c6fe0bacf 100644 --- a/gdb/compile/compile-object-load.c +++ b/gdb/compile/compile-object-load.c @@ -443,10 +443,12 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile, continue; function_block = block; - while (function_block != bv->static_block () - && function_block != bv->global_block ()) + for (auto b : block::block_and_superblocks (block)) { - function_block = function_block->superblock (); + if (b == bv->static_block () || b == bv->global_block ()) + break; + + function_block = b->superblock (); function = function_block->function (); if (function != NULL) break; diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index c8cd5c245aa..534f2d0b8f9 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -613,13 +613,11 @@ cp_lookup_symbol_via_all_imports (const char *scope, const char *name, { struct block_symbol sym; - while (block != NULL) + for (auto b : block::block_and_superblocks (block)) { - sym = cp_lookup_symbol_via_imports (scope, name, block, domain, 0, 1); + sym = cp_lookup_symbol_via_imports (scope, name, b, domain, 0, 1); if (sym.symbol != nullptr) return sym; - - block = block->superblock (); } return {}; diff --git a/gdb/cp-support.c b/gdb/cp-support.c index d040ad79469..c04a5120380 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -1408,15 +1408,11 @@ add_symbol_overload_list_using (const char *func_name, const char *the_namespace, std::vector *overload_list) { - const struct block *block; - /* First, go through the using directives. If any of them apply, look in the appropriate namespaces for new functions to match on. */ - for (block = get_selected_block (0); - block != NULL; - block = block->superblock ()) + for (auto block : block::block_and_superblocks (get_selected_block (0))) for (using_direct *current : block->get_using ()) { /* Prevent recursive calls. */ @@ -1459,7 +1455,7 @@ add_symbol_overload_list_qualified (const char *func_name, /* Search upwards from currently selected frame (so that we can complete on local vars. */ - for (const block *b = selected_block; b != nullptr; b = b->superblock ()) + for (auto b : block::block_and_superblocks (selected_block)) add_symbol_overload_list_block (func_name, b, overload_list); const block *surrounding_static_block = (selected_block == nullptr diff --git a/gdb/d-namespace.c b/gdb/d-namespace.c index 34b90c0ed93..a8bb90320c3 100644 --- a/gdb/d-namespace.c +++ b/gdb/d-namespace.c @@ -481,14 +481,12 @@ d_lookup_symbol_module (const char *scope, const char *name, /* Search for name in modules imported to this and parent blocks. */ - while (block != NULL) + for (auto b : block::block_and_superblocks (block)) { - sym = d_lookup_symbol_imports (scope, name, block, domain); + sym = d_lookup_symbol_imports (scope, name, b, domain); if (sym.symbol != NULL) return sym; - - block = block->superblock (); } return {}; diff --git a/gdb/dwarf2/line-program.c b/gdb/dwarf2/line-program.c index b9da1b4799f..227ec01aec9 100644 --- a/gdb/dwarf2/line-program.c +++ b/gdb/dwarf2/line-program.c @@ -373,21 +373,15 @@ dwarf_find_and_extend_inline_block_range (dwarf2_cu *cu, the child of a non-inline block. This is new inline block is our candidate for extending. */ struct block *block = nullptr; - for (const struct block *b = it->second; - b != nullptr; - b = b->superblock ()) - { - if (b->function () != nullptr && b->inlined_p ()) - { - if (b->superblock () != nullptr - && b->superblock ()->function () != nullptr - && !b->superblock ()->inlined_p ()) - { - block = const_cast (b); - break; - } - } - } + for (auto b : block::block_and_superblocks (it->second)) + if (b->inlined_p () + && b->superblock () != nullptr + && b->superblock ()->function () != nullptr + && !b->superblock ()->inlined_p ()) + { + block = const_cast (b); + break; + } /* If we didn't find a block, or the block we found wasn't called from the expected LINE, then we're done. Maybe we should try harder to diff --git a/gdb/infrun.c b/gdb/infrun.c index 11c5d5214d6..be57c521a0d 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -8261,13 +8261,15 @@ process_event_stop_test (struct execution_control_state *ecs) const struct block *prev = block_for_pc (ecs->event_thread->control.step_frame_id.code_addr); const struct block *curr = block_for_pc (ecs->event_thread->stop_pc ()); - while (curr != nullptr && !curr->contains (prev)) + for (auto b : block::block_and_superblocks (curr)) { - if (curr->inlined_p ()) + if (b->contains (prev)) + break; + + if (b->inlined_p ()) depth++; - else if (curr->function () != nullptr) + else if (b->function () != nullptr) break; - curr = curr->superblock (); } while (inline_skipped_frames (ecs->event_thread) > depth) step_into_inline_frame (ecs->event_thread); diff --git a/gdb/inline-frame.c b/gdb/inline-frame.c index a1ccd4ed0da..3aeaebffa2d 100644 --- a/gdb/inline-frame.c +++ b/gdb/inline-frame.c @@ -217,7 +217,7 @@ inline_frame_sniffer (const struct frame_unwind *self, void **this_cache) { CORE_ADDR this_pc; - const struct block *frame_block, *cur_block; + const struct block *frame_block; int depth; frame_info_ptr next_frame; struct inline_state *state = find_inline_frame_state (inferior_thread ()); @@ -230,15 +230,15 @@ inline_frame_sniffer (const struct frame_unwind *self, /* Calculate DEPTH, the number of inlined functions at this location. */ depth = 0; - cur_block = frame_block; - while (cur_block->superblock ()) + for (auto cur_block : frame_block->block_and_superblocks ()) { + if (cur_block->superblock () == nullptr) + break; + if (cur_block->inlined_p ()) depth++; else if (cur_block->function () != NULL) break; - - cur_block = cur_block->superblock (); } /* Check how many inlined functions already have frames. */ @@ -361,25 +361,22 @@ gather_inline_frames (CORE_ADDR this_pc) return {}; std::vector function_symbols; - while (cur_block != nullptr) - { - if (cur_block->inlined_p ()) - { - gdb_assert (cur_block->function () != nullptr); - - /* See comments in inline_frame_this_id about this use - of BLOCK_ENTRY_PC. */ - if (cur_block->entry_pc () == this_pc - || block_starting_point_at (bv, this_pc, cur_block)) - function_symbols.push_back (cur_block->function ()); - else - break; - } - else if (cur_block->function () != nullptr) - break; - - cur_block = cur_block->superblock (); - } + auto range = block::block_and_superblocks (cur_block); + for (auto b = range.begin (); b != range.end (); ++b, cur_block = *b) + if (cur_block->inlined_p ()) + { + gdb_assert (cur_block->function () != nullptr); + + /* See comments in inline_frame_this_id about this use + of BLOCK_ENTRY_PC. */ + if (cur_block->entry_pc () == this_pc + || block_starting_point_at (bv, this_pc, cur_block)) + function_symbols.push_back (cur_block->function ()); + else + break; + } + else if (cur_block->function () != nullptr) + break; /* If we have a code region for which we have no function blocks, possibly due to bad debug, or possibly just when some debug diff --git a/gdb/linespec.c b/gdb/linespec.c index 6ed4b4553d3..c393e855a91 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -1194,11 +1194,10 @@ iterate_over_file_blocks domain_search_flags domain, for_each_symbol_callback_ftype callback) { - const struct block *block; + const struct block *static_block + = symtab->compunit ()->blockvector ()->static_block (); - for (block = symtab->compunit ()->blockvector ()->static_block (); - block != NULL; - block = block->superblock ()) + for (auto block : block::block_and_superblocks (static_block)) current_language->for_each_symbol (block, name, domain, callback); } diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 89374bd8a2f..f882f3add17 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -961,11 +961,10 @@ block_depth (const struct block *block) { int i = 0; - while ((block = block->superblock ()) != NULL) - { - i++; - } - return i; + for (auto b [[maybe_unused]]: block::block_and_superblocks (block)) + i++; + + return i - 1; } diff --git a/gdb/symtab.c b/gdb/symtab.c index 3c10e1fd750..d8e4e6375d9 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2181,14 +2181,17 @@ lookup_local_symbol (const char *name, const char *scope = block->scope (); - while (!block->is_global_block () && !block->is_static_block ()) + for (auto b : block->block_and_superblocks ()) { + if (b->is_global_block () || b->is_static_block ()) + break; + struct symbol *sym = lookup_symbol_in_block (name, match_type, - block, domain); + b, domain); if (sym != NULL) - return (struct block_symbol) {sym, block}; + return (struct block_symbol) {sym, b}; - struct symbol *function = block->function (); + struct symbol *function = b->function (); if (function != nullptr && function->is_template_function ()) { struct template_symbol *templ = (struct template_symbol *) function; @@ -2196,17 +2199,16 @@ lookup_local_symbol (const char *name, templ->n_template_arguments, templ->template_arguments); if (sym != nullptr) - return (struct block_symbol) {sym, block}; + return (struct block_symbol) {sym, b}; } struct block_symbol blocksym - = langdef->lookup_symbol_local (scope, name, block, domain); + = langdef->lookup_symbol_local (scope, name, b, domain); if (blocksym.symbol != nullptr) return blocksym; - if (block->inlined_p ()) + if (b->inlined_p ()) break; - block = block->superblock (); } /* We've reached the end of the function without finding a result. */ @@ -3829,13 +3831,17 @@ skip_prologue_sal (struct symtab_and_line *sal) use the call site of the function instead. */ const block *function_block = nullptr; - for (const block *b = block_for_pc_sect (sal->pc, sal->section); - b != nullptr; - b = b->superblock ()) - if (b->function () != NULL && b->inlined_p ()) - function_block = b; - else if (b->function () != NULL) - break; + const block *pc_block = block_for_pc_sect (sal->pc, sal->section); + for (auto b: block::block_and_superblocks (pc_block)) + { + if (b->function () == nullptr) + continue; + + if (b->inlined_p ()) + function_block = b; + else + break; + } if (function_block != NULL && function_block->function ()->line () != 0) @@ -3929,7 +3935,8 @@ skip_prologue_using_sal (struct gdbarch *gdbarch, CORE_ADDR func_addr) same function, not something inlined. If it's inlined, then there is no point comparing the line numbers. */ bl = block_for_pc (prologue_sal.end); - while (bl) + auto range = block::block_and_superblocks (bl); + for (auto b = range.begin (); b != range.end (); ++b, bl = *b) { if (bl->inlined_p ()) break; @@ -3938,7 +3945,6 @@ skip_prologue_using_sal (struct gdbarch *gdbarch, CORE_ADDR func_addr) bl = NULL; break; } - bl = bl->superblock (); } if (bl != NULL) break; @@ -5868,7 +5874,7 @@ default_collect_symbol_completion_matches_break_on frees them. I'm not going to worry about this; hopefully there won't be that many. */ - const struct block *b; + const struct block *selected_block; const struct block *surrounding_static_block, *surrounding_global_block; /* The symbol we are completing on. Points in same buffer as text. */ const char *sym_text; @@ -5977,12 +5983,17 @@ default_collect_symbol_completion_matches_break_on this places which match our text string. Only complete on types visible from current context. */ - b = get_selected_block (0); - surrounding_static_block = b == nullptr ? nullptr : b->static_block (); - surrounding_global_block = b == nullptr ? nullptr : b->global_block (); + selected_block = get_selected_block (0); + surrounding_static_block + = selected_block == nullptr ? nullptr : selected_block->static_block (); + surrounding_global_block + = selected_block == nullptr ? nullptr : selected_block->global_block (); if (surrounding_static_block != NULL) - while (b != surrounding_static_block) + for (auto b : block::block_and_superblocks (selected_block)) { + if (b == surrounding_static_block) + break; + QUIT; for (struct symbol *sym : block_iterator_range (b)) @@ -6003,9 +6014,8 @@ default_collect_symbol_completion_matches_break_on /* Stop when we encounter an enclosing function. Do not stop for non-inlined functions - the locals of the enclosing function are in scope for a nested function. */ - if (b->function () != NULL && b->inlined_p ()) + if (b->inlined_p ()) break; - b = b->superblock (); } /* Add fields from the file's types; symbols will be added below. */ -- 2.51.0