public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Change tui_set_layout to return void
Date: Wed, 17 Jul 2019 18:39:00 -0000	[thread overview]
Message-ID: <20190717183952.74102.qmail@sourceware.org> (raw)

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

commit b7fbad913e8874b9a887eb149b14975343bfb7ab
Author: Tom Tromey <tom@tromey.com>
Date:   Sun Jun 30 20:34:57 2019 -0600

    Change tui_set_layout to return void
    
    tui_set_layout can't meaningfully be called with UNDEFINED_LAYOUT; and
    instead of trying to handle this case, simply assert and have the
    function return void.  No caller was checking the return value anyway.
    
    gdb/ChangeLog
    2019-07-17  Tom Tromey  <tom@tromey.com>
    
    	* tui/tui-layout.h (tui/tui-layout): Return void.
    	* tui/tui-layout.c (tui_set_layout): Return void.  Add assert.

Diff:
---
 gdb/ChangeLog        |   5 ++
 gdb/tui/tui-layout.c | 167 ++++++++++++++++++++++++---------------------------
 gdb/tui/tui-layout.h |   2 +-
 3 files changed, 86 insertions(+), 88 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 643ff23..4dce3ac 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2019-07-17  Tom Tromey  <tom@tromey.com>
 
+	* tui/tui-layout.h (tui/tui-layout): Return void.
+	* tui/tui-layout.c (tui_set_layout): Return void.  Add assert.
+
+2019-07-17  Tom Tromey  <tom@tromey.com>
+
 	* tui/tui-layout.c (show_source_disasm_command, show_data):
 	Update.
 	(reset_locator): Remove.
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index d15df2a..7feadd7 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -113,104 +113,97 @@ show_layout (enum tui_layout_type layout)
 
 /* Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
    SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.  */
