Commit Graph

98044 Commits

Author SHA1 Message Date
Tom Tromey
bbc228ee05 Don't check window type in tui_set_win_focus_to
This changes tui_set_win_focus_to so that it no longer checks the
window type.  Instead, now tui_unhighlight_win also checks whether the
window can be highlighted.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (tui_set_win_focus_to): Don't check window type.
	* tui/tui-wingeneral.c (tui_unhighlight_win): Check
	can_highlight.
2019-06-25 07:48:44 -06:00
Tom Tromey
5fcee43a96 Introduce tui_win_info::make_visible_with_new_height
This changes make_visible_with_new_height to be a method on
tui_win_info, letting us remove a spot that checks the window type.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (tui_source_window_base::update_tab_width): Call
	make_visible_with_new_height method.
	(tui_win_info::make_visible_with_new_height): New method.
	(tui_source_window_base::do_make_visible_with_new_height)
	(tui_data_window::do_make_visible_with_new_height)
	(tui_cmd_window::do_make_visible_with_new_height): New methods.
	(make_visible_with_new_height): Remove.
	(tui_resize_all, tui_adjust_win_heights): Use
	make_visible_with_new_height method.
	* tui/tui-data.h (struct tui_win_info)
	<do_make_visible_with_new_height, make_visible_with_new_height>:
	New methods.
	(struct tui_source_window_base, struct tui_data_window)
	(struct tui_cmd_window) <do_make_visible_with_new_height>: New
	methods.
2019-06-25 07:48:43 -06:00
Tom Tromey
d83f1fe65d Introduce tui_win_info::update_tab_width
This introduces a new tui_win_info::update_tab_width method, and
changes the TUI to call it.  This fixes another spot that was checking
the window type.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (tui_source_window_base::update_tab_width): New
	method.
	(update_tab_width): Call update_tab_width method.
	* tui/tui-data.h (struct tui_win_info)
	(struct tui_source_window_base) <update_tab_width>: New methods.
2019-06-25 07:48:43 -06:00
Tom Tromey
17374de40e Introduce enum tui_box
This adds a new enum to the TUI, replacing two #define constants,
providing better type safety.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.h (tui_make_window): Change type of "box_it"
	parameter.
	* tui/tui-wingeneral.c (tui_make_window): Change type of "box_it"
	parameter.
	(tui_gen_win_info::make_visible): Update.
	* tui/tui-layout.c (init_and_make_win): Change type of "box_it"
	parameter.
	* tui/tui-data.h (enum tui_box): New enum.
	(BOX_WINDOW, DONT_BOX_WINDOW): Remove defines.
2019-06-25 07:48:42 -06:00
Tom Tromey
f936bca26d Remove some TUI static allocations
The TUI statically allocates the "execution_info" for the source and
disassembly windows.  However, there's no deep reason to do this, and
this approach makes it harder to allow multiple such windows.

This patch removes the static data and changes the code to simply
allocate these windows as needed.  This required pushing some code
into the tui_gen_win_info destructor, but that seems like a good idea
anyhow.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (make_source_or_disasm_window): Always use
	init_and_make_win for EXEC_INFO_WIN.
	* tui/tui-data.h (struct tui_gen_win_info) <~tui_gen_win_info>: No
	longer inline.
	(struct tui_win_info) <~tui_win_info>: Inline.
	(tui_source_exec_info_win_ptr, tui_disassem_exec_info_win_ptr):
	Don't declare.
	* tui/tui-data.c (source_win, disasm_win): Remove globals.
	(tui_source_exec_info_win_ptr, tui_disassem_exec_info_win_ptr):
	Remove.
	(tui_initialize_static_data): Update.
	(~tui_gen_win_info): Handle more cleanup here.
	(~tui_source_window_base): Delete "execution_info".
	(~tui_win_info): Move code to ~tui_gen_win_info; remove.
2019-06-25 07:48:42 -06:00
Tom Tromey
d6ba6a1164 Introduce tui_gen_win_info::reset method
This introduces the tui_gen_win_info::reset method and changes various
places to use it.  This led to the realization that the can_highlight
member only needs to be set during construction, so this patch makes
that change as well.  Finally, init_and_make_win is drastically
simplified.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (make_command_window): Don't set
	can_highlight.
	(show_source_disasm_command): Call the reset method.
	(show_data): Don't set can_highlight.  Call the reset method.
	(tui_gen_win_info::reset): Rename from init_gen_win_info
	(init_and_make_win): Simplify.  Return tui_gen_win_info.
	(show_source_or_disasm_and_command): Call the reset method.
	* tui/tui-data.h (struct tui_gen_win_info) <reset>: New method.
	(struct tui_cmd_window): Set can_highlight.
