Commit Graph

114 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
Shahab Vahedi 1d5d29e73f gdb: Catch exceptions if the source file is not found
The source_cache::ensure method may throw an exception through
the invocation of source_cache::get_plain_source_lines. This
happens when the source file is not found. The expected behaviour
of "ensure" is only returning "true" or "false" according to the
documentation in the header file.

So far, if gdb is in source layout and a file is missing, you see
some outputs like below:

 ,---------------------------------------------.
 | test.c file is loaded in the source window. |
 |                                             |
 | int main()                                  |
 | ...                                         |
 |---------------------------------------------|
 | Remote debugging using :1234                |
 | __start () at /path/to/crt0.S:141           |
 | /path/to/crt0.S: No such file or directory. |
 | (gdb) p/x $pc                               |
 | $1 = 0x124                                  |
 | (gdb) n                                     |
 | /path/to/crt0.S: No such file or directory. |
 | (gdb) p/x $pc                               |
 | $2 = 0x128                                  |
 | (gdb) [pressing arrow-down key]             |
 | (gdb) terminate called after throwing an    |
 |       instance of 'gdb_exception_error'     |
 `---------------------------------------------'
Other issues have been encountered as well [1].

The patch from Pedro [2] which is about preventing exceptions
from crossing the "readline" mitigates the situation by not
causing gdb crash, but still there are lots of errors printed:

 ,---------------------------------------------.
 | test.c file is loaded in the source window. |
 |                                             |
 | int main()                                  |
 | ...                                         |
 |---------------------------------------------|
 | Remote debugging using :1234                |
 | __start () at /path/to/crt0.S:141           |
 | /path/to/crt0.S: No such file or directory. |
 | (gdb) [pressing arrow-down key]             |
 | /path/to/crt0.S: No such file or directory. |
 | (gdb) [pressing arrow-down key]             |
 | /path/to/crt0.S: No such file or directory. |
 | (gdb) [pressing arrow-up key]               |
 | /path/to/crt0.S: No such file or directory. |
 `---------------------------------------------'

