Commit Graph

110 Commits

Author SHA1 Message Date
Tom Tromey 432b5c4022 Make some tui_source_window_base members "protected"
This renames a few members of tui_source_window_base, and makes them
"protected".

2020-02-22  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (extract_display_start_addr): Rewrite.
	* tui/tui-disasm.h (struct tui_disasm_window)
	<display_start_addr>: Declare.
	* tui/tui-source.h (struct tui_source_window)
	<display_start_addr>: Declare.
	* tui/tui-winsource.h (struct tui_source_window_base)
	<show_source_line, display_start_addr>: New methods.
	<m_horizontal_offset, m_start_line_or_addr, m_gdbarch, m_content>:
	Rename and move to protected section.
	* tui/tui-winsource.c (tui_source_window_base::update_source_window)
	(tui_source_window_base::do_erase_source_content): Update.
	(tui_source_window_base::show_source_line): Now a method.
	(tui_source_window_base::show_source_content)
	(tui_source_window_base::tui_source_window_base)
	(tui_source_window_base::rerender)
	(tui_source_window_base::refill)
	(tui_source_window_base::do_scroll_horizontal)
	(tui_source_window_base::set_is_exec_point_at)
	(tui_source_window_base::update_breakpoint_info)
	(tui_source_window_base::update_exec_info): Update.
	* tui/tui-source.c (tui_source_window::set_contents)
	(tui_source_window::showing_source_p)
	(tui_source_window::do_scroll_vertical)
	(tui_source_window::location_matches_p)
	(tui_source_window::line_is_displayed): Update.
	(tui_source_window::display_start_addr): New method.
	* tui/tui-disasm.c (tui_disasm_window::set_contents)
	(tui_disasm_window::do_scroll_vertical)
	(tui_disasm_window::location_matches_p): Update.
	(tui_disasm_window::display_start_addr): New method.

Change-Id: I74d72b9da5f458664427db643a108634690c6e19
2020-02-22 12:57:25 -07:00
Tom Tromey 2a3d458be3 Use TUI_DISASM_WIN instead of tui_win_list array
This is a minor cleanup to change tui_get_low_disassembly_address to
use TUI_DISASM_WIN, rather than the tui_win_list array.  This is more
in line with what the rest of the TUI code does.

gdb/ChangeLog
2020-02-22  Tom Tromey  <tom@tromey.com>

	* tui/tui-disasm.c (tui_get_low_disassembly_address): Use
	TUI_DISASM_WIN, not tui_win_list.

Change-Id: I999335ee3f63a4b570e84f320236b78f2bd5b780
2020-02-22 11:48:27 -07:00
Andrew Burgess 42330a681a gdb/tui: Disassembler scrolling of very small programs
In TUI mode, if the disassembly output for the program is less than
one screen long, then currently if the user scrolls down until on the
last assembly instruction is displayed and then tries to scroll up
using Page-Up, the display doesn't update - they are stuck viewing the
last line.

If the user tries to scroll up using the Up-Arrow, then the display
scrolls normally.

What is happening is on the Page-Up we ask GDB to scroll backward the
same number of lines as the height of the TUI ASM window.  The back
scanner, which looks for a good place to start disassembling, fails to
find a starting address which will provide the requested number of new
lines before we get back to the original starting address (which is
not surprising, our whole program contains less than a screen height
of instructions), as a result the back scanner gives up and returns
the original starting address.

When we scroll with Up-Arrow we only ask the back scanner to find 1
new instruction, which it manages to do, so this scroll works.

The solution here is, when we fail to find enough instructions, to
return the lowest address we did manage to find.  This will ensure we
jump to the lowest possible address in the disassembly output.

gdb/ChangeLog:

	PR tui/9765
	* tui/tui-disasm.c (tui_find_disassembly_address): If we don't
	have enough lines to fill the screen, still return the lowest
	address we found.

gdb/testsuite/ChangeLog:

	PR tui/9765
	* gdb.tui/tui-layout-asm-short-prog.S: New file.
	* gdb.tui/tui-layout-asm-short-prog.exp: New file.

Change-Id: I6a6a7972c68a0559e9717fd8d82870b669a40af3
2020-01-31 00:41:06 +00:00
Andrew Burgess 733d0a6795 gdb/tui: asm window handles invalid memory and scrolls better
This started as a patch to enable the asm window to handle attempts to
disassemble invalid memory, but it ended up expanding into a
significant rewrite of how the asm window handles scrolling.  These
two things ended up being tied together as it was impossible to
correctly test scrolling into invalid memory when the asm window would
randomly behave weirdly while scrolling.

Things that should work nicely now; scrolling to the bottom or top of
the listing with PageUp, PageDown, Up Arrow, Down Arrow and we should
be able to scroll past small areas of memory that don't have symbols
associated with them.  It should also be possible to scroll to the
start of a section even if there's no symbol at the start of the
section.

Adding tests for this scrolling was a little bit of a problem.  First
I would have liked to add tests for PageUp / PageDown, but the tuiterm
library we use doesn't support these commands right now due to only
emulating a basic ascii terminal.  Changing this to emulate a more
complex terminal would require adding support for more escape sequence
control codes, so I've not tried to tackle that in this patch.

Next, I would have liked to test scrolling to the start or end of the
assembler listing and then trying to scroll even more, however, this
is a problem because in a well behaving GDB a scroll at the start/end
has no effect.  What we need to do is:

  - Move to start of assembler listing,
  - Send scroll up command,
  - Wait for all curses output,
  - Ensure the assembler listing is unchanged, we're still at the
    start of the listing.