2019-06-25 07:48:41 -06:00
Tom Tromey
48a3bd16c2 Move make_visible method to tui_gen_win_info
This moves the make_visible method from tui_win_info to its base
class, tui_gen_win_info.  This allows the removal of another window
type check.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c (tui_gen_win_info::make_visible): Rename
	from make_visible.
	(tui_make_visible, tui_make_invisible): Rewrite.
	(tui_win_info::make_visible): Remove.
	(tui_source_window_base::make_visible): Update.
	* tui/tui-data.h (struct tui_gen_win_info) <make_visible>: New
	method.  Moved from...
	(struct tui_win_info) <make_visible>: ...here.
2019-06-25 07:48:41 -06:00
Tom Tromey
c3bd716ffc Remove tui_scroll_direction enum
The tui_scroll_direction enum is not really needed, because it's
simple to adapt the various scrolling methods to use the sign of their
argument as the direction in which to scroll.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c
	(tui_source_window_base::do_scroll_horizontal): Remove direction
	parameter.
	* tui/tui-windata.c (tui_data_window::do_scroll_vertical): Remove
	direction parameter.
	* tui/tui-win.c (tui_win_info::forward_scroll)
	(tui_win_info::backward_scroll, tui_win_info::left_scroll)
	(tui_win_info::right_scroll): Update.
	* tui/tui-source.c (tui_source_window::do_scroll_vertical): Remove
	direction parameter.
	* tui/tui-disasm.c (tui_disasm_window::do_scroll_vertical): Remove
	direction parameter.
	* tui/tui-data.h (enum tui_scroll_direction): Remove.
	(struct tui_win_info) <do_scroll_vertical, do_scroll_horizontal>:
	Remove direction parameter.
	(struct tui_source_window_base, struct tui_source_window)
	(struct tui_disasm_window, struct tui_data_window)
	(struct tui_cmd_window): Update.
2019-06-25 07:48:41 -06:00
Tom Tromey
21c32dca76 Change more TUI functions to take a tui_source_window_base
Several more TUI functions should only be called with a source or
disassembly window.  This patch changes these functions so that this
can be caught at compile time.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (tui_set_exec_info_content)
	(tui_show_exec_info_content, tui_erase_exec_info_content)
	(tui_clear_exec_info_content, tui_update_exec_info): Change
	argument to tui_source_window_base.
	* tui/tui-winsource.c (tui_set_exec_info_content)
	(tui_show_exec_info_content, tui_erase_exec_info_content)
	(tui_clear_exec_info_content, tui_update_exec_info): Change
	argument to tui_source_window_base.
2019-06-25 07:48:40 -06:00
Tom Tromey
73fbdc65a1 Change tui_set_exec_info_content to return void
tui_set_exec_info_content can't return an error, so change it to
return void instead.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (tui_set_exec_info_content): Return void.
	* tui/tui-winsource.c (tui_set_exec_info_content): Return void.
2019-06-25 07:48:40 -06:00
Tom Tromey
3332534318 Remove NULL check from tui_set_exec_info_content
tui_set_exec_info_content ensures that the window's "execution_info"
is allocated, so the NULL check here is redundant and can be removed.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_set_exec_info_content): Remove NULL
	check.
2019-06-25 07:48:39 -06:00
Tom Tromey
29d2c474f5 Change tui_alloc_source_buffer return type to void
tui_alloc_source_buffer can't actually fail, so change its return type
to void and update the callers.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (tui_alloc_source_buffer): Change return
	type to void.
	* tui/tui-winsource.c (tui_alloc_source_buffer): Change return
	type to void.
	* tui/tui-source.c (tui_set_source_content): Update.
	* tui/tui-disasm.c (tui_set_disassem_content): Update.
2019-06-25 07:48:39 -06:00
Tom Tromey
152f3f4b33 Introduce tui_gen_win_info::name method
This removes tui_win_name and replaces it with a method on
tui_gen_win_info, removing another spot that switched on window type.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (window_name_completer, tui_set_focus)
	(tui_all_windows_info): Use name method.
	* tui/tui-data.h (struct tui_gen_win_info)
	(struct tui_source_window, struct tui_disasm_window)
	(struct tui_data_window, struct tui_cmd_window) <name>: New
	method.
	(tui_win_name): Don't declare.
	* tui/tui-data.c (tui_partial_win_by_name): Use name method.
	(tui_win_name): Remove.
2019-06-25 07:48:38 -06:00
Tom Tromey
be4da58857 Change tui_update_source_window for better type safety
tui_update_source_window can only be called for source and disassembly
windows, so change the argument type to enforce this at compile time.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (tui_update_source_window)
	(tui_update_source_window_as_is): Change parameter type.
	* tui/tui-winsource.c (tui_update_source_window): Change win_info
	to be a tui_source_window_base.
	(tui_update_source_window_as_is): Likewise.
	* tui/tui-win.c (make_visible_with_new_height): Update.
