aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2023-11-22 19:07:47 +0100
committerTom de Vries <tdevries@suse.de>2023-11-22 19:07:47 +0100
commit03893ce67b5d1af649d59f7e63b3959ce0ac0709 (patch)
tree09325fbd5c96caf9e0dada8a4beb8a8166d3ae9d /gdb/testsuite
parent6697fa28bb6ee610323ea10cb815bac85c6d8184 (diff)
downloadgdb-03893ce67b5d1af649d59f7e63b3959ce0ac0709.zip
gdb-03893ce67b5d1af649d59f7e63b3959ce0ac0709.tar.gz
gdb-03893ce67b5d1af649d59f7e63b3959ce0ac0709.tar.bz2
[gdb/tui] Fix resizing of terminal to 1 or 2 lines
When starting TUI in a terminal with 3 lines: ... $ echo $LINES 3 $ gdb -q -tui ... and resizing the terminal to 2 lines we run into a segfault. The problem is that for the source window: - the minimum height is 3 (the default), but - the maximum height is only 2 because there are only 2 lines. This discrepancy eventually leads to a call to newwin in make_window with: ... (gdb) p height $1 = 3 (gdb) p width $2 = 56 (gdb) p y $3 = -1 (gdb) p x $4 = 0 ... which results in a nullptr. This violates the assumption here in tui_apply_current_layout: .... /* Get the new list of currently visible windows. */ std::vector<tui_win_info *> new_tui_windows; applied_layout->get_windows (&new_tui_windows); ... that get_windows only returns visible windows, which leads to tui_windows holding a dangling pointer, which results in the segfault. Fix this by: - making sure get_windows only returns visible windows, and - detecting the situation and dropping windows from the layout if there's no room for them. Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com> PR tui/31044 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31044
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/gdb.tui/resize.exp9
1 files changed, 9 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.tui/resize.exp b/gdb/testsuite/gdb.tui/resize.exp
index 60d5116..e15f8a2 100644
--- a/gdb/testsuite/gdb.tui/resize.exp
+++ b/gdb/testsuite/gdb.tui/resize.exp
@@ -39,3 +39,12 @@ Term::check_contents "source at startup" "\\|.*21 *return 0"
Term::resize 40 90
Term::check_box "source box after resize" 0 0 90 26
+
+# Check that resizing to less than 3 lines doesn't cause problems.
+foreach lines { 2 1 } {
+ with_test_prefix lines=$lines {
+ Term::resize $lines 90 0
+ Term::wait_for ""
+ Term::check_region_contents "has prompt" 0 0 90 $lines "$gdb_prompt"
+ }
+}