From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id obqNAyoUxmo0NA0AWB0awg (envelope-from ) for ; Wed, 07 Oct 2026 05:43:06 -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=aw6hP+yL; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=TH+d/8NW; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=dB6a3Ssn; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=5czbjYL6; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 09BB91E051; Wed, 07 Oct 2026 05:43:06 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.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 autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::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 C68271E04E for ; Wed, 07 Oct 2026 05:43:04 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DDD404BA2E27 for ; Wed, 7 Oct 2026 09:43:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DDD404BA2E27 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=aw6hP+yL; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=TH+d/8NW; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=dB6a3Ssn; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=5czbjYL6 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id CA02B4BA2E27 for ; Wed, 7 Oct 2026 09:41:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CA02B4BA2E27 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 CA02B4BA2E27 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1791366068; cv=none; b=Y7LYOHh5DW0DRAJy6I54BYdj2xQXhrv+W92ycx6TMG3fkrKDHbaLnKXAtpRJKK/zAfTWAAKwYO4rv5Or7exO6SeKy0aVRJL/Kk5Q2X1kU6bbGVmdp31PrQMNmTSaOKMz50sLEtoCQreCwfIio9GWKpvxzsudNVSahwUovOENk9o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1791366068; c=relaxed/simple; bh=2+/cYQg2OhsQYMHFUF6aZ3QvkrO269kdj7a5ta+di8E=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=PioB1/92Z0xtcE7RuckSmSpKD2GweCKnktKyYXSnzm7SfohiSZW9tqOVhcEUXCzbQ79uXBRILcSp/aynBjUzOQprjL9/czXknRDtBxY5cMoQScJBYYgkJKzuxnd16pgKN36Oi/46099laOcjQy1xvqgY9mW5wNcqShnqzg/cO+Q= ARC-Authentication-Results: i=1; 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=aw6hP+yL; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=TH+d/8NW; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=dB6a3Ssn; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=5czbjYL6 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CA02B4BA2E27 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-out1.suse.de (Postfix) with ESMTPS id E7C6C21F50 for ; Wed, 7 Oct 2026 09:40:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1791366062; 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=Ra1Wct86ySHee7iWExtN0fJbZgsmJx96Le1vZzB1EmI=; b=aw6hP+yL28KxaGAEaEVfjqVJDqPUg67lNy+iYHV1Y5zvAhelMXnVlpE6fXg8wwDzHtqabQ /f2J4PuikiToaPKVarMxUi91GSVPfXhp6lboL+XZQ/YKM4VdaC68YMMv2+/DRmzDUge6Fc bs9QdmvB91dstXa3eTHNvaVp6pZgzdw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1791366062; 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=Ra1Wct86ySHee7iWExtN0fJbZgsmJx96Le1vZzB1EmI=; b=TH+d/8NWgPNgkBDJ9NCk2V/kMTXjdpRNEw1Ao9f01rOMOlF38ewrF0Ruodbs16cSg4ZHqR LUDD6loM7WQB7GDw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=dB6a3Ssn; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=5czbjYL6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1791366058; 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=Ra1Wct86ySHee7iWExtN0fJbZgsmJx96Le1vZzB1EmI=; b=dB6a3SsnytokSfj22GguhNgZYzn4PR12fqwGKLNJ+br5JGYHqwPueibe7EIe9ANm6PW8RG kx3ka6cRPAoVQpZE92QR7xS3kcTIHYiFyaF0EI8ZzHd3fxTVkhdc9kYXScyXwLhDWpB7TD X3Oy7UmAnPqwart6sgzO5CvuO0vCPgU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1791366058; 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=Ra1Wct86ySHee7iWExtN0fJbZgsmJx96Le1vZzB1EmI=; b=5czbjYL6A7JSMoEiMTHYIHuGdTF5sCQzm3l1lnhEXkvK8AwUjSvmW1j3JVtM1+MhcWqfL4 8EFWDCGwk7IaJ5CA== 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 AED5D13B96 for ; Wed, 7 Oct 2026 09:40:58 +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 JEXHFKoTxmo3EwAAD6G6ig:T3 (envelope-from ) for ; Wed, 07 Oct 2026 09:40:58 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH v4 02/11] [gdb/tui] Make low_prev loop-local in tui_find_disassembly_address Date: Wed, 7 Oct 2026 11:40:48 +0200 Message-ID: <20261007094057.1811886-3-tdevries@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20261007094057.1811886-1-tdevries@suse.de> References: <20261007094057.1811886-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: E7C6C21F50 X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; 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)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; MIME_TRACE(0.00)[0:+]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_TLS_ALL(0.00)[]; TO_DN_NONE(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action 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 There's a loop in tui_find_disassembly_address: ... CORE_ADDR prev_low; ... do { ... if (last_addr >= pc && new_low != prev_low && asm_lines.size () >= max_lines) ... } while ((last_addr > pc || (last_addr == pc && asm_lines.size () < max_lines)) && new_low != prev_low); ... Simplify the two conditions by handling new_low == prev_low before: ... if (new_low == prev_low) break; ... Now that prev_low is no longer tested in the loop condition, make it a loop-local variable. No functional changes. --- gdb/tui/tui-disasm.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index e9f5969a6e6..18439580ffb 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -234,15 +234,14 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from) will fall back to the address held here. */ std::optional possible_new_low; - /* The previous value of NEW_LOW so we know if the new value is - different or not. */ - CORE_ADDR prev_low; - CORE_ADDR new_low = pc; do { + /* The previous value of NEW_LOW so we know if the new value is + different or not. */ + CORE_ADDR prev_low = new_low; + /* Find an address from which we can start disassembling. */ - prev_low = new_low; new_low = tui_find_backward_disassembly_start_address (new_low); /* Disassemble forward. */ @@ -251,11 +250,13 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from) break; last_addr = asm_lines.back ().addr; + if (new_low == prev_low) + break; + /* If disassembling from the current value of NEW_LOW reached PC (or went past it) then this would do as a starting point if we can't find anything better, so remember it. */ - if (last_addr >= pc && new_low != prev_low - && asm_lines.size () >= max_lines) + if (last_addr >= pc && asm_lines.size () >= max_lines) possible_new_low.emplace (new_low); /* Continue searching until we find a value of NEW_LOW from which @@ -263,9 +264,8 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from) know this means we can find the required number of previous instructions then. */ } - while ((last_addr > pc - || (last_addr == pc && asm_lines.size () < max_lines)) - && new_low != prev_low); + while (last_addr > pc + || (last_addr == pc && asm_lines.size () < max_lines)); /* If we failed to disassemble the required number of lines, try to fall back to a previous possible start address in POSSIBLE_NEW_LOW. */ -- 2.51.0