With the changes of this patch, the behavior is like:
 ,---------------------------------------------.
 | initially, source window is empty because   |
 | crt0.S is not found and according to the    |
 | program counter that is the piece of code   |
 | being executed.                             |
 |                                             |
 | later, when we break at main (see commands  |
 | below), this window will be filled with the |
 | the contents of test.c file.                |
 |---------------------------------------------|
 | Remote debugging using :1234                |
 | __start () at /path/to/crt0.S:141           |
 | (gdb) p/x $pc                               |
 | $1 = 0x124                                  |
 | (gdb) n                                     |
 | (gdb) p/x $pc                               |
 | $2 = 0x128                                  |
 | (gdb) b main                                |
 | Breakpoint 1 at 0x334: file test.c, line 8. |
 | (gdb) cont                                  |
 | Continuing.                                 |
 | Breakpoint 1, main () at hello.c:8          |
 | (gdb) n                                     |
 | (gdb)                                       |
 `---------------------------------------------'

There is no crash and the error message is completely
gone. Maybe it is good practice that the error is
shown inside the source window.

I tested this change against gdb.base/list-missing-source.exp
and there was no regression.

[1]
It has also been observed in the past that the register
values are not transferred from qemu's gdb stub, see:
https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/issues/226

[2]
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=2f267673f0fdee9287e6d404ecd4f2d29da0d2f2

gdb/ChangeLog:

	* source-cache.c (source_cache::ensure): Surround
	get_plain_source_lines with a try/catch.
	(source_cache::get_line_charpos): Get rid of try/catch
	and only check for the return value of "ensure".
	* tui/tui-source.c (tui_source_window::set_contents):
	Simplify "nlines" calculation.

gdb/testsuite/ChangeLog:

	* gdb.tui/tui-missing-src.exp: Add the "missing source
	file" test for the TUI.
2020-02-06 17:54:59 +01:00
Andrew Burgess f5a7c406b1 gdb/tui: Link source and assembler scrolling .... again
Until recently when the source window was scrolled the assembler
window would scroll in sync - keeping the disassembly for the current
line in view.

This was broken in commit:

  commit b4b49dcbff
  Date:   Wed Nov 13 16:47:58 2019 -0700

      Don't call tui_show_source from tui_ui_out

This commit restores the synchronised scrolling and also maintains the
horizontal scroll within the source view when it is vertically
scrolled, something that was broken before.

This commit does not mean that scrolling the assembler view scrolls
the source view.  The connection this way never existed, though maybe
it should, but I'll leave adding this feature for a separate commit.

gdb/ChangeLog:

	* tui/tui-source.c (tui_source_window::do_scroll_vertical): Update
	all source windows, and maintain horizontal scroll status while
	doing so.

gdb/testsuite/ChangeLog:

	* gdb.tui/basic.exp: Add more scrolling tests.

Change-Id: I250114a3bc670040a6a759d41905776771b2f818
2020-01-09 23:11:47 +00:00
Tom Tromey 9ae6bf640d gdb: Fix scrolling in TUI
Hannes Domani pointed out that my previous patch to fix the "list"
command in the TUI instead broke vertical scrolling.  While looking at
this, I found that do_scroll_vertical calls print_source_lines, which
seems like a very roundabout way to change the source window.  This
patch removes this oddity and fixes the bug at the same time.

I've added a new test case.  This is somewhat tricky, because the
obvious approach of sending a dummy command after the scroll did not
work -- due to how the TUI works, sennding a command causes the scroll
to take effect.

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

	PR tui/18932:
	* tui/tui-source.c (tui_source_window::do_scroll_vertical): Call
	update_source_window, not print_source_lines.

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

	PR tui/18932:
	* lib/tuiterm.exp (Term::wait_for): Rename from _accept.  Return a
	meangingful value.
	(Term::command, Term::resize): Update.
	* gdb.tui/basic.exp: Add scrolling test.

Change-Id: I9636a7c8a8cade37431c6165ee996a9d556ef1c8
2020-01-09 23:11:46 +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
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 ace206a5a5 Remove dead code from TUI
I found some dead code in the TUI -- some using #if 0, and some
commented-out code.  There's no reason to keep this, so this patch
removes it.

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

	* tui/tui-source.c (tui_source_window::do_scroll_vertical): Remove
	commented-out code.
	* tui/tui.c: Remove #if 0 code.

Change-Id: Ie00933b2ba498417ce22e5da3f62f5a40c234f33
2019-12-27 09:44:34 -07:00
Tom Tromey 1630140dc6 Remove tui_gen_win_info::viewport_height
tui_gen_win_info::viewport_height is only used in a couple of spots,
and is redundant with "height".  This patch removes viewport_height.

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

	* tui/tui-source.c (tui_source_window::maybe_update): Update.
	* tui/tui-regs.c (tui_data_window::display_registers_from):
	Update.
	* tui/tui-layout.c (tui_gen_win_info::resize): Update.
	* tui/tui-data.h (struct tui_gen_win_info) <viewport_height>:
	Remove.
	* tui/tui-command.c (tui_cmd_window::resize): Update.

Change-Id: I020e026fbe289adda8e2fdfebca91bdbdbc312e8
2019-12-27 09:33:36 -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 469b073133 Remove tui_source_window::show_symtab_source
tui_source_window::show_symtab_source is identical to
update_source_window, so remove the former.

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

	* tui/tui-winsource.c (tui_update_source_windows_with_addr)
	(tui_update_source_windows_with_line): Call update_source_window.
	* tui/tui-source.h (struct tui_source_window)
	<show_symtab_source>: Don't declare.
	* tui/tui-source.c (tui_source_window::show_symtab_source):
	Remove.

Change-Id: I41781df2126e8bafad46d058532d52602a288e06
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
Christian Biesinger 1cd4a20a27 Cast the log10 argument to double to disambiguate it
On Solaris 11 with gcc 5.5.0 (gcc211 on the compile farm), math.h has a
using std::log10; directive. This is unfortunate because std::log10 has
overloads for float/double/long double. To disambiguate this call,
cast the argument to double to fix the build.

gdb/ChangeLog:

2019-12-19  Christian Biesinger  <cbiesinger@google.com>

	* tui/tui-source.c (tui_source_window::set_contents): Cast argument of
	log10 to double to fix Solaris 11 with gcc 5.5.

Change-Id: I6c0c52e9c172b529c899a435d430e5916aeef69f
2019-12-19 13:11:29 -06: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 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 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 7226433c44 Rename a private data member in tui_source_window
This renames tui_source_window::fullname to add the "m_" prefix, as it
is a private data member.

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

	* tui/tui-source.h (struct tui_source_window) <m_fullname>: Rename
	from "fullname".
	* tui/tui-source.c (tui_source_window::set_contents)
	(tui_source_window::location_matches_p)
	(tui_source_window::maybe_update): Update.
2019-09-20 13:49:11 -06:00
Tom Tromey 9923f347c4 Change members of tui_locator_window to std::string
This changes two members of tui_locator_window to have type
std::string.  This removes a static limit.

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

	* tui/tui-stack.h (MAX_LOCATOR_ELEMENT_LEN): Remove define.
	(struct tui_locator_window) <full_name, proc_name>: Now
	std::string.
	* tui/tui-stack.c (tui_locator_window::make_status_line)
	(tui_locator_window::set_locator_fullname)
	(tui_locator_window::set_locator_info): Update.
	* tui/tui-source.c (tui_source_window::set_contents)
	(tui_source_window::showing_source_p): Update.
2019-09-20 13:49:10 -06:00
Tom Tromey 2d81b34998 Move "fullname" to tui_source_window
The "fullname" field in tui_source_window_base is only used by one
subclass.  This patch moves the field to that subclass, and changes it
to be a unique_xmalloc_ptr.

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

	* tui/tui-winsource.h (struct tui_source_window_base)
	<~tui_source_window_base>: Don't declare.
	<fullname>: Remove.
	* tui/tui-winsource.c (~tui_source_window_base): Remove.
	* tui/tui-source.h (struct tui_source_window) <fullname>: New
	member.
	* tui/tui-source.c (tui_source_window::set_contents): Update.
	(tui_source_window::location_matches_p)
	(tui_source_window::maybe_update): Update.
2019-09-20 13:49:05 -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 ab0e1f1a45 Change tui_make_window to be a method
I combined several small changes into one patch here.  I believe I
started by noticing that the "title" is not needed by tui_gen_win_info
and could be self-managing (i.e. std::string).  Moving this revealed
that "can_box" is also a property of tui_win_info and not
tui_gen_win_info; and this in turn caused the changes to
tui_make_window and box_win.

2019-08-20  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.h (tui_make_window): Don't declare.
	* tui/tui-wingeneral.c (box_win): Change type of win_info.
	(box_win): Update.
	(tui_gen_win_info::make_window): Rename from tui_make_window.
	(tui_win_info::make_window): New method.
	(tui_gen_win_info::make_visible): Update.
	* tui/tui-source.c (tui_source_window::set_contents): Update.
	* tui/tui-regs.c (tui_data_window::show_register_group): Update.
	(tui_data_window::display_registers_from): Update.
	* tui/tui-layout.c (tui_gen_win_info::resize): Update.
	* tui/tui-data.h (struct tui_gen_win_info) <make_window>:
	Declare.
	<can_box>: Remove.
	<title>: Remove.
	(struct tui_win_info) <make_window>: Declare.
	<can_box>: Now virtual.
	<title>: New member.
	* tui/tui-data.c (~tui_gen_win_info): Don't free title.
	* tui/tui-command.c (tui_cmd_window::resize): Update.
2019-08-20 16:45:50 -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 bb01dbfc04 Change tui_show_symtab_source to be a method
This changes tui_show_symtab_source to be a method on
tui_source_window.

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

	* tui/tui-winsource.c (tui_update_source_windows_with_addr)
	(tui_update_source_windows_with_line): Update.
	* tui/tui-source.h (struct tui_source_window)
	<show_symtab_source>: Declare.
	(tui_show_symtab_source): Don't declare.
	* tui/tui-source.c (tui_show_symtab_source): Rename from
	tui_show_symtab_source.
2019-08-16 11:28:34 -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 c9033fe839 Change tui_line_is_displayed to be a method
This changes tui_line_is_displayed to be a method on
tui_source_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_line_is_displayed): Don't declare.
	* tui/tui-winsource.c (tui_line_is_displayed): Move to
	tui-source.c.
	* tui/tui-source.h (struct tui_source_window) <line_is_displayed>:
	Declare.
	* tui/tui-source.c (tui_source_window::line_is_displayed): New
	method.
	(tui_source_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 cb44333d99 Add file offsets to the source cache
Currently, gdb stores the number of lines and an array of file offsets
for the start of each line in struct symtab.  This patch moves this
information to the source cache.  This has two benefits.

First, it allows gdb to read a source file less frequently.
Currently, a source file may be read multiple times: once when
computing the file offsets, once when highlighting, and then pieces
may be read again while printing source lines.  With this change, the
file is read once for its source text and file offsets; and then
perhaps read again if it is evicted from the cache.

Second, if multiple symtabs cover the same source file, then this will
share the file offsets between them.  I'm not sure whether this
happens in practice.

gdb/ChangeLog
2019-08-06  Tom Tromey  <tromey@adacore.com>

	* annotate.c (annotate_source_line): Use g_source_cache.
	* source-cache.c (source_cache::get_plain_source_lines): Change
	parameters.  Populate m_offset_cache.
	(source_cache::ensure): New method.
	(source_cache::get_line_charpos): New method.
	(extract_lines): Move lower.  Change parameters.
	(source_cache::get_source_lines): Move lower.
	* source-cache.h (class source_cache): Update comment.
	<get_line_charpos>: New method.
	<get_source_lines>: Update comment.
	<clear>: Clear m_offset_cache.
	<get_plain_source_lines>: Change parameters.
	<ensure>: New method
	<m_offset_cache>: New member.
	* source.c (forget_cached_source_info_for_objfile): Update.
	(info_source_command): Use g_source_cache.
	(find_source_lines, open_source_file_with_line_charpos): Remove.
	(print_source_lines_base, search_command_helper): Use g_source_cache.
	* source.h (open_source_file_with_line_charpos): Don't declare.
	* symtab.h (struct symtab) <nlines, line_charpos>: Remove.
	* tui/tui-source.c (tui_source_window::do_scroll_vertical):
	Use g_source_cache.
2019-08-06 08:04:33 -06:00
Tom Tromey 5104fe361d Move source window common to code to tui-winsource.[ch]
Like the previous rearranging patches, this moves the source and
disassembly window base class code to tui-winsource.[ch].  The
execution info window is also moved, because it is associated with
this base class.

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

	* tui/tui-winsource.h (struct tui_exec_info_window)
	(struct tui_source_window_base): Move from tui-data.h.
	* tui/tui-winsource.c: Move many method definitions from
	elsewhere.  Remove "structuring" comments.
	* tui/tui-wingeneral.c (tui_source_window_base::make_visible)
	(tui_source_window_base::refresh_window): Move to
	tui-winsource.c.
	* tui/tui-win.c (tui_source_window_base::refresh_all)
	(tui_source_window_base::update_tab_width)
	(tui_source_window_base::set_new_height)
	(tui_source_window_base::do_make_visible_with_new_height): Move to
	tui-winsource.c.
	* tui/tui-source.h: Update.
	* tui/tui-source.c (tui_source_window_base::reset): Move to
	tui-winsource.c.
	* tui/tui-disasm.h: Update.
	* tui/tui-data.h (struct tui_exec_info_window): Move to
	tui-winsource.h.
	(struct tui_source_window_base): Likewise.
	* tui/tui-data.c (tui_source_window_base::clear_detail)
	(tui_source_window_base, ~tui_source_window_base): Move to
	tui-winsource.c.
2019-07-17 12:19:25 -06:00
Tom Tromey 1e0c09ba0b Remove the win_type parameter from tui_gen_win_info::reset
tui_gen_win_info::reset has a window type parameter that is only used
for an assertion.  This made sense as a defensive measure when window
creation was more dynamic -- it ensured that one did not make
mistakes.  However, there's no need for it any more, so this removes
it.

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

	* tui/tui-source.c (tui_source_window_base::reset): Remove
	win_type parameter.
	* tui/tui-layout.c (make_command_window, make_source_window)
	(make_disasm_window, make_data_window)
	(show_source_disasm_command, show_data, tui_gen_win_info::reset)
	(reset_locator, show_source_or_disasm_and_command): Update.
	* tui/tui-data.h (struct tui_gen_win_info) <reset>: Remove
	win_type parameter.
	(struct tui_source_window_base) <reset>: Likewise.
2019-07-17 12:19:13 -06:00
Tom Tromey 098f9ed48e Always create an execution info window for a source window
A source or disassembly window will always have an "execution info"
window (the window along the side that displays breakpoint info), but
this isn't immediately clear from the source.  As a result, some code
has checks to see whether the execution_info is NULL.

This changes the source window base class to always instantiate an
execution_info window, then updates the rest of the code.  It also
simplifies window creation in tui-layout.c.

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

	* tui/tui-winsource.c (tui_set_exec_info_content): Remove
	condition.
	* tui/tui-wingeneral.c (tui_source_window_base::make_visible):
	Remove condition.
	* tui/tui-source.c (tui_source_window_base::reset): New method.
	* tui/tui-layout.c (make_command_window): Don't call
	init_and_make_win.
	(make_source_window, make_disasm_window): Don't call
	make_source_or_disasm_window.
	(make_data_window): Don't call init_and_make_win.  Change calling
	convention.
	(show_source_disasm_command, show_data): Simplify.
	(make_source_or_disasm_window): Remove.
	(show_source_or_disasm_and_command): Simplify.
	* tui/tui-data.h (struct tui_gen_win_info) <reset>: Now virtual.
	(struct tui_source_window_base) <reset>: Likewise.
	<execution_info>: Remove initializer.
	* tui/tui-data.c (tui_source_window_base): Initialize
	execution_info.
2019-07-17 12:19:12 -06:00
Tom Tromey f6cc34a91c Remove tui_source_window::content_in_use
Now that source window clearing has been simplified, we don't need a
special flag to say whether the source window is in use -- we can
simply check whether the contents are set.  This patch implements this
idea, removing the content_in_use field.

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

	* tui/tui-winsource.c (tui_clear_source_content)
	(tui_show_source_content): Update.
	* tui/tui-source.c (tui_source_window::showing_source_p): Check
	whether content is empty.
	* tui/tui-data.h (struct tui_source_window_base) <content_in_use>:
	Remove.
2019-07-17 12:19:09 -06:00
Tom Tromey f31ec9af48 Simplify source window clearing
When a TUI source window is empty, it displays a "No Source Available"
message.  The function tui_set_source_content_nil also made sure to
put this message into the window's "content" field.

However, I believe this isn't really necessary.  Instead, it's simpler
to just empty the contents and let curses handle the refreshing.

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

	* tui/tui-winsource.c (tui_erase_source_content): Clear the
	window's contents.
	* tui/tui-source.h (tui_set_source_content_nil): Don't declare.
	* tui/tui-source.c (tui_set_source_content_nil): Remove.
2019-07-17 12:19:09 -06:00
Tom Tromey a38da35d7b Move content_in_use to tui_source_window class
From scanning the source now, it's clear that the content_in_use field
is only used for the source window.  This patch moves the field there,
and changes it to be a bool at the same time.  (A future patch will
clean this up further, removing the field entirely.)

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

	* tui/tui-winsource.c (tui_clear_source_content)
	(tui_show_source_content, tui_show_exec_info_content)
	(tui_clear_exec_info_content): Update.
	* tui/tui-stack.c (tui_show_locator_content): Update.
	(tui_show_frame_info): Update.
	* tui/tui-source.h (tui_source_window): Don't declare.
	* tui/tui-source.c (tui_source_window::showing_source_p): Rename
	from tui_source_is_displayed.
	* tui/tui-data.h (struct tui_gen_win_info) <content_in_use>:
	Remove field.
	(struct tui_source_window_base) <content_in_use>: New field.  Now
	bool.
	(struct tui_source_window) <showing_source_p>: New method.
	(TUI_SRC_WIN): Change cast.
	* tui/tui-data.c (tui_initialize_static_data): Update.
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 b73dd8779c Make source windows be self-updating
This changes the TUI source window to register itself on the
source_styling_changed observable, and removes a bit of code from
tui-hooks.c.  This reduces the number of uses of the TUI_SRC_WIN
global.

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

	* tui/tui-source.c (tui_source_window): New constructor.  Add
	observer.
	(~tui_source_window): New destructor.
	(tui_source_window::style_changed): New method.
	* tui/tui-hooks.c (tui_redisplay_source): Remove.
	(tui_attach_detach_observers): Update.
	* tui/tui-data.h (struct tui_source_window): Make constructor not
	inline.  Add destructor.
	(struct tui_source_window) <style_changed>: New method.
	<m_observable>: New member.
2019-07-17 12:19:04 -06:00
Tom Tromey 5813316fa4 Remove some uses of TUI_WIN_SRC
This adds a 'win_info' parameter to a couple of functions.  This
reduces the number of references to the TUI_WIN_SRC global.

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

	* tui/tui-winsource.c (tui_update_source_window_as_is)
	(tui_update_source_windows_with_addr): Update.
	* tui/tui-source.h (tui_set_source_content)
	(tui_show_symtab_source): Add "win_info" parameter.
	* tui/tui-source.c (tui_set_source_content): Add "win_info"
	parameter.
	(tui_show_symtab_source): Likewise.
2019-07-17 12:18:52 -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 7908abbf18 More type safety for TUI source window functions
A few functions can only operate on a source or disassembly window.
This patch adds a bit more type safety to a few of these functions.
This simplifies a subsequent patch.

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

	* tui/tui-winsource.h (tui_clear_source_content)
	(tui_erase_source_content, tui_show_source_content): Change type
	of win_info.
	* tui/tui-winsource.c (tui_clear_source_content)
	(tui_erase_source_content, tui_show_source_content): Change type
	of win_info.
	* tui/tui-win.c (tui_resize_all, tui_adjust_win_heights): Update.
	* tui/tui-source.h (tui_set_source_content_nil): Change type of
	win_info.
	* tui/tui-source.c (tui_set_source_content_nil): Change type of
	win_info.
	* tui/tui-layout.c (show_source_or_disasm_and_command): Update.
2019-06-25 07:48:50 -06:00
Tom Tromey 02c28df011 Use bool for is_exec_point
This changes tui_source_element::is_exec_point to be a bool.  I looked
at also changing "has_break", but it turns out that this field is used
inconsistently (sometimes as flags and sometimes as a bool), and so
needs more invesstigation before it can be changed.

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

	* tui/tui-winsource.c (tui_clear_source_content)
	(tui_source_window_base::set_is_exec_point_at): Update.
	* tui/tui-source.c (tui_set_source_content_nil): Update.
	* tui/tui-data.h (struct tui_source_element) <is_exec_point>: Now
	a bool.
	* tui/tui-data.c (init_content_element): Update.
2019-06-25 07:48:49 -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