The problem is that there is no curses output, so how long do we wait
at step 3?  The same problem exists for scrolling to the bottom of the
assembler listing.  However, when scrolling down you can at least see
the end coming, so I added a test for this case, however, this feels
like an area of code that is massively under tested.

gdb/ChangeLog:

	PR tui/9765
	* minsyms.c (lookup_minimal_symbol_by_pc_section): Update header
	comment, add extra parameter, and update to store previous symbol
	when appropriate.
	* minsyms.h (lookup_minimal_symbol_by_pc_section): Update comment,
	add extra parameter.
	* tui/tui-disasm.c (tui_disassemble): Update header comment,
	remove unneeded parameter, add try/catch around gdb_print_insn,
	rewrite to add items to asm_lines vector.
	(tui_find_backward_disassembly_start_address): New function.
	(tui_find_disassembly_address): Updated throughout.
	(tui_disasm_window::set_contents): Update for changes to
	tui_disassemble.
	(tui_disasm_window::do_scroll_vertical): No need to adjust the
	number of lines to scroll.

gdb/testsuite/ChangeLog:

	PR tui/9765
	* gdb.tui/tui-layout-asm.exp: Add scrolling test for asm window.

Change-Id: I323987c8fd316962c937e73c17d952ccd3cfa66c
2020-01-24 00:10:33 +00:00
Shahab Vahedi cbfa858117 GDB: Fix the overflow in addr/line_is_displayed()
In tui_disasm_window::addr_is_displayed(), there can be situations
where "content" is empty. For instance, it can happen when the
"content" was not filled in tui_disasm_window::set_contents(),
because tui_disassemble() threw an exception. Usually this exception
is the result of fetching invalid PC addresses like the ones beyond
the end of the program.

Having "content.size ()" zero leads to an overflow in this condition
check inside tui_disasm_window::addr_is_displayed():

  int i = 0;
  while (i < content.size () - threshold ...) {
    ... content[i] ...
  }

"threshold" is 2 and there are times that "content.size ()" is 0.
This results into an overflow and the loop is entered whereas it
should have been skipped. Finally, "content[i]" access leads to
a segmentation fault.

Same problem applies to tui_source_window::line_is_displayed().

The issue has been discussed at length in bug 25345:
  https://sourceware.org/bugzilla/show_bug.cgi?id=25345

This commit avoids the segmentation faults with an early check:

  if (content.size () < SCROLL_THRESHOLD)
    return false;

Moreover, those functions have been overhauled to a leaner code.

gdb/ChangeLog:
2020-01-06  Shahab Vahedi  <shahab@synopsys.com>

	* tui/tui-disasm.c (tui_disasm_window::addr_is_displayed): Avoid
	overflow by an early check of content vs threshold.
        * tui/tui-source.c (tui_source_window::line_is_displayed):
	Likewise.
2020-01-06 19:47:20 +00:00
Shahab Vahedi a61b4f6997 GDB: Remove trailing spaces in tui-disasm.c
A few trailing spaces are removed.

gdb/ChangeLog:
2020-01-06  Shahab Vahedi  <shahab@synopsys.com>

	* tui/tui-disasm.c: Remove trailing spaces.
2020-01-06 13:43:46 +00:00
Joel Brobecker b811d2c292 Update copyright year range in all GDB files.
gdb/ChangeLog:

        Update copyright year range in all GDB files.
2020-01-01 10:20:53 +04:00
Tom Tromey 52469d7673 Reimplement tui_get_begin_asm_address
tui_get_begin_asm_address looks for the inferior's "main" to display
it.  I think this is incorrect in two ways.

First, it should probably instead use the user's most recent source
context, if one has been set.

Second, it uses a hard-coded list of "main" names, but gdb already has
a better approach to handling this.

This patch fixes both of these problems.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

	* tui/tui-disasm.c (tui_get_begin_asm_address): Use
	get_current_source_symtab_and_line, and main_name.

Change-Id: I77dc13d49148e8dec5aa3eeb357ce3968a68d0bd
2019-12-20 09:15:54 -07:00
Tom Tromey 9f7540a5de Use symtab_and_line when updating TUI windows
This changes a few TUI source window methods to take a symtab_and_line
rather than separate symtab and tui_line_or_address parameters.  A
symtab_and_line already incorporates the same information, so this
seemed simpler.  Also, it helps avoid the problem that the source and
disassembly windows need different information -- both forms are
present in the SAL.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (struct tui_source_window_base)
	<set_contents, update_source_window_as_is, update_source_window>:
	Take a sal, not a separate symtab and tui_line_or_address.
	* tui/tui-winsource.c (tui_source_window_base::update_source_window)
	(tui_source_window_base::update_source_window_as_is): Take a sal,
	not a separate symtab and tui_line_or_address.
	(tui_update_source_windows_with_addr)
	(tui_update_source_windows_with_line)
	(tui_source_window_base::rerender)
	(tui_source_window_base::refill): Update.
	* tui/tui-source.h (struct tui_source_window) <set_contents>: Take
	a sal, not a separate symtab and tui_line_or_address.
	* tui/tui-source.c (tui_source_window::set_contents): Take a sal,
	not a separate symtab and tui_line_or_address.
	(tui_source_window::maybe_update): Update.
	* tui/tui-disasm.h (struct tui_disasm_window) <set_contents>: Take
	a sal, not a separate symtab and tui_line_or_address.
	* tui/tui-disasm.c (tui_disasm_window::set_contents): Take a sal,
	not a separate symtab and tui_line_or_address.
	(tui_disasm_window::do_scroll_vertical)
	(tui_disasm_window::maybe_update): Update.

