aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui
AgeCommit message (Collapse)AuthorFilesLines
2020-01-09gdb/tui: Link source and assembler scrolling .... againAndrew Burgess1-1/+3
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 b4b49dcbff6b437fa8b4e2fc0c3f27b457f11310 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-09gdb: Fix scrolling in TUITom Tromey1-10/+13
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-09gdb/tui: Fix 'layout asm' before the inferior has startedAndrew Burgess1-4/+6
Currently if a user starts the tui with 'layout asm' then they will be presented with the 'src' layout. What happens is: 1. Layout command enables TUI, selecting the SRC layout by default. 2. As part of tui_enable we call tui_display_main, which calls tui_get_begin_asm_address, which calls set_default_source_symtab_and_line. This changes core GDBs current symtab and line, which triggers a call to the symtab changed hook tui_symtab_changed, which sets the flag from_source_symtab. 3. Back in the layout command, the layout is changed from SRC to ASM. After this the layout command completes and we return to core GDB which prints the prompt, however... 4. The before prompt hook is called which sees the from_source_symtab flag is set and forces the SRC window to be displayed. This switches us back to SRC view. The solution I propose here is to delay installing the hooks into core GDB until after we have finished setting up the tui and selecting the default frame to view. In this way we effectively ignore the first symtab changed event triggered when making main the default symtab. gdb/ChangeLog: * tui/tui.c (tui_enable): Register tui hooks after calling tui_display_main. gdb/testsuite/ChangeLog: * gdb.tui/tui-layout-asm.exp: New file. Change-Id: I858ab81a17ffb4aa72deb3f36c3755228a9c9d9a
2020-01-06GDB: Fix the overflow in addr/line_is_displayed()Shahab Vahedi2-18/+15
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-06GDB: Remove trailing spaces in tui-disasm.cShahab Vahedi1-3/+3
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-05gdb: use tui_set_layout not show_layout to fix window focusAndrew Burgess1-6/+6
When calling tui_add_win_to_layout, use tui_set_layout not show_layout so that window focus is correctly updated. If the focus is not correctly maintained then GDB can be crashed like this: start tui enable layout asm list SOME_FUNCTION At this point GDB will have "popped up" the source window to display SOME_FUNCTION. Previously no window would have focus at this point, and so if the user now does 'focus next' or 'focus prev', then GDB would crash. Calling tui_set_layout ensures that focus is correctly calculated as the source window is "popped up", and this fixes the issue. gdb/ChangeLog: * tui/tui-layout.c (tui_add_win_to_layout): Use tui_set_layout not show_layout. gdb/testsuite/ChangeLog: * gdb.tui/list.exp: Test 'focus next' after 'list main'. Change-Id: Id0b13f99b0e889261efedfd0adabe82020202f44
2020-01-01Update copyright year range in all GDB files.Joel Brobecker31-31/+31
gdb/ChangeLog: Update copyright year range in all GDB files.
2019-12-30Make some TUI globals "static"Tom Tromey1-10/+10
This changes a few TUI globals to be "static". Tested by rebuilding. gdb/ChangeLog 2019-12-30 Tom Tromey <tom@tromey.com> * tui/tui-win.c (tui_border_mode_translate) (tui_border_kind_translate_vline, tui_border_kind_translate_hline) (tui_border_kind_translate_ulcorner) (tui_border_kind_translate_urcorner) (tui_border_kind_translate_llcorner) (tui_border_kind_translate_lrcorner, tui_active_border_mode) (tui_border_mode, tui_border_kind): Now static. Change-Id: Ibb49a0df195dfe780a5ba1f90e9125ab5f6b7ce1
2019-12-30Use "bool" in more spots in TUITom Tromey6-23/+21
This changes a few spots in the TUI to use "bool" rather than "int". Tested on x86-64 Fedora 28. gdb/ChangeLog 2019-12-30 Tom Tromey <tom@tromey.com> * tui/tui-interp.c (tui_start_enabled): Now bool. (_initialize_tui_interp): Update. * tui/tui-hooks.c (tui_refreshing_registers): Now bool. (tui_register_changed) (tui_refresh_frame_and_register_information): Update. * tui/tui-win.c (tui_update_variables): Return bool. * tui/tui-win.h (tui_update_variables): Return bool. * tui/tui.c (tui_get_command_dimension): Return bool. * tui/tui.h (tui_get_command_dimension): Return bool. Change-Id: I55b7f2d62d2ef88da3587dc914ada9f463ad8d2b
2019-12-27Remove dead code from TUITom Tromey2-58/+0
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-27Change tui_active to boolTom Tromey2-7/+7
This changes tui_active and tui_finish_init to have type "bool". gdb/ChangeLog 2019-12-27 Tom Tromey <tom@tromey.com> * tui/tui.c (tui_active): Now bool. (tui_finish_init): Likewise. (tui_enable): Update. (tui_disable): Update. (tui_is_window_visible): Update. * tui/tui.h (tui_active): Now bool. Change-Id: Ia159ae9beb041137e34956b77f5bcf4e83eaf2b9
2019-12-27Remove tui_gen_win_info::viewport_heightTom Tromey5-17/+2
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-20Don't call tui_show_source from tui_ui_outTom Tromey3-18/+1
This removes the call to tui_show_source from tui_ui_out. This always seemed like a hack, and now that the TUI is using the proper observers, it seems not to be needed. The rest of the logic remains, unfortunately, because it is needed to suppress some gdb output in the TUI case. We could probably find a nicer way to do this (maybe a ui_out_flag), but I haven't attempted this. This was the last caller of tui_show_source, so this is removed as well. gdb/ChangeLog 2019-12-20 Tom Tromey <tom@tromey.com> * tui/tui.c (tui_show_source): Remove. * tui/tui.h (tui_show_source): Don't declare. * tui/tui-out.c (tui_ui_out::do_field_string): Don't call tui_show_source. Change-Id: Id71098e597ee4ebfef0429562baa45f537bd2c2b
2019-12-20Change tui_show_frame_info to return boolTom Tromey3-11/+9
This changes tui_show_frame_info to return bool. gdb/ChangeLog 2019-12-20 Tom Tromey <tom@tromey.com> * tui/tui-stack.h (tui_show_frame_info): Return bool. * tui/tui-stack.c (tui_show_frame_info): Return bool. * tui/tui-hooks.c (tui_refresh_frame_and_register_information): Update. Change-Id: Id1374f04f919c30a9f50c1beeb70cbc10b9a8f3b
2019-12-20Fix "list" command in the TUITom Tromey1-44/+58
PR tui/18932 notes that "list" no longer works in the TUI. At some point in the past, it switched the TUI source window to show the specified source; but now this source briefly flashes before the TUI reverts to showing the current stack frame's source. This patch fixes this bug by introducing a new observer that notices when the user selected context has changed. Then, the existing before-prompt observer is updated to request the correct update: either one based on the current stack frame, or one based on the user's source symtab_and_line. gdb/ChangeLog 2019-12-20 Tom Tromey <tom@tromey.com> PR tui/18932: * tui/tui-hooks.c (tui_refresh_frame_and_register_information): Rename parameters. Handle the not-from-stack-frame case. (from_stack, from_source_symtab): New globals. (tui_before_prompt, tui_normal_stop): Update. (tui_context_changed, tui_symtab_changed): New functions. (tui_attach_detach_observers): Attach new observers. gdb/testsuite/ChangeLog 2019-12-20 Tom Tromey <tom@tromey.com> * gdb.tui/list-before.exp: New file. Change-Id: I62013825f6c1afdd568a1c7a8c019b0c881131af
2019-12-20Use bool in tui_before_promptTom Tromey1-3/+3
This changes tui_before_prompt to take a bool rather than an int. gdb/ChangeLog 2019-12-20 Tom Tromey <tom@tromey.com> * tui/tui-hooks.c (tui_before_prompt): Change parameter to bool. (tui_before_prompt, tui_normal_stop): Update. Change-Id: I9c7f2b764748fe19621851dc4fed4775a6db211a
2019-12-20Don't call set_current_source_symtab_and_line from TUITom Tromey1-7/+0
update_source_window_as_is calls set_current_source_symtab_and_line, but I don't think there is any reason it should be doing this. This patch removes the call. 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 call set_current_source_symtab_and_line. Change-Id: I1152fc7c78150974bd3d555b8568a6f88b65dbe6
2019-12-20Change set_locator_info to take a symtab_and_lineTom Tromey2-38/+24
This changes set_locator_info to take a symtab_and_line, rather than the individual components. gdb/ChangeLog 2019-12-20 Tom Tromey <tom@tromey.com> * tui/tui-stack.h (struct tui_locator_window) <set_locator_info>: Take a symtab_and_line. * tui/tui-stack.c (tui_locator_window::set_locator_info): Take a symtab_and_line. (tui_show_frame_info): Update. Change-Id: Icb58d67e6c5bdc034eede9e5bbe8c1d1e633fbb5
2019-12-20Remove a call to update_exec_infoTom Tromey1-4/+1
tui_show_frame_info calls update_exec_info after calling erase_source_content, but there's no need to do this, as erase_source_content already clears the exec info. gdb/ChangeLog 2019-12-20 Tom Tromey <tom@tromey.com> * tui/tui-stack.c (tui_show_frame_info): Don't call update_exec_info. Change-Id: I63d658561028ac1bc0a0a2b7ac17da1b9c6134fe
2019-12-20Display "main" on initial TUI startupTom Tromey1-0/+2
I noticed that even when there's a symbol file, "tui enable" won't show "main" by default. I think it should, and this patch fixes this. gdb/ChangeLog 2019-12-20 Tom Tromey <tom@tromey.com> * tui/tui.c (tui_enable): Call tui_display_main. gdb/testsuite/ChangeLog 2019-12-20 Tom Tromey <tom@tromey.com> * gdb.tui/list.exp: Check for source on initial listing. Change-Id: Ic7bfc930e1179f5b61111e30a2dae46a98b00064
2019-12-20Reimplement tui_get_begin_asm_addressTom Tromey1-14/+17
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-20Simplify tui_update_source_windows_with_lineTom Tromey3-31/+10
This changes tui_update_source_windows_with_line to take a symtab_and_line, rather than separate parameters, and then updates the caller. gdb/ChangeLog 2019-12-20 Tom Tromey <tom@tromey.com> * tui/tui.c (tui_show_source): Update. * tui/tui-winsource.h (tui_update_source_windows_with_line): Update. * tui/tui-winsource.c (tui_update_source_windows_with_line): Take a symtab_symbol_info, not a separate symtab and line. Simplify. Change-Id: I8803a0a6fd2938ceee859aea53a57ce582f3e80d
2019-12-20Simplify tui_update_source_windows_with_addrTom Tromey1-13/+4
After the previous changes, tui_update_source_windows_with_addr simply updates each source-like window separately, passing the same data to each. So, it can be simplified by using a loop instead. gdb/ChangeLog 2019-12-20 Tom Tromey <tom@tromey.com> * tui/tui-winsource.c (tui_update_source_windows_with_addr): Simplify. Change-Id: Id2ba6b3145ec005dbed1b1115118bd1ef4efb842
2019-12-20Use symtab_and_line when updating TUI windowsTom Tromey6-81/+64
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-20Use start_line_or_addr in TUI windowsTom Tromey3-4/+4
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-20Change tui_source_window_base::set_contents to return boolTom Tromey6-89/+80
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-20Remove tui_source_window::show_symtab_sourceTom Tromey3-17/+2
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-20Remove tui_show_disassemTom Tromey3-19/+9
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-20Remove some unnecessary focus switchesTom Tromey2-12/+0
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-20Simplify tui_source_window_base::maybe_update methodTom Tromey6-25/+21
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-20Remove some TUI assertsTom Tromey1-6/+0
This removes a few asserts from the TUI. These asserts aren't useful, because they simply check an invariant that's already ensured by the type system. gdb/ChangeLog 2019-12-20 Tom Tromey <tom@tromey.com> * tui/tui-winsource.c (tui_source_window_base::set_is_exec_point_at) (tui_source_window_base::update_breakpoint_info): Remove asserts. Change-Id: I807e1e9bdb0cfa475e70375ceca3a5d4f2eb8d0b
2019-12-20Remove tui_show_disassem_and_update_sourceTom Tromey3-37/+4
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-20Remove parameters from tui_show_sourceTom Tromey3-4/+4
tui_show_source does not need its parameters, so this removes them. gdb/ChangeLog 2019-12-20 Tom Tromey <tom@tromey.com> * tui/tui.h (tui_show_source): Remove parameters. * tui/tui.c (tui_show_source): Remove parameters. * tui/tui-out.c (tui_ui_out::do_field_string): Update. Change-Id: I7cbcf20175b459c269549f1832d4fb844cc573db
2019-12-20Change tui_update_locator_fullname to take a symtabTom Tromey5-13/+11
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-20Make isearch change readline prompt in TUITom Tromey1-10/+1
PR tui/23619 points out that isearch changes the prompt in the CLI gdb (and in Bash) -- but not in the TUI. This turns out to be easily fixed by removing tui_rl_saved_prompt and instead using the prompt that readline computes. This is stored in rl_display_prompt, which according to git was added in readline 6.2. gdb/ChangeLog 2019-12-20 Tom Tromey <tom@tromey.com> PR tui/23619: * tui/tui-io.c (tui_rl_saved_prompt): Remove. (tui_redisplay_readline): Use rl_display_prompt. (tui_prep_terminal): Update. Change-Id: Iae97e9776a5540bbe52c73b05e4707941d9cd11a
2019-12-19Cast the log10 argument to double to disambiguate itChristian Biesinger1-1/+3
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-17Add virtual destructor to tui_layout_baseSimon Marchi1-0/+2
I stumbled on some ASan failures when using the TUI, when tearing down a TUI layout. The simplest way to trigger it is to run: $ ./gdb --data-directory=data-directory -batch -ex "layout next" The ASan report is: ================================================================= ==2829136==ERROR: AddressSanitizer: new-delete-type-mismatch on 0x608000009a20 in thread T0: object passed to delete has wrong type: size of the allocated type: 88 bytes; size of the deallocated type: 24 bytes. #0 0x7f470fe2507e in operator delete(void*, unsigned long) /build/gcc/src/gcc/libsanitizer/asan/asan_new_delete.cc:177 #1 0x55f88c75700d in std::default_delete<tui_layout_base>::operator()(tui_layout_base*) const /usr/include/c++/9.2.0/bits/unique_ptr.h:81 #2 0x55f88c756328 in std::unique_ptr<tui_layout_base, std::default_delete<tui_layout_base> >::~unique_ptr() /usr/include/c++/9.2.0/bits/unique_ptr.h:284 #3 0x7f470ee536a6 in __run_exit_handlers (/usr/lib/libc.so.6+0x3e6a6) #4 0x7f470ee5385d in __GI_exit (/usr/lib/libc.so.6+0x3e85d) #5 0x55f88c69f2ac in quit_force(int*, int) /home/simark/src/binutils-gdb/gdb/top.c:1766 #6 0x55f88becc29a in captured_main_1 /home/simark/src/binutils-gdb/gdb/main.c:1183 #7 0x55f88becc814 in captured_main /home/simark/src/binutils-gdb/gdb/main.c:1192 #8 0x55f88becc8a9 in gdb_main(captured_main_args*) /home/simark/src/binutils-gdb/gdb/main.c:1217 #9 0x55f88b3159cd in main /home/simark/src/binutils-gdb/gdb/gdb.c:32 #10 0x7f470ee3c152 in __libc_start_main (/usr/lib/libc.so.6+0x27152) #11 0x55f88b31579d in _start (/home/simark/build/binutils-gdb/gdb/gdb+0x11fb79d) 0x608000009a20 is located 0 bytes inside of 88-byte region [0x608000009a20,0x608000009a78) allocated by thread T0 here: #0 0x7f470fe238f8 in operator new(unsigned long) /build/gcc/src/gcc/libsanitizer/asan/asan_new_delete.cc:104 #1 0x55f88c750906 in tui_layout_split::clone() const /home/simark/src/binutils-gdb/gdb/tui/tui-layout.c:515 #2 0x55f88c74e60e in show_layout /home/simark/src/binutils-gdb/gdb/tui/tui-layout.c:90 #3 0x55f88c74e7db in tui_set_layout(tui_layout_type) /home/simark/src/binutils-gdb/gdb/tui/tui-layout.c:116 #4 0x55f88c782f4f in tui_enable() /home/simark/src/binutils-gdb/gdb/tui/tui.c:481 #5 0x55f88c74eeb2 in tui_layout_command /home/simark/src/binutils-gdb/gdb/tui/tui-layout.c:286 #6 0x55f88b6f969b in do_const_cfunc /home/simark/src/binutils-gdb/gdb/cli/cli-decode.c:107 #7 0x55f88b701859 in cmd_func(cmd_list_element*, char const*, int) /home/simark/src/binutils-gdb/gdb/cli/cli-decode.c:1952 #8 0x55f88c69b455 in execute_command(char const*, int) /home/simark/src/binutils-gdb/gdb/top.c:652 #9 0x55f88bec9026 in catch_command_errors /home/simark/src/binutils-gdb/gdb/main.c:400 #10 0x55f88becc1f2 in captured_main_1 /home/simark/src/binutils-gdb/gdb/main.c:1167 #11 0x55f88becc814 in captured_main /home/simark/src/binutils-gdb/gdb/main.c:1192 #12 0x55f88becc8a9 in gdb_main(captured_main_args*) /home/simark/src/binutils-gdb/gdb/main.c:1217 #13 0x55f88b3159cd in main /home/simark/src/binutils-gdb/gdb/gdb.c:32 #14 0x7f470ee3c152 in __libc_start_main (/usr/lib/libc.so.6+0x27152) The problem is that the tui_layout_base is missing a virtual destructor. We allocate a derived object (tui_layout_split), but delete it through a tui_layout_base pointer. Since the tui_layout_base destructor is not virtual, the derived (tui_layout_split) destructor is not called, only the base destructor. That code is not in gdb-9-branch, so I don't think this patch is relevant for the stable branch. Note that this is caught as a diagnostic with clang: In file included from /home/simark/src/binutils-gdb/gdb/tui/tui-layout.c:22: In file included from /home/simark/src/binutils-gdb/gdb/defs.h:28: In file included from /home/simark/src/binutils-gdb/gdb/gdbsupport/common-defs.h:133: In file included from /home/simark/src/binutils-gdb/gdb/gdbsupport/common-exceptions.h:25: In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../include/c++/9.2.0/memory:80: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../include/c++/9.2.0/bits/unique_ptr.h:81:2: error: delete called on 'tui_layout_base' that is abstract but has non-virtual destructor [-Werror,-Wdelete-abstract-non-virtual-dtor] delete __ptr; ^ /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../include/c++/9.2.0/bits/unique_ptr.h:284:4: note: in instantiation of member function 'std::default_delete<tui_layout_base>::operator()' requested here get_deleter()(std::move(__ptr)); ^ /home/simark/src/binutils-gdb/gdb/tui/tui-layout.c:54:41: note: in instantiation of member function 'std::unique_ptr<tui_layout_base, std::default_delete<tui_layout_base> >::~unique_ptr' requested here static std::unique_ptr<tui_layout_base> applied_layout; ^ 1 error generated. GCC has the similar -Wdelete-non-virtual-dtor, enabled by -Wall, but it doesn't show up because warnings are inhibited for system headers, where std::unique_ptr is defined. There is a bug about it here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876 gdb/ChangeLog: * tui/tui-layout.h (class tui_layout_base): Add virtual destructor.
2019-12-11Change "winheight" resizing to use new layout codeTom Tromey3-279/+14
The "winheight" command resizes a specified window, resizing the other windows in the layout to adapt. In the current code, this is done by examining each possible layout separately. The new layout code has a more general approach to handling this, and this patch simply removes the old code in favor of a call into the new layout engine. gdb/ChangeLog 2019-12-11 Tom Tromey <tom@tromey.com> * tui/tui-win.c (tui_set_win_height_command): Call tui_adjust_window_height. (tui_adjust_win_heights, new_height_ok): Remove. * tui/tui-layout.h (tui_adjust_window_height): Declare. * tui/tui-layout.c (tui_adjust_window_height): New function. Change-Id: I6bb681375a46adc8d29fd06f581deed4e078e78a
2019-12-11Re-apply the current layout when resizingTom Tromey1-104/+2
The TUI has separate code for each possible layout to handle the case where the terminal window is resized. With the new layout code, this can all be replaced with a call to tui_apply_current_layout, which simply re-applies the current layout. This results in some small differences in behavior when resizing, so some tests are updated. gdb/ChangeLog 2019-12-11 Tom Tromey <tom@tromey.com> * tui/tui-win.c (tui_resize_all): Remove code, call tui_apply_current_layout. gdb/testsuite/ChangeLog 2019-12-11 Tom Tromey <tom@tromey.com> * gdb.tui/resize.exp: Update. * gdb.tui/empty.exp (layouts): Update. Change-Id: I3dc6c02a753d495d9ab5e8213d550a147198ce6f
2019-12-11First use of tui_layoutTom Tromey2-167/+52
This patch introduces the first use of tui_layout, by changing show_layout to clone and use the appropriate tui_layout. This resulted in one minor layout change, and also in the unintended -- but good -- side effect that the title of each boxed window is now visible. gdb/ChangeLog 2019-12-11 Tom Tromey <tom@tromey.com> * tui/tui-layout.h (tui_apply_current_layout): Declare. * tui/tui-layout.c (standard_layouts, applied_layout): New globals. (tui_apply_current_layout): New function. (show_layout): Set applied_layout. Call tui_apply_current_layout. (show_source_command, show_disasm_command) (show_source_disasm_command, show_data) (show_source_or_disasm_and_command): Remove. (initialize_layouts): New function. (_initialize_tui_layout): Call initialize_layouts. gdb/testsuite/ChangeLog 2019-12-11 Tom Tromey <tom@tromey.com> * gdb.tui/regs.exp: Update. * gdb.tui/empty.exp (layouts): Update. * gdb.tui/basic.exp: Update. * lib/tuiterm.exp (_check_box): Don't check bottom border. Change-Id: If1ee06ee58f4803e8c213f4ab0f5bb59f4650ec2
2019-12-11Introduce new layout codeTom Tromey2-0/+506
This introduces a new approach to window layout for the TUI. The idea behind this code is that a layout should be specified in a declarative way, and then be applied by generic code that does not need to know the specifics of every possible layout. This patch itself does not change any behavior, because the new layout engine isn't yet connected to anything. That is, this merely introduces the implementation. This generic approach makes the code more maintainable. It also enables some future changes: * New window types are simpler to add; * User-specified layouts are possible; and * Horizontal layouts are more attainable gdb/ChangeLog 2019-12-11 Tom Tromey <tom@tromey.com> * tui/tui-layout.h (class tui_layout_base) (class tui_layout_window, class tui_layout_split): New. * tui/tui-layout.c (tui_get_window_by_name) (tui_layout_window::clone, tui_layout_window::apply) (tui_layout_window::get_sizes, tui_layout_window::add_split) (tui_layout_split::add_window, tui_layout_split::clone) (tui_layout_split::get_sizes) (tui_layout_split::set_weights_from_heights) (tui_layout_split::adjust_size, tui_layout_split::apply): New functions. (tui_layout_split::add_split, tui_layout_split::add_split) (tui_layout_split::set_weights_from_heights) (tui_layout_split::set_weights_from_heights): New functions. Change-Id: I3a4cae666327b617d862aaa356f8179f945c6a4e
2019-12-11Remove struct tui_pointTom Tromey5-30/+25
struct tui_point does not help very much. It is only used for storage, and never passed between functions. I think it makes the code more verbose without any corresponding benefit, so this patch removes it. gdb/ChangeLog 2019-12-11 Tom Tromey <tom@tromey.com> * tui/tui-wingeneral.c (tui_gen_win_info::make_window): Update. * tui/tui-win.c (tui_adjust_win_heights, tui_resize_all): Update. * tui/tui-layout.c (tui_gen_win_info::resize): Update. * tui/tui-data.h (struct tui_point): Remove. (struct tui_gen_win_info) <origin>: Remove. <x, y>: New fields. * tui/tui-command.c (tui_cmd_window::resize): Update. Change-Id: I3f77920585b9ea9e2b4b189f3f3ae32d4da0c252
2019-12-11Introduce the tui_gen_win_info::min_height methodTom Tromey3-0/+18
This introduces a new method, tui_gen_win_info::min_height, to fetch the minimum height of a window. This is used in the subsequent unified layout patch. gdb/ChangeLog 2019-12-11 Tom Tromey <tom@tromey.com> * tui/tui-stack.h (struct tui_locator_window) <min_height>: Implement. * tui/tui-regs.h (struct tui_data_item_window) <min_height>: Implement. * tui/tui-data.h (struct tui_gen_win_info) <min_height>: New method. (struct tui_win_info) <min_height>: Implement. Change-Id: Id33baffdf041fde072e15c1ff89b75f8b8118adb
2019-12-11Move can_box to tui_gen_win_infoTom Tromey1-1/+7
This moves the can_box method to tui_gen_win_info, so that it will be available on the tui_locator_window class. This will be used in a subsequent patch. gdb/ChangeLog 2019-12-11 Tom Tromey <tom@tromey.com> * tui/tui-data.h (struct tui_gen_win_info) <can_box>: New method. (struct tui_win_info) <can_box>: Update. Change-Id: Idfa58af41341607932d3c39415f6a35ee9b5d3dc
2019-12-11Move max_height method to tui_gen_win_infoTom Tromey3-2/+14
This moves the max_height method to tui_gen_win_info and implements it in the subclasses. This is used by a subsequent patch, which will normalize window layout across all window types. gdb/ChangeLog 2019-12-11 Tom Tromey <tom@tromey.com> * tui/tui-stack.h (struct tui_locator_window) <max_height>: New method. * tui/tui-regs.h (struct tui_data_item_window) <max_height>: New method. * tui/tui-data.h (struct tui_gen_win_info) <max_height>: New method. (struct tui_win_info) <max_height>: Now override. Change-Id: I4ba3e8899bc4668328d3d78e3c1674c61882450d
2019-12-01Treat inactive TUI specially in "info win"Tom Tromey1-0/+6
I noticed that "info win" will print the table header, but no windows, when the TUI is inactive. This patch changes this to print a message instead. gdb/ChangeLog 2019-12-01 Tom Tromey <tom@tromey.com> * tui/tui-win.c (tui_all_windows_info): Treat inactive TUI specially. Change-Id: Ia860be8c786a71289da6609aa14d86b8365424db
2019-12-01Fix latent bug in tui_copy_source_lineTom Tromey1-0/+2
tui_copy_source_line has a bug, where it can advance past the terminating \0 in its input string. This patch fixes the bug and adds a test case for this function. gdb/ChangeLog 2019-12-01 Tom Tromey <tom@tromey.com> * tui/tui-winsource.c (tui_copy_source_line): Don't advance past \0. * unittests/tui-selftests.c: New file. * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add tui-selftests.c. Change-Id: I46cdabe6e57549983149b8f640cda5edd16fa260
2019-12-01Re-highlight windows when needed during TUI startupTom Tromey1-2/+3
I noticed that "tui enable" did not correctly show the source window as having the focus. Debugging showed that the problem was that tui_update_variables was called after the windows were drawn, and its result was being ignored. This changed the code to re-highlight the windows if the value changed. gdb/ChangeLog 2019-12-01 Tom Tromey <tom@tromey.com> * tui/tui.c (tui_enable): Call tui_update_variables earlier. Change-Id: I1a4563fb431833dd3211a224c9e2df3b936fe9ce
2019-12-01Add TUI border colorsTom Tromey4-4/+19
This adds the ability to change the color of the TUI borders, both ordinary and active. Unlike other styling options, this doesn't allow setting the intensity, because that is already done by the TUI in a different way. gdb/ChangeLog 2019-12-01 Tom Tromey <tom@tromey.com> * NEWS: Document new settings. * tui/tui-wingeneral.c (box_win): Apply appropriate border style. * tui/tui-win.c (_initialize_tui_win): Add border style observers. * tui/tui-io.h (tui_apply_style): Declare. * tui/tui-io.c (tui_apply_style): Rename from apply_style. No longer static. (apply_ansi_escape, tui_set_reverse_mode): Update. * cli/cli-style.h (class cli_style_option) <add_setshow_commands>: Add "skip_intensity" parameter. <changed>: New member. <do_set_value>: Declare. (tui_border_style, tui_active_border_style): Declare. * cli/cli-style.c (tui_border_style, tui_active_border_style): New globals. (cli_style_option): Initialize "changed". (cli_style_option::do_set_value): New function. (cli_style_option::add_setshow_commands): Add "skip_intensity" parameter. Update. (STYLE_ADD_SETSHOW_COMMANDS): Add "SKIP" parameter. (_initialize_cli_style): Update. Create TUI border style commands. gdb/doc/ChangeLog 2019-12-01 Tom Tromey <tom@tromey.com> * gdb.texinfo (TUI Configuration): Mention TUI border styles. (Output Styling): Document new settings. Change-Id: Id13e2af0af2a0bde61282752f2c379db3220c9fc
2019-12-01Allow using less horizontal space in TUI source windowTom Tromey6-11/+67
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