* 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
|
|
|
|
|
2020-01-01 10:20:01 +04:00
|
|
|
|
Copyright (C) 1998-2020 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"
|
2020-02-22 11:48:26 -07:00
|
|
|
|
#include "cli/cli-cmds.h"
|
|
|
|
|
#include "cli/cli-decode.h"
|
2020-02-22 11:48:26 -07:00
|
|
|
|
#include "cli/cli-utils.h"
|
2001-07-17 22:22:40 +00:00
|
|
|
|
#include <ctype.h>
|
2020-02-22 11:48:26 -07:00
|
|
|
|
#include <unordered_set>
|
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
|
|
|
|
|
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
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* The layouts. */
|
|
|
|
|
static std::vector<std::unique_ptr<tui_layout_split>> layouts;
|
2019-10-09 16:35:41 -06:00
|
|
|
|
|
|
|
|
|
/* The layout that is currently applied. */
|
|
|
|
|
static std::unique_ptr<tui_layout_base> applied_layout;
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* The "skeleton" version of the layout that is currently applied. */
|
|
|
|
|
static tui_layout_split *applied_skeleton;
|
2019-07-05 12:13:40 -06:00
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* The two special "regs" layouts. Note that these aren't registered
|
|
|
|
|
as commands and so can never be deleted. */
|
|
|
|
|
static tui_layout_split *src_regs_layout;
|
|
|
|
|
static tui_layout_split *asm_regs_layout;
|
2019-07-05 12:13:40 -06:00
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* See tui-data.h. */
|
|
|
|
|
std::vector<tui_win_info *> tui_windows;
|
|
|
|
|
|
2019-10-09 16:35:41 -06:00
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
tui_apply_current_layout ()
|
|
|
|
|
{
|
2020-02-22 11:48:26 -07:00
|
|
|
|
struct gdbarch *gdbarch;
|
|
|
|
|
CORE_ADDR addr;
|
|
|
|
|
|
|
|
|
|
extract_display_start_addr (&gdbarch, &addr);
|
|
|
|
|
|
|
|
|
|
std::vector<tui_win_info *> saved_windows = std::move (tui_windows);
|
2020-02-22 11:48:26 -07:00
|
|
|
|
tui_windows.clear ();
|
2020-02-22 11:48:26 -07:00
|
|
|
|
|
|
|
|
|
for (tui_win_info *win_info : saved_windows)
|
|
|
|
|
win_info->make_visible (false);
|
|
|
|
|
|
2019-10-09 16:35:41 -06:00
|
|
|
|
applied_layout->apply (0, 0, tui_term_width (), tui_term_height ());
|
2020-02-22 11:48:26 -07:00
|
|
|
|
|
|
|
|
|
/* Keep the list of internal windows up-to-date. */
|
|
|
|
|
for (int win_type = SRC_WIN; (win_type < MAX_MAJOR_WINDOWS); win_type++)
|
|
|
|
|
if (tui_win_list[win_type] != nullptr
|
|
|
|
|
&& !tui_win_list[win_type]->is_visible ())
|
|
|
|
|
tui_win_list[win_type] = nullptr;
|
|
|
|
|
|
|
|
|
|
/* This should always be made visible by a layout. */
|
|
|
|
|
gdb_assert (TUI_CMD_WIN->is_visible ());
|
|
|
|
|
|
|
|
|
|
/* Now delete any window that was not re-applied. */
|
|
|
|
|
tui_win_info *focus = tui_win_with_focus ();
|
|
|
|
|
for (tui_win_info *win_info : saved_windows)
|
|
|
|
|
{
|
|
|
|
|
if (!win_info->is_visible ())
|
|
|
|
|
{
|
|
|
|
|
if (focus == win_info)
|
|
|
|
|
tui_set_win_focus_to (tui_windows[0]);
|
|
|
|
|
delete win_info;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (gdbarch == nullptr && TUI_DISASM_WIN != nullptr)
|
|
|
|
|
tui_get_begin_asm_address (&gdbarch, &addr);
|
|
|
|
|
tui_update_source_windows_with_addr (gdbarch, addr);
|
2019-10-09 16:35:41 -06:00
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2019-10-26 16:37:32 -06:00
|
|
|
|
/* See tui-layout. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
tui_adjust_window_height (struct tui_win_info *win, int new_height)
|
|
|
|
|
{
|
|
|
|
|
applied_layout->adjust_size (win->name (), new_height);
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* Set the current layout to LAYOUT. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
static void
|
|
|
|
|
tui_set_layout (tui_layout_split *layout)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2020-02-22 11:48:26 -07:00
|
|
|
|
applied_skeleton = layout;
|
|
|
|
|
applied_layout = layout->clone ();
|
|
|
|
|
tui_apply_current_layout ();
|
2002-08-24 12:28:33 +00:00
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
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
|
|
|
|
{
|
2020-02-22 11:48:26 -07:00
|
|
|
|
gdb_assert (type == SRC_WIN || type == DISASSEM_WIN);
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* If the window already exists, no need to add it. */
|
|
|
|
|
if (tui_win_list[type] != nullptr)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* If the window we are trying to replace doesn't exist, we're
|
|
|
|
|
done. */
|
|
|
|
|
enum tui_win_type other = type == SRC_WIN ? DISASSEM_WIN : SRC_WIN;
|
|
|
|
|
if (tui_win_list[other] == nullptr)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const char *name = type == SRC_WIN ? SRC_NAME : DISASSEM_NAME;
|
|
|
|
|
applied_layout->replace_window (tui_win_list[other]->name (), name);
|
|
|
|
|
tui_apply_current_layout ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Find LAYOUT in the "layouts" global and return its index. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
static size_t
|
|
|
|
|
find_layout (tui_layout_split *layout)
|
|
|
|
|
{
|
|
|
|
|
for (size_t i = 0; i < layouts.size (); ++i)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2020-02-22 11:48:26 -07:00
|
|
|
|
if (layout == layouts[i].get ())
|
|
|
|
|
return i;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
2020-02-22 11:48:26 -07:00
|
|
|
|
gdb_assert_not_reached (_("layout not found!?"));
|
2004-02-08 00:05:16 +00:00
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* Function to set the layout. */
|
2015-03-26 14:13:57 +00:00
|
|
|
|
|
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
|
2020-02-22 11:48:26 -07:00
|
|
|
|
tui_apply_layout (struct cmd_list_element *command,
|
|
|
|
|
const char *args, int from_tty)
|
2015-03-26 14:13:57 +00:00
|
|
|
|
{
|
2020-02-22 11:48:26 -07:00
|
|
|
|
tui_layout_split *layout
|
|
|
|
|
= (tui_layout_split *) get_cmd_context (command);
|
2015-03-26 14:13:57 +00:00
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* Make sure the curses mode is enabled. */
|
|
|
|
|
tui_enable ();
|
|
|
|
|
tui_set_layout (layout);
|
2015-03-26 14:13:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* See tui-layout.h. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
void
|
|
|
|
|
tui_next_layout ()
|
|
|
|
|
{
|
|
|
|
|
size_t index = find_layout (applied_skeleton);
|
|
|
|
|
++index;
|
|
|
|
|
if (index == layouts.size ())
|
|
|
|
|
index = 0;
|
|
|
|
|
tui_set_layout (layouts[index].get ());
|
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* Implement the "layout next" command. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
static void
|
|
|
|
|
tui_next_layout_command (const char *arg, int from_tty)
|
|
|
|
|
{
|
2019-06-30 20:43:32 -06:00
|
|
|
|
tui_enable ();
|
2020-02-22 11:48:26 -07:00
|
|
|
|
tui_next_layout ();
|
2001-07-18 22:03:22 +00:00
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
|
|
|
|
void
|
2020-02-22 11:48:26 -07:00
|
|
|
|
tui_set_initial_layout ()
|
|
|
|
|
{
|
|
|
|
|
tui_set_layout (layouts[0].get ());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Implement the "layout prev" command. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tui_prev_layout_command (const char *arg, int from_tty)
|
2020-02-22 11:48:26 -07:00
|
|
|
|
{
|
2020-02-22 11:48:26 -07:00
|
|
|
|
tui_enable ();
|
|
|
|
|
size_t index = find_layout (applied_skeleton);
|
|
|
|
|
if (index == 0)
|
|
|
|
|
index = layouts.size ();
|
|
|
|
|
--index;
|
|
|
|
|
tui_set_layout (layouts[index].get ());
|
2020-02-22 11:48:26 -07:00
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
void
|
|
|
|
|
tui_regs_layout ()
|
|
|
|
|
{
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* If there's already a register window, we're done. */
|
|
|
|
|
if (TUI_DATA_WIN != nullptr)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
tui_set_layout (TUI_DISASM_WIN != nullptr
|
|
|
|
|
? asm_regs_layout
|
|
|
|
|
: src_regs_layout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Implement the "layout regs" command. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tui_regs_layout_command (const char *arg, int from_tty)
|
|
|
|
|
{
|
|
|
|
|
tui_enable ();
|
|
|
|
|
tui_regs_layout ();
|
2020-02-22 11:48:26 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
void
|
|
|
|
|
tui_remove_some_windows ()
|
|
|
|
|
{
|
|
|
|
|
tui_win_info *focus = tui_win_with_focus ();
|
|
|
|
|
|
|
|
|
|
if (strcmp (focus->name (), "cmd") == 0)
|
|
|
|
|
{
|
|
|
|
|
/* Try leaving the source or disassembly window. If neither
|
|
|
|
|
exists, just do nothing. */
|
|
|
|
|
focus = TUI_SRC_WIN;
|
|
|
|
|
if (focus == nullptr)
|
|
|
|
|
focus = TUI_DISASM_WIN;
|
|
|
|
|
if (focus == nullptr)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
applied_layout->remove_windows (focus->name ());
|
|
|
|
|
tui_apply_current_layout ();
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
{
|
2020-02-22 11:48:26 -07:00
|
|
|
|
struct gdbarch *gdbarch = nullptr;
|
|
|
|
|
CORE_ADDR addr = 0;
|
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
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
if (TUI_SRC_WIN != nullptr)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
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;
|
2020-02-22 11:48:26 -07:00
|
|
|
|
}
|
|
|
|
|
else if (TUI_DISASM_WIN != nullptr)
|
|
|
|
|
{
|
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
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
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_;
|
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
|
|
|
|
|
{
|
2020-02-22 11:48:26 -07:00
|
|
|
|
gdb_assert (name == "status");
|
2019-10-07 18:03:02 -06:00
|
|
|
|
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);
|
2020-02-22 11:48:26 -07:00
|
|
|
|
if (dynamic_cast<tui_win_info *> (m_window) != nullptr)
|
|
|
|
|
tui_windows.push_back ((tui_win_info *) m_window);
|
2019-10-07 18:03:02 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
|
|
|
|
void
|
2020-02-22 11:48:26 -07:00
|
|
|
|
tui_layout_window::get_sizes (bool height, int *min_value, int *max_value)
|
2019-10-07 18:03:02 -06:00
|
|
|
|
{
|
|
|
|
|
if (m_window == nullptr)
|
|
|
|
|
m_window = tui_get_window_by_name (m_contents);
|
2020-02-22 11:48:26 -07:00
|
|
|
|
if (height)
|
|
|
|
|
{
|
|
|
|
|
*min_value = m_window->min_height ();
|
|
|
|
|
*max_value = m_window->max_height ();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*min_value = m_window->min_width ();
|
|
|
|
|
*max_value = m_window->max_width ();
|
|
|
|
|
}
|
2019-10-07 18:03:02 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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. */
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
void
|
|
|
|
|
tui_layout_window::replace_window (const char *name, const char *new_window)
|
|
|
|
|
{
|
|
|
|
|
if (m_contents == name)
|
|
|
|
|
{
|
|
|
|
|
m_contents = new_window;
|
|
|
|
|
if (m_window != nullptr)
|
|
|
|
|
{
|
|
|
|
|
m_window->make_visible (false);
|
|
|
|
|
m_window = tui_get_window_by_name (m_contents);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
void
|
2020-02-22 11:48:26 -07:00
|
|
|
|
tui_layout_window::specification (ui_file *output, int depth)
|
2020-02-22 11:48:26 -07:00
|
|
|
|
{
|
|
|
|
|
fputs_unfiltered (get_name (), output);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
void
|
|
|
|
|
tui_layout_split::add_split (std::unique_ptr<tui_layout_split> &&layout,
|
|
|
|
|
int weight)
|
2019-10-07 18:03:02 -06:00
|
|
|
|
{
|
2020-02-22 11:48:26 -07:00
|
|
|
|
split s = {weight, std::move (layout)};
|
2019-10-07 18:03:02 -06:00
|
|
|
|
m_splits.push_back (std::move (s));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
|
{
|
2020-02-22 11:48:26 -07:00
|
|
|
|
tui_layout_split *result = new tui_layout_split (m_vertical);
|
2019-10-07 18:03:02 -06:00
|
|
|
|
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
|
2020-02-22 11:48:26 -07:00
|
|
|
|
tui_layout_split::get_sizes (bool height, int *min_value, int *max_value)
|
2019-10-07 18:03:02 -06:00
|
|
|
|
{
|
2020-02-22 11:48:26 -07:00
|
|
|
|
*min_value = 0;
|
|
|
|
|
*max_value = 0;
|
|
|
|
|
bool first_time = true;
|
2019-10-07 18:03:02 -06:00
|
|
|
|
for (const split &item : m_splits)
|
|
|
|
|
{
|
|
|
|
|
int new_min, new_max;
|
2020-02-22 11:48:26 -07:00
|
|
|
|
item.layout->get_sizes (height, &new_min, &new_max);
|
|
|
|
|
/* For the mismatch case, the first time through we want to set
|
|
|
|
|
the min and max to the computed values -- the "first_time"
|
|
|
|
|
check here is just a funny way of doing that. */
|
|
|
|
|
if (height == m_vertical || first_time)
|
|
|
|
|
{
|
|
|
|
|
*min_value += new_min;
|
|
|
|
|
*max_value += new_max;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*min_value = std::max (*min_value, new_min);
|
|
|
|
|
*max_value = std::min (*max_value, new_max);
|
|
|
|
|
}
|
|
|
|
|
first_time = false;
|
2019-10-07 18:03:02 -06:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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. */
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
tui_adjust_result
|
2019-10-07 18:03:02 -06:00
|
|
|
|
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)
|
|
|
|
|
{
|
2020-02-22 11:48:26 -07:00
|
|
|
|
tui_adjust_result adjusted
|
|
|
|
|
= m_splits[i].layout->adjust_size (name, new_height);
|
|
|
|
|
if (adjusted == HANDLED)
|
|
|
|
|
return HANDLED;
|
|
|
|
|
if (adjusted == FOUND)
|
2019-10-07 18:03:02 -06:00
|
|
|
|
{
|
2020-02-22 11:48:26 -07:00
|
|
|
|
if (!m_vertical)
|
|
|
|
|
return FOUND;
|
2019-10-07 18:03:02 -06:00
|
|
|
|
found_index = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (found_index == -1)
|
2020-02-22 11:48:26 -07:00
|
|
|
|
return NOT_FOUND;
|
2019-10-07 18:03:02 -06:00
|
|
|
|
if (m_splits[found_index].layout->height == new_height)
|
2020-02-22 11:48:26 -07:00
|
|
|
|
return HANDLED;
|
2019-10-07 18:03:02 -06:00
|
|
|
|
|
|
|
|
|
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;
|
2020-02-22 11:48:26 -07:00
|
|
|
|
m_splits[index].layout->get_sizes (m_vertical, &new_min, &new_max);
|
2019-10-07 18:03:02 -06:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
return HANDLED;
|
2019-10-07 18:03:02 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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_;
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
struct size_info
|
2019-10-07 18:03:02 -06:00
|
|
|
|
{
|
2020-02-22 11:48:26 -07:00
|
|
|
|
int size;
|
|
|
|
|
int min_size;
|
|
|
|
|
int max_size;
|
2019-10-07 18:03:02 -06:00
|
|
|
|
/* True if this window will share a box border with the previous
|
|
|
|
|
window in the list. */
|
|
|
|
|
bool share_box;
|
|
|
|
|
};
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
std::vector<size_info> info (m_splits.size ());
|
2019-10-07 18:03:02 -06:00
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* Step 1: Find the min and max size of each sub-layout.
|
|
|
|
|
Fixed-sized layouts are given their desired size, and then the
|
2019-10-07 18:03:02 -06:00
|
|
|
|
remaining space is distributed among the remaining windows
|
|
|
|
|
according to the weights given. */
|
2020-02-22 11:48:26 -07:00
|
|
|
|
int available_size = m_vertical ? height : width;
|
2019-10-07 18:03:02 -06:00
|
|
|
|
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. */
|
2020-02-22 11:48:26 -07:00
|
|
|
|
m_splits[i].layout->get_sizes (m_vertical, &info[i].min_size,
|
|
|
|
|
&info[i].max_size);
|
2019-10-07 18:03:02 -06:00
|
|
|
|
|
|
|
|
|
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
|
2020-02-22 11:48:26 -07:00
|
|
|
|
same. Setting the min and max sizes this way ensures
|
2019-10-07 18:03:02 -06:00
|
|
|
|
that the resizing step, below, does the right thing with
|
|
|
|
|
this window. */
|
2020-02-22 11:48:26 -07:00
|
|
|
|
info[i].min_size = (m_vertical
|
|
|
|
|
? TUI_CMD_WIN->height
|
|
|
|
|
: TUI_CMD_WIN->width);
|
|
|
|
|
info[i].max_size = info[i].min_size;
|
2019-10-07 18:03:02 -06:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
if (info[i].min_size == info[i].max_size)
|
|
|
|
|
available_size -= info[i].min_size;
|
2019-10-07 18:03:02 -06:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
last_index = i;
|
|
|
|
|
total_weight += m_splits[i].weight;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Two adjacent boxed windows will share a border, making a bit
|
2020-02-22 11:48:26 -07:00
|
|
|
|
more size available. */
|
2019-10-07 18:03:02 -06:00
|
|
|
|
if (i > 0
|
|
|
|
|
&& m_splits[i - 1].layout->bottom_boxed_p ()
|
|
|
|
|
&& m_splits[i].layout->top_boxed_p ())
|
|
|
|
|
info[i].share_box = true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* Step 2: Compute the size of each sub-layout. Fixed-sized items
|
2019-10-07 18:03:02 -06:00
|
|
|
|
are given their fixed size, while others are resized according to
|
|
|
|
|
their weight. */
|
2020-02-22 11:48:26 -07:00
|
|
|
|
int used_size = 0;
|
2019-10-07 18:03:02 -06:00
|
|
|
|
for (int i = 0; i < m_splits.size (); ++i)
|
|
|
|
|
{
|
|
|
|
|
/* Compute the height and clamp to the allowable range. */
|
2020-02-22 11:48:26 -07:00
|
|
|
|
info[i].size = available_size * m_splits[i].weight / total_weight;
|
|
|
|
|
if (info[i].size > info[i].max_size)
|
|
|
|
|
info[i].size = info[i].max_size;
|
|
|
|
|
if (info[i].size < info[i].min_size)
|
|
|
|
|
info[i].size = info[i].min_size;
|
|
|
|
|
/* If there is any leftover size, just redistribute it to the
|
2019-10-07 18:03:02 -06:00
|
|
|
|
last resizeable window, by dropping it from the allocated
|
2020-02-22 11:48:26 -07:00
|
|
|
|
size. We could try to be fancier here perhaps, by
|
|
|
|
|
redistributing this size among all windows, not just the
|
2019-10-07 18:03:02 -06:00
|
|
|
|
last window. */
|
2020-02-22 11:48:26 -07:00
|
|
|
|
if (info[i].min_size != info[i].max_size)
|
2019-10-07 18:03:02 -06:00
|
|
|
|
{
|
2020-02-22 11:48:26 -07:00
|
|
|
|
used_size += info[i].size;
|
2019-10-07 18:03:02 -06:00
|
|
|
|
if (info[i].share_box)
|
2020-02-22 11:48:26 -07:00
|
|
|
|
--used_size;
|
2019-10-07 18:03:02 -06:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* Allocate any leftover size. */
|
|
|
|
|
if (available_size >= used_size && last_index != -1)
|
|
|
|
|
info[last_index].size += available_size - used_size;
|
2019-10-07 18:03:02 -06:00
|
|
|
|
|
|
|
|
|
/* Step 3: Resize. */
|
2020-02-22 11:48:26 -07:00
|
|
|
|
int size_accum = 0;
|
|
|
|
|
const int maximum = m_vertical ? height : width;
|
2019-10-07 18:03:02 -06:00
|
|
|
|
for (int i = 0; i < m_splits.size (); ++i)
|
|
|
|
|
{
|
|
|
|
|
/* If we fall off the bottom, just make allocations overlap.
|
|
|
|
|
GIGO. */
|
2020-02-22 11:48:26 -07:00
|
|
|
|
if (size_accum + info[i].size > maximum)
|
|
|
|
|
size_accum = maximum - info[i].size;
|
2019-10-07 18:03:02 -06:00
|
|
|
|
else if (info[i].share_box)
|
2020-02-22 11:48:26 -07:00
|
|
|
|
--size_accum;
|
|
|
|
|
if (m_vertical)
|
|
|
|
|
m_splits[i].layout->apply (x, y + size_accum, width, info[i].size);
|
|
|
|
|
else
|
|
|
|
|
m_splits[i].layout->apply (x + size_accum, y, info[i].size, height);
|
|
|
|
|
size_accum += info[i].size;
|
2019-10-07 18:03:02 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_applied = true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
tui_layout_split::remove_windows (const char *name)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < m_splits.size (); ++i)
|
|
|
|
|
{
|
|
|
|
|
const char *this_name = m_splits[i].layout->get_name ();
|
|
|
|
|
if (this_name == nullptr)
|
|
|
|
|
m_splits[i].layout->remove_windows (name);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (strcmp (this_name, name) == 0
|
|
|
|
|
|| strcmp (this_name, "cmd") == 0)
|
|
|
|
|
{
|
|
|
|
|
/* Keep. */
|
|
|
|
|
}
|
|
|
|
|
m_splits.erase (m_splits.begin () + i);
|
|
|
|
|
--i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
tui_layout_split::replace_window (const char *name, const char *new_window)
|
|
|
|
|
{
|
|
|
|
|
for (auto &item : m_splits)
|
|
|
|
|
item.layout->replace_window (name, new_window);
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* See tui-layout.h. */
|
|
|
|
|
|
|
|
|
|
void
|
2020-02-22 11:48:26 -07:00
|
|
|
|
tui_layout_split::specification (ui_file *output, int depth)
|
2020-02-22 11:48:26 -07:00
|
|
|
|
{
|
2020-02-22 11:48:26 -07:00
|
|
|
|
if (depth > 0)
|
|
|
|
|
fputs_unfiltered ("{", output);
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
if (!m_vertical)
|
|
|
|
|
fputs_unfiltered ("-horizontal ", output);
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
bool first = true;
|
|
|
|
|
for (auto &item : m_splits)
|
|
|
|
|
{
|
|
|
|
|
if (!first)
|
|
|
|
|
fputs_unfiltered (" ", output);
|
|
|
|
|
first = false;
|
2020-02-22 11:48:26 -07:00
|
|
|
|
item.layout->specification (output, depth + 1);
|
2020-02-22 11:48:26 -07:00
|
|
|
|
fprintf_unfiltered (output, " %d", item.weight);
|
|
|
|
|
}
|
2020-02-22 11:48:26 -07:00
|
|
|
|
|
|
|
|
|
if (depth > 0)
|
|
|
|
|
fputs_unfiltered ("}", output);
|
2020-02-22 11:48:26 -07:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* Destroy the layout associated with SELF. */
|
|
|
|
|
|
2019-10-09 16:35:41 -06:00
|
|
|
|
static void
|
2020-02-22 11:48:26 -07:00
|
|
|
|
destroy_layout (struct cmd_list_element *self, void *context)
|
|
|
|
|
{
|
|
|
|
|
tui_layout_split *layout = (tui_layout_split *) context;
|
|
|
|
|
size_t index = find_layout (layout);
|
|
|
|
|
layouts.erase (layouts.begin () + index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* List holding the sub-commands of "layout". */
|
|
|
|
|
|
|
|
|
|
static struct cmd_list_element *layout_list;
|
|
|
|
|
|
|
|
|
|
/* Add a "layout" command with name NAME that switches to LAYOUT. */
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
static struct cmd_list_element *
|
2020-02-22 11:48:26 -07:00
|
|
|
|
add_layout_command (const char *name, tui_layout_split *layout)
|
2019-10-09 16:35:41 -06:00
|
|
|
|
{
|
2020-02-22 11:48:26 -07:00
|
|
|
|
struct cmd_list_element *cmd;
|
2019-10-09 16:35:41 -06:00
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
string_file spec;
|
2020-02-22 11:48:26 -07:00
|
|
|
|
layout->specification (&spec, 0);
|
2020-02-22 11:48:26 -07:00
|
|
|
|
|
|
|
|
|
gdb::unique_xmalloc_ptr<char> doc
|
|
|
|
|
(xstrprintf (_("Apply the \"%s\" layout.\n\
|
|
|
|
|
This layout was created using:\n\
|
|
|
|
|
tui new-layout %s %s"),
|
|
|
|
|
name, name, spec.c_str ()));
|
2019-10-09 16:35:41 -06:00
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
cmd = add_cmd (name, class_tui, nullptr, doc.get (), &layout_list);
|
|
|
|
|
set_cmd_context (cmd, layout);
|
|
|
|
|
/* There is no API to set this. */
|
|
|
|
|
cmd->func = tui_apply_layout;
|
|
|
|
|
cmd->destroyer = destroy_layout;
|
|
|
|
|
cmd->doc_allocated = 1;
|
|
|
|
|
doc.release ();
|
|
|
|
|
layouts.emplace_back (layout);
|
2020-02-22 11:48:26 -07:00
|
|
|
|
|
|
|
|
|
return cmd;
|
2020-02-22 11:48:26 -07:00
|
|
|
|
}
|
2019-10-09 16:35:41 -06:00
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* Initialize the standard layouts. */
|
2019-10-09 16:35:41 -06:00
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
static void
|
|
|
|
|
initialize_layouts ()
|
|
|
|
|
{
|
|
|
|
|
tui_layout_split *layout;
|
|
|
|
|
|
|
|
|
|
layout = new tui_layout_split ();
|
|
|
|
|
layout->add_window ("src", 2);
|
|
|
|
|
layout->add_window ("status", 0);
|
|
|
|
|
layout->add_window ("cmd", 1);
|
|
|
|
|
add_layout_command ("src", layout);
|
|
|
|
|
|
|
|
|
|
layout = new tui_layout_split ();
|
|
|
|
|
layout->add_window ("asm", 2);
|
|
|
|
|
layout->add_window ("status", 0);
|
|
|
|
|
layout->add_window ("cmd", 1);
|
|
|
|
|
add_layout_command ("asm", layout);
|
|
|
|
|
|
|
|
|
|
layout = new tui_layout_split ();
|
|
|
|
|
layout->add_window ("src", 1);
|
|
|
|
|
layout->add_window ("asm", 1);
|
|
|
|
|
layout->add_window ("status", 0);
|
|
|
|
|
layout->add_window ("cmd", 1);
|
|
|
|
|
add_layout_command ("split", layout);
|
|
|
|
|
|
|
|
|
|
layout = new tui_layout_split ();
|
|
|
|
|
layout->add_window ("regs", 1);
|
|
|
|
|
layout->add_window ("src", 1);
|
|
|
|
|
layout->add_window ("status", 0);
|
|
|
|
|
layout->add_window ("cmd", 1);
|
|
|
|
|
layouts.emplace_back (layout);
|
|
|
|
|
src_regs_layout = layout;
|
|
|
|
|
|
|
|
|
|
layout = new tui_layout_split ();
|
|
|
|
|
layout->add_window ("regs", 1);
|
|
|
|
|
layout->add_window ("asm", 1);
|
|
|
|
|
layout->add_window ("status", 0);
|
|
|
|
|
layout->add_window ("cmd", 1);
|
|
|
|
|
layouts.emplace_back (layout);
|
|
|
|
|
asm_regs_layout = layout;
|
2019-10-09 16:35:41 -06:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-07 18:03:02 -06:00
|
|
|
|
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* A helper function that returns true if NAME is the name of an
|
|
|
|
|
available window. */
|
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
|
validate_window_name (const std::string &name)
|
|
|
|
|
{
|
|
|
|
|
return (name == "src" || name == "cmd"
|
|
|
|
|
|| name == "regs" || name == "asm"
|
|
|
|
|
|| name == "status");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Implementation of the "tui new-layout" command. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tui_new_layout_command (const char *spec, int from_tty)
|
|
|
|
|
{
|
|
|
|
|
std::string new_name = extract_arg (&spec);
|
|
|
|
|
if (new_name.empty ())
|
|
|
|
|
error (_("No layout name specified"));
|
|
|
|
|
if (new_name[0] == '-')
|
|
|
|
|
error (_("Layout name cannot start with '-'"));
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
bool is_vertical = true;
|
|
|
|
|
spec = skip_spaces (spec);
|
|
|
|
|
if (check_for_argument (&spec, "-horizontal"))
|
|
|
|
|
is_vertical = false;
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
std::vector<std::unique_ptr<tui_layout_split>> splits;
|
2020-02-22 11:48:26 -07:00
|
|
|
|
splits.emplace_back (new tui_layout_split (is_vertical));
|
2020-02-22 11:48:26 -07:00
|
|
|
|
std::unordered_set<std::string> seen_windows;
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
2020-02-22 11:48:26 -07:00
|
|
|
|
spec = skip_spaces (spec);
|
|
|
|
|
if (spec[0] == '\0')
|
2020-02-22 11:48:26 -07:00
|
|
|
|
break;
|
2020-02-22 11:48:26 -07:00
|
|
|
|
|
|
|
|
|
if (spec[0] == '{')
|
|
|
|
|
{
|
2020-02-22 11:48:26 -07:00
|
|
|
|
is_vertical = true;
|
|
|
|
|
spec = skip_spaces (spec + 1);
|
|
|
|
|
if (check_for_argument (&spec, "-horizontal"))
|
|
|
|
|
is_vertical = false;
|
|
|
|
|
splits.emplace_back (new tui_layout_split (is_vertical));
|
2020-02-22 11:48:26 -07:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool is_close = false;
|
|
|
|
|
std::string name;
|
|
|
|
|
if (spec[0] == '}')
|
|
|
|
|
{
|
|
|
|
|
is_close = true;
|
|
|
|
|
++spec;
|
|
|
|
|
if (splits.size () == 1)
|
|
|
|
|
error (_("Extra '}' in layout specification"));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
name = extract_arg (&spec);
|
|
|
|
|
if (name.empty ())
|
|
|
|
|
break;
|
|
|
|
|
if (!validate_window_name (name))
|
|
|
|
|
error (_("Unknown window \"%s\""), name.c_str ());
|
|
|
|
|
if (seen_windows.find (name) != seen_windows.end ())
|
|
|
|
|
error (_("Window \"%s\" seen twice in layout"), name.c_str ());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ULONGEST weight = get_ulongest (&spec, '}');
|
2020-02-22 11:48:26 -07:00
|
|
|
|
if ((int) weight != weight)
|
|
|
|
|
error (_("Weight out of range: %s"), pulongest (weight));
|
2020-02-22 11:48:26 -07:00
|
|
|
|
if (is_close)
|
|
|
|
|
{
|
|
|
|
|
std::unique_ptr<tui_layout_split> last_split
|
|
|
|
|
= std::move (splits.back ());
|
|
|
|
|
splits.pop_back ();
|
|
|
|
|
splits.back ()->add_split (std::move (last_split), weight);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
splits.back ()->add_window (name.c_str (), weight);
|
|
|
|
|
seen_windows.insert (name);
|
|
|
|
|
}
|
2020-02-22 11:48:26 -07:00
|
|
|
|
}
|
2020-02-22 11:48:26 -07:00
|
|
|
|
if (splits.size () > 1)
|
|
|
|
|
error (_("Missing '}' in layout specification"));
|
2020-02-22 11:48:26 -07:00
|
|
|
|
if (seen_windows.empty ())
|
|
|
|
|
error (_("New layout does not contain any windows"));
|
|
|
|
|
if (seen_windows.find ("cmd") == seen_windows.end ())
|
|
|
|
|
error (_("New layout does not contain the \"cmd\" window"));
|
|
|
|
|
|
|
|
|
|
gdb::unique_xmalloc_ptr<char> cmd_name
|
|
|
|
|
= make_unique_xstrdup (new_name.c_str ());
|
2020-02-22 11:48:26 -07:00
|
|
|
|
std::unique_ptr<tui_layout_split> new_layout = std::move (splits.back ());
|
2020-02-22 11:48:26 -07:00
|
|
|
|
struct cmd_list_element *cmd
|
|
|
|
|
= add_layout_command (cmd_name.get (), new_layout.get ());
|
|
|
|
|
cmd->name_allocated = 1;
|
|
|
|
|
cmd_name.release ();
|
|
|
|
|
new_layout.release ();
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
/* Base command for "layout". */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tui_layout_command (const char *layout_name, int from_tty)
|
|
|
|
|
{
|
|
|
|
|
help_list (layout_list, "layout ", all_commands, gdb_stdout);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-08 15:44:18 -06:00
|
|
|
|
/* Function to initialize gdb commands, for tui window layout
|
|
|
|
|
manipulation. */
|
|
|
|
|
|
2020-01-13 14:01:38 -05:00
|
|
|
|
void _initialize_tui_layout ();
|
2019-10-08 15:44:18 -06:00
|
|
|
|
void
|
2020-01-13 14:01:38 -05:00
|
|
|
|
_initialize_tui_layout ()
|
2019-10-08 15:44:18 -06:00
|
|
|
|
{
|
2020-02-22 11:48:26 -07:00
|
|
|
|
add_prefix_cmd ("layout", class_tui, tui_layout_command, _("\
|
2019-10-08 15:44:18 -06:00
|
|
|
|
Change the layout of windows.\n\
|
2020-02-22 11:48:26 -07:00
|
|
|
|
Usage: layout prev | next | LAYOUT-NAME"),
|
|
|
|
|
&layout_list, "layout ", 0, &cmdlist);
|
|
|
|
|
|
|
|
|
|
add_cmd ("next", class_tui, tui_next_layout_command,
|
|
|
|
|
_("Apply the next TUI layout"),
|
|
|
|
|
&layout_list);
|
|
|
|
|
add_cmd ("prev", class_tui, tui_prev_layout_command,
|
|
|
|
|
_("Apply the previous TUI layout"),
|
|
|
|
|
&layout_list);
|
|
|
|
|
add_cmd ("regs", class_tui, tui_regs_layout_command,
|
|
|
|
|
_("Apply the TUI register layout"),
|
|
|
|
|
&layout_list);
|
2019-10-09 16:35:41 -06:00
|
|
|
|
|
2020-02-22 11:48:26 -07:00
|
|
|
|
add_cmd ("new-layout", class_tui, tui_new_layout_command,
|
|
|
|
|
_("Create a new TUI layout.\n\
|
2020-02-22 11:48:26 -07:00
|
|
|
|
Usage: tui new-layout [-horizontal] NAME WINDOW WEIGHT [WINDOW WEIGHT]...\n\
|
2020-02-22 11:48:26 -07:00
|
|
|
|
Create a new TUI layout. The new layout will be named NAME,\n\
|
|
|
|
|
and can be accessed using \"layout NAME\".\n\
|
|
|
|
|
The windows will be displayed in the specified order.\n\
|
2020-02-22 11:48:26 -07:00
|
|
|
|
A WINDOW can also be of the form:\n\
|
2020-02-22 11:48:26 -07:00
|
|
|
|
{ [-horizontal] NAME WEIGHT [NAME WEIGHT]... }\n\
|
2020-02-22 11:48:26 -07:00
|
|
|
|
This form indicates a sub-frame.\n\
|
2020-02-22 11:48:26 -07:00
|
|
|
|
Each WEIGHT is an integer, which holds the relative size\n\
|
|
|
|
|
to be allocated to the window."),
|
|
|
|
|
tui_get_cmd_list ());
|
|
|
|
|
|
2019-10-09 16:35:41 -06:00
|
|
|
|
initialize_layouts ();
|
2019-10-08 15:44:18 -06:00
|
|
|
|
}
|