Change-Id: I6974a03589930a0f910c657ef50b7f6f7397c87d
2019-12-20 09:15:53 -07:00
Tom Tromey 57e4b379e9 Use start_line_or_addr in TUI windows
A few spots in the TUI source and disassembly windows referred to
content[0], where start_line_or_addr is equivalent.  This patch makes
this substitution.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_source_window_base::refill): Use
	start_line_or_addr.
	* tui/tui-source.c (tui_source_window::do_scroll_vertical): Use
	start_line_or_addr.
	* tui/tui-disasm.c (tui_disasm_window::do_scroll_vertical): Use
	start_line_or_addr.

Change-Id: I1fa807321cd7ad88b3cc5e41cc50f4d4e2d46271
2019-12-20 09:15:52 -07:00
Tom Tromey 61c33f105c Change tui_source_window_base::set_contents to return bool
This changes tui_source_window_base::set_contents to return bool,
rather than tui_status.  It also changes one implementation of
set_contents to use early returns rather than a variable, which IMO
makes it easier to follow.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (struct tui_source_window_base)
	<set_contents>: Return bool.
	* tui/tui-winsource.c
	(tui_source_window_base::update_source_window_as_is): Update.
	* tui/tui-source.h (struct tui_source_window) <set_contents>:
	Return bool.
	* tui/tui-source.c (tui_source_window::set_contents): Return
	bool.  Simplify.
	* tui/tui-disasm.h (struct tui_disasm_window) <set_contents>:
	Return bool.
	* tui/tui-disasm.c (tui_disasm_window::set_contents): Return
	bool.

Change-Id: I8c5212400cd7aadf35760c22d5344cd3b9435674
2019-12-20 09:15:52 -07:00
Tom Tromey 855f89b3da Remove tui_show_disassem
tui_show_disassem is just a wrapper for the update_source_window
method, and it only has a single caller.  This removes the function
and inlines the logic into that caller.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_update_source_windows_with_addr): Call
	update_source_window directly.
	* tui/tui-disasm.h (tui_show_disassem): Don't declare.
	* tui/tui-disasm.c (tui_show_disassem): Remove.

Change-Id: I7ae7a3309f64a4a949c07a80c46e1664c7f12913
2019-12-20 09:15:51 -07:00
Tom Tromey d4669c0fc7 Remove some unnecessary focus switches
A couple of lower-level utility functions can change the TUI focus.
This seems incorrect to me -- focus switches should only be done
either by explicit user request, or ass a side effect of changing the
layout.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c
	(tui_source_window_base::update_source_window_as_is): Don't switch focus.
	* tui/tui-disasm.c (tui_show_disassem): Don't switch focus.

Change-Id: I0a5bb8a407cf8d52e2fd23b0598eb9bce56b1251
2019-12-20 09:15:51 -07:00
Tom Tromey 1ae58f0c64 Simplify tui_source_window_base::maybe_update method
tui_source_window_base::maybe_update takes a symtab_and_line, plus a
separate line number and PC.  Because a symtab_and_line already holds
a line number and a PC, it is possible to remove these extra
parameters.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (struct tui_source_window_base)
	<maybe_update>: Remove line_no and addr parameters.
	* tui/tui-stack.c (tui_show_frame_info): Set PC on sal.  Update.
	* tui/tui-source.h (struct tui_source_window) <maybe_update>:
	Update.
	* tui/tui-source.c (tui_source_window::maybe_update): Remove
	line_no and addr parameters.
	* tui/tui-disasm.h (struct tui_disasm_window) <maybe_update>:
	Update.
	* tui/tui-disasm.c (tui_disasm_window::maybe_update): Remove
	line_no and addr parameters.

Change-Id: I33d8e1a669a179544edb4197f5f7c5429dfc368e
2019-12-20 09:15:50 -07:00
Tom Tromey 8acfefcc8f Remove tui_show_disassem_and_update_source
tui_show_disassem_and_update_source only has a single caller.  This
patch simplifies that caller, by having it call tui_show_disassem, and
then removes tui_show_disassem_and_update_source.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_update_source_windows_with_addr): Call
	tui_show_disassem.
	* tui/tui-disasm.h (tui_show_disassem_and_update_source): Don't
	declare.
	* tui/tui-disasm.c (tui_show_disassem_and_update_source): Remove.

Change-Id: I7554eca8e259f3539ea7710f2ff369b4a630dd9d
2019-12-20 09:15:49 -07:00
Tom Tromey c1b167d76e Change tui_update_locator_fullname to take a symtab
This changes tui_update_locator_fullname to take a symtab.  This
somewhat consolidates the "??" handling.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

	* tui/tui.c (tui_show_source): Update.
	* tui/tui-winsource.c (tui_display_main): Update.
	* tui/tui-stack.h (tui_update_locator_fullname): Change parameter
	to symtab.
	* tui/tui-stack.c (tui_update_locator_fullname): Change parameter
	to symtab.
	* tui/tui-disasm.c (tui_show_disassem_and_update_source): Update.

