[binutils-gdb] Make "file" clear TUI source window
Tom Tromey
tromey@sourceware.org
Sun Jan 19 20:14:00 GMT 2020
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4f13c1c00be32131845ae50aef788d4f2c652dff
commit 4f13c1c00be32131845ae50aef788d4f2c652dff
Author: Tom Tromey <tom@tromey.com>
Date: Sat Dec 21 11:14:56 2019 -0700
Make "file" clear TUI source window
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
Diff:
---
gdb/ChangeLog | 5 +++++
gdb/testsuite/ChangeLog | 4 ++++
gdb/testsuite/gdb.tui/main.exp | 7 +++++++
gdb/tui/tui-winsource.c | 11 ++++++-----
4 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f7798de..d8482aa 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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.
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index c4a760e..b642641 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -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).
diff --git a/gdb/testsuite/gdb.tui/main.exp b/gdb/testsuite/gdb.tui/main.exp
index 26ca004..ae2393e 100644
--- a/gdb/testsuite/gdb.tui/main.exp
+++ b/gdb/testsuite/gdb.tui/main.exp
@@ -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"
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index fbee2e3..3ba2f2b 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -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);
More information about the Gdb-cvs
mailing list