diff mbox

[2/3] Make "disassemble" always use TUI disassembly window

Message ID 20191227235034.5453-3-tom@tromey.com
State New
Headers show

Commit Message

Tom Tromey Dec. 27, 2019, 11:50 p.m. UTC
Currently the "disassemble" command will use the TUI disassembly
window if it is already showing.  I think it makes more sense to
unconditionally switch to it.  This patch implements this.

gdb/ChangeLog
2019-12-27  Tom Tromey  <tom@tromey.com>

	* cli/cli-cmds.c (print_disassembly): Just check tui_active.

gdb/testsuite/ChangeLog
2019-12-27  Tom Tromey  <tom@tromey.com>

	* gdb.tui/disasm.exp: New file.

Change-Id: I3bf3a93f618b2138c49c28156cf6c6f5ca0fa762
---
 gdb/ChangeLog                    |  4 ++++
 gdb/cli/cli-cmds.c               |  2 +-
 gdb/testsuite/ChangeLog          |  4 ++++
 gdb/testsuite/gdb.tui/disasm.exp | 36 ++++++++++++++++++++++++++++++++
 4 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 gdb/testsuite/gdb.tui/disasm.exp

Comments

Tom Tromey Jan. 19, 2020, 8:07 p.m. UTC | #1
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

Tom> Currently the "disassemble" command will use the TUI disassembly
Tom> window if it is already showing.  I think it makes more sense to
Tom> unconditionally switch to it.  This patch implements this.

I wonder if this should be limited to the case where the options to
disassemble are compatible with what the TUI does.

Tom
Andrew Burgess Jan. 19, 2020, 11:23 p.m. UTC | #2
* Tom Tromey <tom@tromey.com> [2020-01-19 13:07:30 -0700]:

> >>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
> 
> Tom> Currently the "disassemble" command will use the TUI disassembly
> Tom> window if it is already showing.  I think it makes more sense to
> Tom> unconditionally switch to it.  This patch implements this.
> 
> I wonder if this should be limited to the case where the options to
> disassemble are compatible with what the TUI does.

I've wondered for a while if we should have something like:

  set tui disassemble-flags ...

where a user can set the flags used by the disassembler.  My main
interest initially was /r, but it might be nice if /m and /s could be
supported too, though I'm not quite sure how that might look or work.

Anyway, if we had something like this then using a disassemble command
could effectively be an alternative path to set the flags. So
something like:

  (gdb) show tui disassemble-flags
  TUI will disassemble using no flags.
  (gdb) disassemble /r 0x.....
  # TUI ASM window updates, and includes opcodes.
  (gdb) show tui disassemble-flags
  TUI will disassemble using flags /r.
  # User doesn't want the opcodes any more, no problem.
  (gdb) set tui disassemble-flags    # <-- passing nothing here to
                                     #  clear the flags
  # TUI updates, but not longer shows opcodes.

Just a thought.

Thanks,
Andrew
Tom Tromey Jan. 23, 2020, 7:45 p.m. UTC | #3
Tom> I wonder if this should be limited to the case where the options to
Tom> disassemble are compatible with what the TUI does.

Andrew> I've wondered for a while if we should have something like:

Andrew>   set tui disassemble-flags ...

Andrew> where a user can set the flags used by the disassembler.  My main
Andrew> interest initially was /r, but it might be nice if /m and /s could be
Andrew> supported too, though I'm not quite sure how that might look or work.

I've considered this too (and also adding support for the new binutils
mode that graphically shows jump targets).

However, I wasn't sure how these flags would interact with the current
TUI model of disassembly, where it shows a window on the entire memory
space, and not just a single function.

Tom
diff mbox

Patch

diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index e1410690aaf..b2ef904ff60 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1338,7 +1338,7 @@  print_disassembly (struct gdbarch *gdbarch, const char *name,
 		   gdb_disassembly_flags flags)
 {
 #if defined(TUI)
-  if (tui_is_window_visible (DISASSEM_WIN))
+  if (tui_active)
     tui_show_assembly (gdbarch, low);
   else
 #endif
diff --git a/gdb/testsuite/gdb.tui/disasm.exp b/gdb/testsuite/gdb.tui/disasm.exp
new file mode 100644
index 00000000000..362aa7087ec
--- /dev/null
+++ b/gdb/testsuite/gdb.tui/disasm.exp
@@ -0,0 +1,36 @@ 
+# Copyright 2019 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 that "disassemble" shows the disassembly window.
+
+load_lib "tuiterm.exp"
+
+standard_testfile tui-layout.c
+
+if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} {
+    return -1
+}
+
+Term::clean_restart 24 80 $testfile
+if {![Term::enter_tui]} {
+    unsupported "TUI not supported"
+}
+
+set text [Term::get_all_lines]
+gdb_assert {![string match "No Source Available" $text]} \
+    "initial source listing"
+
+Term::command "disassemble main"
+Term::check_contents "asm window is showing" "$hex <main>"