--- /dev/null
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2025 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/>. */
+
+extern int foo (void);
+
+int
+foo (void)
+{
+ return 0;
+}
--- /dev/null
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2025 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/>. */
+
+extern int foo (void);
+
+int
+main (void)
+{
+ return foo ();
+}
--- /dev/null
+# Copyright 2025 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/>.
+
+# Test TUI resizing while showing "No Source Available".
+
+require allow_tui_tests
+
+standard_testfile -main.c -foo.c
+
+if { [build_executable_from_specs "failed to prepare" \
+ $testfile {debug} \
+ $srcfile {debug} \
+ $srcfile2 {nodebug}] == -1 } {
+ return -1
+}
+
+tuiterm_env
+
+Term::clean_restart 24 80 $testfile
+
+# It would be simpler to run directly to foo and then enter TUI, but that
+# fails to trigger PR32614. So instead, we first run to main, enter TUI and
+# then run to foo.
+if {![runto_main]} {
+ perror "test suppressed"
+ return
+}
+
+# Set a breakpoint on foo, easier to do before entering TUI.
+gdb_breakpoint foo
+
+if {![Term::enter_tui]} {
+ unsupported "TUI not supported"
+ return
+}
+
+# Continue to foo.
+Term::command continue
+
+with_test_prefix "before resize" {
+ Term::check_contents "Source window empty" \
+ "No Source Available"
+}
+
+Term::resize 40 90
+
+with_test_prefix "after resize" {
+ # Regression test for PR32614.
+ Term::check_contents "Source window empty" \
+ "No Source Available"
+
+ Term::command "layout asm"
+
+ # Check that, when we switch to the assembler window, the
+ # disassembly is still shown.
+ Term::check_contents_not \
+ "No Assembly message is not displayed" \
+ "No Assembly Available"
+ Term::check_contents "Assembler for foo is shown" \
+ "$hex\\s+<foo"
+}
}
else if (deprecated_safe_get_selected_frame () != NULL)
{
- symtab_and_line cursal
- = get_current_source_symtab_and_line (current_program_space);
frame_info_ptr frame = deprecated_safe_get_selected_frame ();
- struct gdbarch *gdbarch = get_frame_arch (frame);
-
- struct symtab *s = find_pc_line_symtab (get_frame_pc (frame));
- if (this != tui_src_win ())
- find_line_pc (s, cursal.line, &cursal.pc);
-
- /* This centering code is copied from tui_source_window::maybe_update.
- It would be nice to do centering more often, and do it in just one
- location. But since this is a regression fix, handle this
- conservatively for now. */
- int start_line = (cursal.line - ((height - box_size ()) / 2)) + 1;
- if (start_line <= 0)
- start_line = 1;
- cursal.line = start_line;
-
- update_source_window (gdbarch, cursal);
+ symtab_and_line sal = find_frame_sal (frame);
+
+ /* find_frame_sal does not always set SAL.PC, but we want to ensure
+ that it is available in the SAL before updating the window. */
+ get_frame_pc_if_available (frame, &sal.pc);
+
+ maybe_update (get_frame_arch (frame), sal);
+ update_exec_info (false);
}
else
{