[binutils-gdb] Simplify show_source_disasm_command

Tom Tromey tromey@sourceware.org
Wed Jul 17 18:40:00 GMT 2019


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f4e049775aa3b025501d6b4aae1cdb975505a767

commit f4e049775aa3b025501d6b4aae1cdb975505a767
Author: Tom Tromey <tom@tromey.com>
Date:   Sun Jun 30 20:46:18 2019 -0600

    Simplify show_source_disasm_command
    
    This is the first of a few patches to further simplify window
    (re-)initialization in tui-layout.c.  When changing the layout, a
    window may be created or, if it already exists, simply resized.  These
    two cases normally are identical, but this was obscured by the way the
    code was written.  This patch changes show_source_disasm_command to
    unify the creation and re-initialization cases.
    
    gdb/ChangeLog
    2019-07-17  Tom Tromey  <tom@tromey.com>
    
    	* tui/tui-layout.c (show_source_disasm_command): Simplify window
    	resetting.

Diff:
---
 gdb/ChangeLog        |  5 +++++
 gdb/tui/tui-layout.c | 48 +++++++++++++++++-------------------------------
 2 files changed, 22 insertions(+), 31 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d964520..be9bce1 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2019-07-17  Tom Tromey  <tom@tromey.com>
 
+	* tui/tui-layout.c (show_source_disasm_command): Simplify window
+	resetting.
+
+2019-07-17  Tom Tromey  <tom@tromey.com>
+
 	* tui/tui.h (tui_set_layout_by_name): Don't declare.
 	* tui/tui-regs.c (tui_reg_layout): New function.
 	(tui_show_registers, tui_reg_command): Use it.
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 0ed7b29..4e914b7 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -559,43 +559,29 @@ show_source_disasm_command (void)
       asm_height = tui_term_height () - (src_height + cmd_height);
 
       if (TUI_SRC_WIN == NULL)
-	tui_win_list[SRC_WIN] = make_source_window (src_height, 0);
-      else
-	{
-	  TUI_SRC_WIN->reset (src_height,
-			      tui_term_width (),
-			      0,
-			      0);
-	  tui_make_visible (TUI_SRC_WIN);
-	  TUI_SRC_WIN->m_has_locator = false;
-	}
+	tui_win_list[SRC_WIN] = new tui_source_window ();
+      TUI_SRC_WIN->reset (src_height,
+			  tui_term_width (),
+			  0,
+			  0);
+      tui_make_visible (TUI_SRC_WIN);
+      TUI_SRC_WIN->m_has_locator = false;
 
       struct tui_locator_window *locator = tui_locator_win_info_ptr ();
       gdb_assert (locator != nullptr);
 
       tui_show_source_content (TUI_SRC_WIN);
       if (TUI_DISASM_WIN == NULL)
-	{
-	  tui_win_list[DISASSEM_WIN]
-	    = make_disasm_window (asm_height, src_height - 1);
-	  locator->reset (2 /* 1 */ ,
-			  tui_term_width (),
-			  0,
-			  (src_height + asm_height) - 1);
-	}
-      else
-	{
-	  locator->reset (2 /* 1 */ ,
-			  tui_term_width (),
-			  0,
-			  (src_height + asm_height) - 1);
-	  TUI_DISASM_WIN->m_has_locator = true;
-	  TUI_DISASM_WIN->reset (asm_height,
-				 tui_term_width (),
-				 0,
-				 src_height - 1);
-	  tui_make_visible (TUI_DISASM_WIN);
-	}
+	tui_win_list[DISASSEM_WIN] = new tui_disasm_window ();
+      TUI_DISASM_WIN->reset (asm_height,
+			     tui_term_width (),
+			     0,
+			     src_height - 1);
+      tui_make_visible (TUI_DISASM_WIN);
+      locator->reset (2 /* 1 */ ,
+		      tui_term_width (),
+		      0,
+		      (src_height + asm_height) - 1);
       TUI_SRC_WIN->m_has_locator = false;
       TUI_DISASM_WIN->m_has_locator = true;
       tui_make_visible (locator);



More information about the Gdb-cvs mailing list