2019-06-25 07:48:38 -06:00
Tom Tromey
5b81daba91 Introduce refresh_window method
This replaces tui_refresh_win with a new refresh_window method.  This
removes another spot that was checking the window's type.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_erase_source_content)
	(tui_show_source_content, tui_show_exec_info_content)
	(tui_erase_exec_info_content): Use refresh_window method.
	* tui/tui-wingeneral.h (tui_refresh_win): Don't declare.
	* tui/tui-wingeneral.c (tui_gen_win_info::refresh_window): Rename
	from tui_refresh_win.
	(tui_data_window::refresh_window): New method.
	(tui_win_info::refresh, tui_source_window_base::refresh)
	(tui_refresh_all): Use refresh_window method.
	* tui/tui-stack.c (tui_show_locator_content): Call refresh_window
	method.
	* tui/tui-regs.c (tui_display_register): Call refresh_window
	method.
	* tui/tui-layout.c (show_source_disasm_command)
	(show_source_or_disasm_and_command): Call refresh_window method.
	* tui/tui-data.h (struct tui_gen_win_info)
	(struct tui_data_window, struct tui_cmd_window) <refresh_window>:
	New method.
2019-06-25 07:48:38 -06:00
Tom Tromey
cb2ce89305 Derive tui_win_info from tui_gen_win_info
This changes tui_win_info to derive from tui_gen_win_info, rather than
having a tui_gen_win_info as a member.  This removes a layer of member
access from the entire TUI, which is why this patch is so large.  This
change will enable further removal of switches based on window type.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui.c (tui_rl_other_window, tui_enable)
	(tui_is_window_visible, tui_get_command_dimension): Update.
	* tui/tui-winsource.c (tui_update_source_window_as_is)
	(tui_clear_source_content, tui_erase_source_content)
	(tui_show_source_line, tui_source_window_base::refill)
	(tui_source_window_base::do_scroll_horizontal)
	(tui_source_window_base::set_is_exec_point_at)
	(tui_update_breakpoint_info, tui_set_exec_info_content)
	(tui_alloc_source_buffer, tui_line_is_displayed)
	(tui_addr_is_displayed): Update.
	* tui/tui-wingeneral.c (tui_unhighlight_win, tui_highlight_win)
	(tui_check_and_display_highlight_if_needed)
	(tui_win_info::make_visible, tui_win_info::refresh)
	(tui_refresh_all): Update.
	* tui/tui-windata.c (tui_first_data_item_displayed)
	(tui_delete_data_content_windows, tui_erase_data_content)
	(tui_display_all_data, tui_data_window::refresh_all)
	(tui_check_data_values): Update.
	* tui/tui-win.c (window_name_completer, tui_update_gdb_sizes)
	(tui_set_win_focus_to, tui_win_info::forward_scroll)
	(tui_win_info::backward_scroll, tui_refresh_all_win)
	(tui_resize_all, tui_set_focus, tui_all_windows_info)
	(update_tab_width, tui_set_win_height, tui_adjust_win_heights)
	(tui_source_window_base::set_new_height)
	(tui_data_window::set_new_height)
	(make_invisible_and_set_new_height)
	(make_visible_with_new_height, new_height_ok)
	(parse_scrolling_args): Update.
	* tui/tui-stack.c (tui_show_frame_info): Update.
	* tui/tui-source.c (tui_set_source_content)
	(tui_set_source_content_nil, tui_source_is_displayed)
	(tui_source_window::do_scroll_vertical): Update.
	* tui/tui-regs.c (tui_show_registers, tui_show_register_group)
	(tui_display_registers_from, tui_display_reg_element_at_line)
	(tui_check_register_values, tui_reg_command): Update.
	* tui/tui-layout.c (tui_default_win_height)
	(show_source_disasm_command, show_data, init_and_make_win)
	(show_source_or_disasm_and_command): 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_cont_sig)
	(tui_getc): Update.
	* tui/tui-disasm.c (tui_set_disassem_content)
	(tui_disasm_window::do_scroll_vertical): Update.
	* tui/tui-data.h (struct tui_gen_win_info) <~tui_gen_win_info>:
	Now virtual.
	(struct tui_win_info): Derive from tui_gen_win_info.
	<~tui_win_info>: Mark as override.
	<generic>: Remove member.
	* tui/tui-data.c (tui_cmd_window::clear_detail, tui_next_win)
	(tui_prev_win, tui_partial_win_by_name, tui_win_info)
	(~tui_data_window, ~tui_win_info)
	(tui_free_all_source_wins_content): Update.
	* tui/tui-command.c (tui_refresh_cmd_win): Update.
