diff options
author | Tom de Vries <tdevries@suse.de> | 2023-12-08 17:36:35 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2023-12-08 17:36:35 +0100 |
commit | ee1e9bbb5139d766d70cfa036979cec73a1223b7 (patch) | |
tree | 1ece1cc9745f4b7c440581531d8a4d61dc514d95 /gdb/testsuite | |
parent | 44671f3f7f4c6435e7a639ad2215629f4e1ea8a7 (diff) | |
download | gdb-ee1e9bbb5139d766d70cfa036979cec73a1223b7.zip gdb-ee1e9bbb5139d766d70cfa036979cec73a1223b7.tar.gz gdb-ee1e9bbb5139d766d70cfa036979cec73a1223b7.tar.bz2 |
[gdb/tui] Fix displaying main after resizing
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 the responsibility for showing main from tui_enable to
tui_source_window_base::rerender.
Tested on x86_64-linux.
Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/gdb.tui/resize-one-line.exp | 50 |
1 files changed, 50 insertions, 0 deletions
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 0000000..5f8847c --- /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 <http://www.gnu.org/licenses/>. + +# 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" +} |