Change-Id: Ic61749517b44ac68561d829ff81f16976b830dec
2019-12-20 09:15:48 -07:00
Tom Tromey d1da6b0160 Allow using less horizontal space in TUI source window
The source window currently uses a field width of 6 for line numbers,
and it further aligns to the next tab stop.  This seemed a bit
wasteful of horizontal space to me, so I changed that in an earlier
patch.

However, that change wasn't universally popular.  This patch instead
adds the option to use less horizontal space in the TUI source window.

gdb/ChangeLog
2019-12-01  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (tui_copy_source_line): Add "ndigits"
	parameter.
	* tui/tui-winsource.c (tui_copy_source_line): Add "ndigits"
	parameter.
	* tui/tui-win.h (compact_source): Declare.
	* tui/tui-win.c (compact_source): New global.
	(tui_set_compact_source, tui_show_compact_source): New functions.
	(_initialize_tui_win): Add "compact-source" setting.
	* tui/tui-source.c (tui_source_window::set_contents): Handle
	compact_source setting.
	* tui/tui-disasm.c (tui_disasm_window::set_contents): Update.
	* NEWS: Document new setting.

gdb/doc/ChangeLog
2019-12-01  Tom Tromey  <tom@tromey.com>

	* gdb.texinfo (TUI Configuration): Document new setting.

Change-Id: I46ce9a68b12c9c79332d510f9c14b3c84b7efadd
2019-12-01 11:59:23 -07:00
Tom Tromey 825165c57e Fix regression from TUI disassembly style patch
My previous patch to add styling to the TUI disassembly failed to
correctly fix a bug that Simon had pointed out in review.  This patch
fixes the bug.

gdb/ChangeLog
2019-11-05  Tom Tromey  <tom@tromey.com>

	* tui/tui-disasm.c (struct tui_asm_line) <addr_size>: New member.
	(tui_disassemble): Set addr_size.
	(tui_disasm_window::set_contents): Use addr_size.

Change-Id: Ic0152f3b82a2f79be28ae46d590096661f271580
2019-11-05 18:39:23 -07:00
Tom Tromey 1df2f9ef6c Style disassembly in the TUI
This patch changes the TUI disassembly window to style its contents.
The styling should be identical to what is seen in the CLI.  This
involved a bit of rearrangement, so that the source and disassembly
windows could share both the copy_source_line utility function, and
the ability to react to changes in "set style enabled".

This version introduces a new function to strip the styling from the
address string when computing the length.  As a byproduct, it also
removes the unused "insn_size" computation from
tui_disasm_window::set_contents.

gdb/ChangeLog
2019-11-05  Tom Tromey  <tom@tromey.com>

	* tui/tui-source.h (struct tui_source_window): Inline
	constructor.  Remove destructor.
	<style_changed, m_observable>: Move to superclass.
	* tui/tui-winsource.h (tui_copy_source_line): Declare.
	(struct tui_source_window_base): Move private members to end.
	<style_changed, m_observable>: Move from tui_source_window.
	* tui/tui-winsource.c (tui_copy_source_line): Move from
	tui-source.c.  Rename from copy_source_line.  Add special handling
	for negative line number.
	(tui_source_window_base::style_changed): Move from
	tui_source_window.
	(tui_source_window_base): Register observer.
	(~tui_source_window_base): New.
	* tui/tui-source.c (copy_source_line): Move to tui-winsource.c;
	rename.
	(tui_source_window::set_contents): Use tui_copy_source_line.
	(tui_source_window::tui_source_window): Move to tui-source.h.
	(tui_source_window::~tui_source_window): Remove.
	(tui_source_window::style_changed): Move to superclass.
	* tui/tui-disasm.c (tui_disassemble): Create string file with
	styling, when possible.  Add "addr_size" parameter.
	(tui_disasm_window::set_contents): Use tui_copy_source_line.
	Don't compute maximum size.
	(len_without_escapes): New function

Change-Id: I8722635eeecbbb1633d943a65b856404c2d467b0
2019-11-05 15:23:36 -07:00
Tom Tromey 5d0510553e Change tui_source_element::line to have type std::string
This changes tui_source_element::line to be of type std::string.  This
reduces the number of copies made.

gdb/ChangeLog
2019-11-05  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (struct tui_source_element) <line>: Now a
	std::string.
	* tui/tui-winsource.c (tui_show_source_line): Update.
	* tui/tui-source.c (tui_source_window::set_contents): Update.
	* tui/tui-disasm.c (tui_disasm_window::set_contents): Update.

Change-Id: Id600f3e1d386a2911f187366e05e2ec599068dd2
2019-11-05 15:23:36 -07:00
Tom Tromey 6d7fd9aa47 Remove tui_default_win_viewport_height
tui_default_win_viewport_height was only called from a single spot,
for a single type of window.  This patch removes the function and
moves the logic into the sole caller.

gdb/ChangeLog
2019-10-09  Tom Tromey  <tom@tromey.com>

	* tui/tui-disasm.c (tui_get_low_disassembly_address): Compute
	window height directly.
	* tui/tui-layout.h (tui_default_win_viewport_height): Don't
	declare.
	* tui/tui-layout.c (tui_default_win_height): Remove.
	(tui_default_win_viewport_height): Remove.
2019-10-09 16:50:33 -06:00
Tom Tromey f074b67ec8 Use make_unique_xstrdup in TUI
This changes a couple of spots in the TUI to use make_unique_xstrdup.
This simplifies the code slightly.