2019-06-25 07:48:37 -06:00
Tom Tromey
ab313b35e5 Use new and delete for tui_gen_win_info
This changes tui_gen_win_info to be allocated with new and destroyed
with delete.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (init_and_make_win): Use new.
	* tui/tui-data.h (struct tui_gen_win_info): Add constructor,
	destructor, initializers.
	(tui_alloc_generic_win_info): Don't declare.
	* tui/tui-data.c (_locator): Add argument to constructor.
	(source_win, disasm_win): New globals.
	(exec_info): Remove.
	(tui_source_exec_info_win_ptr, tui_disassem_exec_info_win_ptr):
	Update.
	(tui_alloc_generic_win_info): Remove.
	(init_content_element): Use new.
	(tui_win_info::tui_win_info): Update.
	(free_content_elements) <case DATA_WIN>: Use delete.
2019-06-25 07:48:37 -06:00
Tom Tromey
dc2c33e456 Change tui_which_element::data_window to be a pointer
A coming patch will add a constructor to tui_gen_win_info.  However,
because the tui_which_element union contains an object of this type,
first something must be done here in order to avoid having a union
with a member that has a constructor.  This patch changes this element
to be a pointer instead.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c (tui_refresh_win): Update.
	* tui/tui-windata.c (tui_first_data_item_displayed)
	(tui_delete_data_content_windows): Update.
	* tui/tui-win.c (tui_data_window::set_new_height): Update.
	* tui/tui-regs.c (tui_show_registers, tui_show_register_group)
	(tui_display_registers_from, tui_check_register_values): Update.
	* tui/tui-data.h (union tui_which_element) <data_window>: Now a
	pointer.
	* tui/tui-data.c (init_content_element): Update.  Allocate the new
	window.
	(tui_free_data_content): Update.
	(free_content_elements) <case DATA_WIN>: Free the window.
2019-06-25 07:48:36 -06:00
Tom Tromey
214a5cbea6 Introduce set_highlight method
This introduces the tui_win_info::set_highlight method, and changes
the highlighting-related code to use bool rather than int.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c (tui_unhighlight_win, tui_highlight_win):
	Update.
	* tui/tui-layout.c (make_command_window)
	(show_source_disasm_command, show_data, init_and_make_win)
	(show_source_or_disasm_and_command): Update.
	* tui/tui-data.h (struct tui_win_info) <set_highlight>: New
	method.
	<can_highight, is_highlighted>: Now bool.
	(tui_set_win_highlight): Don't declare.
	* tui/tui-data.c (tui_set_win_highlight): Remove.
2019-06-25 07:48:36 -06:00
Tom Tromey
8e2daf1532 Remove redundant check from make_visible
This removes a check of the window type from make_visible.  This
function already checks that the window type is not CMD_WIN near the
top, so this condition can never be false.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c (make_visible): Remove check of window
	type.
2019-06-25 07:48:35 -06:00
Tom Tromey
8903bd8a37 Introduce max_height method
This introduces the tui_win_info::max_height method and changes
new_height_ok to use it, rather than checking the window type
directly.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (tui_win_info::max_height)
	(tui_cmd_window::max_height): New methods.
	(new_height_ok): Call max_height.
	* tui/tui-data.h (struct tui_win_info, struct tui_cmd_window)
	<max_height>: New method.
2019-06-25 07:48:35 -06:00
Tom Tromey
3f02ce1e3d Introduce set_new_height method
This introduces tui_win_info::set_new_height and implements it in the
subclasses as appropriate.  This removes another switch on the window
type.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (tui_source_window_base::set_new_height)
	(tui_data_window::set_new_height): New methods.
	(make_invisible_and_set_new_height): Call set_new_height method.
	* tui/tui-data.h (struct tui_win_info)
	(struct tui_source_window_base, struct tui_data_window)
	<set_new_height>: New method.
2019-06-25 07:48:34 -06:00
Tom Tromey
1825f487ae Introduce the refresh_all method
This introduces the tui_win_info::refresh_all method and implements it
as needed in subclasses.  The name and comment are a bit of a guess on
my part.  The main benefit of this patch is removing another switch on
the type of the window.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui.c (tui_rl_other_window): Call the refresh_all method.
	* tui/tui-windata.c (tui_data_window::refresh_all): Rename from
	tui_refresh_data_win.
	* tui/tui-win.c (tui_source_window_base::refresh_all): New
	method.
	(tui_refresh_all_win): Call the refresh_all method.
	(tui_set_focus): Likewise.
	* tui/tui-data.h (struct tui_win_info) <refresh_all>: New method.
	(struct tui_source_window_base, struct tui_data_window) <refresh>:
	Likewise.
