Remove --xdb
[deliverable/binutils-gdb.git] / gdb / tui / tui-layout.c
index cffa2178bba0856c7622b6fdf090eed5b6243e92..4c25d43d0002459f87fcf3062a8926b5afc5f785 100644 (file)
@@ -1,7 +1,6 @@
 /* TUI layout window management.
 
-   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007
-   Free Software Foundation, Inc.
+   Copyright (C) 1998-2015 Free Software Foundation, Inc.
 
    Contributed by Hewlett-Packard Company.
 
@@ -9,7 +8,7 @@
 
    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 2 of the License, or
+   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,
    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, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
+#include "arch-utils.h"
 #include "command.h"
 #include "symtab.h"
 #include "frame.h"
@@ -38,8 +36,7 @@
 #include "tui/tui-win.h"
 #include "tui/tui-winsource.h"
 #include "tui/tui-disasm.h"
-
-#include "gdb_string.h"
+#include "tui/tui-layout.h"
 #include "gdb_curses.h"
 
 /*******************************
@@ -66,10 +63,7 @@ static void show_data (enum tui_layout_type);
 static enum tui_layout_type next_layout (void);
 static enum tui_layout_type prev_layout (void);
 static void tui_layout_command (char *, int);
-static void tui_toggle_layout_command (char *, int);
-static void tui_toggle_split_layout_command (char *, int);
-static CORE_ADDR extract_display_start_addr (void);
-static void tui_handle_xdb_layout (struct tui_layout_def *);
+static void extract_display_start_addr (struct gdbarch **, CORE_ADDR *);
 
 
 /***************************************
@@ -91,7 +85,8 @@ show_layout (enum tui_layout_type layout)
          source/asm.  */
       tui_free_all_source_wins_content ();
       tui_clear_source_windows ();