gdb/ChangeLog
2019-09-20  Tom Tromey  <tom@tromey.com>

	* tui/tui-source.c (tui_source_window::set_contents): Use
	make_unique_xstrdup.
	* tui/tui-disasm.c (tui_disasm_window::set_contents): Use
	make_unique_xstrdup.
2019-09-20 13:49:12 -06:00
Tom Tromey 6b915f7d0c Simplify TUI disassembly
This simplifies TUI disassembly somewhat, by removing manual memory
management.

gdb/ChangeLog
2019-09-20  Tom Tromey  <tom@tromey.com>

	* tui/tui-disasm.c (struct tui_asm_line) <addr_string, insn>: Now
	std::string.
	(tui_disassemble): Add "pos" parameter.
	(tui_disasm_window::set_contents): Simplify.
2019-09-20 13:49:07 -06:00
Tom Tromey f14bec587f Change tui_source_element::line to be a unique_xmalloc_ptr
This changes tui_source_element::line to be a unique_xmalloc_ptr,
removing some manual memory management.

gdb/ChangeLog
2019-09-20  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (~tui_source_element): Remove.
	(tui_source_element): Update.
	(struct tui_source_element) <line>: Now a unique_xmalloc_ptr.
	* tui/tui-winsource.c (tui_show_source_line): Update.
	* tui/tui-source.c (tui_source_window::set_contents): Update.
	* tui/tui-disasm.c (tui_disasm_window::set_contents): Update.
2019-09-20 13:49:04 -06:00
Tom Tromey 398fdd6086 Remove the TUI execution info window
The TUI execution info window is unusual in that it is always linked
to a source or disassembly window.  Even updates of its content are
handled by the source window, so it really has no life of its own.

This patch removes this window entirely and puts its functionality
directly into the source window.  This simplifies the code somewhat.

This is a user-visible change, because now the box around the source
(or disassembly) window encloses the execution info as well.  I
consider this an improvement as well, though.

Note that this patch caused ncurses to start emitting the "CSI Z"
sequence, so I've added this to the test suite terminal
implementation.

gdb/ChangeLog
2019-08-16  Tom Tromey  <tom@tromey.com>

	* tui/tui.h (enum tui_win_type) <EXEC_INFO_WIN>: Remove.
	* tui/tui-winsource.h (struct tui_exec_info_window): Remove.
	(struct tui_source_window_base) <make_visible, refresh_window,
	resize>: Remove methods.
	<execution_info>: Remove field.
	* tui/tui-winsource.c (tui_source_window_base::do_erase_source_content)
	(tui_show_source_line, tui_source_window_base)
	(~tui_source_window_base): Update.
	(tui_source_window_base::resize)
	(tui_source_window_base::make_visible)
	(tui_source_window_base::refresh_window): Remove.
	(tui_source_window_base::update_exec_info): Update.
	* tui/tui-source.c (tui_source_window::set_contents): Update.
	* tui/tui-disasm.c (tui_disasm_window::set_contents): Update.

gdb/testsuite/ChangeLog
2019-08-16  Tom Tromey  <tom@tromey.com>

	* lib/tuiterm.exp (_csi_Z): New proc.
	* gdb.tui/basic.exp: Update window positions.
	* gdb.tui/empty.exp: Update window positions.
2019-08-16 14:17:36 -06:00
Tom Tromey 81c82c4b90 Introduce tui_source_window_base::set_contents method
This introduces the tui_source_window_base::set_contents method and
implements it in the subclasses.  This removes a check of the window
type.

gdb/ChangeLog
2019-08-16  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (struct tui_source_window_base)
	<set_contents>: Declare.
	* tui/tui-winsource.c
	(tui_source_window_base::update_source_window_as_is): Update.
	* tui/tui-source.h (struct tui_source_window) <set_contents>:
	Declare.
	(tui_set_source_content): Don't declare.
	* tui/tui-source.c (tui_source_window::set_contents): Rename from
	tui_set_source_content.
	* tui/tui-disasm.h (struct tui_disasm_window) <set_contents>:
	Declare.
	(tui_set_disassem_content): Don't declare.
	* tui/tui-disasm.c (tui_disasm_window::set_contents): Rename from
	tui_set_disassem_content.
2019-08-16 11:28:34 -06:00
Tom Tromey 017f982820 Change tui_update_source_window to be a method
This changes tui_update_source_window to be a method on
tui_source_window_base.

gdb/ChangeLog
2019-08-16  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (struct tui_source_window_base)
	<update_source_window>: Declare.
	(tui_update_source_window): Don't declare.
	* tui/tui-winsource.c
	(tui_source_window_base::update_source_window): Rename from
	tui_update_source_window.
	(tui_source_window_base::rerender): Update.
	* tui/tui-source.c (tui_source_window::maybe_update): Update.
	* tui/tui-disasm.c (tui_show_disassem)
	(tui_show_disassem_and_update_source)
	(tui_disasm_window::maybe_update): Update.
2019-08-16 11:28:34 -06:00
Tom Tromey ed8358e949 Change tui_update_source_window_as_is to be a method
This changes tui_update_source_window_as_is to be a method on
tui_source_window_base.

gdb/ChangeLog
2019-08-16  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (struct tui_source_window_base)
	<update_source_window_as_is>: Declare.
	(tui_update_source_window_as_is): Don't declare.
	* tui/tui-winsource.c (tui_update_source_window): Update
	(tui_source_window_base::update_source_window_as_is): Rename from
	tui_update_source_window_as_is.
	(tui_source_window_base::refill): Update.
	* tui/tui-source.c (tui_show_symtab_source): Update.
	* tui/tui-disasm.c (tui_disasm_window::do_scroll_vertical):
	Update.