2019-06-25 07:48:34 -06:00
Tom Tromey
ad54d15bdb Introduce two TUI source window methods
This adds two methods to the TUI source window.  These are just
renamings of existing functions.  It also changes the source window
list to have a more precise type, letting the code be more type-safe.
This will be useful again later.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (tui_refill_source_window)
	(tui_set_is_exec_point_at): Don't declare.
	* tui/tui-winsource.c (tui_update_source_windows_with_addr)
	(tui_source_window_base::refill): Rename from
	tui_refill_source_window.
	(tui_source_window_base::do_scroll_horizontal): Update.
	(tui_source_window_base::set_is_exec_point_at): Rename from
	tui_set_is_exec_point_at.
	(tui_update_all_breakpoint_info): Update.
	* tui/tui-stack.c (tui_show_frame_info): Update.
	* tui/tui-layout.c (show_data): Add cast.
	* tui/tui-hooks.c (tui_redisplay_source): Call refill method.
	* tui/tui-data.h (struct tui_source_window_base) <refill,
	set_is_exec_point_at>: New methods.
	(tui_source_windows, tui_add_to_source_windows): Update types.
	(tui_add_to_source_windows): Remove redundant declaration.
	* tui/tui-data.c (source_windows): Store tui_source_window_base.
	(tui_source_windows): Change return type.
	(tui_clear_source_windows_detail): Update.
	(tui_add_to_source_windows): Change type of parameter.
	(tui_free_all_source_wins_content): Update.
2019-06-25 07:48:34 -06:00
Tom Tromey
2042b506c8 Introduce the refresh method
This adds tui_win_info::refresh and updates tui_source_window_base to
implement it as well.  This lets us simplify tui_refresh_all, removing
a check of the window type.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c (tui_win_info::refresh)
	(tui_source_window_base::refresh): New methods.
	(tui_refresh_all): Call the refresh method.
	* tui/tui-data.h (struct tui_win_info)
	(struct tui_source_window_base) <refresh>: New method.
2019-06-25 07:48:33 -06:00
Tom Tromey
56122977c0 Use bool for visibility
This changes the visibility-related functions and data members in the
TUI to use bool rather than int.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui.h (tui_is_window_visible): Return bool.
	* tui/tui.c (tui_is_window_visible): Return bool.
	* tui/tui-wingeneral.c (tui_make_window, make_visible)
	(tui_make_visible, tui_make_invisible)
	(tui_win_info::make_visible)
	(tui_source_window_base::make_visible, make_all_visible)
	(tui_make_all_visible, tui_make_all_invisible): Update.
	* tui/tui-windata.c (tui_delete_data_content_windows): Update.
	* tui/tui-data.h (struct tui_gen_win_info) <is_visible>: Now
	bool.
	(struct tui_win_info, struct tui_source_window_base)
	(struct tui_cmd_window) <make_visible>: Change parameter to bool.
	* tui/tui-data.c (tui_init_generic_part): Update.
2019-06-25 07:48:33 -06:00
Tom Tromey
cda37efbff Introduce make_visible method
This introduceds the make_visible to tui_win_info and overrides it in
subclasses as appropriate.  This allows the removal of the
tui_win_is_source_type, as it is no longer used.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c (tui_win_info::make_visible)
	(tui_source_window_base::make_visible): New methods.
	(make_all_visible): Make method call.
	* tui/tui-data.h (struct tui_win_info) <make_visible>: New method.
	(struct tui_source_window_base, struct tui_cmd_window): Override
	make_visible.
	(tui_win_is_source_type): Don't declare.
	* tui/tui-data.c (tui_win_is_source_type): Remove.
2019-06-25 07:48:32 -06:00
Tom Tromey
6a0ee02c22 Remove an unneeded NULL check
show_source_or_disasm_and_command will either create or reset the
source window, so the final NULL check is not necessary.  This patch
removes it.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (show_source_or_disasm_and_command): Remove
	NULL check.
2019-06-25 07:48:32 -06:00
Tom Tromey
63901aeccf Inline constructors and initializers
This inlines the constructors and initializers for tui_cmd_window and
tui_data_window.  This makes the code a bit simpler.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.h (struct tui_data_window, struct tui_cmd_window):
	Inline constructor.  Add initializers for members.
	* tui/tui-data.c (tui_data_window, tui_cmd_window): Remove
	constructors; now inline in class.
2019-06-25 07:48:31 -06:00
Tom Tromey
ceb13a1382 Change tui_data_window::display_regs to bool
This changes tui_data_window::display_regs to bool and updates the
uses.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.c (tui_show_registers): Update.
	* tui/tui-data.h (struct tui_data_window) <display_regs>: Now
	bool.
	* tui/tui-data.c (tui_data_window::clear_detail)
	(tui_data_window): Update.
2019-06-25 07:48:31 -06:00
Tom Tromey
238eb706f9 Remove struct tui_data_info
Like the previous two patches, this removes struct tui_data_info in
favor of inlining its contents into tui_data_window.  This was the
last member of the tui_win_info detail union, so that is removed.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-windata.c (tui_display_all_data)
	(tui_display_data_from_line, tui_display_data_from)
	(tui_check_data_values, tui_data_window::do_scroll_vertical):
	Update.
	* tui/tui-regs.c (tui_last_regs_line_no)
	(tui_line_from_reg_element_no, tui_first_reg_element_no_inline)
	(tui_show_registers, tui_show_register_group)
	(tui_display_registers_from, tui_display_reg_element_at_line)
	(tui_display_registers_from_line, tui_check_register_values)
	(tui_reg_next, tui_reg_prev): Update.
	* tui/tui-layout.c (tui_set_layout, show_data): Update.
	* tui/tui-data.h (struct tui_data_info): Remove.  Move contents to
	tui_data_window.
	(struct tui_win_info) <detail>: Remove.  Add new fields from
	tui_data_info.
	(TUI_DATA_WIN): Add cast.
	* tui/tui-data.c (tui_data_window::clear_detail, tui_data_window)
	(~tui_data_window): Simplify.
