* tuiWin.c, tuiWin.h, tui.c, tui.h, tuiCommand.c: Add FSF copyright.
tuiCommand.h, tuiIO.c, tuiIO.h, tuiData.h, tuiData.c: Likewise.
tuiDataWin.c, tuiDataWin.h, tuiDisassem.c, tuiDisassem.h: Likewise.
tuiGeneralWin.c, tuiGeneralWin.h, tuiLayout.c, tuiLayout.h: Likewise.
tuiRegs.c, tuiRegs.h, tuiSource.c, tuiSource.h: Likewise.
tuiSouceWin.c, tuiSourceWin.h, tuiStack.c, tuiStack.h: Likewise.
2001-07-14 19:01:25 +00:00
|
|
|
|
/* TUI layout window management.
|
2002-03-01 06:19:28 +00:00
|
|
|
|
|
2019-01-01 10:01:51 +04:00
|
|
|
|
Copyright (C) 1998-2019 Free Software Foundation, Inc.
|
2002-03-01 06:19:28 +00:00
|
|
|
|
|
* tuiWin.c, tuiWin.h, tui.c, tui.h, tuiCommand.c: Add FSF copyright.
tuiCommand.h, tuiIO.c, tuiIO.h, tuiData.h, tuiData.c: Likewise.
tuiDataWin.c, tuiDataWin.h, tuiDisassem.c, tuiDisassem.h: Likewise.
tuiGeneralWin.c, tuiGeneralWin.h, tuiLayout.c, tuiLayout.h: Likewise.
tuiRegs.c, tuiRegs.h, tuiSource.c, tuiSource.h: Likewise.
tuiSouceWin.c, tuiSourceWin.h, tuiStack.c, tuiStack.h: Likewise.
2001-07-14 19:01:25 +00:00
|
|
|
|
Contributed by Hewlett-Packard Company.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
* tuiWin.c, tuiWin.h, tui.c, tui.h, tuiCommand.c: Add FSF copyright.
tuiCommand.h, tuiIO.c, tuiIO.h, tuiData.h, tuiData.c: Likewise.
tuiDataWin.c, tuiDataWin.h, tuiDisassem.c, tuiDisassem.h: Likewise.
tuiGeneralWin.c, tuiGeneralWin.h, tuiLayout.c, tuiLayout.h: Likewise.
tuiRegs.c, tuiRegs.h, tuiSource.c, tuiSource.h: Likewise.
tuiSouceWin.c, tuiSourceWin.h, tuiStack.c, tuiStack.h: Likewise.
2001-07-14 19:01:25 +00:00
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
|
|
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
|
2007-08-23 18:08:50 +00:00
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
* tuiWin.c, tuiWin.h, tui.c, tui.h, tuiCommand.c: Add FSF copyright.
tuiCommand.h, tuiIO.c, tuiIO.h, tuiData.h, tuiData.c: Likewise.
tuiDataWin.c, tuiDataWin.h, tuiDisassem.c, tuiDisassem.h: Likewise.
tuiGeneralWin.c, tuiGeneralWin.h, tuiLayout.c, tuiLayout.h: Likewise.
tuiRegs.c, tuiRegs.h, tuiSource.c, tuiSource.h: Likewise.
tuiSouceWin.c, tuiSourceWin.h, tuiStack.c, tuiStack.h: Likewise.
2001-07-14 19:01:25 +00:00
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-23 18:08:50 +00:00
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
#include "defs.h"
|
2010-03-20 05:17:10 +00:00
|
|
|
|
#include "arch-utils.h"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#include "command.h"
|
|
|
|
|
#include "symtab.h"
|
|
|
|
|
#include "frame.h"
|
2002-09-30 00:52:27 +00:00
|
|
|
|
#include "source.h"
|
2001-07-17 22:22:40 +00:00
|
|
|
|
#include <ctype.h>
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2004-01-19 04:31:53 +00:00
|
|
|
|
#include "tui/tui.h"
|
2019-07-02 15:48:59 -06:00
|
|
|
|
#include "tui/tui-command.h"
|
2004-01-19 04:31:53 +00:00
|
|
|
|
#include "tui/tui-data.h"
|
|
|
|
|
#include "tui/tui-wingeneral.h"
|
|
|
|
|
#include "tui/tui-stack.h"
|
|
|
|
|
#include "tui/tui-regs.h"
|
|
|
|
|
#include "tui/tui-win.h"
|
|
|
|
|
#include "tui/tui-winsource.h"
|
|
|
|
|
#include "tui/tui-disasm.h"
|
2008-02-21 Pedro Alves <pedro@codesorcery.com>
Silence a few -Wmissing-prototypes warnings.
PR build/9877:
* amd64-nat.c: Include "amd64-nat.h".
* fork-child.c (_initialize_fork_child): Ditto.
* gcore.c (_initialize_gcore): Ditto.
* inf-ptrace.c: Include "inf-ptrace.h".
(inf_ptrace_store_registers): Make it static.
* linux-nat.c (linux_nat_terminal_ours): Make it static.
(_initialize_linux_nat): Declare before definition.
* linux-tdep.c: Include "linux-tdep.h".
* linux-thread-db.c (_initialize_thread_db): Declare before
definition.
* proc-service.c (_initialize_proc_service): Ditto.
* remote.c (remote_send_printf): Make it static.
* solib.c: Include "solib.h".
* symfile-mem.c (_initialize_symfile_mem): Declare before
definition.
* ada-lang.c (ada_la_decode, ada_match_name)
(ada_suppress_symbol_printing, ada_is_array_type)
(ada_value_ptr_subscript, ada_array_length)
(ada_to_static_fixed_value): Make them static.
(_initialize_ada_language): Declare before definition.
* ada-tasks.c (ada_get_task_number, ada_get_environment_task)
(ada_task_list_changed, ada_new_objfile_observer): Make them
static.
(_initialize_tasks): Declare before definition.
* addrmap.c (_initialize_addrmap): Declare before definition.
* auxv.c (default_auxv_parse): Make it static.
* bfd-target.c (target_bfd_xfer_partial, target_bfd_xclose): Make
them static.
* breakpoint.c (remove_sal): Add line break.
(expand_line_sal_maybe): Make it static.
* cp-name-parser.y: Include "cp-support.h".
* cp-valprint.c (cp_find_class_member): Make it static.
* eval.c (value_f90_subarray): Ditto.
* exceptions.c (print_any_exception): Ditto.
* findcmd.c (_initialize_mem_search): Declare before definition.
* frame.c (frame_observer_target_changed): Make it static.
* gnu-v3-abi.c (gnuv3_find_method_in): Make it static.
* inf-child.c: Include "inf-child.h".
* inferior.h (valid_inferior_id): Rename to ...
(valid_gdb_inferior_id): ... this.
* infrun.c (infrun_thread_stop_requested, siginfo_make_value):
Make them static.
* jv-lang.c (java_language_arch_info): Make it static.
* m2-typeprint.c (m2_get_discrete_bounds): Ditto.
* osdata.c (info_osdata_command): Make it static.
* regcache.c (regcache_observer_target_changed): Make it static.
* reverse.c (_initialize_reverse): Declare before definition.
* stabsread.c (cleanup_undefined_types_noname)
(cleanup_undefined_types_1): Make them static.
* symfile.c (place_section): Make it static.
* symtab.c (find_pc_sect_psymtab_closer): Make it static.
* target-descriptions.c (_initialize_target_descriptions): Declare
before definition.
* target.c (default_get_ada_task_ptid, find_default_can_async_p)
(find_default_is_async_p, find_default_supports_non_stop): Make
them static.
(target_supports_non_stop): Add prototype.
(dummy_pid_to_str): Make it static.
* utils.c (_initialize_utils): Declare before definition.
* ada-exp.y (_initialize_ada_exp): Declare before definition.
* solib-svr4.c (HAS_LM_DYNAMIC_FROM_LINK_MAP): Add a prototype.
* target.h (struct target_ops): Add a prototype to the
to_can_execute_reverse callback.
* macroscope.c (_initialize_macroscope): Declare before definition.
* cp-namespace.c (_initialize_cp_namespace): Declare before definition.
* python/python.c (_initialize_python): Declare before definition.
* tui/tui-command.c: Include "tui/tui-command.h".
* tui/tui-data.c (init_content_element, init_win_info): Make them
static.
* tui/tui-disasm.c: Include "tui/tui-disasm.h".
* tui/tui-interp.c (_initialize_tui_interp): Declare before
definition.
* tui/tui-layout.c: Include "tui/tui-layout.h".
(_initialize_tui_layout): Declare before definition.
* tui/tui-regs.c: Include "tui/tui-regs.h".
(tui_display_reg_element_at_line): Make it static.
(_initialize_tui_regs): Declare before definition.
* tui/tui-stack.c (_initialize_tui_stack): Declare before
definition.
* tui/tui-win.c: Include "tui/tui-win.h".
(_initialize_tui_win): Declare before definition.
(tui_sigwinch_handler): Make it static. Wrap in ifdef SIGWINCH.
* tui/tui-win.h (tui_sigwinch_handler): Delete declaration.
(tui_get_cmd_list): Add a prototype.
* tui/tui-windata.c: Include tui-windata.h.
* tui/tui-wingeneral.c (box_win): Make it static.
* cli/cli-logging.c (show_logging_command): Make it static.
(_initialize_cli_logging): Declare before definition.
* mi/mi-common.c (_initialize_gdb_mi_common): Declare before
definition.
2009-02-21 16:14:50 +00:00
|
|
|
|
#include "tui/tui-layout.h"
|
2019-07-02 15:55:01 -06:00
|
|
|
|
#include "tui/tui-source.h"
|
2004-02-10 Andrew Cagney <cagney@redhat.com>
* defs.h: Do not include "tui.h".
* gdb_curses.h: New file.
* tui/tui-hooks.h: New file.
* tui/tui.h (tui_update_all_exec_infos): Delete declaration.
(tui_install_hooks, tui_remove_hooks): Delete declarations.
(tui_initialize_io): Delete declaration.
(tui_initialize_readline: Delete redundant declaration.
(struct tui_point): Delete definition.
* tui/tui-data.h (struct tui_point): Define.
* cli/cli-decode.c [TUI]: Include "tui/tui.h".
* utils.c: Include "tui/tui.h".
* tui/tui-data.h: Include "tui/tui.h" and "gdb_curses.h".
* printcmd.c [TUI]: Include "tui/tui.h".
* cli/cli-cmds.c [TUI]: Include "tui/tui.h".
* tui/tui-command.c: Include "gdb_curses.h".
* tui/tui.c, tui/tui-winsource.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-windata.c, tui/tui-win.c, tui/tui-stack.c: Ditto.
* tui/tui-source.c, tui/tui-regs.c, tui/tui-layout.c: Ditto.
* tui/tui-io.c, tui/tui-disasm.c, tui/tui-data.c: : Ditto.
* tui/tui-hooks.c: Include "tui-hooks.h" and "gdb_curses.h".
* Makefile.in: Update all dependencies.
(tui_hooks_h, gdb_curses_h): Define.
(SUBDIR_TUI_CFLAGS): Remove -I${srcdir}/tui.
2004-02-10 19:08:19 +00:00
|
|
|
|
#include "gdb_curses.h"
|
2003-06-22 15:21:39 +00:00
|
|
|
|
|
2004-02-08 00:05:16 +00:00
|
|
|
|
static void show_layout (enum tui_layout_type);
|
|
|
|
|
static enum tui_layout_type next_layout (void);
|
|
|
|
|
static enum tui_layout_type prev_layout (void);
|
Constify add_com
This changes add_com to take a cmd_const_cfunc_ftype, and then fixes
up all the command implementations.
In most cases this is trivial.
In a couple of places I had to again introduce a temporary non-const
overload. These overloads will be removed when add_info is
constified.
gdb/ChangeLog
2017-11-07 Tom Tromey <tom@tromey.com>
* solib.h (no_shared_libraries): Constify.
* frame.h (return_command): Constify.
* cli/cli-cmds.h (quit_command): Constify.
* top.h (quit_command, execute_command): Constify.
* target.h (flash_erase_command): Constify.
* inferior.h (set_inferior_args, attach_command): Constify.
* tracepoint.h (start_tracing, stop_tracing): Constify.
* breakpoint.h (break_command, tbreak_command)
(hbreak_command_wrapper, thbreak_command_wrapper)
(rbreak_command_wrapper, watch_command_wrapper)
(awatch_command_wrapper, rwatch_command_wrapper)
(get_tracepoint_by_number): Constify.
* symtab.c (info_variables_command, rbreak_command)
(symtab_symbol_info): Constify.
(info_variables_command): Add non-const overload.
* top.c (dont_repeat_command): Constify.
* breakpoint.c (ignore_command, commands_command)
(condition_command, tbreak_command, hbreak_command)
(thbreak_command, clear_command, break_command)
(info_breakpoints_command, watch_command, rwatch_command)
(awatch_command, trace_command, ftrace_command, strace_command)
(trace_pass_command, break_range_command, dprintf_command)
(agent_printf_command, get_tracepoint_by_number)
(watch_maybe_just_location, trace_pass_command): Constify.
(info_breakpoints_command): Add non-const overload.
* tracefile.c (tsave_command): Constify.
* infcmd.c (attach_command, disconnect_command, signal_command)
(queue_signal_command, stepi_command, nexti_command)
(finish_command, next_command, step_command, until_command)
(advance_command, jump_command, continue_command, run_command)
(start_command, starti_command, interrupt_command)
(run_command_1, set_inferior_args, step_1): Constify.
* inferior.c (add_inferior_command, remove_inferior_command)
(clone_inferior_command): Constify.
* linux-fork.c (checkpoint_command, restart_command): Constify.
* windows-nat.c (signal_event_command): Constify.
* guile/guile.c (guile_repl_command, guile_command): Constify.
* printcmd.c (x_command, display_command, printf_command)
(output_command, set_command, call_command, print_command)
(eval_command): Constify.
(non_const_set_command): Remove.
(_initialize_printcmd): Update.
* source.c (forward_search_command, reverse_search_command):
Constify.
* jit.c (jit_reader_load_command, jit_reader_unload_command):
Constify.
* infrun.c (handle_command): Constify.
* memattr.c (mem_command): Constify.
* stack.c (return_command, up_command, up_silently_command)
(down_command, down_silently_command, frame_command)
(backtrace_command, func_command, backtrace_command_1): Constify.
(backtrace_command): Add non-const overload.
* remote-sim.c (simulator_command): Constify.
* exec.c (set_section_command): Constify.
* tracepoint.c (tdump_command, trace_variable_command)
(tstatus_command, tstop_command, tstart_command)
(end_actions_pseudocommand, while_stepping_pseudocommand)
(collect_pseudocommand, teval_pseudocommand, actions_command)
(start_tracing, stop_tracing): Constify.
* value.c (init_if_undefined_command): Constify.
* tui/tui-stack.c (tui_update_command): Constify.
* tui/tui-win.c (tui_refresh_all_command)
(tui_set_tab_width_command, tui_set_win_height_command)
(tui_set_focus_command, tui_scroll_forward_command)
(tui_scroll_backward_command, tui_scroll_left_command)
(tui_scroll_right_command, parse_scrolling_args, tui_set_focus)
(tui_set_win_height): Constify.
* tui/tui-layout.c (tui_layout_command): Constify.
* procfs.c (proc_trace_syscalls, proc_trace_sysentry_cmd)
(proc_trace_sysexit_cmd, proc_untrace_sysentry_cmd)
(proc_untrace_sysexit_cmd): Constify.
* remote.c (threadlist_test_cmd, threadinfo_test_cmd)
(threadset_test_cmd, threadlist_update_test_cmd)
(threadalive_test): Constify.
* objc-lang.c (print_object_command): Constify.
* command.h (add_com): Constify.
* cli/cli-dump.c (restore_command): Constify.
* cli/cli-cmds.c (pwd_command, echo_command, quit_command)
(help_command, complete_command, shell_command, edit_command)
(list_command, disassemble_command, make_command)
(apropos_command, alias_command): Constify.
* cli/cli-script.c (document_command, define_command)
(while_command, if_command, validate_comname): Constify.
* cli/cli-decode.c (struct cmd_list_element): Change type of
"fun".
* target.c (do_monitor_command, flash_erase_command): Constify.
* regcache.c (reg_flush_command): Constify.
* reverse.c (reverse_step, reverse_next, reverse_stepi)
(reverse_nexti, reverse_continue, reverse_finish)
(save_bookmark_command, goto_bookmark_command)
(exec_reverse_once): Constify.
* python/python.c (python_interactive_command, python_command):
Constify.
* typeprint.c (ptype_command, whatis_command, whatis_exp):
Constify.
* solib.c (sharedlibrary_command, no_shared_libraries): Constify.
* gcore.c (gcore_command): Constify.
2017-10-11 15:43:01 -06:00
|
|
|
|
static void tui_layout_command (const char *, int);
|
2009-07-02 17:17:42 +00:00
|
|
|
|
static void extract_display_start_addr (struct gdbarch **, CORE_ADDR *);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
|
2019-10-09 16:35:41 -06:00
|
|
|
|
/* The pre-defined layouts. */
|
|
|
|
|
static tui_layout_split *standard_layouts[UNDEFINED_LAYOUT];
|
|
|
|
|
|
|
|
|
|
/* The layout that is currently applied. */
|
|
|
|
|
static std::unique_ptr<tui_layout_base> applied_layout;
|
|
|
|
|
|
2019-07-05 12:13:40 -06:00
|
|
|
|
static enum tui_layout_type current_layout = UNDEFINED_LAYOUT;
|
|
|
|
|
|
|
|
|
|
/* Accessor for the current layout. */
|
|
|
|
|
enum tui_layout_type
|
|
|
|
|
tui_current_layout (void)
|
|
|
|
|
{
|
|
|
|
|
return current_layout;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-09 16:35:41 -06:00
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
tui_apply_current_layout ()
|
|
|
|
|
{
|
|
|
|
|
applied_layout->apply (0, 0, tui_term_width (), tui_term_height ());
|
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2002-08-24 15:25:25 +00:00
|
|
|
|
/* Show the screen layout defined. */
|
|
|
|
|
static void
|
2004-02-08 00:05:16 +00:00
|
|
|
|
show_layout (enum tui_layout_type layout)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2004-02-08 00:05:16 +00:00
|
|
|
|
enum tui_layout_type cur_layout = tui_current_layout ();
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2004-02-08 00:05:16 +00:00
|
|
|
|
if (layout != cur_layout)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2019-07-05 12:29:18 -06:00
|
|
|
|
tui_make_all_invisible ();
|
2019-10-09 16:35:41 -06:00
|
|
|
|
applied_layout = standard_layouts[layout]->clone ();
|
|
|
|
|
tui_apply_current_layout ();
|
2019-10-08 20:06:09 -06:00
|
|
|
|
current_layout = layout;
|
2019-07-05 12:46:23 -06:00
|
|
|
|
tui_delete_invisible_windows ();
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
2002-08-24 12:28:33 +00:00
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
|
2004-01-23 23:25:17 +00:00
|
|
|
|
/* Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
|
gdb: Remove register class specific layout names.
The layout command supports the layout names $FREGS, $GREGS, $SREGS,
and $REGS. The intention of these layout names was to display the tui
register window with a specific set of registers.
First, these layout names no longer work, and haven't for a while, using
any of them will just result in switching to the general register view.
Second there is already the command 'tui reg GROUP' command to set the
displayed register set to GROUP, so making the layout command also
control the register set feels like unnecessary overloading of the
layout command.
This commit removes all code relating to supporting the register set
specific names from the layout command. Afterwards the user can select
an available layout using the layout command, and control the choice of
register set using the 'tui reg GROUP' command.
gdb/ChangeLog:
* tui/tui-layout.c (tui_set_layout): Remove
tui_register_display_type parameter. Remove all checking of this
parameter, and reindent function. Update header comment.
(tui_set_layout_for_display_command): Rename to...
(tui_set_layout_by_name): ...this, and don't check for different
register class types, don't pass a tui_register_display_type to
tui_set_layout. Update header comment.
(layout_names): Remove register set specific names.
* tui/tui-layout.h (tui_set_layout): Remove
tui_register_display_type parameter.
* tui/tui.c (tui_rl_change_windows): Don't pass a
tui_register_display_type to tui_set_layout.
(tui_rl_delete_other_windows): Likewise.
(tui_enable): Likewise.
* tui/tui-data.h (TUI_FLOAT_REGS_NAME): Remove.
(TUI_FLOAT_REGS_NAME_LOWER): Remove.
(TUI_GENERAL_REGS_NAME): Remove.
(TUI_GENERAL_REGS_NAME_LOWER): Remove.
(TUI_SPECIAL_REGS_NAME): Remove.
(TUI_SPECIAL_REGS_NAME_LOWER): Remove.
(TUI_GENERAL_SPECIAL_REGS_NAME): Remove.
(TUI_GENERAL_SPECIAL_REGS_NAME_LOWER): Remove.
(enum tui_register_display_type): Remove.
(struct tui_layout_def): Remove regs_display_type and
float_regs_display_type fields.
(struct tui_data_info): Remove regs_display_type field.
(tui_layout_command): Use new name for
tui_set_layout_for_display_command.
* tui/tui-data.c (layout_def): Don't initialise removed fields.
(tui_clear_win_detail): Don't initialise removed fields of
win_info.
* tui/tui-regs.c (tui_show_registers): Use new name for
tui_set_layout_for_display_command.
* tui/tui.h (tui_set_layout_for_display_command): Rename
declaration to...
(tui_set_layout_by_name): ...this.
* printcmd.c (display_command): Remove tui related layout call,
and reindent.
2015-05-20 23:35:07 +02:00
|
|
|
|
SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND. */
|
2019-06-30 20:34:57 -06:00
|
|
|
|
void
|
gdb: Remove register class specific layout names.
The layout command supports the layout names $FREGS, $GREGS, $SREGS,
and $REGS. The intention of these layout names was to display the tui
register window with a specific set of registers.
First, these layout names no longer work, and haven't for a while, using
any of them will just result in switching to the general register view.
Second there is already the command 'tui reg GROUP' command to set the
displayed register set to GROUP, so making the layout command also
control the register set feels like unnecessary overloading of the
layout command.
This commit removes all code relating to supporting the register set
specific names from the layout command. Afterwards the user can select
an available layout using the layout command, and control the choice of
register set using the 'tui reg GROUP' command.
gdb/ChangeLog:
* tui/tui-layout.c (tui_set_layout): Remove
tui_register_display_type parameter. Remove all checking of this
parameter, and reindent function. Update header comment.
(tui_set_layout_for_display_command): Rename to...
(tui_set_layout_by_name): ...this, and don't check for different
register class types, don't pass a tui_register_display_type to
tui_set_layout. Update header comment.
(layout_names): Remove register set specific names.
* tui/tui-layout.h (tui_set_layout): Remove
tui_register_display_type parameter.
* tui/tui.c (tui_rl_change_windows): Don't pass a
tui_register_display_type to tui_set_layout.
(tui_rl_delete_other_windows): Likewise.
(tui_enable): Likewise.
* tui/tui-data.h (TUI_FLOAT_REGS_NAME): Remove.
(TUI_FLOAT_REGS_NAME_LOWER): Remove.
(TUI_GENERAL_REGS_NAME): Remove.
(TUI_GENERAL_REGS_NAME_LOWER): Remove.
(TUI_SPECIAL_REGS_NAME): Remove.
(TUI_SPECIAL_REGS_NAME_LOWER): Remove.
(TUI_GENERAL_SPECIAL_REGS_NAME): Remove.
(TUI_GENERAL_SPECIAL_REGS_NAME_LOWER): Remove.
(enum tui_register_display_type): Remove.
(struct tui_layout_def): Remove regs_display_type and
float_regs_display_type fields.
(struct tui_data_info): Remove regs_display_type field.
(tui_layout_command): Use new name for
tui_set_layout_for_display_command.
* tui/tui-data.c (layout_def): Don't initialise removed fields.
(tui_clear_win_detail): Don't initialise removed fields of
win_info.
* tui/tui-regs.c (tui_show_registers): Use new name for
tui_set_layout_for_display_command.
* tui/tui.h (tui_set_layout_for_display_command): Rename
declaration to...
(tui_set_layout_by_name): ...this.
* printcmd.c (display_command): Remove tui related layout call,
and reindent.
2015-05-20 23:35:07 +02:00
|
|
|
|
tui_set_layout (enum tui_layout_type layout_type)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2019-06-30 20:34:57 -06:00
|
|
|
|
gdb_assert (layout_type != UNDEFINED_LAYOUT);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2019-06-30 20:34:57 -06:00
|
|
|
|
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 ();
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2019-06-30 20:34:57 -06:00
|
|
|
|
extract_display_start_addr (&gdbarch, &addr);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2019-06-30 20:34:57 -06:00
|
|
|
|
enum tui_layout_type new_layout = layout_type;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2019-06-30 20:34:57 -06:00
|
|
|
|
if (new_layout != cur_layout)
|
|
|
|
|
{
|
|
|
|
|
show_layout (new_layout);
|
2007-08-14 21:39:22 +00:00
|
|
|
|
|
2019-06-30 20:34:57 -06:00
|
|
|
|
/* Now determine where focus should be. */
|
|
|
|
|
if (win_with_focus != TUI_CMD_WIN)
|
|
|
|
|
{
|
|
|
|
|
switch (new_layout)
|
gdb: Remove register class specific layout names.
The layout command supports the layout names $FREGS, $GREGS, $SREGS,
and $REGS. The intention of these layout names was to display the tui
register window with a specific set of registers.
First, these layout names no longer work, and haven't for a while, using
any of them will just result in switching to the general register view.
Second there is already the command 'tui reg GROUP' command to set the
displayed register set to GROUP, so making the layout command also
control the register set feels like unnecessary overloading of the
layout command.
This commit removes all code relating to supporting the register set
specific names from the layout command. Afterwards the user can select
an available layout using the layout command, and control the choice of
register set using the 'tui reg GROUP' command.
gdb/ChangeLog:
* tui/tui-layout.c (tui_set_layout): Remove
tui_register_display_type parameter. Remove all checking of this
parameter, and reindent function. Update header comment.
(tui_set_layout_for_display_command): Rename to...
(tui_set_layout_by_name): ...this, and don't check for different
register class types, don't pass a tui_register_display_type to
tui_set_layout. Update header comment.
(layout_names): Remove register set specific names.
* tui/tui-layout.h (tui_set_layout): Remove
tui_register_display_type parameter.
* tui/tui.c (tui_rl_change_windows): Don't pass a
tui_register_display_type to tui_set_layout.
(tui_rl_delete_other_windows): Likewise.
(tui_enable): Likewise.
* tui/tui-data.h (TUI_FLOAT_REGS_NAME): Remove.
(TUI_FLOAT_REGS_NAME_LOWER): Remove.
(TUI_GENERAL_REGS_NAME): Remove.
(TUI_GENERAL_REGS_NAME_LOWER): Remove.
(TUI_SPECIAL_REGS_NAME): Remove.
(TUI_SPECIAL_REGS_NAME_LOWER): Remove.
(TUI_GENERAL_SPECIAL_REGS_NAME): Remove.
(TUI_GENERAL_SPECIAL_REGS_NAME_LOWER): Remove.
(enum tui_register_display_type): Remove.
(struct tui_layout_def): Remove regs_display_type and
float_regs_display_type fields.
(struct tui_data_info): Remove regs_display_type field.
(tui_layout_command): Use new name for
tui_set_layout_for_display_command.
* tui/tui-data.c (layout_def): Don't initialise removed fields.
(tui_clear_win_detail): Don't initialise removed fields of
win_info.
* tui/tui-regs.c (tui_show_registers): Use new name for
tui_set_layout_for_display_command.
* tui/tui.h (tui_set_layout_for_display_command): Rename
declaration to...
(tui_set_layout_by_name): ...this.
* printcmd.c (display_command): Remove tui related layout call,
and reindent.
2015-05-20 23:35:07 +02:00
|
|
|
|
{
|
2019-06-30 20:34:57 -06:00
|
|
|
|
case SRC_COMMAND:
|
|
|
|
|
tui_set_win_focus_to (TUI_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);
|
|
|
|
|
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);
|
|
|
|
|
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);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-06-30 20:34:57 -06:00
|
|
|
|
/*
|
|
|
|
|
* Now update the window content.
|
|
|
|
|
*/
|
|
|
|
|
tui_update_source_windows_with_addr (gdbarch, addr);
|
|
|
|
|
if (new_layout == SRC_DATA_COMMAND
|
|
|
|
|
|| new_layout == DISASSEM_DATA_COMMAND)
|
2019-07-14 19:45:55 -06:00
|
|
|
|
TUI_DATA_WIN->show_registers (TUI_DATA_WIN->get_current_group ());
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
2002-08-24 12:28:33 +00:00
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2004-01-23 23:25:17 +00:00
|
|
|
|
/* Add the specified window to the layout in a logical way. This
|
|
|
|
|
means setting up the most logical layout given the window to be
|
|
|
|
|
added. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
void
|
2004-01-23 23:25:17 +00:00
|
|
|
|
tui_add_win_to_layout (enum tui_win_type type)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2004-02-08 00:05:16 +00:00
|
|
|
|
enum tui_layout_type cur_layout = tui_current_layout ();
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case SRC_WIN:
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-disasm.c, tui-file.c, tui-io.c,
tui-layout.c, tui-regs.c, tui-source.c, tui-win.c, tui-windata.c,
tui-wingeneral.c, tui-winsource.c: Coding standard, && and ||
go at beginning of new line.
2007-08-15 00:19:44 +00:00
|
|
|
|
if (cur_layout != SRC_COMMAND
|
|
|
|
|
&& cur_layout != SRC_DISASSEM_COMMAND
|
|
|
|
|
&& cur_layout != SRC_DATA_COMMAND)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2004-02-08 00:05:16 +00:00
|
|
|
|
if (cur_layout == DISASSEM_DATA_COMMAND)
|
|
|
|
|
show_layout (SRC_DATA_COMMAND);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
else
|
2004-02-08 00:05:16 +00:00
|
|
|
|
show_layout (SRC_COMMAND);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DISASSEM_WIN:
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-disasm.c, tui-file.c, tui-io.c,
tui-layout.c, tui-regs.c, tui-source.c, tui-win.c, tui-windata.c,
tui-wingeneral.c, tui-winsource.c: Coding standard, && and ||
go at beginning of new line.
2007-08-15 00:19:44 +00:00
|
|
|
|
if (cur_layout != DISASSEM_COMMAND
|
|
|
|
|
&& cur_layout != SRC_DISASSEM_COMMAND
|
|
|
|
|
&& cur_layout != DISASSEM_DATA_COMMAND)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2004-02-08 00:05:16 +00:00
|
|
|
|
if (cur_layout == SRC_DATA_COMMAND)
|
|
|
|
|
show_layout (DISASSEM_DATA_COMMAND);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
else
|
2004-02-08 00:05:16 +00:00
|
|
|
|
show_layout (DISASSEM_COMMAND);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DATA_WIN:
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-disasm.c, tui-file.c, tui-io.c,
tui-layout.c, tui-regs.c, tui-source.c, tui-win.c, tui-windata.c,
tui-wingeneral.c, tui-winsource.c: Coding standard, && and ||
go at beginning of new line.
2007-08-15 00:19:44 +00:00
|
|
|
|
if (cur_layout != SRC_DATA_COMMAND
|
|
|
|
|
&& cur_layout != DISASSEM_DATA_COMMAND)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2004-02-08 00:05:16 +00:00
|
|
|
|
if (cur_layout == DISASSEM_COMMAND)
|
|
|
|
|
show_layout (DISASSEM_DATA_COMMAND);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
else
|
2004-02-08 00:05:16 +00:00
|
|
|
|
show_layout (SRC_DATA_COMMAND);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2004-02-08 00:05:16 +00:00
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2015-03-26 14:13:57 +00:00
|
|
|
|
/* Complete possible layout names. TEXT is the complete text entered so
|
|
|
|
|
far, WORD is the word currently being completed. */
|
|
|
|
|
|
Introduce class completion_tracker & rewrite completion<->readline interaction
This patch reworks the whole completion machinery, and prepares it
for later enhancements.
Adds a new "completion_tracker" class that is meant to hold everything
about the state of the current completion operation.
This class now has the responsibility of tracking the list of
completion matches, and checking whether the max completions limit has
been reached. You can look at this as this patch starting out by
C++fying the existing "completion_tracker" in symtab.c (it's just an
htab_t typedef currently), moving it to completer.h/c, and then making
it a class/generalizing/enhancing it.
Unlike with the current tracking, completion_tracker now checks
whether the limit has been reached on each completion match list
insertion. This both simplifies the max-completions handling code
(maybe_add_completion_enum is gone, for example), and is a
prerequisite for follow up patches.
The current completion_tracker is only used for symbol completions,
and the symbol code gets at the current instance via globals. This
patch cleans that up by adding a completion_tracker reference to the
signature of the completion functions, and passing the tracker around
everywhere necessary.
Then, the patch changes how the completion match list is handed over
to readline. Currently, we're using the rl_completion_entry_function
readline entry point, and the patch switches to
rl_attempted_completion_function. A following patch will want to let
GDB itself decide the common completion prefix between all matches
(what readline calls the "lowest common denominator"), instead of
having readline compute it, and that's not possible with the
rl_completion_entry_function entry point. Also,
rl_attempted_completion_function lets GDB hand over the match list to
readline as an array in one go instead of passing down matches one by
one, so from that angle it's a nicer entry point anyway.
Lastly, the patch catches exceptions around the readline entry points,
because we can't let C++ exceptions cross readline. We handle that in
the readline input entry point, but the completion entry point isn't
guarded, so GDB can abort if completion throws. E.g., in current
master:
(gdb) b -function "fun<tab>
terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR'
Aborted (core dumped)
This patch fixes that. This will be exercised in the new tests added
later on in the series.
gdb/ChangeLog:
2017-07-17 Pedro Alves <palves@redhat.com>
* ada-lang.c (symbol_completion_match): Adjust comments.
(symbol_completion_add): Replace vector parameter with
completion_tracker parameter. Use it.
(ada_make_symbol_completion_list): Rename to...
(ada_collect_symbol_completion_matches): ... this. Add
completion_tracker parameter and use it.
(ada_language_defn): Adjust.
* break-catch-syscall.c (catch_syscall_completer): Adjust
prototype and work with completion_tracker instead of VEC.
* breakpoint.c (condition_completer): Adjust prototype and work
with completion_tracker instead of VEC.
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Adjust to renames.
* cli/cli-cmds.c (complete_command): Rework using
completion_tracker. Catch exceptions when completing.
* cli/cli-decode.c (integer_unlimited_completer)
(complete_on_cmdlist, complete_on_enum): Adjust prototype and work
with completion_tracker instead of VEC.
* command.h (struct completion_tracker): Forward declare.
(completer_ftype, completer_handle_brkchars_ftype): Change
types.
(complete_on_cmdlist, complete_on_enum): Adjust.
* completer.c: Include <algorithm>.
(struct gdb_completer_state): New.
(current_completion): New global.
(readline_line_completion_function): Delete.
(noop_completer, filename_completer)
(filename_completer_handle_brkchars, complete_files_symbols)
(linespec_location_completer): Adjust to work with a
completion_tracker instead of a VEC.
(string_or_empty): New.
(collect_explicit_location_matches): Adjust to work with a
completion_tracker instead of a VEC.
(explicit_location_completer): Rename to ...
(complete_explicit_location): ... this and adjust to work with a
completion_tracker instead of a VEC.
(location_completer): Adjust to work with a completion_tracker
instead of a VEC.
(add_struct_fields): Adjust to work with a completion_list instead
of VEC.
(expression_completer): Rename to ...
(complete_expression): ... this and adjust to work with a
completion_tracker instead of a VEC. Use complete_files_symbols.
(expression_completer): Reimplement on top of complete_expression.
(symbol_completer): Adjust to work with a completion_tracker
instead of a VEC.
(enum complete_line_internal_reason): Add describing comments.
(complete_line_internal_normal_command): Adjust to work with a
completion_tracker instead of a VEC.
(complete_line_internal): Rename to ...
(complete_line_internal_1): ... this and adjust to work with a
completion_tracker instead of a VEC. Assert TEXT is NULL in the
handle_brkchars phase.
(new_completion_tracker): Delete.
(complete_line_internal): Reimplement as TRY/CATCH wrapper around
complete_line_internal_1.
(free_completion_tracker): Delete.
(INITIAL_COMPLETION_HTAB_SIZE): New.
(completion_tracker::completion_tracker)
(completion_tracker::~completion_tracker): New.
(maybe_add_completion): Delete.
(completion_tracker::maybe_add_completion)
(completion_tracker::add_completion)
(completion_tracker::add_completions): New.
(throw_max_completions_reached_error): Delete.
(complete_line): Adjust to work with a completion_tracker instead
of a VEC. Don't create a completion_tracker_t or check for max
completions here.
(command_completer, command_completer_handle_brkchars)
(signal_completer, reg_or_group_completer_1)
(reg_or_group_completer, default_completer_handle_brkchars):
Adjust to work with a completion_tracker.
(gdb_completion_word_break_characters_throw): New.
(gdb_completion_word_break_characters): Reimplement.
(line_completion_function): Delete.
(completion_tracker::recompute_lowest_common_denominator)
(expand_preserving_ws)
(completion_tracker::build_completion_result)
(completion_result::completion_result)
(completion_result::completion_result)
(completion_result::~completion_result)
(completion_result::completion_result)
(completion_result::release_match_list, compare_cstrings)
(completion_result::sort_match_list)
(completion_result::reset_match_list)
(gdb_rl_attempted_completion_function_throw)
(gdb_rl_attempted_completion_function): New.
* completer.h (completion_list, struct completion_result)
(class completion_tracker): New.
(complete_line): Add completion_tracker parameter.
(readline_line_completion_function): Delete.
(gdb_rl_attempted_completion_function): New.
(noop_completer, filename_completer, expression_completer)
(location_completer, symbol_completer, command_completer)
(signal_completer, reg_or_group_completer): Update prototypes.
(completion_tracker_t, new_completion_tracker)
(make_cleanup_free_completion_tracker): Delete.
(enum maybe_add_completion_enum): Delete.
(maybe_add_completion): Delete.
(throw_max_completions_reached_error): Delete.
* corefile.c (complete_set_gnutarget): Adjust to work with a
completion_tracker instead of a VEC.
* cp-abi.c (cp_abi_completer): Adjust to work with a
completion_tracker instead of a VEC.
* d-lang.c (d_language_defn): Adjust.
* disasm.c (disassembler_options_completer): Adjust to work with a
completion_tracker instead of a VEC.
* f-lang.c (f_make_symbol_completion_list): Rename to ...
(f_collect_symbol_completion_matches): ... this. Adjust to work
with a completion_tracker instead of a VEC.
(f_language_defn): Adjust.
* go-lang.c (go_language_defn): Adjust.
* guile/scm-cmd.c (cmdscm_add_completion, cmdscm_completer):
Adjust to work with a completion_tracker instead of a VEC.
* infrun.c (handle_completer): Likewise.
* interps.c (interpreter_completer): Likewise.
* interps.h (interpreter_completer): Likewise.
* language.c (unknown_language_defn, auto_language_defn)
(local_language_defn): Adjust.
* language.h (language_defn::la_make_symbol_completion_list):
Rename to ...
(language_defn::la_collect_symbol_completion_matches): ... this
and adjust to work with a completion_tracker instead of a VEC.
* m2-lang.c (m2_language_defn): Adjust.
* objc-lang.c (objc_language_defn): Adjust.
* opencl-lang.c (opencl_language_defn): Adjust.
* p-lang.c (pascal_language_defn): Adjust.
* python/py-cmd.c (cmdpy_completer_helper): Handle NULL word.
(cmdpy_completer_handle_brkchars, cmdpy_completer): Adjust to work
with a completion_tracker.
* rust-lang.c (rust_language_defn): Adjust.
* symtab.c (free_completion_list, do_free_completion_list)
(return_val, completion_tracker): Delete.
(completion_list_add_name, completion_list_add_symbol)
(completion_list_add_msymbol, completion_list_objc_symbol)
(completion_list_add_fields, add_symtab_completions): Add
completion_tracker parameter and use it.
(default_make_symbol_completion_list_break_on_1): Rename to...
(default_collect_symbol_completion_matches_break_on): ... this.
Add completion_tracker parameter and use it instead of allocating
a completion tracker here.
(default_make_symbol_completion_list_break_on): Delete old
implementation.
(default_make_symbol_completion_list): Delete.
(default_collect_symbol_completion_matches): New.
(make_symbol_completion_list): Delete.
(collect_symbol_completion_matches): New.
(make_symbol_completion_type): Rename to ...
(collect_symbol_completion_matches_type): ... this. Add
completion_tracker parameter and use it instead of VEC.
(make_file_symbol_completion_list_1): Rename to...
(collect_file_symbol_completion_matches): ... this. Add
completion_tracker parameter and use it instead of VEC.
(make_file_symbol_completion_list): Delete.
(add_filename_to_list): Use completion_list instead of a VEC.
(add_partial_filename_data::list): Now a completion_list.
(make_source_files_completion_list): Work with a completion_list
instead of a VEC.
* symtab.h: Include "completer.h".
(default_make_symbol_completion_list_break_on)
(default_make_symbol_completion_list, make_symbol_completion_list)
(make_symbol_completion_type, make_file_symbol_completion_list)
(make_source_files_completion_list): Delete.
(default_collect_symbol_completion_matches_break_on)
(default_collect_symbol_completion_matches)
(collect_symbol_completion_matches)
(collect_symbol_completion_matches_type)
(collect_file_symbol_completion_matches)
(make_source_files_completion_list): New.
* top.c (init_main): Don't install a rl_completion_entry_function
hook. Install a rl_attempted_completion_function hook instead.
* tui/tui-layout.c (layout_completer): Adjust to work with a
completion_tracker.
* tui/tui-regs.c (tui_reggroup_completer):
* tui/tui-win.c (window_name_completer, focus_completer)
(winheight_completer): Adjust to work with a completion_tracker.
* value.c: Include "completer.h".
(complete_internalvar): Adjust to work with a completion_tracker.
* value.h (complete_internalvar): Likewise.
2017-07-17 14:45:59 +01:00
|
|
|
|
static void
|
2015-03-26 14:13:57 +00:00
|
|
|
|
layout_completer (struct cmd_list_element *ignore,
|
Introduce class completion_tracker & rewrite completion<->readline interaction
This patch reworks the whole completion machinery, and prepares it
for later enhancements.
Adds a new "completion_tracker" class that is meant to hold everything
about the state of the current completion operation.
This class now has the responsibility of tracking the list of
completion matches, and checking whether the max completions limit has
been reached. You can look at this as this patch starting out by
C++fying the existing "completion_tracker" in symtab.c (it's just an
htab_t typedef currently), moving it to completer.h/c, and then making
it a class/generalizing/enhancing it.
Unlike with the current tracking, completion_tracker now checks
whether the limit has been reached on each completion match list
insertion. This both simplifies the max-completions handling code
(maybe_add_completion_enum is gone, for example), and is a
prerequisite for follow up patches.
The current completion_tracker is only used for symbol completions,
and the symbol code gets at the current instance via globals. This
patch cleans that up by adding a completion_tracker reference to the
signature of the completion functions, and passing the tracker around
everywhere necessary.
Then, the patch changes how the completion match list is handed over
to readline. Currently, we're using the rl_completion_entry_function
readline entry point, and the patch switches to
rl_attempted_completion_function. A following patch will want to let
GDB itself decide the common completion prefix between all matches
(what readline calls the "lowest common denominator"), instead of
having readline compute it, and that's not possible with the
rl_completion_entry_function entry point. Also,
rl_attempted_completion_function lets GDB hand over the match list to
readline as an array in one go instead of passing down matches one by
one, so from that angle it's a nicer entry point anyway.
Lastly, the patch catches exceptions around the readline entry points,
because we can't let C++ exceptions cross readline. We handle that in
the readline input entry point, but the completion entry point isn't
guarded, so GDB can abort if completion throws. E.g., in current
master:
(gdb) b -function "fun<tab>
terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR'
Aborted (core dumped)
This patch fixes that. This will be exercised in the new tests added
later on in the series.
gdb/ChangeLog:
2017-07-17 Pedro Alves <palves@redhat.com>
* ada-lang.c (symbol_completion_match): Adjust comments.
(symbol_completion_add): Replace vector parameter with
completion_tracker parameter. Use it.
(ada_make_symbol_completion_list): Rename to...
(ada_collect_symbol_completion_matches): ... this. Add
completion_tracker parameter and use it.
(ada_language_defn): Adjust.
* break-catch-syscall.c (catch_syscall_completer): Adjust
prototype and work with completion_tracker instead of VEC.
* breakpoint.c (condition_completer): Adjust prototype and work
with completion_tracker instead of VEC.
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Adjust to renames.
* cli/cli-cmds.c (complete_command): Rework using
completion_tracker. Catch exceptions when completing.
* cli/cli-decode.c (integer_unlimited_completer)
(complete_on_cmdlist, complete_on_enum): Adjust prototype and work
with completion_tracker instead of VEC.
* command.h (struct completion_tracker): Forward declare.
(completer_ftype, completer_handle_brkchars_ftype): Change
types.
(complete_on_cmdlist, complete_on_enum): Adjust.
* completer.c: Include <algorithm>.
(struct gdb_completer_state): New.
(current_completion): New global.
(readline_line_completion_function): Delete.
(noop_completer, filename_completer)
(filename_completer_handle_brkchars, complete_files_symbols)
(linespec_location_completer): Adjust to work with a
completion_tracker instead of a VEC.
(string_or_empty): New.
(collect_explicit_location_matches): Adjust to work with a
completion_tracker instead of a VEC.
(explicit_location_completer): Rename to ...
(complete_explicit_location): ... this and adjust to work with a
completion_tracker instead of a VEC.
(location_completer): Adjust to work with a completion_tracker
instead of a VEC.
(add_struct_fields): Adjust to work with a completion_list instead
of VEC.
(expression_completer): Rename to ...
(complete_expression): ... this and adjust to work with a
completion_tracker instead of a VEC. Use complete_files_symbols.
(expression_completer): Reimplement on top of complete_expression.
(symbol_completer): Adjust to work with a completion_tracker
instead of a VEC.
(enum complete_line_internal_reason): Add describing comments.
(complete_line_internal_normal_command): Adjust to work with a
completion_tracker instead of a VEC.
(complete_line_internal): Rename to ...
(complete_line_internal_1): ... this and adjust to work with a
completion_tracker instead of a VEC. Assert TEXT is NULL in the
handle_brkchars phase.
(new_completion_tracker): Delete.
(complete_line_internal): Reimplement as TRY/CATCH wrapper around
complete_line_internal_1.
(free_completion_tracker): Delete.
(INITIAL_COMPLETION_HTAB_SIZE): New.
(completion_tracker::completion_tracker)
(completion_tracker::~completion_tracker): New.
(maybe_add_completion): Delete.
(completion_tracker::maybe_add_completion)
(completion_tracker::add_completion)
(completion_tracker::add_completions): New.
(throw_max_completions_reached_error): Delete.
(complete_line): Adjust to work with a completion_tracker instead
of a VEC. Don't create a completion_tracker_t or check for max
completions here.
(command_completer, command_completer_handle_brkchars)
(signal_completer, reg_or_group_completer_1)
(reg_or_group_completer, default_completer_handle_brkchars):
Adjust to work with a completion_tracker.
(gdb_completion_word_break_characters_throw): New.
(gdb_completion_word_break_characters): Reimplement.
(line_completion_function): Delete.
(completion_tracker::recompute_lowest_common_denominator)
(expand_preserving_ws)
(completion_tracker::build_completion_result)
(completion_result::completion_result)
(completion_result::completion_result)
(completion_result::~completion_result)
(completion_result::completion_result)
(completion_result::release_match_list, compare_cstrings)
(completion_result::sort_match_list)
(completion_result::reset_match_list)
(gdb_rl_attempted_completion_function_throw)
(gdb_rl_attempted_completion_function): New.
* completer.h (completion_list, struct completion_result)
(class completion_tracker): New.
(complete_line): Add completion_tracker parameter.
(readline_line_completion_function): Delete.
(gdb_rl_attempted_completion_function): New.
(noop_completer, filename_completer, expression_completer)
(location_completer, symbol_completer, command_completer)
(signal_completer, reg_or_group_completer): Update prototypes.
(completion_tracker_t, new_completion_tracker)
(make_cleanup_free_completion_tracker): Delete.
(enum maybe_add_completion_enum): Delete.
(maybe_add_completion): Delete.
(throw_max_completions_reached_error): Delete.
* corefile.c (complete_set_gnutarget): Adjust to work with a
completion_tracker instead of a VEC.
* cp-abi.c (cp_abi_completer): Adjust to work with a
completion_tracker instead of a VEC.
* d-lang.c (d_language_defn): Adjust.
* disasm.c (disassembler_options_completer): Adjust to work with a
completion_tracker instead of a VEC.
* f-lang.c (f_make_symbol_completion_list): Rename to ...
(f_collect_symbol_completion_matches): ... this. Adjust to work
with a completion_tracker instead of a VEC.
(f_language_defn): Adjust.
* go-lang.c (go_language_defn): Adjust.
* guile/scm-cmd.c (cmdscm_add_completion, cmdscm_completer):
Adjust to work with a completion_tracker instead of a VEC.
* infrun.c (handle_completer): Likewise.
* interps.c (interpreter_completer): Likewise.
* interps.h (interpreter_completer): Likewise.
* language.c (unknown_language_defn, auto_language_defn)
(local_language_defn): Adjust.
* language.h (language_defn::la_make_symbol_completion_list):
Rename to ...
(language_defn::la_collect_symbol_completion_matches): ... this
and adjust to work with a completion_tracker instead of a VEC.
* m2-lang.c (m2_language_defn): Adjust.
* objc-lang.c (objc_language_defn): Adjust.
* opencl-lang.c (opencl_language_defn): Adjust.
* p-lang.c (pascal_language_defn): Adjust.
* python/py-cmd.c (cmdpy_completer_helper): Handle NULL word.
(cmdpy_completer_handle_brkchars, cmdpy_completer): Adjust to work
with a completion_tracker.
* rust-lang.c (rust_language_defn): Adjust.
* symtab.c (free_completion_list, do_free_completion_list)
(return_val, completion_tracker): Delete.
(completion_list_add_name, completion_list_add_symbol)
(completion_list_add_msymbol, completion_list_objc_symbol)
(completion_list_add_fields, add_symtab_completions): Add
completion_tracker parameter and use it.
(default_make_symbol_completion_list_break_on_1): Rename to...
(default_collect_symbol_completion_matches_break_on): ... this.
Add completion_tracker parameter and use it instead of allocating
a completion tracker here.
(default_make_symbol_completion_list_break_on): Delete old
implementation.
(default_make_symbol_completion_list): Delete.
(default_collect_symbol_completion_matches): New.
(make_symbol_completion_list): Delete.
(collect_symbol_completion_matches): New.
(make_symbol_completion_type): Rename to ...
(collect_symbol_completion_matches_type): ... this. Add
completion_tracker parameter and use it instead of VEC.
(make_file_symbol_completion_list_1): Rename to...
(collect_file_symbol_completion_matches): ... this. Add
completion_tracker parameter and use it instead of VEC.
(make_file_symbol_completion_list): Delete.
(add_filename_to_list): Use completion_list instead of a VEC.
(add_partial_filename_data::list): Now a completion_list.
(make_source_files_completion_list): Work with a completion_list
instead of a VEC.
* symtab.h: Include "completer.h".
(default_make_symbol_completion_list_break_on)
(default_make_symbol_completion_list, make_symbol_completion_list)
(make_symbol_completion_type, make_file_symbol_completion_list)
(make_source_files_completion_list): Delete.
(default_collect_symbol_completion_matches_break_on)
(default_collect_symbol_completion_matches)
(collect_symbol_completion_matches)
(collect_symbol_completion_matches_type)
(collect_file_symbol_completion_matches)
(make_source_files_completion_list): New.
* top.c (init_main): Don't install a rl_completion_entry_function
hook. Install a rl_attempted_completion_function hook instead.
* tui/tui-layout.c (layout_completer): Adjust to work with a
completion_tracker.
* tui/tui-regs.c (tui_reggroup_completer):
* tui/tui-win.c (window_name_completer, focus_completer)
(winheight_completer): Adjust to work with a completion_tracker.
* value.c: Include "completer.h".
(complete_internalvar): Adjust to work with a completion_tracker.
* value.h (complete_internalvar): Likewise.
2017-07-17 14:45:59 +01:00
|
|
|
|
completion_tracker &tracker,
|
2015-03-26 14:13:57 +00:00
|
|
|
|
const char *text, const char *word)
|
|
|
|
|
{
|
|
|
|
|
static const char *layout_names [] =
|
|
|
|
|
{ "src", "asm", "split", "regs", "next", "prev", NULL };
|
|
|
|
|
|
Introduce class completion_tracker & rewrite completion<->readline interaction
This patch reworks the whole completion machinery, and prepares it
for later enhancements.
Adds a new "completion_tracker" class that is meant to hold everything
about the state of the current completion operation.
This class now has the responsibility of tracking the list of
completion matches, and checking whether the max completions limit has
been reached. You can look at this as this patch starting out by
C++fying the existing "completion_tracker" in symtab.c (it's just an
htab_t typedef currently), moving it to completer.h/c, and then making
it a class/generalizing/enhancing it.
Unlike with the current tracking, completion_tracker now checks
whether the limit has been reached on each completion match list
insertion. This both simplifies the max-completions handling code
(maybe_add_completion_enum is gone, for example), and is a
prerequisite for follow up patches.
The current completion_tracker is only used for symbol completions,
and the symbol code gets at the current instance via globals. This
patch cleans that up by adding a completion_tracker reference to the
signature of the completion functions, and passing the tracker around
everywhere necessary.
Then, the patch changes how the completion match list is handed over
to readline. Currently, we're using the rl_completion_entry_function
readline entry point, and the patch switches to
rl_attempted_completion_function. A following patch will want to let
GDB itself decide the common completion prefix between all matches
(what readline calls the "lowest common denominator"), instead of
having readline compute it, and that's not possible with the
rl_completion_entry_function entry point. Also,
rl_attempted_completion_function lets GDB hand over the match list to
readline as an array in one go instead of passing down matches one by
one, so from that angle it's a nicer entry point anyway.
Lastly, the patch catches exceptions around the readline entry points,
because we can't let C++ exceptions cross readline. We handle that in
the readline input entry point, but the completion entry point isn't
guarded, so GDB can abort if completion throws. E.g., in current
master:
(gdb) b -function "fun<tab>
terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR'
Aborted (core dumped)
This patch fixes that. This will be exercised in the new tests added
later on in the series.
gdb/ChangeLog:
2017-07-17 Pedro Alves <palves@redhat.com>
* ada-lang.c (symbol_completion_match): Adjust comments.
(symbol_completion_add): Replace vector parameter with
completion_tracker parameter. Use it.
(ada_make_symbol_completion_list): Rename to...
(ada_collect_symbol_completion_matches): ... this. Add
completion_tracker parameter and use it.
(ada_language_defn): Adjust.
* break-catch-syscall.c (catch_syscall_completer): Adjust
prototype and work with completion_tracker instead of VEC.
* breakpoint.c (condition_completer): Adjust prototype and work
with completion_tracker instead of VEC.
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Adjust to renames.
* cli/cli-cmds.c (complete_command): Rework using
completion_tracker. Catch exceptions when completing.
* cli/cli-decode.c (integer_unlimited_completer)
(complete_on_cmdlist, complete_on_enum): Adjust prototype and work
with completion_tracker instead of VEC.
* command.h (struct completion_tracker): Forward declare.
(completer_ftype, completer_handle_brkchars_ftype): Change
types.
(complete_on_cmdlist, complete_on_enum): Adjust.
* completer.c: Include <algorithm>.
(struct gdb_completer_state): New.
(current_completion): New global.
(readline_line_completion_function): Delete.
(noop_completer, filename_completer)
(filename_completer_handle_brkchars, complete_files_symbols)
(linespec_location_completer): Adjust to work with a
completion_tracker instead of a VEC.
(string_or_empty): New.
(collect_explicit_location_matches): Adjust to work with a
completion_tracker instead of a VEC.
(explicit_location_completer): Rename to ...
(complete_explicit_location): ... this and adjust to work with a
completion_tracker instead of a VEC.
(location_completer): Adjust to work with a completion_tracker
instead of a VEC.
(add_struct_fields): Adjust to work with a completion_list instead
of VEC.
(expression_completer): Rename to ...
(complete_expression): ... this and adjust to work with a
completion_tracker instead of a VEC. Use complete_files_symbols.
(expression_completer): Reimplement on top of complete_expression.
(symbol_completer): Adjust to work with a completion_tracker
instead of a VEC.
(enum complete_line_internal_reason): Add describing comments.
(complete_line_internal_normal_command): Adjust to work with a
completion_tracker instead of a VEC.
(complete_line_internal): Rename to ...
(complete_line_internal_1): ... this and adjust to work with a
completion_tracker instead of a VEC. Assert TEXT is NULL in the
handle_brkchars phase.
(new_completion_tracker): Delete.
(complete_line_internal): Reimplement as TRY/CATCH wrapper around
complete_line_internal_1.
(free_completion_tracker): Delete.
(INITIAL_COMPLETION_HTAB_SIZE): New.
(completion_tracker::completion_tracker)
(completion_tracker::~completion_tracker): New.
(maybe_add_completion): Delete.
(completion_tracker::maybe_add_completion)
(completion_tracker::add_completion)
(completion_tracker::add_completions): New.
(throw_max_completions_reached_error): Delete.
(complete_line): Adjust to work with a completion_tracker instead
of a VEC. Don't create a completion_tracker_t or check for max
completions here.
(command_completer, command_completer_handle_brkchars)
(signal_completer, reg_or_group_completer_1)
(reg_or_group_completer, default_completer_handle_brkchars):
Adjust to work with a completion_tracker.
(gdb_completion_word_break_characters_throw): New.
(gdb_completion_word_break_characters): Reimplement.
(line_completion_function): Delete.
(completion_tracker::recompute_lowest_common_denominator)
(expand_preserving_ws)
(completion_tracker::build_completion_result)
(completion_result::completion_result)
(completion_result::completion_result)
(completion_result::~completion_result)
(completion_result::completion_result)
(completion_result::release_match_list, compare_cstrings)
(completion_result::sort_match_list)
(completion_result::reset_match_list)
(gdb_rl_attempted_completion_function_throw)
(gdb_rl_attempted_completion_function): New.
* completer.h (completion_list, struct completion_result)
(class completion_tracker): New.
(complete_line): Add completion_tracker parameter.
(readline_line_completion_function): Delete.
(gdb_rl_attempted_completion_function): New.
(noop_completer, filename_completer, expression_completer)
(location_completer, symbol_completer, command_completer)
(signal_completer, reg_or_group_completer): Update prototypes.
(completion_tracker_t, new_completion_tracker)
(make_cleanup_free_completion_tracker): Delete.
(enum maybe_add_completion_enum): Delete.
(maybe_add_completion): Delete.
(throw_max_completions_reached_error): Delete.
* corefile.c (complete_set_gnutarget): Adjust to work with a
completion_tracker instead of a VEC.
* cp-abi.c (cp_abi_completer): Adjust to work with a
completion_tracker instead of a VEC.
* d-lang.c (d_language_defn): Adjust.
* disasm.c (disassembler_options_completer): Adjust to work with a
completion_tracker instead of a VEC.
* f-lang.c (f_make_symbol_completion_list): Rename to ...
(f_collect_symbol_completion_matches): ... this. Adjust to work
with a completion_tracker instead of a VEC.
(f_language_defn): Adjust.
* go-lang.c (go_language_defn): Adjust.
* guile/scm-cmd.c (cmdscm_add_completion, cmdscm_completer):
Adjust to work with a completion_tracker instead of a VEC.
* infrun.c (handle_completer): Likewise.
* interps.c (interpreter_completer): Likewise.
* interps.h (interpreter_completer): Likewise.
* language.c (unknown_language_defn, auto_language_defn)
(local_language_defn): Adjust.
* language.h (language_defn::la_make_symbol_completion_list):
Rename to ...
(language_defn::la_collect_symbol_completion_matches): ... this
and adjust to work with a completion_tracker instead of a VEC.
* m2-lang.c (m2_language_defn): Adjust.
* objc-lang.c (objc_language_defn): Adjust.
* opencl-lang.c (opencl_language_defn): Adjust.
* p-lang.c (pascal_language_defn): Adjust.
* python/py-cmd.c (cmdpy_completer_helper): Handle NULL word.
(cmdpy_completer_handle_brkchars, cmdpy_completer): Adjust to work
with a completion_tracker.
* rust-lang.c (rust_language_defn): Adjust.
* symtab.c (free_completion_list, do_free_completion_list)
(return_val, completion_tracker): Delete.
(completion_list_add_name, completion_list_add_symbol)
(completion_list_add_msymbol, completion_list_objc_symbol)
(completion_list_add_fields, add_symtab_completions): Add
completion_tracker parameter and use it.
(default_make_symbol_completion_list_break_on_1): Rename to...
(default_collect_symbol_completion_matches_break_on): ... this.
Add completion_tracker parameter and use it instead of allocating
a completion tracker here.
(default_make_symbol_completion_list_break_on): Delete old
implementation.
(default_make_symbol_completion_list): Delete.
(default_collect_symbol_completion_matches): New.
(make_symbol_completion_list): Delete.
(collect_symbol_completion_matches): New.
(make_symbol_completion_type): Rename to ...
(collect_symbol_completion_matches_type): ... this. Add
completion_tracker parameter and use it instead of VEC.
(make_file_symbol_completion_list_1): Rename to...
(collect_file_symbol_completion_matches): ... this. Add
completion_tracker parameter and use it instead of VEC.
(make_file_symbol_completion_list): Delete.
(add_filename_to_list): Use completion_list instead of a VEC.
(add_partial_filename_data::list): Now a completion_list.
(make_source_files_completion_list): Work with a completion_list
instead of a VEC.
* symtab.h: Include "completer.h".
(default_make_symbol_completion_list_break_on)
(default_make_symbol_completion_list, make_symbol_completion_list)
(make_symbol_completion_type, make_file_symbol_completion_list)
(make_source_files_completion_list): Delete.
(default_collect_symbol_completion_matches_break_on)
(default_collect_symbol_completion_matches)
(collect_symbol_completion_matches)
(collect_symbol_completion_matches_type)
(collect_file_symbol_completion_matches)
(make_source_files_completion_list): New.
* top.c (init_main): Don't install a rl_completion_entry_function
hook. Install a rl_attempted_completion_function hook instead.
* tui/tui-layout.c (layout_completer): Adjust to work with a
completion_tracker.
* tui/tui-regs.c (tui_reggroup_completer):
* tui/tui-win.c (window_name_completer, focus_completer)
(winheight_completer): Adjust to work with a completion_tracker.
* value.c: Include "completer.h".
(complete_internalvar): Adjust to work with a completion_tracker.
* value.h (complete_internalvar): Likewise.
2017-07-17 14:45:59 +01:00
|
|
|
|
complete_on_enum (tracker, layout_names, text, word);
|
2015-03-26 14:13:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
gdb: Remove register class specific layout names.
The layout command supports the layout names $FREGS, $GREGS, $SREGS,
and $REGS. The intention of these layout names was to display the tui
register window with a specific set of registers.
First, these layout names no longer work, and haven't for a while, using
any of them will just result in switching to the general register view.
Second there is already the command 'tui reg GROUP' command to set the
displayed register set to GROUP, so making the layout command also
control the register set feels like unnecessary overloading of the
layout command.
This commit removes all code relating to supporting the register set
specific names from the layout command. Afterwards the user can select
an available layout using the layout command, and control the choice of
register set using the 'tui reg GROUP' command.
gdb/ChangeLog:
* tui/tui-layout.c (tui_set_layout): Remove
tui_register_display_type parameter. Remove all checking of this
parameter, and reindent function. Update header comment.
(tui_set_layout_for_display_command): Rename to...
(tui_set_layout_by_name): ...this, and don't check for different
register class types, don't pass a tui_register_display_type to
tui_set_layout. Update header comment.
(layout_names): Remove register set specific names.
* tui/tui-layout.h (tui_set_layout): Remove
tui_register_display_type parameter.
* tui/tui.c (tui_rl_change_windows): Don't pass a
tui_register_display_type to tui_set_layout.
(tui_rl_delete_other_windows): Likewise.
(tui_enable): Likewise.
* tui/tui-data.h (TUI_FLOAT_REGS_NAME): Remove.
(TUI_FLOAT_REGS_NAME_LOWER): Remove.
(TUI_GENERAL_REGS_NAME): Remove.
(TUI_GENERAL_REGS_NAME_LOWER): Remove.
(TUI_SPECIAL_REGS_NAME): Remove.
(TUI_SPECIAL_REGS_NAME_LOWER): Remove.
(TUI_GENERAL_SPECIAL_REGS_NAME): Remove.
(TUI_GENERAL_SPECIAL_REGS_NAME_LOWER): Remove.
(enum tui_register_display_type): Remove.
(struct tui_layout_def): Remove regs_display_type and
float_regs_display_type fields.
(struct tui_data_info): Remove regs_display_type field.
(tui_layout_command): Use new name for
tui_set_layout_for_display_command.
* tui/tui-data.c (layout_def): Don't initialise removed fields.
(tui_clear_win_detail): Don't initialise removed fields of
win_info.
* tui/tui-regs.c (tui_show_registers): Use new name for
tui_set_layout_for_display_command.
* tui/tui.h (tui_set_layout_for_display_command): Rename
declaration to...
(tui_set_layout_by_name): ...this.
* printcmd.c (display_command): Remove tui related layout call,
and reindent.
2015-05-20 23:35:07 +02:00
|
|
|
|
/* Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA, or
|
|
|
|
|
REGS. */
|
2019-06-30 20:43:32 -06:00
|
|
|
|
static void
|
|
|
|
|
tui_layout_command (const char *layout_name, int from_tty)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2019-06-30 20:43:32 -06:00
|
|
|
|
enum tui_layout_type new_layout = UNDEFINED_LAYOUT;
|
|
|
|
|
enum tui_layout_type cur_layout = tui_current_layout ();
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2019-07-23 16:01:03 -06:00
|
|
|
|
if (layout_name == NULL || *layout_name == '\0')
|
2019-06-30 20:43:32 -06:00
|
|
|
|
error (_("Usage: layout prev | next | LAYOUT-NAME"));
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2019-06-30 20:43:32 -06:00
|
|
|
|
/* First check for ambiguous input. */
|
2019-07-23 16:01:03 -06:00
|
|
|
|
if (strcmp (layout_name, "s") == 0)
|
2019-06-30 20:43:32 -06:00
|
|
|
|
error (_("Ambiguous command input."));
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2019-07-23 16:01:03 -06:00
|
|
|
|
if (subset_compare (layout_name, "src"))
|
2019-06-30 20:43:32 -06:00
|
|
|
|
new_layout = SRC_COMMAND;
|
2019-07-23 16:01:03 -06:00
|
|
|
|
else if (subset_compare (layout_name, "asm"))
|
2019-06-30 20:43:32 -06:00
|
|
|
|
new_layout = DISASSEM_COMMAND;
|
2019-07-23 16:01:03 -06:00
|
|
|
|
else if (subset_compare (layout_name, "split"))
|
2019-06-30 20:43:32 -06:00
|
|
|
|
new_layout = SRC_DISASSEM_COMMAND;
|
2019-07-23 16:01:03 -06:00
|
|
|
|
else if (subset_compare (layout_name, "regs"))
|
2019-06-30 20:43:32 -06:00
|
|
|
|
{
|
|
|
|
|
if (cur_layout == SRC_COMMAND
|
|
|
|
|
|| cur_layout == SRC_DATA_COMMAND)
|
|
|
|
|
new_layout = SRC_DATA_COMMAND;
|
|
|
|
|
else
|
|
|
|
|
new_layout = DISASSEM_DATA_COMMAND;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
2019-07-23 16:01:03 -06:00
|
|
|
|
else if (subset_compare (layout_name, "next"))
|
2019-06-30 20:43:32 -06:00
|
|
|
|
new_layout = next_layout ();
|
2019-07-23 16:01:03 -06:00
|
|
|
|
else if (subset_compare (layout_name, "prev"))
|
2019-06-30 20:43:32 -06:00
|
|
|
|
new_layout = prev_layout ();
|
1999-04-16 01:35:26 +00:00
|
|
|
|
else
|
2019-06-30 20:43:32 -06:00
|
|
|
|
error (_("Unrecognized layout: %s"), layout_name);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2019-06-30 20:43:32 -06:00
|
|
|
|
/* Make sure the curses mode is enabled. */
|
|
|
|
|
tui_enable ();
|
|
|
|
|
tui_set_layout (new_layout);
|
2001-07-18 22:03:22 +00:00
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
|
2009-07-02 17:17:42 +00:00
|
|
|
|
static void
|
|
|
|
|
extract_display_start_addr (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2004-02-08 00:05:16 +00:00
|
|
|
|
enum tui_layout_type cur_layout = tui_current_layout ();
|
2010-03-20 05:17:10 +00:00
|
|
|
|
struct gdbarch *gdbarch = get_current_arch ();
|
2001-07-18 20:59:00 +00:00
|
|
|
|
CORE_ADDR addr;
|
2001-07-17 22:22:40 +00:00
|
|
|
|
CORE_ADDR pc;
|
2002-09-30 00:52:27 +00:00
|
|
|
|
struct symtab_and_line cursal = get_current_source_symtab_and_line ();
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2004-02-08 00:05:16 +00:00
|
|
|
|
switch (cur_layout)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
case SRC_COMMAND:
|
|
|
|
|
case SRC_DATA_COMMAND:
|
2019-06-16 13:46:18 -06:00
|
|
|
|
gdbarch = TUI_SRC_WIN->gdbarch;
|
2002-09-30 00:52:27 +00:00
|
|
|
|
find_line_pc (cursal.symtab,
|
2019-06-16 13:46:18 -06:00
|
|
|
|
TUI_SRC_WIN->start_line_or_addr.u.line_no,
|
2001-07-17 22:22:40 +00:00
|
|
|
|
&pc);
|
2001-07-18 20:59:00 +00:00
|
|
|
|
addr = pc;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
break;
|
|
|
|
|
case DISASSEM_COMMAND:
|
|
|
|
|
case SRC_DISASSEM_COMMAND:
|
|
|
|
|
case DISASSEM_DATA_COMMAND:
|
2019-06-16 13:46:18 -06:00
|
|
|
|
gdbarch = TUI_DISASM_WIN->gdbarch;
|
|
|
|
|
addr = TUI_DISASM_WIN->start_line_or_addr.u.addr;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2001-07-18 20:59:00 +00:00
|
|
|
|
addr = 0;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-02 17:17:42 +00:00
|
|
|
|
*gdbarch_p = gdbarch;
|
|
|
|
|
*addr_p = addr;
|
2004-02-08 00:05:16 +00:00
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
|
2004-02-08 00:05:16 +00:00
|
|
|
|
/* Answer the previous layout to cycle to. */
|
2004-02-07 Andrew Cagney <cagney@redhat.com>
* tui/tui-data.h (tui_win_element): Rename TuiWinElement.
(tui_exec_info_content): Rename TuiExecInfoContent.
(TuiGenWinInfo, TuiGenWinInfoPtr): Delete definitions.
(TuiWinInfo, TuiWinInfoPtr): Ditto.
(TuiScrollDirection, TuiScrollDirectionPtr): Ditto.
(TuiList, TuiListPtr): Ditto.
(TuiLayoutType, TuiLayoutTypePtr): Ditto.
(TuiDataType, TuiDataTypePtr): Ditto.
(TuiRegisterDisplayType, TuiRegisterDisplayTypePtr): Ditto.
(TuiLineOrAddress, TuiLineOrAddressPtr): Ditto.
(TuiLayoutDef, TuiLayoutDefPtr): Ditto.
(TuiSourceElement, TuiSourceElementPtr): Ditto.
(TuiDataElement, TuiDataElementPtr): Ditto.
(TuiWinElement, TuiWinElementPtr): Ditto.
(TuiDataInfo, TuiDataInfoPtr): Ditto.
(TuiCommandElement, TuiCommandElementPtr): Ditto.
(TuiLocatorElement, TuiLocatorElementPtr): Ditto.
(TuiWhichElement, TuiWhichElementPtr): Ditto.
(TuiSourceInfo, TuiSourceInfoPtr): Ditto.
(TuiCommandInfo, TuiCommandInfoPtr): Ditto.
* tui/tui-command.c, tui/tui-data.c: Update references.
* tui/tui-data.h, tui/tui-disasm.c, tui/tui-layout.c: Ditto.
* tui/tui-regs.c, tui/tui-source.c, tui/tui-stack.c: Ditto.
* tui/tui-win.c, tui/tui-windata.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-winsource.c, tui/tui.c: Ditto.
2004-02-07 16:31:22 +00:00
|
|
|
|
static enum tui_layout_type
|
2004-02-08 00:05:16 +00:00
|
|
|
|
next_layout (void)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2014-10-22 06:08:20 +01:00
|
|
|
|
int new_layout;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2004-02-08 00:05:16 +00:00
|
|
|
|
new_layout = tui_current_layout ();
|
|
|
|
|
if (new_layout == UNDEFINED_LAYOUT)
|
|
|
|
|
new_layout = SRC_COMMAND;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2004-02-08 00:05:16 +00:00
|
|
|
|
new_layout++;
|
|
|
|
|
if (new_layout == UNDEFINED_LAYOUT)
|
|
|
|
|
new_layout = SRC_COMMAND;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-22 06:08:20 +01:00
|
|
|
|
return (enum tui_layout_type) new_layout;
|
2004-02-08 00:05:16 +00:00
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
|
2004-02-08 00:05:16 +00:00
|
|
|
|
/* Answer the next layout to cycle to. */
|
2004-02-07 Andrew Cagney <cagney@redhat.com>
* tui/tui-data.h (tui_win_element): Rename TuiWinElement.
(tui_exec_info_content): Rename TuiExecInfoContent.
(TuiGenWinInfo, TuiGenWinInfoPtr): Delete definitions.
(TuiWinInfo, TuiWinInfoPtr): Ditto.
(TuiScrollDirection, TuiScrollDirectionPtr): Ditto.
(TuiList, TuiListPtr): Ditto.
(TuiLayoutType, TuiLayoutTypePtr): Ditto.
(TuiDataType, TuiDataTypePtr): Ditto.
(TuiRegisterDisplayType, TuiRegisterDisplayTypePtr): Ditto.
(TuiLineOrAddress, TuiLineOrAddressPtr): Ditto.
(TuiLayoutDef, TuiLayoutDefPtr): Ditto.
(TuiSourceElement, TuiSourceElementPtr): Ditto.
(TuiDataElement, TuiDataElementPtr): Ditto.
(TuiWinElement, TuiWinElementPtr): Ditto.
(TuiDataInfo, TuiDataInfoPtr): Ditto.
(TuiCommandElement, TuiCommandElementPtr): Ditto.
(TuiLocatorElement, TuiLocatorElementPtr): Ditto.
(TuiWhichElement, TuiWhichElementPtr): Ditto.
(TuiSourceInfo, TuiSourceInfoPtr): Ditto.
(TuiCommandInfo, TuiCommandInfoPtr): Ditto.
* tui/tui-command.c, tui/tui-data.c: Update references.
* tui/tui-data.h, tui/tui-disasm.c, tui/tui-layout.c: Ditto.
* tui/tui-regs.c, tui/tui-source.c, tui/tui-stack.c: Ditto.
* tui/tui-win.c, tui/tui-windata.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-winsource.c, tui/tui.c: Ditto.
2004-02-07 16:31:22 +00:00
|
|
|
|
static enum tui_layout_type
|
2004-02-08 00:05:16 +00:00
|
|
|
|
prev_layout (void)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2014-10-22 06:08:20 +01:00
|
|
|
|
int new_layout;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2004-02-08 00:05:16 +00:00
|
|
|
|
new_layout = tui_current_layout ();
|
|
|
|
|
if (new_layout == SRC_COMMAND)
|
|
|
|
|
new_layout = DISASSEM_DATA_COMMAND;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2004-02-08 00:05:16 +00:00
|
|
|
|
new_layout--;
|
|
|
|
|
if (new_layout == UNDEFINED_LAYOUT)
|
|
|
|
|
new_layout = DISASSEM_DATA_COMMAND;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-22 06:08:20 +01:00
|
|
|
|
return (enum tui_layout_type) new_layout;
|
2004-02-08 00:05:16 +00:00
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2019-06-17 14:08:44 -06:00
|
|
|
|
void
|
2019-07-06 17:32:45 -06:00
|
|
|
|
tui_gen_win_info::resize (int height_, int width_,
|
|
|
|
|
int origin_x_, int origin_y_)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2019-07-15 15:28:56 -06:00
|
|
|
|
if (width == width_ && height == height_
|
2019-10-26 16:00:01 -06:00
|
|
|
|
&& x == origin_x_ && y == origin_y_
|
2019-07-15 15:28:56 -06:00
|
|
|
|
&& handle != nullptr)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-06-17 14:08:44 -06:00
|
|
|
|
width = width_;
|
2019-07-09 15:35:17 -06:00
|
|
|
|
height = height_;
|
|
|
|
|
if (height > 1)
|
|
|
|
|
viewport_height = height - 2;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
else
|
2019-06-17 14:08:44 -06:00
|
|
|
|
viewport_height = 1;
|
2019-10-26 16:00:01 -06:00
|
|
|
|
x = origin_x_;
|
|
|
|
|
y = origin_y_;
|
2019-07-09 15:35:17 -06:00
|
|
|
|
|
|
|
|
|
if (handle != nullptr)
|
|
|
|
|
{
|
|
|
|
|
#ifdef HAVE_WRESIZE
|
Make TUI window handle a unique_ptr
This changes tui_gen_win_info::handle to be a specialization of
unique_ptr. This is perhaps mildly uglier in some spots, due to the
proliferation of "get"; but on the other hand it cleans up some manual
management and it allows for the removal of tui_delete_win.
gdb/ChangeLog
2019-10-09 Tom Tromey <tom@tromey.com>
* tui/tui-wingeneral.h (tui_delete_win): Don't declare.
* tui/tui-stack.c (tui_locator_window::rerender): Update.
* tui/tui-command.c (tui_cmd_window::resize)
(tui_refresh_cmd_win): Update.
* tui/tui-win.c (tui_resize_all, tui_set_focus_command): Update.
* tui/tui.c (tui_rl_other_window, tui_enable): Update.
* tui/tui-data.c (~tui_gen_win_info): Remove.
* tui/tui-layout.c (tui_gen_win_info::resize): Update.
* tui/tui-io.c (update_cmdwin_start_line, tui_putc, tui_puts)
(tui_redisplay_readline, tui_mld_flush)
(tui_mld_erase_entire_line, tui_mld_getc, tui_getc): Update.
* tui/tui-regs.c (tui_data_window::delete_data_content_windows)
(tui_data_window::erase_data_content)
(tui_data_item_window::rerender)
(tui_data_item_window::refresh_window): Update.
* tui/tui-wingeneral.c (tui_gen_win_info::refresh_window)
(box_win, tui_gen_win_info::make_window)
(tui_gen_win_info::make_visible): Update.
(tui_delete_win): Remove.
* tui/tui-winsource.c
(tui_source_window_base::do_erase_source_content): Update.
(tui_show_source_line, tui_source_window_base::update_tab_width)
(tui_source_window_base::update_exec_info): Update.
* tui/tui-data.h (struct curses_deleter): New.
(struct tui_gen_win_info) <handle>: Now a unique_ptr.
(struct tui_gen_win_info) <~tui_gen_win_info>: Define.
2019-10-01 17:29:49 -06:00
|
|
|
|
wresize (handle.get (), height, width);
|
2019-10-26 16:00:01 -06:00
|
|
|
|
mvwin (handle.get (), y, x);
|
Make TUI window handle a unique_ptr
This changes tui_gen_win_info::handle to be a specialization of
unique_ptr. This is perhaps mildly uglier in some spots, due to the
proliferation of "get"; but on the other hand it cleans up some manual
management and it allows for the removal of tui_delete_win.
gdb/ChangeLog
2019-10-09 Tom Tromey <tom@tromey.com>
* tui/tui-wingeneral.h (tui_delete_win): Don't declare.
* tui/tui-stack.c (tui_locator_window::rerender): Update.
* tui/tui-command.c (tui_cmd_window::resize)
(tui_refresh_cmd_win): Update.
* tui/tui-win.c (tui_resize_all, tui_set_focus_command): Update.
* tui/tui.c (tui_rl_other_window, tui_enable): Update.
* tui/tui-data.c (~tui_gen_win_info): Remove.
* tui/tui-layout.c (tui_gen_win_info::resize): Update.
* tui/tui-io.c (update_cmdwin_start_line, tui_putc, tui_puts)
(tui_redisplay_readline, tui_mld_flush)
(tui_mld_erase_entire_line, tui_mld_getc, tui_getc): Update.
* tui/tui-regs.c (tui_data_window::delete_data_content_windows)
(tui_data_window::erase_data_content)
(tui_data_item_window::rerender)
(tui_data_item_window::refresh_window): Update.
* tui/tui-wingeneral.c (tui_gen_win_info::refresh_window)
(box_win, tui_gen_win_info::make_window)
(tui_gen_win_info::make_visible): Update.
(tui_delete_win): Remove.
* tui/tui-winsource.c
(tui_source_window_base::do_erase_source_content): Update.
(tui_show_source_line, tui_source_window_base::update_tab_width)
(tui_source_window_base::update_exec_info): Update.
* tui/tui-data.h (struct curses_deleter): New.
(struct tui_gen_win_info) <handle>: Now a unique_ptr.
(struct tui_gen_win_info) <~tui_gen_win_info>: Define.
2019-10-01 17:29:49 -06:00
|
|
|
|
wmove (handle.get (), 0, 0);
|
2019-07-09 15:35:17 -06:00
|
|
|
|
#else
|
Make TUI window handle a unique_ptr
This changes tui_gen_win_info::handle to be a specialization of
unique_ptr. This is perhaps mildly uglier in some spots, due to the
proliferation of "get"; but on the other hand it cleans up some manual
management and it allows for the removal of tui_delete_win.
gdb/ChangeLog
2019-10-09 Tom Tromey <tom@tromey.com>
* tui/tui-wingeneral.h (tui_delete_win): Don't declare.
* tui/tui-stack.c (tui_locator_window::rerender): Update.
* tui/tui-command.c (tui_cmd_window::resize)
(tui_refresh_cmd_win): Update.
* tui/tui-win.c (tui_resize_all, tui_set_focus_command): Update.
* tui/tui.c (tui_rl_other_window, tui_enable): Update.
* tui/tui-data.c (~tui_gen_win_info): Remove.
* tui/tui-layout.c (tui_gen_win_info::resize): Update.
* tui/tui-io.c (update_cmdwin_start_line, tui_putc, tui_puts)
(tui_redisplay_readline, tui_mld_flush)
(tui_mld_erase_entire_line, tui_mld_getc, tui_getc): Update.
* tui/tui-regs.c (tui_data_window::delete_data_content_windows)
(tui_data_window::erase_data_content)
(tui_data_item_window::rerender)
(tui_data_item_window::refresh_window): Update.
* tui/tui-wingeneral.c (tui_gen_win_info::refresh_window)
(box_win, tui_gen_win_info::make_window)
(tui_gen_win_info::make_visible): Update.
(tui_delete_win): Remove.
* tui/tui-winsource.c
(tui_source_window_base::do_erase_source_content): Update.
(tui_show_source_line, tui_source_window_base::update_tab_width)
(tui_source_window_base::update_exec_info): Update.
* tui/tui-data.h (struct curses_deleter): New.
(struct tui_gen_win_info) <handle>: Now a unique_ptr.
(struct tui_gen_win_info) <~tui_gen_win_info>: Define.
2019-10-01 17:29:49 -06:00
|
|
|
|
handle.reset (nullptr);
|
2019-07-09 15:35:17 -06:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (handle == nullptr)
|
2019-07-13 16:47:31 -06:00
|
|
|
|
make_window ();
|
2019-07-09 17:29:13 -06:00
|
|
|
|
|
|
|
|
|
rerender ();
|
2019-06-17 14:08:44 -06:00
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2019-10-08 15:44:18 -06:00
|
|
|
|
|
|
|
|
|
|
2019-10-07 18:03:02 -06:00
|
|
|
|
/* Helper function that returns a TUI window, given its name. */
|
|
|
|
|
|
|
|
|
|
static tui_gen_win_info *
|
|
|
|
|
tui_get_window_by_name (const std::string &name)
|
|
|
|
|
{
|
|
|
|
|
if (name == "src")
|
|
|
|
|
{
|
|
|
|
|
if (tui_win_list[SRC_WIN] == nullptr)
|
|
|
|
|
tui_win_list[SRC_WIN] = new tui_source_window ();
|
|
|
|
|
return tui_win_list[SRC_WIN];
|
|
|
|
|
}
|
|
|
|
|
else if (name == "cmd")
|
|
|
|
|
{
|
|
|
|
|
if (tui_win_list[CMD_WIN] == nullptr)
|
|
|
|
|
tui_win_list[CMD_WIN] = new tui_cmd_window ();
|
|
|
|
|
return tui_win_list[CMD_WIN];
|
|
|
|
|
}
|
|
|
|
|
else if (name == "regs")
|
|
|
|
|
{
|
|
|
|
|
if (tui_win_list[DATA_WIN] == nullptr)
|
|
|
|
|
tui_win_list[DATA_WIN] = new tui_data_window ();
|
|
|
|
|
return tui_win_list[DATA_WIN];
|
|
|
|
|
}
|
|
|
|
|
else if (name == "asm")
|
|
|
|
|
{
|
|
|
|
|
if (tui_win_list[DISASSEM_WIN] == nullptr)
|
|
|
|
|
tui_win_list[DISASSEM_WIN] = new tui_disasm_window ();
|
|
|
|
|
return tui_win_list[DISASSEM_WIN];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gdb_assert (name == "locator");
|
|
|
|
|
return tui_locator_win_info_ptr ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<tui_layout_base>
|
|
|
|
|
tui_layout_window::clone () const
|
|
|
|
|
{
|
|
|
|
|
tui_layout_window *result = new tui_layout_window (m_contents.c_str ());
|
|
|
|
|
return std::unique_ptr<tui_layout_base> (result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
tui_layout_window::apply (int x_, int y_, int width_, int height_)
|
|
|
|
|
{
|
|
|
|
|
x = x_;
|
|
|
|
|
y = y_;
|
|
|
|
|
width = width_;
|
|
|
|
|
height = height_;
|
|
|
|
|
gdb_assert (m_window != nullptr);
|
|
|
|
|
m_window->resize (height, width, x, y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
tui_layout_window::get_sizes (int *min_height, int *max_height)
|
|
|
|
|
{
|
|
|
|
|
if (m_window == nullptr)
|
|
|
|
|
m_window = tui_get_window_by_name (m_contents);
|
|
|
|
|
*min_height = m_window->min_height ();
|
|
|
|
|
*max_height = m_window->max_height ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
tui_layout_window::top_boxed_p () const
|
|
|
|
|
{
|
|
|
|
|
gdb_assert (m_window != nullptr);
|
|
|
|
|
return m_window->can_box ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
tui_layout_window::bottom_boxed_p () const
|
|
|
|
|
{
|
|
|
|
|
gdb_assert (m_window != nullptr);
|
|
|
|
|
return m_window->can_box ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
|
|
|
|
tui_layout_split *
|
|
|
|
|
tui_layout_split::add_split (int weight)
|
|
|
|
|
{
|
|
|
|
|
tui_layout_split *result = new tui_layout_split ();
|
|
|
|
|
split s = {weight, std::unique_ptr<tui_layout_base> (result)};
|
|
|
|
|
m_splits.push_back (std::move (s));
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
tui_layout_split::add_window (const char *name, int weight)
|
|
|
|
|
{
|
|
|
|
|
tui_layout_window *result = new tui_layout_window (name);
|
|
|
|
|
split s = {weight, std::unique_ptr<tui_layout_base> (result)};
|
|
|
|
|
m_splits.push_back (std::move (s));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<tui_layout_base>
|
|
|
|
|
tui_layout_split::clone () const
|
|
|
|
|
{
|
|
|
|
|
tui_layout_split *result = new tui_layout_split ();
|
|
|
|
|
for (const split &item : m_splits)
|
|
|
|
|
{
|
|
|
|
|
std::unique_ptr<tui_layout_base> next = item.layout->clone ();
|
|
|
|
|
split s = {item.weight, std::move (next)};
|
|
|
|
|
result->m_splits.push_back (std::move (s));
|
|
|
|
|
}
|
|
|
|
|
return std::unique_ptr<tui_layout_base> (result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
tui_layout_split::get_sizes (int *min_height, int *max_height)
|
|
|
|
|
{
|
|
|
|
|
*min_height = 0;
|
|
|
|
|
*max_height = 0;
|
|
|
|
|
for (const split &item : m_splits)
|
|
|
|
|
{
|
|
|
|
|
int new_min, new_max;
|
|
|
|
|
item.layout->get_sizes (&new_min, &new_max);
|
|
|
|
|
*min_height += new_min;
|
|
|
|
|
*max_height += new_max;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
tui_layout_split::top_boxed_p () const
|
|
|
|
|
{
|
|
|
|
|
if (m_splits.empty ())
|
|
|
|
|
return false;
|
|
|
|
|
return m_splits[0].layout->top_boxed_p ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
tui_layout_split::bottom_boxed_p () const
|
|
|
|
|
{
|
|
|
|
|
if (m_splits.empty ())
|
|
|
|
|
return false;
|
|
|
|
|
return m_splits.back ().layout->top_boxed_p ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
tui_layout_split::set_weights_from_heights ()
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < m_splits.size (); ++i)
|
|
|
|
|
m_splits[i].weight = m_splits[i].layout->height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
tui_layout_split::adjust_size (const char *name, int new_height)
|
|
|
|
|
{
|
|
|
|
|
/* Look through the children. If one is a layout holding the named
|
|
|
|
|
window, we're done; or if one actually is the named window,
|
|
|
|
|
update it. */
|
|
|
|
|
int found_index = -1;
|
|
|
|
|
for (int i = 0; i < m_splits.size (); ++i)
|
|
|
|
|
{
|
|
|
|
|
if (m_splits[i].layout->adjust_size (name, new_height))
|
|
|
|
|
return true;
|
|
|
|
|
const char *win_name = m_splits[i].layout->get_name ();
|
|
|
|
|
if (win_name != nullptr && strcmp (name, win_name) == 0)
|
|
|
|
|
{
|
|
|
|
|
found_index = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (found_index == -1)
|
|
|
|
|
return false;
|
|
|
|
|
if (m_splits[found_index].layout->height == new_height)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
set_weights_from_heights ();
|
|
|
|
|
int delta = m_splits[found_index].weight - new_height;
|
|
|
|
|
m_splits[found_index].weight = new_height;
|
|
|
|
|
|
|
|
|
|
/* Distribute the "delta" over the next window; but if the next
|
|
|
|
|
window cannot hold it all, keep going until we either find a
|
|
|
|
|
window that does, or until we loop all the way around. */
|
|
|
|
|
for (int i = 0; delta != 0 && i < m_splits.size () - 1; ++i)
|
|
|
|
|
{
|
|
|
|
|
int index = (found_index + 1 + i) % m_splits.size ();
|
|
|
|
|
|
|
|
|
|
int new_min, new_max;
|
|
|
|
|
m_splits[index].layout->get_sizes (&new_min, &new_max);
|
|
|
|
|
|
|
|
|
|
if (delta < 0)
|
|
|
|
|
{
|
|
|
|
|
/* The primary window grew, so we are trying to shrink other
|
|
|
|
|
windows. */
|
|
|
|
|
int available = m_splits[index].weight - new_min;
|
|
|
|
|
int shrink_by = std::min (available, -delta);
|
|
|
|
|
m_splits[index].weight -= shrink_by;
|
|
|
|
|
delta += shrink_by;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* The primary window shrank, so we are trying to grow other
|
|
|
|
|
windows. */
|
|
|
|
|
int available = new_max - m_splits[index].weight;
|
|
|
|
|
int grow_by = std::min (available, delta);
|
|
|
|
|
m_splits[index].weight += grow_by;
|
|
|
|
|
delta -= grow_by;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (delta != 0)
|
|
|
|
|
{
|
|
|
|
|
warning (_("Invalid window height specified"));
|
|
|
|
|
/* Effectively undo any modifications made here. */
|
|
|
|
|
set_weights_from_heights ();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Simply re-apply the updated layout. */
|
|
|
|
|
apply (x, y, width, height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
tui_layout_split::apply (int x_, int y_, int width_, int height_)
|
|
|
|
|
{
|
|
|
|
|
x = x_;
|
|
|
|
|
y = y_;
|
|
|
|
|
width = width_;
|
|
|
|
|
height = height_;
|
|
|
|
|
|
|
|
|
|
struct height_info
|
|
|
|
|
{
|
|
|
|
|
int height;
|
|
|
|
|
int min_height;
|
|
|
|
|
int max_height;
|
|
|
|
|
/* True if this window will share a box border with the previous
|
|
|
|
|
window in the list. */
|
|
|
|
|
bool share_box;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
std::vector<height_info> info (m_splits.size ());
|
|
|
|
|
|
|
|
|
|
/* Step 1: Find the min and max height of each sub-layout.
|
|
|
|
|
Fixed-sized layouts are given their desired height, and then the
|
|
|
|
|
remaining space is distributed among the remaining windows
|
|
|
|
|
according to the weights given. */
|
|
|
|
|
int available_height = height;
|
|
|
|
|
int last_index = -1;
|
|
|
|
|
int total_weight = 0;
|
|
|
|
|
for (int i = 0; i < m_splits.size (); ++i)
|
|
|
|
|
{
|
|
|
|
|
bool cmd_win_already_exists = TUI_CMD_WIN != nullptr;
|
|
|
|
|
|
|
|
|
|
/* Always call get_sizes, to ensure that the window is
|
|
|
|
|
instantiated. This is a bit gross but less gross than adding
|
|
|
|
|
special cases for this in other places. */
|
|
|
|
|
m_splits[i].layout->get_sizes (&info[i].min_height, &info[i].max_height);
|
|
|
|
|
|
|
|
|
|
if (!m_applied
|
|
|
|
|
&& cmd_win_already_exists
|
|
|
|
|
&& m_splits[i].layout->get_name () != nullptr
|
|
|
|
|
&& strcmp (m_splits[i].layout->get_name (), "cmd") == 0)
|
|
|
|
|
{
|
|
|
|
|
/* If this layout has never been applied, then it means the
|
|
|
|
|
user just changed the layout. In this situation, it's
|
|
|
|
|
desirable to keep the size of the command window the
|
|
|
|
|
same. Setting the min and max heights this way ensures
|
|
|
|
|
that the resizing step, below, does the right thing with
|
|
|
|
|
this window. */
|
|
|
|
|
info[i].min_height = TUI_CMD_WIN->height;
|
|
|
|
|
info[i].max_height = TUI_CMD_WIN->height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (info[i].min_height == info[i].max_height)
|
|
|
|
|
available_height -= info[i].min_height;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
last_index = i;
|
|
|
|
|
total_weight += m_splits[i].weight;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Two adjacent boxed windows will share a border, making a bit
|
|
|
|
|
more height available. */
|
|
|
|
|
if (i > 0
|
|
|
|
|
&& m_splits[i - 1].layout->bottom_boxed_p ()
|
|
|
|
|
&& m_splits[i].layout->top_boxed_p ())
|
|
|
|
|
info[i].share_box = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Step 2: Compute the height of each sub-layout. Fixed-sized items
|
|
|
|
|
are given their fixed size, while others are resized according to
|
|
|
|
|
their weight. */
|
|
|
|
|
int used_height = 0;
|
|
|
|
|
for (int i = 0; i < m_splits.size (); ++i)
|
|
|
|
|
{
|
|
|
|
|
/* Compute the height and clamp to the allowable range. */
|
|
|
|
|
info[i].height = available_height * m_splits[i].weight / total_weight;
|
|
|
|
|
if (info[i].height > info[i].max_height)
|
|
|
|
|
info[i].height = info[i].max_height;
|
|
|
|
|
if (info[i].height < info[i].min_height)
|
|
|
|
|
info[i].height = info[i].min_height;
|
|
|
|
|
/* If there is any leftover height, just redistribute it to the
|
|
|
|
|
last resizeable window, by dropping it from the allocated
|
|
|
|
|
height. We could try to be fancier here perhaps, by
|
|
|
|
|
redistributing this height among all windows, not just the
|
|
|
|
|
last window. */
|
|
|
|
|
if (info[i].min_height != info[i].max_height)
|
|
|
|
|
{
|
|
|
|
|
used_height += info[i].height;
|
|
|
|
|
if (info[i].share_box)
|
|
|
|
|
--used_height;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Allocate any leftover height. */
|
|
|
|
|
if (available_height >= used_height && last_index != -1)
|
|
|
|
|
info[last_index].height += available_height - used_height;
|
|
|
|
|
|
|
|
|
|
/* Step 3: Resize. */
|
|
|
|
|
int height_accum = 0;
|
|
|
|
|
for (int i = 0; i < m_splits.size (); ++i)
|
|
|
|
|
{
|
|
|
|
|
/* If we fall off the bottom, just make allocations overlap.
|
|
|
|
|
GIGO. */
|
|
|
|
|
if (height_accum + info[i].height > height)
|
|
|
|
|
height_accum = height - info[i].height;
|
|
|
|
|
else if (info[i].share_box)
|
|
|
|
|
--height_accum;
|
|
|
|
|
m_splits[i].layout->apply (x, y + height_accum, width, info[i].height);
|
|
|
|
|
height_accum += info[i].height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_applied = true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-09 16:35:41 -06:00
|
|
|
|
static void
|
|
|
|
|
initialize_layouts ()
|
|
|
|
|
{
|
|
|
|
|
standard_layouts[SRC_COMMAND] = new tui_layout_split ();
|
|
|
|
|
standard_layouts[SRC_COMMAND]->add_window ("src", 2);
|
|
|
|
|
standard_layouts[SRC_COMMAND]->add_window ("locator", 0);
|
|
|
|
|
standard_layouts[SRC_COMMAND]->add_window ("cmd", 1);
|
|
|
|
|
|
|
|
|
|
standard_layouts[DISASSEM_COMMAND] = new tui_layout_split ();
|
|
|
|
|
standard_layouts[DISASSEM_COMMAND]->add_window ("asm", 2);
|
|
|
|
|
standard_layouts[DISASSEM_COMMAND]->add_window ("locator", 0);
|
|
|
|
|
standard_layouts[DISASSEM_COMMAND]->add_window ("cmd", 1);
|
|
|
|
|
|
|
|
|
|
standard_layouts[SRC_DATA_COMMAND] = new tui_layout_split ();
|
|
|
|
|
standard_layouts[SRC_DATA_COMMAND]->add_window ("regs", 1);
|
|
|
|
|
standard_layouts[SRC_DATA_COMMAND]->add_window ("src", 1);
|
|
|
|
|
standard_layouts[SRC_DATA_COMMAND]->add_window ("locator", 0);
|
|
|
|
|
standard_layouts[SRC_DATA_COMMAND]->add_window ("cmd", 1);
|
|
|
|
|
|
|
|
|
|
standard_layouts[DISASSEM_DATA_COMMAND] = new tui_layout_split ();
|
|
|
|
|
standard_layouts[DISASSEM_DATA_COMMAND]->add_window ("regs", 1);
|
|
|
|
|
standard_layouts[DISASSEM_DATA_COMMAND]->add_window ("asm", 1);
|
|
|
|
|
standard_layouts[DISASSEM_DATA_COMMAND]->add_window ("locator", 0);
|
|
|
|
|
standard_layouts[DISASSEM_DATA_COMMAND]->add_window ("cmd", 1);
|
|
|
|
|
|
|
|
|
|
standard_layouts[SRC_DISASSEM_COMMAND] = new tui_layout_split ();
|
|
|
|
|
standard_layouts[SRC_DISASSEM_COMMAND]->add_window ("src", 1);
|
|
|
|
|
standard_layouts[SRC_DISASSEM_COMMAND]->add_window ("asm", 1);
|
|
|
|
|
standard_layouts[SRC_DISASSEM_COMMAND]->add_window ("locator", 0);
|
|
|
|
|
standard_layouts[SRC_DISASSEM_COMMAND]->add_window ("cmd", 1);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-07 18:03:02 -06:00
|
|
|
|
|
|
|
|
|
|
2019-10-08 15:44:18 -06:00
|
|
|
|
/* Function to initialize gdb commands, for tui window layout
|
|
|
|
|
manipulation. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_initialize_tui_layout (void)
|
|
|
|
|
{
|
|
|
|
|
struct cmd_list_element *cmd;
|
|
|
|
|
|
|
|
|
|
cmd = add_com ("layout", class_tui, tui_layout_command, _("\
|
|
|
|
|
Change the layout of windows.\n\
|
|
|
|
|
Usage: layout prev | next | LAYOUT-NAME\n\
|
|
|
|
|
Layout names are:\n\
|
|
|
|
|
src : Displays source and command windows.\n\
|
|
|
|
|
asm : Displays disassembly and command windows.\n\
|
|
|
|
|
split : Displays source, disassembly and command windows.\n\
|
|
|
|
|
regs : Displays register window. If existing layout\n\
|
|
|
|
|
is source/command or assembly/command, the \n\
|
|
|
|
|
register window is displayed. If the\n\
|
|
|
|
|
source/assembly/command (split) is displayed, \n\
|
|
|
|
|
the register window is displayed with \n\
|
|
|
|
|
the window that has current logical focus."));
|
|
|
|
|
set_cmd_completer (cmd, layout_completer);
|
2019-10-09 16:35:41 -06:00
|
|
|
|
|
|
|
|
|
initialize_layouts ();
|
2019-10-08 15:44:18 -06:00
|
|
|
|
}
|