2019-08-16 11:28:34 -06:00
Tom Tromey 20149b6b20 Remove "noerror" parameter from some TUI functions
A few TUI functions take a "noerror" parameter.  This is only checked
in one spot: in tui_set_source_content, if noerror is false, and if an
error occurs, then the function will call print_sys_errmsg.

This seems misguided to me, so this patch removes that code and this
parameter.

gdb/ChangeLog
2019-08-16  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (tui_update_source_window)
	(tui_update_source_window_as_is): Remove "noerror" parameter.
	* tui/tui-winsource.c (tui_update_source_window)
	(tui_update_source_window_as_is): Remove "noerror" parameter.
	(tui_update_source_windows_with_addr)
	(tui_update_source_windows_with_line)
	(tui_source_window_base::rerender)
	(tui_source_window_base::refill): Update.
	* tui/tui-source.h (tui_set_source_content)
	(tui_show_symtab_source): Remove "noerror" parameter.
	* tui/tui-source.c (tui_set_source_content): Remove "noerror"
	parameter.
	(tui_show_symtab_source): Likewise.
	(tui_source_window::maybe_update): Update.
	* tui/tui-disasm.c (tui_show_disassem)
	(tui_show_disassem_and_update_source)
	(tui_disasm_window::do_scroll_vertical)
	(tui_disasm_window::maybe_update): Update.
2019-08-16 11:28:34 -06:00
Tom Tromey 2d83e710a1 Remove separate visibility flag
TUI windows keep track of their visibility in a boolean field.
However, this is not needed, because a window is visible if and only
if it has an underlying curses handle.  So, we can remove this
separate field.

gdb/ChangeLog
2019-08-16  Tom Tromey  <tom@tromey.com>

	* tui/tui.c (tui_is_window_visible): Update.
	* tui/tui-wingeneral.c (tui_make_window)
	(tui_gen_win_info::make_visible, tui_refresh_all): Update.
	* tui/tui-win.c (window_name_completer, tui_refresh_all_win)
	(tui_set_focus_command, tui_all_windows_info, update_tab_width)
	(tui_set_win_height_command, parse_scrolling_args): Update.
	* tui/tui-source.c (tui_source_window::style_changed): Update.
	* tui/tui-regs.c (tui_show_registers)
	(tui_data_window::first_data_item_displayed)
	(tui_data_window::delete_data_content_windows)
	(tui_check_register_values, tui_reg_command): Update.
	* tui/tui-disasm.c (tui_show_disassem): Update.
	* tui/tui-data.h (struct tui_gen_win_info) <is_visible>: New
	method.
	<is_visible>: Remove field.
	* tui/tui-data.c (tui_next_win, tui_prev_win)
	(tui_delete_invisible_windows): Update.
2019-08-16 11:28:33 -06:00
Tom Tromey 002f15c277 Remove tui_alloc_source_buffer
There is no longer any need for tui_alloc_source_buffer.  The two
callers of this function immediately change the contents of the
window, undoing the work done by this function.

This required adding a move constructor to tui_source_element -- a
mildly surprising find, but without this, resizing the vector will
cause crashes.  This issue was masked earlier because
tui_alloc_source_buffer handled this.

Note that a patch for this bug was submitted here:

    https://sourceware.org/ml/gdb-patches/2019-08/msg00094.html

That patch is better, IMO, but the author as yet hasn't responded to a
request for a ChangeLog entry.

gdb/ChangeLog
2019-08-15  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (tui_alloc_source_buffer): Don't declare.
	(struct tui_source_element): Add DISABLE_COPY_AND_ASSIGN, and move
	constructor.
	* tui/tui-winsource.c (tui_alloc_source_buffer): Remove.
	* tui/tui-source.c (tui_set_source_content): Update.
	* tui/tui-disasm.c (tui_set_disassem_content): Update.
2019-08-15 12:29:28 -06:00
Tom Tromey 088f37dd90 Change tui_addr_is_displayed into a method
This changes tui_addr_is_displayed to be a method on
tui_disasm_window, now that it is obvious that it can only be called
for this type.

gdb/ChangeLog
2019-08-15  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (tui_addr_is_displayed): Don't declare.
	* tui/tui-winsource.c (tui_addr_is_displayed): Move to
	tui-disasm.c.
	* tui/tui-disasm.h (struct tui_disasm_window) <addr_is_displayed>:
	Declare.
	* tui/tui-disasm.c (tui_disasm_window::addr_is_displayed): New
	method.
	(tui_disasm_window::maybe_update): Update.
2019-08-15 12:29:28 -06:00
Tom Tromey a54700c6c4 Move contents of tui_show_frame_info to new method
This moves much of the body of tui_show_frame_info to a new method on
tui_source_window_base.  This removes a check for the type of a
window.

gdb/ChangeLog
2019-08-15  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (struct tui_source_window_base)
	<maybe_update>: Declare.
	* tui/tui-stack.c (tui_show_frame_info): Call maybe_update
	method.
	* tui/tui-source.h (struct tui_source_window) <maybe_update>:
	Declare.
	* tui/tui-source.c (tui_source_window::maybe_update): New method.
	* tui/tui-disasm.h (struct tui_disasm_window) <maybe_update>:
	Declare.
	* tui/tui-disasm.c (tui_disasm_window::maybe_update): New method.
