From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 7C5963858D20 for ; Fri, 24 Nov 2023 08:59:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7C5963858D20 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 7C5963858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700816349; cv=none; b=M2Szc47UZI8GQ4ATySlyM4Ud7Z8L1VGoj4pndYKbSqUZcLol07Zc/nJYOAyr5SLZUsimjq/gwXrjl6k1v8xKUVZA+ch5PNE4zVf0Or6ZLHXgi4udnSQuKoAzQ22OtnwI+JwHiqCOIeK9CgeTgCNlYAVok7u0EizD9oz/4fM8aGY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700816349; c=relaxed/simple; bh=LXE4EQRSC+Jml5iizQXAfxy51VuHxgxPY1lH2uEL7LU=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=XPmRWazj7iM8KcVixaGPdaL9O0oomB9I7RHg6QrlTBNRwDFA7oon2t1MxaPhmY+8YBHEbzLClpmi283oQPjYLBXclTzYyRpqx5A8ylfebdu/HF1L7wZve7LIB1fP6ehDhlq/VnZZV96OSXPbRVn42r/3FEUw31POYCpJPW6nYH4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 7EFCB21C62 for ; Fri, 24 Nov 2023 08:59:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1700816346; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=GNbFw1MpoSwDZPTvR5cBnX5GQNIGQ4OwA/ljZgDbSqc=; b=byb5qCZvtyUWn4kcs1twFofNFcvSF1tSRrdHj/4JaRnOAi7myFcZCVmZEOUmGESkl8m0ud 8v4otAppIinvj0Yo+pzsXeXUIG47afyAXLm5+zBD8n1fwwYjAOJm7UmWBdGcexEpbVHG96 rNTKT7yqAWoD7mI+Ld6h5dWbISfKURQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1700816346; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=GNbFw1MpoSwDZPTvR5cBnX5GQNIGQ4OwA/ljZgDbSqc=; b=PK+G37MvIoSYUm3dkoymfxVdP37hUt3sqcphlvTljjzoa66OrpfL5TATPiR4KC/oUVf1Rn ioFGPn+HqO0wKxCA== 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 686C11340B for ; Fri, 24 Nov 2023 08:59: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 zGk8GNplYGXrWwAAD6G6ig (envelope-from ) for ; Fri, 24 Nov 2023 08:59:06 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH] [gdb/tui] Fix displaying main after resizing Date: Fri, 24 Nov 2023 09:59:02 +0100 Message-Id: <20231124085902.24318-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: smtp-out1.suse.de; none X-Spam-Score: 2.75 X-Spamd-Result: default: False [2.75 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_NONE(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[gnu.org:url]; NEURAL_SPAM_SHORT(1.85)[0.617]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: A TUI src window is displaying either: - the source for the current frame, - the source for main, or - the string "[ No Source Available ]". Since commit 03893ce67b5 ("[gdb/tui] Fix resizing of terminal to 1 or 2 lines") we're able to resize the TUI to 1 line without crashing. I noticed that if TUI is displaying main, and we resize to 1 line (destroying the src window) and then back to a larger terminal (reconstructing the src window), the TUI displays "[ No Source Available ]" instead of main. Fix this by moving a call to tui_display_main from tui_enable to tui_apply_current_layout. Tested on x86_64-linux. --- gdb/testsuite/gdb.tui/resize-one-line.exp | 50 +++++++++++++++++++++++ gdb/tui/tui-layout.c | 5 ++- gdb/tui/tui.c | 2 - 3 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 gdb/testsuite/gdb.tui/resize-one-line.exp diff --git a/gdb/testsuite/gdb.tui/resize-one-line.exp b/gdb/testsuite/gdb.tui/resize-one-line.exp new file mode 100644 index 00000000000..5f8847cb94b --- /dev/null +++ b/gdb/testsuite/gdb.tui/resize-one-line.exp @@ -0,0 +1,50 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Check that when showing main (because of lack of current frame) in the src +# window, resizing to 1 line and back doesn't change the contents of the src +# window. + +tuiterm_env + +standard_testfile main-one-line.c + +if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} { + return -1 +} + +Term::clean_restart 24 80 $testfile + +if {![Term::enter_tui]} { + unsupported "TUI not supported" + return +} + +# Check that we have a source box containing main. +Term::check_box "source box" 0 0 80 15 +Term::check_region_contents "src window shows main" 0 0 80 15 "main" + +# Resize to a single line. +Term::resize 1 80 0 +Term::wait_for "" + +# Resize back to the previous size. +Term::resize 24 80 0 + +# Check that we still have a source box containing main. +with_test_prefix "after resizing" { + gdb_assert { [Term::wait_for_region_contents 0 0 80 15 "main"] } \ + "src window shows main" +} diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index 85f4991c769..e1507fa25c2 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -111,7 +111,10 @@ tui_apply_current_layout (bool preserve_cmd_win_size_p) if (gdbarch == nullptr && TUI_DISASM_WIN != nullptr) tui_get_begin_asm_address (&gdbarch, &addr); - tui_update_source_windows_with_addr (gdbarch, addr); + if (addr == 0) + tui_display_main (); + else + tui_update_source_windows_with_addr (gdbarch, addr); } /* See tui-layout. */ diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c index 941c65c970f..83fe343bd3d 100644 --- a/gdb/tui/tui.c +++ b/gdb/tui/tui.c @@ -495,8 +495,6 @@ tui_enable (void) if (deprecated_safe_get_selected_frame ()) tui_show_frame_info (deprecated_safe_get_selected_frame ()); - else - tui_display_main (); /* Install the TUI specific hooks. This must be done after the call to tui_display_main so that we don't detect the symtab changed event it base-commit: ad785961c9ee2dbe80f233cf7f6f408e678d2197 -- 2.35.3