2019-06-25 07:48:30 -06:00
Tom Tromey
81491aa096 Remove struct tui_command_info
Like the previous patch, this removes tui_command_info in favor of
putting it elements directly into tui_cmd_window.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (show_source_disasm_command)
	(show_source_or_disasm_and_command): Update.
	* tui/tui-io.c (update_cmdwin_start_line)
	(tui_redisplay_readline): Update.
	* tui/tui-data.h (struct tui_command_info): Remove.
	(struct tui_win_info) <detail>: Remove command_info member.
	(struct tui_data_window) <start_line>: New member, from
	tui_command_info.
	(TUI_CMD_WIN): Add casts.
2019-06-25 07:48:30 -06:00
Tom Tromey
e6e4150110 Remove struct tui_source_info
The tui_source_info struct is used as a member of the "detail" union
in tui_win_info, and this member of the union is only used by source
and disassembly windows.  This patch removes tui_source_info and moves
its members directly to tui_source_window_base.  This simplifies the
code by removing a layer of references from many places.  In a few
spots, a new cast was needed, but most of these will be removed by the
end of the series.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_update_source_window)
	(tui_refill_source_window)
	(tui_source_window_base::do_scroll_horizontal)
	(tui_update_breakpoint_info, tui_set_exec_info_content)
	(tui_show_exec_info_content, tui_erase_exec_info_content)
	(tui_clear_exec_info_content): Update.
	* tui/tui-wingeneral.c (make_all_visible, tui_refresh_all):
	Update.
	* tui/tui-win.c (make_invisible_and_set_new_height)
	(make_visible_with_new_height): Update.
	* tui/tui-source.c (tui_set_source_content)
	(tui_show_symtab_source): Update.
	* tui/tui-layout.c (extract_display_start_addr)
	(show_source_disasm_command, show_data)
	(make_source_or_disasm_window)
	(show_source_or_disasm_and_command): Update.
	* tui/tui-disasm.c (tui_set_disassem_content): Simplify.
	(tui_disasm_window::do_scroll_vertical): Remove shadowing
	"gdbarch".
	* tui/tui-data.h (struct tui_source_info): Remove.  Move contents
	to tui_source_window_base.
	(struct tui_win_info) <detail>: Remove source_info member.
	(struct tui_source_window_base) <has_locator>: Inline.
	Move contents from tui_source_info; rename has_locator member to
	m_has_locator.
	(TUI_SRC_WIN, TUI_DISASM_WIN): Add casts.
	* tui/tui-data.c (tui_source_window_base::has_locator): Move to
	header file.
	(tui_source_window_base::clear_detail, ~tui_source_window_base):
	Simplify.
	(tui_free_all_source_wins_content): Cast to
	tui_source_window_base.
2019-06-25 07:48:30 -06:00
Tom Tromey
44f0e208eb Introduce has_locator method
This changes tui_win_has_locator to be a method on tui_win_info, and
changes the locator code to use bool rather than int.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (make_invisible_and_set_new_height)
	(make_visible_with_new_height): Call has_locator method.
	* tui/tui-layout.c (show_source_disasm_command, show_data)
	(show_source_or_disasm_and_command): Update for bool change.
	* tui/tui-data.h (struct tui_source_info) <has_locator>: Now bool.
	(tui_win_info) <has_locator>: New method.
	(struct tui_source_window_base) <has_locator>: New method.
	(tui_win_has_locator): Don't declare.
	* tui/tui-data.c (tui_source_window_base::has_locator): Rename
	from tui_win_has_locator.
	(tui_source_window_base): Use false, not FALSE.
2019-06-25 07:48:29 -06:00
Tom Tromey
7778b9128f Remove tui_clear_win_detail
An earlier patch changed the context of the sole call to
tui_clear_win_detail to make it clear that this can never be called
with a NULL window pointer.  So, remove tui_clear_win_detail in favor
of calling the method directly.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.h (tui_clear_win_detail): Don't declare.
	* tui/tui-data.c (tui_clear_source_windows_detail): Call the
	clear_detail method directly.
	(tui_clear_win_detail): Remove.
