[gdb/tui] Fix displaying main after resizing
commitee1e9bbb5139d766d70cfa036979cec73a1223b7
authorTom de Vries <tdevries@suse.de>
Fri, 8 Dec 2023 16:36:35 +0000 (8 17:36 +0100)
committerTom de Vries <tdevries@suse.de>
Fri, 8 Dec 2023 16:36:35 +0000 (8 17:36 +0100)
tree1ece1cc9745f4b7c440581531d8a4d61dc514d95
parent44671f3f7f4c6435e7a639ad2215629f4e1ea8a7
[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>
gdb/testsuite/gdb.tui/resize-one-line.exp [new file with mode: 0644]
gdb/tui/tui-layout.c
gdb/tui/tui-winsource.c
gdb/tui/tui-winsource.h
gdb/tui/tui.c