2019-08-15 12:29:28 -06:00
Tom Tromey 22c3f4909a Simplify tui_show_disassem
tui_show_disassem does not need to call tui_add_win_to_layout, because
the callers that could change the layout have already ensured that it
exists.

gdb/ChangeLog
2019-08-13  Tom Tromey  <tom@tromey.com>

	* tui/tui-disasm.c (tui_show_disassem): Add assertion.  Don't call
	tui_add_win_to_layout.
2019-08-13 14:52:09 -06:00
Tom Tromey d8f68fcb93 Remove unnecessary "return"s
The TUI has some "return;" statements at the end of void-returning
functions.  There's no need for these, so this patch removes them.

gdb/ChangeLog
2019-07-17  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_update_source_window)
	(tui_update_source_window_as_is)
	(tui_update_source_windows_with_line): Remove return.
	* tui/tui-disasm.c (tui_show_disassem)
	(tui_show_disassem_and_update_source): Remove return.
	* tui/tui.c (tui_reset): Remove return.
	* tui/tui-wingeneral.c
	(tui_check_and_display_highlight_if_needed): Remove return.
2019-07-17 12:19:26 -06:00
Tom Tromey bfad453707 Move tui_source_window to tui-source.h
This moves tui_source_window to tui-source.h.  In this case there were
no method definitions to be moved.

gdb/ChangeLog
2019-07-17  Tom Tromey  <tom@tromey.com>

	* tui/tui.c: Update.
	* tui/tui-source.h (struct tui_source_window): Move from
	tui-data.h.
	* tui/tui-layout.c: Update.
	* tui/tui-disasm.c: Update.
	* tui/tui-data.h (struct tui_source_window): Move to
	tui-source.h.
2019-07-17 12:19:24 -06:00
Tom Tromey 9d391078d1 Add win_info parameter to tui_set_disassem_content
This adds a win_info parameter to tui_set_disassem_content, removing
uses of the TUI_DISASM_WIN global.

gdb/ChangeLog
2019-07-17  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_update_source_window_as_is): Update.
	* tui/tui-disasm.h (tui_set_disassem_content): Add win_info
	parameter.
	* tui/tui-disasm.c (tui_set_disassem_content): Add win_info
	parameter.
2019-07-17 12:19:06 -06:00
Tom Tromey c2cd899466 Introduce tui_source_window_base::location_matches_p method
This introduces the location_matches_p method, removing a spot that
explicitly examines a window's type.

gdb/ChangeLog
2019-07-17  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_update_breakpoint_info): Use
	location_matches_p.
	* tui/tui-source.c (tui_source_window::location_matches_p): New
	method.
	* tui/tui-disasm.c (tui_disasm_window::location_matches_p): New
	method.
	* tui/tui-data.h (struct tui_source_window_base)
	<location_matches_p>: New method.
	(struct tui_source_window, struct tui_disasm_window)
	<location_matches_p>: Likewise.
2019-07-17 12:19:05 -06:00
Tom Tromey 0598af4880 Fix TUI use of "has_break" field
The TUI uses the "has_break" in two different ways: sometimes as a
boolean, and sometimes as flags.

This patch changes the TUI to be more type-safe here, and fixes the
code.  I could not find a bug that this caused, so apparently this is
just cosmetic.

This deletes some code from tui_set_disassem_content.  Whenver this is
called, I believe the TUI updates the breakpoint information
afterward, so this assignment is redundant; which is good because it
is also incorrect.

gdb/ChangeLog
2019-07-04  Tom Tromey  <tom@tromey.com>

	PR tui/24724:
	* tui/tui-winsource.c (tui_clear_source_content): Update.
	(tui_source_window_base::set_is_exec_point_at): Fix comment.
	(tui_update_breakpoint_info): Update.
	(tui_set_exec_info_content): Update.
	* tui/tui-source.c (tui_set_source_content_nil): Update.
	* tui/tui-disasm.c (tui_set_disassem_content): Don't set
	has_break.
	* tui/tui-data.h (enum tui_bp_flag): New.
	(tui_bp_flags): New enum flags type.
	(struct tui_source_element) <break_mode>: Change type.  Rename
	from has_break.
	(TUI_BP_ENABLED, TUI_BP_DISABLED, TUI_BP_HIT)
	(TUI_BP_CONDITIONAL, TUI_BP_HARDWARE): Don't define.  Now enum
	constants.
	* tui/tui-winsource.h: Fix comment.
2019-07-04 10:36:31 -06:00
Tom Tromey 17568d782d Remove NULL checks before xfree
A couple of spots in the TUI did a NULL check before an xfree.  This
isn't necessary, and most other cases were removed from gdb a while
ago.

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

	* tui/tui-source.c (tui_set_source_content): Don't check before
	xfree.
	* tui/tui-disasm.c (tui_disassemble): Don't check before xfree.