2019-06-25 07:48:29 -06:00
Tom Tromey
f83d391c5a Don't use TUI_DISASM_WIN in tui_disasm_window method
The previous patch made it clear that the diassembly window scrolling
method was written to assume there could only ever be a single
disassembly window.  This changes that spot to use "this" rather than
the TUI_DISASM_WIN global.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-disasm.c (tui_disasm_window::do_scroll_vertical): Use
	"this", not TUI_DISASM_WIN.
2019-06-25 07:48:28 -06:00
Tom Tromey
13446e05a3 Introduce methods for scrolling
This changes the TUI to use virtual methods on the various window
types for scrolling.  Window-specific functions for this purpose are
renamed to be methods, and the generic tui_scroll function is removed
as it is no longer called.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (tui_horizontal_source_scroll):  Don't
	declare.
	* tui/tui-winsource.c
	(tui_source_window_base::do_scroll_horizontal): Rename from
	tui_horizontal_source_scroll.
	* tui/tui-windata.h (tui_vertical_data_scroll): Don't declare.
	* tui/tui-windata.c (tui_data_window::do_scroll_vertical): Rename
	from tui_vertical_data_scroll.
	* tui/tui-win.h (tui_scroll): Don't declare.
	* tui/tui-win.c (tui_win_info::forward_scroll)
	(tui_win_info::backward_scroll, tui_win_info::left_scroll)
	(tui_win_info::right_scroll): Rename and update.
	(tui_scroll_forward_command, tui_scroll_backward_command)
	(tui_scroll_left_command, tui_scroll_right_command): Update.
	(tui_scroll): Remove.
	* tui/tui-source.h: Don't declare tui_vertical_source_scroll.
	* tui/tui-source.c (tui_source_window::do_scroll_vertical): Rename
	from tui_vertical_source_scroll.
	* tui/tui-disasm.h (tui_vertical_disassem_scroll): Don't declare.
	* tui/tui-disasm.c (tui_disasm_window::do_scroll_vertical): Rename
	from tui_vertical_disassem_scroll.
	* tui/tui-data.h (struct tui_win_info) <do_scroll_vertical,
	do_scroll_horizontal>: New methods.
	<forward_scroll, backward_scroll, left_scroll, right_scroll>:
	Likewise.
	(struct tui_source_window_base): Add do_scroll_horizontal.
	(struct tui_source_window, struct tui_disasm_window): Add
	do_scroll_vertical.
	(struct tui_data_window, struct tui_cmd_window): Add
	do_scroll_horizontal and do_scroll_vertical.
	* tui/tui-command.c (tui_dispatch_ctrl_char): Use method calls.
2019-06-25 07:48:28 -06:00
Tom Tromey
5cf82909a7 Create tui_disasm_window
This introduces the new tui_disasm_window class, which represents a
disassembly window.  It shares a lot of behavior with the source
window, so a new tui_source_window_base class is also created.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.h (struct tui_source_window_base): New struct.
	(struct tui_source_window): Derive from tui_source_window_base.
	(struct tui_disasm_window): New struct.
	* tui/tui-data.c (tui_source_window_base::clear_detail): Rename
	from tui_source_window::clear_detail.
	(tui_source_window_base): Rename from tui_source_window.
	(~tui_source_window_base): Rename from ~tui_source_window.
	(tui_alloc_win_info): Create a tui_disasm_window.
2019-06-25 07:48:27 -06:00
Tom Tromey
ee1d42d6c1 Split the tui_win_info destructor
This patch adds destructors to tui_source_window and tui_data_window,
and splits ~tui_win_info as appropriate.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.h (struct tui_source_window)
	(struct tui_data_window): Declare destructors.
	* tui/tui-data.c (~tui_source_window, ~tui_data_window): New
	destructors.
	(tui_win_info): Simplify.
2019-06-25 07:48:27 -06:00
Tom Tromey
b4eb24524b Remove tui_list
This removes the tui_list type in favor of a std::vector.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_display_main)
	(tui_update_source_windows_with_addr)
	(tui_update_all_breakpoint_info): Update.
	* tui/tui-win.c (tui_resize_all, tui_adjust_win_heights)
	(new_height_ok, parse_scrolling_args): Update.
	* tui/tui-stack.c (tui_show_frame_info): Update.
	* tui/tui-data.h (struct tui_list): Remove.
	(tui_source_windows): Return a reference to a std::vector.
	* tui/tui-data.c (source_windows): Now a std::vector.
	(tui_source_windows): Change return type.
	(tui_clear_source_windows): Rewrite.
	(tui_clear_source_windows_detail, tui_add_to_source_windows)
	(tui_free_all_source_wins_content): Rewrite.
2019-06-25 07:48:27 -06:00
Tom Tromey
8761a91b26 Introduce tui_win_info::clear_detail method
This introduces the clear_detail method and updates the various
subclasses of tui_win_info to implement it.  A subsequent patch will
remove tui_clear_win_detail, but that isn't done for now because at
this point it isn't readily obvious that the NULL check is not needed.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.h (struct tui_win_info, struct tui_source_window)
	(struct tui_data_window, struct tui_cmd_window): Declare
	clear_detail method.
	* tui/tui-data.c (tui_source_window::clear_detail)
	(tui_cmd_window::clear_detail, tui_data_window::clear_detail): New
	methods.
	(tui_clear_win_detail): Simplify.
