Remove the TUI execution info window

Message ID 20190816183628.12579-1-tom@tromey.com
State New, archived
Headers

Commit Message

Tom Tromey Aug. 16, 2019, 6:36 p.m. UTC
  The TUI execution info window is unusual in that it is always linked
to a source or disassembly window.  Even updates of its content are
handled by the source window, so it really has no life of its own.

This patch removes this window entirely and puts its functionality
directly into the source window.  This simplifies the code somewhat.

This is a user-visible change, because now the box around the source
(or disassembly) window encloses the execution info as well.  I
consider this an improvement as well, though.

Note that this patch caused ncurses to start emitting the "CSI Z"
sequence, so I've added this to the test suite terminal
implementation.

gdb/ChangeLog
2019-07-17  Tom Tromey  <tom@tromey.com>

	* tui/tui.h (enum tui_win_type) <EXEC_INFO_WIN>: Remove.
	* tui/tui-winsource.h (struct tui_exec_info_window): Remove.
	(struct tui_source_window_base) <make_visible, refresh_window,
	resize>: Remove methods.
	<execution_info>: Remove field.
	* tui/tui-winsource.c (tui_source_window_base::do_erase_source_content)
	(tui_show_source_line, tui_source_window_base)
	(~tui_source_window_base): Update.
	(tui_source_window_base::resize)
	(tui_source_window_base::make_visible)
	(tui_source_window_base::refresh_window): Remove.
	(tui_source_window_base::update_exec_info): Update.
	* tui/tui-source.c (tui_source_window::set_contents): Update.
	* tui/tui-disasm.c (tui_disasm_window::set_contents): Update.

gdb/testsuite/ChangeLog
2019-08-16  Tom Tromey  <tom@tromey.com>

	* lib/tuiterm.exp (_csi_Z): New proc.
	* gdb.tui/basic.exp: Update window positions.
	* gdb.tui/empty.exp: Update window positions.
---
 gdb/ChangeLog                   | 17 ++++++++++++++
 gdb/testsuite/ChangeLog         |  6 +++++
 gdb/testsuite/gdb.tui/basic.exp |  8 +++----
 gdb/testsuite/gdb.tui/empty.exp | 12 +++++-----
 gdb/testsuite/lib/tuiterm.exp   |  7 ++++++
 gdb/tui/tui-disasm.c            |  2 +-
 gdb/tui/tui-source.c            |  2 +-
 gdb/tui/tui-winsource.c         | 41 ++++-----------------------------
 gdb/tui/tui-winsource.h         | 17 --------------
 gdb/tui/tui.h                   |  1 -
 10 files changed, 46 insertions(+), 67 deletions(-)
  

Comments

Pedro Alves Aug. 16, 2019, 8:12 p.m. UTC | #1
On 8/16/19 7:36 PM, Tom Tromey wrote:
> The TUI execution info window is unusual in that it is always linked
> to a source or disassembly window.  Even updates of its content are
> handled by the source window, so it really has no life of its own.
> 
> This patch removes this window entirely and puts its functionality
> directly into the source window.  This simplifies the code somewhat.
> 
> This is a user-visible change, because now the box around the source
> (or disassembly) window encloses the execution info as well.  I
> consider this an improvement as well, though.

I tried it and it seems fine to me.

> 
> Note that this patch caused ncurses to start emitting the "CSI Z"
> sequence, so I've added this to the test suite terminal
> implementation.
> 
> gdb/ChangeLog
> 2019-07-17  Tom Tromey  <tom@tromey.com>
> 
> 	* tui/tui.h (enum tui_win_type) <EXEC_INFO_WIN>: Remove.
> 	* tui/tui-winsource.h (struct tui_exec_info_window): Remove.
> 	(struct tui_source_window_base) <make_visible, refresh_window,
> 	resize>: Remove methods.
> 	<execution_info>: Remove field.
> 	* tui/tui-winsource.c (tui_source_window_base::do_erase_source_content)
> 	(tui_show_source_line, tui_source_window_base)
> 	(~tui_source_window_base): Update.
> 	(tui_source_window_base::resize)
> 	(tui_source_window_base::make_visible)
> 	(tui_source_window_base::refresh_window): Remove.
> 	(tui_source_window_base::update_exec_info): Update.
> 	* tui/tui-source.c (tui_source_window::set_contents): Update.
> 	* tui/tui-disasm.c (tui_disasm_window::set_contents): Update.
> 
> gdb/testsuite/ChangeLog
> 2019-08-16  Tom Tromey  <tom@tromey.com>
> 
> 	* lib/tuiterm.exp (_csi_Z): New proc.
> 	* gdb.tui/basic.exp: Update window positions.
> 	* gdb.tui/empty.exp: Update window positions.

