]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Make "file" clear TUI source window
authorTom Tromey <tom@tromey.com>
Sat, 21 Dec 2019 18:14:56 +0000 (11:14 -0700)
committerTom Tromey <tom@tromey.com>
Sun, 19 Jan 2020 20:08:48 +0000 (13:08 -0700)
I noticed that a plain "file" will leave the current source file in
the TUI source window.  Instead, I think, it should clear the source
window.  This patch implements this.

gdb/ChangeLog
2020-01-19  Tom Tromey  <tom@tromey.com>

* tui/tui-winsource.c (tui_update_source_windows_with_line):
Handle case where symtab is null.

gdb/testsuite/ChangeLog
2020-01-19  Tom Tromey  <tom@tromey.com>

* gdb.tui/main.exp: Add check for plain "file".

Change-Id: I8424acf837f1a47f75bc6a833d1e917d4c10b51e

gdb/ChangeLog
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.tui/main.exp
gdb/tui/tui-winsource.c

index f7798def4fb0869903fd091f1f0f8e8b9a417898..d8482aaaa5614371561d994216847b26331d1a05 100644 (file)
@@ -1,3 +1,8 @@
+2020-01-19  Tom Tromey  <tom@tromey.com>
+
+       * tui/tui-winsource.c (tui_update_source_windows_with_line):
+       Handle case where symtab is null.
+
 2020-01-19  Simon Marchi  <simon.marchi@polymtl.ca>
 
        * linux-fork.c (one_fork_p): Simplify.
index c4a760ef5167410161a451bcb8573aaeec743cfb..b642641376be32408e0a95532b60b55b299cc38b 100644 (file)
@@ -1,3 +1,7 @@
+2020-01-19  Tom Tromey  <tom@tromey.com>
+
+       * gdb.tui/main.exp: Add check for plain "file".
+
 2020-01-16  Christian Biesinger  <cbiesinger@google.com>
 
        * lib/gdb.exp: Fix spelling error (seperatelly).
index 26ca0046fcc8be888780635a37961657d9eafb9a..ae2393e6e98cba5e32821c80c7da533db26c6f14 100644 (file)
@@ -26,9 +26,16 @@ if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} {
 # Note: don't pass the executable here
 Term::clean_restart 24 80
 
+# Later on we'd like to avoid having to answer a question.
+gdb_test_no_output "set interactive-mode off"
+
 if {![Term::enter_tui]} {
     unsupported "TUI not supported"
 }
 
 Term::command "file [standard_output_file $testfile]"
 Term::check_contents "show main after file" "\\|.*21 *return 0"
+
+# Ensure that "file" clears the source window.
+Term::command "file"
+Term::check_contents "file clears window" "No Source Available"
index fbee2e3e1813bc8acbcc393f9a704bb1d5230406..3ba2f2b041e93b5eb6c3e9d7d1f6da3f497ad026 100644 (file)
@@ -212,11 +212,12 @@ tui_update_source_windows_with_addr (struct gdbarch *gdbarch, CORE_ADDR addr)
 void
 tui_update_source_windows_with_line (struct symtab_and_line sal)
 {
-  if (!sal.symtab)
-    return;
-
-  find_line_pc (sal.symtab, sal.line, &sal.pc);
-  struct gdbarch *gdbarch = get_objfile_arch (SYMTAB_OBJFILE (sal.symtab));
+  struct gdbarch *gdbarch = nullptr;
+  if (sal.symtab != nullptr)
+    {
+      find_line_pc (sal.symtab, sal.line, &sal.pc);
+      gdbarch = get_objfile_arch (SYMTAB_OBJFILE (sal.symtab));
+    }
 
   for (struct tui_source_window_base *win_info : tui_source_windows ())
     win_info->update_source_window (gdbarch, sal);