-      if (layout == SRC_DATA_COMMAND || layout == DISASSEM_DATA_COMMAND)
+      if (layout == SRC_DATA_COMMAND 
+         || layout == DISASSEM_DATA_COMMAND)
        {
          show_data (layout);
          tui_refresh_all (tui_win_list);
@@ -137,33 +132,39 @@ tui_set_layout (enum tui_layout_type layout_type,
 {
   enum tui_status status = TUI_SUCCESS;
 
-  if (layout_type != UNDEFINED_LAYOUT || regs_display_type != TUI_UNDEFINED_REGS)
+  if (layout_type != UNDEFINED_LAYOUT 
+      || regs_display_type != TUI_UNDEFINED_REGS)
     {
-      enum tui_layout_type cur_layout = tui_current_layout (), new_layout = UNDEFINED_LAYOUT;
+      enum tui_layout_type cur_layout = tui_current_layout (),
+       new_layout = UNDEFINED_LAYOUT;
       int regs_populate = FALSE;
-      CORE_ADDR addr = extract_display_start_addr ();
+      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);
 
-      if (layout_type == UNDEFINED_LAYOUT &&
-         regs_display_type != TUI_UNDEFINED_REGS)
+      if (layout_type == UNDEFINED_LAYOUT
+         && regs_display_type != TUI_UNDEFINED_REGS)
        {
          if (cur_layout == SRC_DISASSEM_COMMAND)
            new_layout = DISASSEM_DATA_COMMAND;
-         else if (cur_layout == SRC_COMMAND || cur_layout == SRC_DATA_COMMAND)
+         else if (cur_layout == SRC_COMMAND 
+                  || cur_layout == SRC_DATA_COMMAND)
            new_layout = SRC_DATA_COMMAND;
-         else if (cur_layout == DISASSEM_COMMAND ||
-                  cur_layout == DISASSEM_DATA_COMMAND)
+         else if (cur_layout == DISASSEM_COMMAND 
+                  || cur_layout == DISASSEM_DATA_COMMAND)
            new_layout = DISASSEM_DATA_COMMAND;
        }
       else
        new_layout = layout_type;
 
-      regs_populate = (new_layout == SRC_DATA_COMMAND ||
-                     new_layout == DISASSEM_DATA_COMMAND ||
-                     regs_display_type != TUI_UNDEFINED_REGS);
-      if (new_layout != cur_layout || regs_display_type != TUI_UNDEFINED_REGS)
+      regs_populate = (new_layout == SRC_DATA_COMMAND 
+                      || new_layout == DISASSEM_DATA_COMMAND 
+                      || regs_display_type != TUI_UNDEFINED_REGS);
+      if (new_layout != cur_layout
+         || regs_display_type != TUI_UNDEFINED_REGS)
        {
          if (new_layout != cur_layout)
            {
@@ -188,7 +189,7 @@ tui_set_layout (enum tui_layout_type layout_type,
                         2. if target was compiled without -g
                         We still want to show the assembly though!  */
 
-                     addr = tui_get_begin_asm_address ();
+                     tui_get_begin_asm_address (&gdbarch, &addr);
                      tui_set_win_focus_to (TUI_DISASM_WIN);
                      layout_def->display_mode = DISASSEM_WIN;
                      layout_def->split = FALSE;
@@ -202,7 +203,7 @@ tui_set_layout (enum tui_layout_type layout_type,
                         2. if target was compiled without -g
                         We still want to show the assembly though!  */
 
-                     addr = tui_get_begin_asm_address ();
+                     tui_get_begin_asm_address (&gdbarch, &addr);
                      if (win_with_focus == TUI_SRC_WIN)
                        tui_set_win_focus_to (TUI_SRC_WIN);
                      else
@@ -226,7 +227,7 @@ tui_set_layout (enum tui_layout_type layout_type,
                         2. if target was compiled without -g
                         We still want to show the assembly though!  */
 
-                     addr = tui_get_begin_asm_address ();
+                     tui_get_begin_asm_address (&gdbarch, &addr);
                      if (win_with_focus != TUI_DATA_WIN)
                        tui_set_win_focus_to (TUI_DISASM_WIN);
                      else
@@ -241,12 +242,12 @@ tui_set_layout (enum tui_layout_type layout_type,
              /*
               * Now update the window content.
               */
-             if (!regs_populate &&
-                 (new_layout == SRC_DATA_COMMAND ||
-                  new_layout == DISASSEM_DATA_COMMAND))
+             if (!regs_populate 
+                 && (new_layout == SRC_DATA_COMMAND 
+                     || new_layout == DISASSEM_DATA_COMMAND))
                tui_display_all_data ();
 
-             tui_update_source_windows_with_addr (addr);
+             tui_update_source_windows_with_addr (gdbarch, addr);
            }
          if (regs_populate)
            {
@@ -271,9 +272,9 @@ tui_add_win_to_layout (enum tui_win_type type)
   switch (type)
     {
     case SRC_WIN:
-      if (cur_layout != SRC_COMMAND &&
-         cur_layout != SRC_DISASSEM_COMMAND &&
-         cur_layout != SRC_DATA_COMMAND)
+      if (cur_layout != SRC_COMMAND
+         && cur_layout != SRC_DISASSEM_COMMAND
+         && cur_layout != SRC_DATA_COMMAND)
        {
          tui_clear_source_windows_detail ();
          if (cur_layout == DISASSEM_DATA_COMMAND)
@@ -283,9 +284,9 @@ tui_add_win_to_layout (enum tui_win_type type)
        }
       break;
     case DISASSEM_WIN:
-      if (cur_layout != DISASSEM_COMMAND &&
-         cur_layout != SRC_DISASSEM_COMMAND &&
-         cur_layout != DISASSEM_DATA_COMMAND)
+      if (cur_layout != DISASSEM_COMMAND
+         && cur_layout != SRC_DISASSEM_COMMAND
+         && cur_layout != DISASSEM_DATA_COMMAND)
        {
          tui_clear_source_windows_detail ();
          if (cur_layout == SRC_DATA_COMMAND)
@@ -295,8 +296,8 @@ tui_add_win_to_layout (enum tui_win_type type)
        }
       break;
     case DATA_WIN:
-      if (cur_layout != SRC_DATA_COMMAND &&
-         cur_layout != DISASSEM_DATA_COMMAND)
+      if (cur_layout != SRC_DATA_COMMAND
+         && cur_layout != DISASSEM_DATA_COMMAND)
        {
          if (cur_layout == DISASSEM_COMMAND)
            show_layout (DISASSEM_DATA_COMMAND);
@@ -372,6 +373,10 @@ tui_default_win_viewport_height (enum tui_win_type type,
 
 /* Function to initialize gdb commands, for tui window layout
    manipulation.  */
+
+/* Provide a prototype to silence -Wmissing-prototypes.  */
+extern initialize_file_ftype _initialize_tui_layout;
+
 void
 _initialize_tui_layout (void)
 {
@@ -388,14 +393,6 @@ Layout names are:\n\
            source/assembly/command (split) is displayed, \n\
            the register window is displayed with \n\
            the window that has current logical focus.\n"));
-  if (xdb_commands)
-    {
-      add_com ("td", class_tui, tui_toggle_layout_command, _("\
-Toggle between Source/Command and Disassembly/Command layouts.\n"));
-      add_com ("ts", class_tui, tui_toggle_split_layout_command, _("\
-Toggle between Source/Command or Disassembly/Command and \n\
-Source/Disassembly/Command layouts.\n"));
-    }
 }
 
 
@@ -424,7 +421,8 @@ tui_set_layout_for_display_command (const char *layout_name)
        buf_ptr[i] = toupper (buf_ptr[i]);
 
       /* First check for ambiguous input.  */
-      if (strlen (buf_ptr) <= 1 && (*buf_ptr == 'S' || *buf_ptr == '$'))
+      if (strlen (buf_ptr) <= 1 
+         && (*buf_ptr == 'S' || *buf_ptr == '$'))
        {
          warning (_("Ambiguous command input."));
          status = TUI_FAILURE;
@@ -437,13 +435,14 @@ tui_set_layout_for_display_command (const char *layout_name)
            new_layout = DISASSEM_COMMAND;
          else if (subset_compare (buf_ptr, "SPLIT"))
            new_layout = SRC_DISASSEM_COMMAND;
-         else if (subset_compare (buf_ptr, "REGS") ||
-                  subset_compare (buf_ptr, TUI_GENERAL_SPECIAL_REGS_NAME) ||
-                  subset_compare (buf_ptr, TUI_GENERAL_REGS_NAME) ||
-                  subset_compare (buf_ptr, TUI_FLOAT_REGS_NAME) ||
-                  subset_compare (buf_ptr, TUI_SPECIAL_REGS_NAME))
+         else if (subset_compare (buf_ptr, "REGS") 
+                  || subset_compare (buf_ptr, TUI_GENERAL_SPECIAL_REGS_NAME)
+                  || subset_compare (buf_ptr, TUI_GENERAL_REGS_NAME)
+                  || subset_compare (buf_ptr, TUI_FLOAT_REGS_NAME)
+                  || subset_compare (buf_ptr, TUI_SPECIAL_REGS_NAME))
            {
-             if (cur_layout == SRC_COMMAND || cur_layout == SRC_DATA_COMMAND)
+             if (cur_layout == SRC_COMMAND 
+                 || cur_layout == SRC_DATA_COMMAND)
                new_layout = SRC_DATA_COMMAND;
              else
                new_layout = DISASSEM_DATA_COMMAND;
@@ -455,10 +454,10 @@ tui_set_layout_for_display_command (const char *layout_name)
                 up this code.  - edie epstein  */
              if (subset_compare (buf_ptr, TUI_FLOAT_REGS_NAME))
                {
-                 if (TUI_DATA_WIN->detail.data_display_info.regs_display_type !=
-                     TUI_SFLOAT_REGS &&
-                     TUI_DATA_WIN->detail.data_display_info.regs_display_type !=
-                     TUI_DFLOAT_REGS)
+                 if (TUI_DATA_WIN->detail.data_display_info.regs_display_type
+                     != TUI_SFLOAT_REGS
+                     && TUI_DATA_WIN->detail.data_display_info.regs_display_type
+                     != TUI_DFLOAT_REGS)
                    dpy_type = TUI_SFLOAT_REGS;
                  else
                    dpy_type =
@@ -473,10 +472,10 @@ tui_set_layout_for_display_command (const char *layout_name)
                dpy_type = TUI_SPECIAL_REGS;
              else if (TUI_DATA_WIN)
                {
-                 if (TUI_DATA_WIN->detail.data_display_info.regs_display_type !=
-                     TUI_UNDEFINED_REGS)
-                   dpy_type =
-                     TUI_DATA_WIN->detail.data_display_info.regs_display_type;
+                 if (TUI_DATA_WIN->detail.data_display_info.regs_display_type
+                     != TUI_UNDEFINED_REGS)
+                   dpy_type
+                     TUI_DATA_WIN->detail.data_display_info.regs_display_type;
                  else
                    dpy_type = TUI_GENERAL_REGS;
                }
@@ -508,10 +507,11 @@ tui_set_layout_for_display_command (const char *layout_name)
 }
 
 
-static CORE_ADDR
-extract_display_start_addr (void)
+static void
+extract_display_start_addr (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
 {
   enum tui_layout_type cur_layout = tui_current_layout ();
+  struct gdbarch *gdbarch = get_current_arch ();
   CORE_ADDR addr;
   CORE_ADDR pc;
   struct symtab_and_line cursal = get_current_source_symtab_and_line ();
@@ -520,6 +520,7 @@ extract_display_start_addr (void)
     {
     case SRC_COMMAND:
     case SRC_DATA_COMMAND:
+      gdbarch = TUI_SRC_WIN->detail.source_info.gdbarch;
       find_line_pc (cursal.symtab,
                    TUI_SRC_WIN->detail.source_info.start_line_or_addr.u.line_no,
                    &pc);
@@ -528,6 +529,7 @@ extract_display_start_addr (void)
     case DISASSEM_COMMAND:
     case SRC_DISASSEM_COMMAND:
     case DISASSEM_DATA_COMMAND:
+      gdbarch = TUI_DISASM_WIN->detail.source_info.gdbarch;
       addr = TUI_DISASM_WIN->detail.source_info.start_line_or_addr.u.addr;
       break;
     default:
@@ -535,54 +537,8 @@ extract_display_start_addr (void)
       break;
     }
 
-  return addr;
-}
-
-
-static void
-tui_handle_xdb_layout (struct tui_layout_def *layout_def)
-{
-  if (layout_def->split)
-    {
-      tui_set_layout (SRC_DISASSEM_COMMAND, TUI_UNDEFINED_REGS);
-      tui_set_win_focus_to (tui_win_list[layout_def->display_mode]);
-    }
-  else
-    {
-      if (layout_def->display_mode == SRC_WIN)
-       tui_set_layout (SRC_COMMAND, TUI_UNDEFINED_REGS);
-      else
-       tui_set_layout (DISASSEM_DATA_COMMAND, layout_def->regs_display_type);
-    }
-}
-
-
-static void
-tui_toggle_layout_command (char *arg, int from_tty)
-{
-  struct tui_layout_def *layout_def = tui_layout_def ();
-
-  /* Make sure the curses mode is enabled.  */
-  tui_enable ();
-  if (layout_def->display_mode == SRC_WIN)
-    layout_def->display_mode = DISASSEM_WIN;
-  else
-    layout_def->display_mode = SRC_WIN;
-
-  if (!layout_def->split)
-    tui_handle_xdb_layout (layout_def);
-}
-
-
-static void
-tui_toggle_split_layout_command (char *arg, int from_tty)
-{
-  struct tui_layout_def *layout_def = tui_layout_def ();
-
-  /* Make sure the curses mode is enabled.  */
-  tui_enable ();
-  layout_def->split = (!layout_def->split);
-  tui_handle_xdb_layout (layout_def);
+  *gdbarch_p = gdbarch;
+  *addr_p = addr;
 }
 
 
@@ -602,7 +558,7 @@ tui_layout_command (char *arg, int from_tty)
 static enum tui_layout_type
 next_layout (void)
 {
-  enum tui_layout_type new_layout;
+  int new_layout;
 
   new_layout = tui_current_layout ();
   if (new_layout == UNDEFINED_LAYOUT)
@@ -614,7 +570,7 @@ next_layout (void)
        new_layout = SRC_COMMAND;
     }
 
-  return new_layout;
+  return (enum tui_layout_type) new_layout;
 }
 
 
@@ -622,7 +578,7 @@ next_layout (void)
 static enum tui_layout_type
 prev_layout (void)
 {
-  enum tui_layout_type new_layout;
+  int new_layout;
 
   new_layout = tui_current_layout ();
   if (new_layout == SRC_COMMAND)
@@ -634,7 +590,7 @@ prev_layout (void)
        new_layout = DISASSEM_DATA_COMMAND;
     }
 
-  return new_layout;
+  return (enum tui_layout_type) new_layout;
 }
 
 
This page took 0.029685 seconds and 4 git commands to generate.