LGTM.

Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/testsuite/gdb.tui/basic.exp b/gdb/testsuite/gdb.tui/basic.exp
index a0054001630..f60011c386a 100644
--- a/gdb/testsuite/gdb.tui/basic.exp
+++ b/gdb/testsuite/gdb.tui/basic.exp
@@ -38,12 +38,12 @@  Term::check_contents "list main" "21 *return 0"
 # This check fails because the file name in the title overwrites the
 # box.
 setup_xfail *-*-*
-Term::check_box "source box" 3 0 77 15
+Term::check_box "source box" 0 0 80 15
 
 Term::command "layout asm"
 Term::check_contents "asm window shows main" "$hex <main>"
 
-Term::check_box "asm box" 3 0 77 15
+Term::check_box "asm box" 0 0 80 15
 
 Term::command "layout split"
 Term::check_contents "split layout contents" "21 *return 0.*$hex <main>"
@@ -51,5 +51,5 @@  Term::check_contents "split layout contents" "21 *return 0.*$hex <main>"
 # This check fails because the file name in the title overwrites the
 # box.
 setup_xfail *-*-*
-Term::check_box "source box in split layout" 3 0 77 8
-Term::check_box "asm box in split layout" 3 7 77 8
+Term::check_box "source box in split layout" 0 0 80 8
+Term::check_box "asm box in split layout" 0 7 80 8
diff --git a/gdb/testsuite/gdb.tui/empty.exp b/gdb/testsuite/gdb.tui/empty.exp
index 8c504562803..09185226a90 100644
--- a/gdb/testsuite/gdb.tui/empty.exp
+++ b/gdb/testsuite/gdb.tui/empty.exp
@@ -32,26 +32,26 @@  if {![Term::enter_tui]} {
 # 4. List of boxes in 90x40 mode
 # 5. List of test name and text for the empty window
 set layouts {
-    {src src {{3 0 77 15}} {{3 0 87 23}}
+    {src src {{0 0 80 15}} {{0 0 90 23}}
 	{{"no source" "No Source Available"}}}
-    {regs src-regs {{0 0 80 8} {3 7 77 8}} {{0 0 90 13} {3 13 87 13}}
+    {regs src-regs {{0 0 80 8} {0 7 80 8}} {{0 0 90 13} {0 13 90 13}}
 	{
 	    {"no source" "No Source Available"}
 	    {"no regs" "Register Values Unavailable"}
 	}}
-    {asm asm {{3 0 77 15}} {{3 0 87 23}}
+    {asm asm {{0 0 80 15}} {{0 0 90 23}}
 	{"no asm" "No Assembly Available"}}
-    {regs asm-regs {{0 0 80 8} {3 7 77 9}} {{0 0 90 13} {3 13 87 14}}
+    {regs asm-regs {{0 0 80 8} {0 7 80 9}} {{0 0 90 13} {0 13 90 14}}
 	{
 	    {"no asm" "No Assembly Available"}
 	    {"no regs" "Register Values Unavailable"}
 	}}
-    {split split {{3 0 77 8} {3 7 77 9}} {{3 0 87 13} {3 13 87 14}}
+    {split split {{0 0 80 8} {0 7 80 9}} {{0 0 90 13} {0 13 90 14}}
 	{
 	    {"no source" "No Source Available"}
 	    {"no asm" "No Assembly Available"}
 	}}
-    {regs split-regs {{0 0 80 8} {3 7 77 9}} {{0 0 90 13} {3 13 87 14}}
+    {regs split-regs {{0 0 80 8} {0 7 80 9}} {{0 0 90 13} {0 13 90 14}}
 	{
 	    {"no asm" "No Assembly Available"}
 	    {"no regs" "Register Values Unavailable"}
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index cd728156fc8..c6a938e227d 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -266,6 +266,13 @@  namespace eval Term {
 	}
     }
 
+    # Backward tab stops.
+    proc _csi_Z {args} {
+	set n [_default [lindex $args 0] 1]
+	variable _cur_x
+	set _cur_x [expr {max (int (($_cur_x - 1) / 8) * 8 - ($n - 1) * 8, 0)}]
+    }
+
     # Repeat.
     proc _csi_b {args} {
 	variable _last_char
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 2a291831e27..1d019ca60c1 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -189,7 +189,7 @@  tui_disasm_window::set_contents (struct gdbarch *arch,
 
   /* Window size, excluding highlight box.  */
   max_lines = height - 2;
-  line_width = width - 2;
+  line_width = width - TUI_EXECINFO_SIZE - 2;
 
   /* Get temporary table that will hold all strings (addr & insn).  */
   asm_lines = XALLOCAVEC (struct tui_asm_line, max_lines);
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 57d27aee4af..07de328bb04 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -137,7 +137,7 @@  tui_source_window::set_contents (struct gdbarch *arch,
       int line_width, nlines;
 
       ret = TUI_SUCCESS;
-      line_width = width - 1;
+      line_width = width - TUI_EXECINFO_SIZE - 1;
       /* Take hilite (window border) into account, when
 	 calculating the number of lines.  */
       nlines = (line_no + (height - 2)) - line_no;
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 43e8a28df5a..0a3eb78bb5a 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -206,9 +206,6 @@  tui_source_window_base::do_erase_source_content (const char *str)
 		 (char *) str);
 
       refresh_window ();
-
-      werase (execution_info->handle);
-      execution_info->refresh_window ();
     }
 }
 
@@ -224,7 +221,7 @@  tui_show_source_line (struct tui_source_window_base *win_info, int lineno)
   if (line->is_exec_point)
     tui_set_reverse_mode (win_info->handle, true);
 
-  wmove (win_info->handle, lineno, 1);
+  wmove (win_info->handle, lineno, TUI_EXECINFO_SIZE);
   tui_puts (line->line,
 	    win_info->handle);
   if (line->is_exec_point)
@@ -268,8 +265,7 @@  tui_source_window_base::clear_detail ()
 }
 
 tui_source_window_base::tui_source_window_base (enum tui_win_type type)
-  : tui_win_info (type),
-    execution_info (new tui_exec_info_window ())
+  : tui_win_info (type)
 {
   gdb_assert (type == SRC_WIN || type == DISASSEM_WIN);
   start_line_or_addr.loa = LOA_ADDRESS;
@@ -280,18 +276,8 @@  tui_source_window_base::tui_source_window_base (enum tui_win_type type)
 tui_source_window_base::~tui_source_window_base ()
 {
   xfree (fullname);
-  delete execution_info;
 }  
 
-void
-tui_source_window_base::resize (int height, int width,
-				int origin_x, int origin_y)
-{
-  tui_gen_win_info::resize (height, width - 3,
-			    origin_x + 3, origin_y);
-  execution_info->resize (height, 3, origin_x, origin_y);
-}
-
 /* See tui-data.h.  */
 
 void
@@ -350,24 +336,6 @@  tui_source_window_base::rerender ()
 
 /* See tui-data.h.  */
 
-void
-tui_source_window_base::make_visible (bool visible)
-{
-  execution_info->make_visible (visible);
-  tui_win_info::make_visible (visible);
-}
-
-/* See tui-data.h.  */
-
-void
-tui_source_window_base::refresh_window ()
-{
-  execution_info->refresh_window ();
-  tui_win_info::refresh_window ();
-}
-
-/* See tui-data.h.  */
-
 void
 tui_source_window_base::refill ()
 {
@@ -521,7 +489,6 @@  tui_source_window_base::update_breakpoint_info
 void
 tui_source_window_base::update_exec_info ()
 {
-  werase (execution_info->handle);
   update_breakpoint_info (nullptr, true);
   for (int i = 0; i < content.size (); i++)
     {
@@ -544,7 +511,7 @@  tui_source_window_base::update_exec_info ()
       if (src_element->is_exec_point)
 	element[TUI_EXEC_POS] = '>';
 
-      mvwaddstr (execution_info->handle, i + 1, 0, element);
+      mvwaddstr (handle, i + 1, 1, element);
     }
-  execution_info->refresh_window ();
+  refresh_window ();
 }
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 85e83021be1..1804ca7224a 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -45,16 +45,6 @@  DEF_ENUM_FLAGS_TYPE (enum tui_bp_flag, tui_bp_flags);
 
 typedef char tui_exec_info_content[TUI_EXECINFO_SIZE];
 
-/* Execution info window class.  */
-
-struct tui_exec_info_window : public tui_gen_win_info
-{
-  tui_exec_info_window ()
-    : tui_gen_win_info (EXEC_INFO_WIN)
-  {
-  }
-};
-
 /* Elements in the Source/Disassembly Window.  */
 struct tui_source_element
 {
@@ -113,8 +103,6 @@  public:
 
   void clear_detail ();
 
-  void make_visible (bool visible) override;
-  void refresh_window () override;
   void refresh_all () override;
 
   /* Refill the source window's source cache and update it.  If this
@@ -128,9 +116,6 @@  public:
 
   virtual bool location_matches_p (struct bp_location *loc, int line_no) = 0;
 
-  void resize (int height, int width,
-	       int origin_x, int origin_y) override;
-
   void show_source_content ();
 
   void update_exec_info ();
@@ -158,8 +143,6 @@  public:
   /* Erase the source content.  */
   virtual void erase_source_content () = 0;
 
-  /* Execution information window.  */
-  struct tui_exec_info_window *execution_info;
   /* Used for horizontal scroll.  */
   int horizontal_offset = 0;
   struct tui_line_or_address start_line_or_addr;
diff --git a/gdb/tui/tui.h b/gdb/tui/tui.h
index 76ab01443b7..25ae0c5e471 100644
--- a/gdb/tui/tui.h
+++ b/gdb/tui/tui.h
@@ -44,7 +44,6 @@  enum tui_win_type
   MAX_MAJOR_WINDOWS,
   /* Auxiliary windows.  */
   LOCATOR_WIN,
-  EXEC_INFO_WIN,
   DATA_ITEM_WIN
 };