/* 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.
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"
#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"
/*******************************
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 *);
/***************************************
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);
{
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)
{
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;
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
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
/*
* 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)
{
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)
}
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)
}
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);
/* 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)
{
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"));
- }
}
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;
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;
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 =
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;
}
}
-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 ();
{
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);
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:
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;
}
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)
new_layout = SRC_COMMAND;
}
- return new_layout;
+ return (enum tui_layout_type) new_layout;
}
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)
new_layout = DISASSEM_DATA_COMMAND;
}
- return new_layout;
+ return (enum tui_layout_type) new_layout;
}