-enum tui_status
+void
 tui_set_layout (enum tui_layout_type layout_type)
 {
-  enum tui_status status = TUI_SUCCESS;
+  gdb_assert (layout_type != UNDEFINED_LAYOUT);
 
-  if (layout_type != UNDEFINED_LAYOUT)
-    {
-      enum tui_layout_type cur_layout = tui_current_layout ();
-      struct gdbarch *gdbarch;
-      CORE_ADDR addr;
-      struct tui_win_info *win_with_focus = tui_win_with_focus ();
-      struct tui_layout_def *layout_def = tui_layout_def ();
+  enum tui_layout_type cur_layout = tui_current_layout ();
+  struct gdbarch *gdbarch;
+  CORE_ADDR addr;
+  struct tui_win_info *win_with_focus = tui_win_with_focus ();
+  struct tui_layout_def *layout_def = tui_layout_def ();
 
-      extract_display_start_addr (&gdbarch, &addr);
+  extract_display_start_addr (&gdbarch, &addr);
 
-      enum tui_layout_type new_layout = layout_type;
+  enum tui_layout_type new_layout = layout_type;
 
-      if (new_layout != cur_layout)
-	{
-	  show_layout (new_layout);
+  if (new_layout != cur_layout)
+    {
+      show_layout (new_layout);
 
-	  /* Now determine where focus should be.  */
-	  if (win_with_focus != TUI_CMD_WIN)
+      /* Now determine where focus should be.  */
+      if (win_with_focus != TUI_CMD_WIN)
+	{
+	  switch (new_layout)
 	    {
-	      switch (new_layout)
-		{
-		case SRC_COMMAND:
-		  tui_set_win_focus_to (TUI_SRC_WIN);
-		  layout_def->display_mode = SRC_WIN;
-		  break;
-		case DISASSEM_COMMAND:
-		  /* The previous layout was not showing code.
-		     This can happen if there is no source
-		     available:
-
-		     1. if the source file is in another dir OR
-		     2. if target was compiled without -g
-		     We still want to show the assembly though!  */
-
-		  tui_get_begin_asm_address (&gdbarch, &addr);
-		  tui_set_win_focus_to (TUI_DISASM_WIN);
-		  layout_def->display_mode = DISASSEM_WIN;
-		  break;
-		case SRC_DISASSEM_COMMAND:
-		  /* The previous layout was not showing code.
-		     This can happen if there is no source
-		     available:
-
-		     1. if the source file is in another dir OR
-		     2. if target was compiled without -g
-		     We still want to show the assembly though!  */
-
-		  tui_get_begin_asm_address (&gdbarch, &addr);
-		  if (win_with_focus == TUI_SRC_WIN)
-		    tui_set_win_focus_to (TUI_SRC_WIN);
-		  else
-		    tui_set_win_focus_to (TUI_DISASM_WIN);
-		  break;
-		case SRC_DATA_COMMAND:
-		  if (win_with_focus != TUI_DATA_WIN)
-		    tui_set_win_focus_to (TUI_SRC_WIN);
-		  else
-		    tui_set_win_focus_to (TUI_DATA_WIN);
-		  layout_def->display_mode = SRC_WIN;
-		  break;
-		case DISASSEM_DATA_COMMAND:
-		  /* The previous layout was not showing code.
-		     This can happen if there is no source
-		     available:
-
-		     1. if the source file is in another dir OR
-		     2. if target was compiled without -g
-		     We still want to show the assembly though!  */
-
-		  tui_get_begin_asm_address (&gdbarch, &addr);
-		  if (win_with_focus != TUI_DATA_WIN)
-		    tui_set_win_focus_to (TUI_DISASM_WIN);
-		  else
-		    tui_set_win_focus_to (TUI_DATA_WIN);
-		  layout_def->display_mode = DISASSEM_WIN;
-		  break;
-		default:
-		  break;
-		}
+	    case SRC_COMMAND:
+	      tui_set_win_focus_to (TUI_SRC_WIN);
+	      layout_def->display_mode = SRC_WIN;
+	      break;
+	    case DISASSEM_COMMAND:
+	      /* The previous layout was not showing code.
+		 This can happen if there is no source
+		 available:
+
+		 1. if the source file is in another dir OR
+		 2. if target was compiled without -g
+		 We still want to show the assembly though!  */
+
+	      tui_get_begin_asm_address (&gdbarch, &addr);
+	      tui_set_win_focus_to (TUI_DISASM_WIN);
+	      layout_def->display_mode = DISASSEM_WIN;
+	      break;
+	    case SRC_DISASSEM_COMMAND:
+	      /* The previous layout was not showing code.
+		 This can happen if there is no source
+		 available:
+
+		 1. if the source file is in another dir OR
+		 2. if target was compiled without -g
+		 We still want to show the assembly though!  */
+
+	      tui_get_begin_asm_address (&gdbarch, &addr);
+	      if (win_with_focus == TUI_SRC_WIN)
+		tui_set_win_focus_to (TUI_SRC_WIN);
+	      else
+		tui_set_win_focus_to (TUI_DISASM_WIN);
+	      break;
+	    case SRC_DATA_COMMAND:
+	      if (win_with_focus != TUI_DATA_WIN)
+		tui_set_win_focus_to (TUI_SRC_WIN);
+	      else
+		tui_set_win_focus_to (TUI_DATA_WIN);
+	      layout_def->display_mode = SRC_WIN;
+	      break;
+	    case DISASSEM_DATA_COMMAND:
+	      /* The previous layout was not showing code.
+		 This can happen if there is no source
+		 available:
+
+		 1. if the source file is in another dir OR
+		 2. if target was compiled without -g
+		 We still want to show the assembly though!  */
+
+	      tui_get_begin_asm_address (&gdbarch, &addr);
+	      if (win_with_focus != TUI_DATA_WIN)
+		tui_set_win_focus_to (TUI_DISASM_WIN);
+	      else
+		tui_set_win_focus_to (TUI_DATA_WIN);
+	      layout_def->display_mode = DISASSEM_WIN;
+	      break;
+	    default:
+	      break;
 	    }
-	  /*
-	   * Now update the window content.
-	   */
-	  tui_update_source_windows_with_addr (gdbarch, addr);
-	  if (new_layout == SRC_DATA_COMMAND
-	      || new_layout == DISASSEM_DATA_COMMAND)
-	    tui_show_registers (TUI_DATA_WIN->current_group);
 	}
+      /*
+       * Now update the window content.
+       */
+      tui_update_source_windows_with_addr (gdbarch, addr);
+      if (new_layout == SRC_DATA_COMMAND
+	  || new_layout == DISASSEM_DATA_COMMAND)
+	tui_show_registers (TUI_DATA_WIN->current_group);
     }
-  else
-    status = TUI_FAILURE;
-
-  return status;
 }
 
 /* Add the specified window to the layout in a logical way.  This
diff --git a/gdb/tui/tui-layout.h b/gdb/tui/tui-layout.h
index bc21d29..5f19933 100644
--- a/gdb/tui/tui-layout.h
+++ b/gdb/tui/tui-layout.h
@@ -30,6 +30,6 @@ extern int tui_default_win_height (enum tui_win_type,
 				   enum tui_layout_type);
 extern int tui_default_win_viewport_height (enum tui_win_type,
 					    enum tui_layout_type);
-extern enum tui_status tui_set_layout (enum tui_layout_type);
+extern void tui_set_layout (enum tui_layout_type);
 
 #endif /* TUI_TUI_LAYOUT_H */


                 reply	other threads:[~2019-07-17 18:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190717183952.74102.qmail@sourceware.org \
    --to=tromey@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).