2019-06-25 07:48:26 -06:00
Tom Tromey
0ed69edaab Simplify source and disassembly window creation
Similar to the previous patch, neither make_source_window nor
make_disasm_window could be called when *win_info_ptr was non-NULL.
This patch simplifies the functions by removing the parameter and
having them return their results directly.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (make_source_window, make_disasm_window)
	(make_source_or_disasm_window): Remove win_info_ptr parameter.
	Return the new window.
	(show_source_disasm_command, show_data)
	(show_source_or_disasm_and_command): Update.
2019-06-25 07:48:26 -06:00
Tom Tromey
82432e1014 Simplify command window creation
make_command_window is never called when *win_info_ptr is non-NULL, so
this patch simplifies the function by removing the parameter and
having it return its result directly.  This in turn makes it more
obvious that a NULL check in show_source_disasm_command can be
removed.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (make_command_window): Remove win_info_ptr
	parameter.  Return the new window.
	(show_source_disasm_command): Update and remove NULL check.
	(show_source_or_disasm_and_command): Update.
2019-06-25 07:48:25 -06:00
Tom Tromey
ec328aa512 Remove an unnecessary NULL check from the TUI
In init_and_make_win, opaque_win_info can't be NULL after a new window
is allocated.  This patch removes an unnecessary NULL check.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (init_and_make_win): Remove NULL check.
2019-06-25 07:48:25 -06:00
Tom Tromey
33b906abfa Create subclasses for different window types
This changes the TUI so that each different major window type has its
own subclass.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.h (struct tui_win_info): Make constructor
	protected.  Make destructor virtual.  Add initializers.
	(tui_source_window, tui_data_window, tui_cmd_window): New
	classes.
	* tui/tui-data.c (tui_win_info): Rename from init_win_info.  Now a
	constructor.  Add "type" parameter.
	(tui_source_window, tui_data_window, tui_cmd_window): New
	constructors.
	(tui_alloc_win_info): Instantiate the appropriate subclass.
2019-06-25 07:48:24 -06:00
Tom Tromey
e7e11af42d Add destructor to tui_win_info
This changes tui_free_window into a destructor for tui_free_window and
then updates the users.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (tui_resize_all): Use delete.
	* tui/tui-data.h (struct tui_win_info) <~tui_win_info>: Declare
	destructor.
	(tui_free_window): Don't declare.
	* tui/tui-data.c (~tui_win_info): Rename from tui_free_window.
	Update.
2019-06-25 07:48:24 -06:00
Tom Tromey
6792b55e08 Use new and delete for TUI windows
This changes tui_win_info to use new and delete, rather than XNEW and
xfree.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.h (struct tui_win_info): Add constructor.
	* tui/tui-data.c (tui_alloc_win_info): Use new.
	(tui_free_window): Use delete.
2019-06-25 07:48:23 -06:00
Jan Beulich
8e5cb9a54e ld/plugins: avoid shadowing a C library symbol
With my (oldish) gcc/glibc combination I'm seeing

.../ld/plugin.c: In function ‘get_lto_kind’:
.../ld/plugin.c:664: error: declaration of ‘index’ shadows a global declaration
/usr/include/string.h:487: error: shadowed declaration is here
.../ld/plugin.c: In function ‘get_lto_resolution’:
.../ld/plugin.c:685: error: declaration of ‘index’ shadows a global declaration
/usr/include/string.h:487: error: shadowed declaration is here
.../ld/plugin.c: In function ‘get_lto_visibility’:
.../ld/plugin.c:711: error: declaration of ‘index’ shadows a global declaration
/usr/include/string.h:487: error: shadowed declaration is here
2019-06-25 12:02:23 +02:00
Jan Beulich
ab9f654ca3 bfd/elf-properties: avoid shadowing a C library symbol
With my (oldish) gcc/glibc combination I'm seeing

.../bfd/elf-properties.c: In function ‘elf_find_and_remove_property’:
.../bfd/elf-properties.c:244: error: declaration of ‘remove’ shadows a global declaration
/usr/include/stdio.h:157: error: shadowed declaration is here
2019-06-25 12:01:50 +02:00
Jan Beulich
3e50a591d9 readelf: avoid shadowing a libiberty symbol
With my (oldish) gcc I'm seeing

.../binutils/readelf.c: In function ‘dump_ctf_indent_lines’:
.../binutils/readelf.c:13851: error: declaration of ‘spaces’ shadows a global declaration
.../binutils/../include/libiberty.h:253: error: shadowed declaration is here
2019-06-25 11:09:22 +02:00