2019-06-25 07:48:51 -06:00
Tom Tromey 53e7cdbaa1 Remove union tui_which_element
This removes union tui_which_element, instead moving the content
directly into tui_source_window_base.  This allows for the deletion of
a fair amount of code.  Now the TUI window hierarchy is more
type-safe.  In particular, there is never any confusion now about
which members are in use by which subtype.

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

	* tui/tui-winsource.h (tui_update_source_window_as_is)
	(tui_alloc_source_buffer, tui_line_is_displayed)
	(tui_addr_is_displayed): Change type of win_info.
	* tui/tui-winsource.c (tui_update_source_window_as_is)
	(tui_clear_source_content, tui_show_source_line)
	(tui_show_source_content, tui_source_window_base::refill)
	(tui_source_window_base::set_is_exec_point_at)
	(tui_source_window_base::set_is_exec_point_at)
	(tui_update_breakpoint_info, tui_set_exec_info_content): Update.
	(tui_alloc_source_buffer, tui_line_is_displayed)
	(tui_addr_is_displayed): Change type of win_info.  Update.
	* tui/tui-win.c (tui_resize_all, tui_adjust_win_heights)
	(tui_source_window_base::do_make_visible_with_new_height):
	Update.
	* tui/tui-source.c (tui_set_source_content)
	(tui_set_source_content_nil)
	(tui_source_window::do_scroll_vertical): Update.
	* tui/tui-layout.c (show_layout): Update.
	* tui/tui-disasm.c (tui_set_disassem_content)
	(tui_disasm_window::do_scroll_vertical): Update.
	* tui/tui-data.h (tui_win_content): Remove.
	(struct tui_gen_win_info) <content, content_size>: Remove.
	(struct tui_source_element): Add initializers and destructor.
	(union tui_which_element, struct tui_win_element): Remove.
	(struct tui_source_window_base) <content>: New field.
	(struct tui_data_window): Remove destructor.
	(tui_alloc_content, tui_free_win_content)
	(tui_free_all_source_wins_content): Don't declare.
	* tui/tui-data.c (tui_initialize_static_data): Update.
	(init_content_element, tui_alloc_content): Remove.
	(~tui_gen_win_info): Update.
	(~tui_data_window, tui_free_all_source_wins_content)
	(tui_free_win_content, free_content, free_content_elements):
	Remove.
2019-06-25 07:48:50 -06:00
Tom Tromey 3add462fff Separate out locator window
This introduces a new subclass of tui_gen_win_info for the locator,
letting us remove another element from union tui_which_element.

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

	* tui/tui-wingeneral.c (tui_refresh_all): Update.
	* tui/tui-win.c (tui_resize_all, tui_adjust_win_heights)
	(tui_source_window_base::set_new_height): Update.
	* tui/tui-stack.c (tui_make_status_line): Change parameter type.
	Update.
	(tui_set_locator_fullname, tui_set_locator_info)
	(tui_show_frame_info): Update.
	* tui/tui-source.c (tui_set_source_content)
	(tui_source_is_displayed): Update.
	* tui/tui-layout.c (show_source_disasm_command, show_data)
	(show_source_or_disasm_and_command): Update.
	* tui/tui-disasm.c (tui_set_disassem_content)
	(tui_get_begin_asm_address): Update.
	* tui/tui-data.h (struct tui_locator_element): Remove.
	(union tui_which_element) <locator>: Remove.
	(struct tui_locator_window): New.
	(tui_locator_win_info_ptr): Change return type.
	* tui/tui-data.c (_locator): Change type.
	(tui_locator_win_info_ptr): Change return type.
	(init_content_element): Remove LOCATOR_WIN case.  Add assert.
	(tui_alloc_content): Add assert.
2019-06-25 07:48:45 -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 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 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 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 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
Joel Brobecker 42a4f53d2b Update copyright year range in all GDB files.
This commit applies all changes made after running the gdb/copyright.py
script.

Note that one file was flagged by the script, due to an invalid
copyright header
(gdb/unittests/basic_string_view/element_access/char/empty.cc).
As the file was copied from GCC's libstdc++-v3 testsuite, this commit
leaves this file untouched for the time being; a patch to fix the header
was sent to gcc-patches first.

gdb/ChangeLog:

	Update copyright year range in all GDB files.
2019-01-01 10:01:51 +04:00
Tom Tromey 7806cea723 Deprecate and replace the "tabset" command
The "tabset" command sets the tab width as used by the TUI for source
and disassembly display.

This command has long seemed to be misnamed to me.  It is more in
keeping with gdb design to call it "set tui tab-width".  Also, making
this change allows for the corresponding "show" command to work.

gdb/ChangeLog
2018-10-19  Tom Tromey  <tom@tromey.com>

	PR tui/18388:
	* NEWS: Mention tabset deprecation.
	* tui/tui-win.c (tui_tab_width, internal_tab_width): New globals.
	(update_tab_width): New function.
	(tui_set_tab_width, tui_show_tab_width): New functions.
	(tui_set_tab_width_command): Use update_tab_width.
	(_initialize_tui_win): Move to end of file.  Deprecate "tabset".
	Add new "set tui tab-width" command.
	* tui/tui-source.c (tui_set_source_content): Update.
	* tui/tui-disasm.c (tui_set_disassem_content): Update.
	* tui/tui-data.h (tui_default_tab_len, tui_set_default_tab_len):
	Don't declare.
	(tui_tab_width): Declare.
	* tui/tui-data.c (default_tab_len, tui_default_tab_len)
	(tui_set_default_tab_len): Remove.

gdb/doc/ChangeLog
2018-10-19  Tom Tromey  <tom@tromey.com>

	PR tui/18388:
	* gdb.texinfo (TUI Commands): Remove tabset documentation.
	(TUI Configuration): Document "set tui tab-width".
2018-10-19 17:22:27 -06:00