gdb/
[platform/upstream/binutils.git] / gdb / tui / tui-layout.c
index 9da0f3c..0c622b9 100644 (file)
@@ -1,7 +1,7 @@
 /* TUI layout window management.
 
-   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007
-   Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008, 2009,
+   2010 Free Software Foundation, Inc.
 
    Contributed by Hewlett-Packard Company.
 
@@ -9,7 +9,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,6 +37,7 @@
 #include "tui/tui-win.h"
 #include "tui/tui-winsource.h"
 #include "tui/tui-disasm.h"
+#include "tui/tui-layout.h"
 
 #include "gdb_string.h"
 #include "gdb_curses.h"
@@ -68,7 +68,7 @@ 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 extract_display_start_addr (struct gdbarch **, CORE_ADDR *);
 static void tui_handle_xdb_layout (struct tui_layout_def *);
 
 
@@ -144,10 +144,12 @@ tui_set_layout (enum tui_layout_type layout_type,
       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)
@@ -193,7 +195,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;
@@ -207,7 +209,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
@@ -231,7 +233,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
@@ -251,7 +253,7 @@ tui_set_layout (enum tui_layout_type layout_type,
                      || 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)
            {
@@ -377,6 +379,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)
 {
@@ -513,10 +519,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 ();
@@ -525,6 +532,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);
@@ -533,6 +541,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:
@@ -540,7 +549,8 @@ extract_display_start_addr (void)
       break;
     }
 
-  return addr;
+  *gdbarch_p = gdbarch;
+  *addr_p = addr;
 }