aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui/tui-winsource.c
AgeCommit message (Collapse)AuthorFilesLines
2019-11-05Style disassembly in the TUITom Tromey1-0/+99
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-05Change tui_source_element::line to have type std::stringTom Tromey1-1/+1
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-10-15Make tui-winsource not use breakpoint_chainChristian Biesinger1-7/+4
That's an internal variable of breakpoint.c. Insted, use iterate_over_breakpoints to update the breakpoint list. gdb/ChangeLog: 2019-10-15 Christian Biesinger <cbiesinger@google.com> * breakpoint.c (breakpoint_chain): Make static. * tui/tui-winsource.c: Call iterate_over_breakpoints instead of accessing breakpoint_chain. Change-Id: Ic259b2c3a4c1f5a47f34cfd7fccbdcf274417429
2019-10-09Make TUI window handle a unique_ptrTom Tromey1-11/+11
This changes tui_gen_win_info::handle to be a specialization of unique_ptr. This is perhaps mildly uglier in some spots, due to the proliferation of "get"; but on the other hand it cleans up some manual management and it allows for the removal of tui_delete_win. gdb/ChangeLog 2019-10-09 Tom Tromey <tom@tromey.com> * tui/tui-wingeneral.h (tui_delete_win): Don't declare. * tui/tui-stack.c (tui_locator_window::rerender): Update. * tui/tui-command.c (tui_cmd_window::resize) (tui_refresh_cmd_win): Update. * tui/tui-win.c (tui_resize_all, tui_set_focus_command): Update. * tui/tui.c (tui_rl_other_window, tui_enable): Update. * tui/tui-data.c (~tui_gen_win_info): Remove. * tui/tui-layout.c (tui_gen_win_info::resize): Update. * tui/tui-io.c (update_cmdwin_start_line, tui_putc, tui_puts) (tui_redisplay_readline, tui_mld_flush) (tui_mld_erase_entire_line, tui_mld_getc, tui_getc): Update. * tui/tui-regs.c (tui_data_window::delete_data_content_windows) (tui_data_window::erase_data_content) (tui_data_item_window::rerender) (tui_data_item_window::refresh_window): Update. * tui/tui-wingeneral.c (tui_gen_win_info::refresh_window) (box_win, tui_gen_win_info::make_window) (tui_gen_win_info::make_visible): Update. (tui_delete_win): Remove. * tui/tui-winsource.c (tui_source_window_base::do_erase_source_content): Update. (tui_show_source_line, tui_source_window_base::update_tab_width) (tui_source_window_base::update_exec_info): Update. * tui/tui-data.h (struct curses_deleter): New. (struct tui_gen_win_info) <handle>: Now a unique_ptr. (struct tui_gen_win_info) <~tui_gen_win_info>: Define.
2019-09-20Simplify tui_source_window_base::show_source_contentTom Tromey1-8/+3
tui_source_window_base::show_source_content is not used outside the class any more, so this makes it private. Examining the callers shows that it can't be called without source contents, so it can be simplified as well. gdb/ChangeLog 2019-09-20 Tom Tromey <tom@tromey.com> * tui/tui-winsource.h (struct tui_source_window_base) <show_source_content>: Now private. * tui/tui-winsource.c (tui_source_window_base::show_source_content): Don't handle empty content case.
2019-09-20Move "fullname" to tui_source_windowTom Tromey1-5/+0
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-20Change tui_source_element::line to be a unique_xmalloc_ptrTom Tromey1-2/+1
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-20Remove tui_clear_source_windows_detailTom Tromey1-11/+0
The calls to tui_clear_source_windows_detail in tui_add_win_to_layout aren't needed, because (after the resize unification) resizing will update the window contents. Removing these calls lets us remove several other things as well. gdb/ChangeLog 2019-09-20 Tom Tromey <tom@tromey.com> * tui/tui-data.h (tui_clear_source_windows_detail): Don't declare. * tui/tui-layout.c (tui_add_win_to_layout): Don't call tui_clear_source_windows_detail. * tui/tui-winsource.h (struct tui_source_window_base) <clear_detail>: Don't declare. * tui/tui-winsource.c (tui_source_window_base::clear_detail): Remove. * tui/tui-data.c (tui_clear_source_windows_detail): Remove.
2019-08-30Remove tui_win_info::refresh_allTom Tromey1-10/+0
The TUI has two duplicate "re-render this window" methods, "rerender" and "refresh_all". They differ only slightly in semantics, so I wanted to see if they could be unified. After looking into this, I decided that refresh_all was not needed. There are 4 calls to tui_refresh_all_win (the only caller of this method): 1. tui_enable. This sets the layout, which renders the windows. 2. tui_cont_sig. Here, I think it's sufficient to simply redraw the current window contents from the curses backing store, because gdb state didn't change while it was suspended 3. tui_dispatch_ctrl_char. This is the C-l handler, and here it's explicitly enough to just refresh the screen (as above). 4. tui_refresh_all_command. This is the command equivalent of C-l. So, this patch removes this method entirely and simplifies tui_refresh_all_win. gdb/ChangeLog 2019-08-30 Tom Tromey <tom@tromey.com> * tui/tui-winsource.h (struct tui_source_window_base) <refresh_all>: Don't declare. * tui/tui-winsource.c (tui_source_window_base::refresh_all): Remove. * tui/tui-win.c (tui_refresh_all_win): Don't call refresh_all or tui_show_locator_content. * tui/tui-regs.h (struct tui_data_window) <refresh_all>: Don't declare. * tui/tui-regs.c (tui_data_window::refresh_all): Remove. * tui/tui-data.h (struct tui_win_info) <refresh_all>: Don't declare.
2019-08-16Remove the TUI execution info windowTom Tromey1-37/+4
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-16Change tui_show_symtab_source to be a methodTom Tromey1-2/+2
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-16Introduce tui_source_window_base::set_contents methodTom Tromey1-6/+2
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-16Change tui_update_breakpoint_info to be a methodTom Tromey1-12/+9
This changes tui_update_breakpoint_info 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_breakpoint_info>: Declare. (tui_update_breakpoint_info): Don't declare. * tui/tui-winsource.c (tui_source_window_base::update_source_window_as_is) (tui_update_all_breakpoint_info): Update. (tui_source_window_base::update_breakpoint_info): Rename from tui_update_breakpoint_info. (tui_source_window_base::update_exec_info): Update.
2019-08-16Change tui_update_source_window to be a methodTom Tromey1-9/+8
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-16Change tui_update_source_window_as_is to be a methodTom Tromey1-18/+16
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-16Remove "noerror" parameter from some TUI functionsTom Tromey1-13/+9
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-15TUI resize unificationTom Tromey1-37/+5
The TUI currently has two different ways to resize a window: the resize method, and the methods make_invisible_and_set_new_height and make_visible_with_new_height. There's no deep reason to have two different ways to resize a window, so this patch unifies them, leaving just the "resize" method. This also changes the locator to be handled more like an ordinary window and less like an adjunct of the associated source window. gdb/ChangeLog 2019-08-15 Tom Tromey <tom@tromey.com> * tui/tui-io.c (tui_puts_internal): Check TUI_CMD_WIN before calling update_cmdwin_start_line. * tui/tui-winsource.h (struct tui_source_window_base) <do_make_visible_with_new_height, set_new_height>: Don't declare. <rerender>: Declare. * tui/tui-winsource.c (tui_source_window_base::update_tab_width): Call rerender. (tui_source_window_base::set_new_height): Remove. (tui_source_window_base::rerender): Rename from do_make_visible_with_new_height. * tui/tui-win.c (tui_resize_all, tui_adjust_win_heights): Use resize method. (tui_win_info::make_invisible_and_set_new_height) (tui_win_info::make_visible_with_new_height): Remove. * tui/tui-stack.h (struct tui_locator_window) <rerender>: Declare. * tui/tui-stack.c (tui_locator_window::rerender): New method. * tui/tui-regs.h (struct tui_data_window) <set_new_height, do_make_visible_with_new_height>: Don't declare. <rerender>: Declare. * tui/tui-regs.c (tui_data_window::rerender): Rename from set_new_height. (tui_data_window::do_make_visible_with_new_height): Remove. * tui/tui-layout.c (show_source_disasm_command, show_data): Don't call tui_show_locator_content. (tui_gen_win_info::resize): Call rerender. (show_source_or_disasm_and_command): Don't call tui_show_locator_content. * tui/tui-data.h (struct tui_gen_win_info) <rerender>: New method. (struct tui_win_info) <rerender>: Declare. <set_new_height, make_invisible_and_set_new_height, make_visible_with_new_height>: Don't declare. * tui/tui-data.c (tui_win_list::rerender): New method. * tui/tui-command.h (struct tui_cmd_window) <do_make_visible_with_new_height>: Don't declare. * tui/tui-command.c (tui_cmd_window::do_make_visible_with_new_height): Remove. gdb/testsuite/ChangeLog 2019-08-15 Tom Tromey <tom@tromey.com> * gdb.tui/empty.exp: Enable resizing tests.
2019-08-15Change TUI source window iterationTom Tromey1-1/+2
Currently the TUI does separate bookkeeping to track which source windows exist. It seems better to me to just refer to the list of windows for this, so this patch removes the special handling and instead adds a new iterator. gdb/ChangeLog 2019-08-15 Tom Tromey <tom@tromey.com> * tui/tui-winsource.h (struct tui_source_window_iterator): New. (struct tui_source_windows): New. * tui/tui-winsource.c (tui_display_main): Update. * tui/tui-win.c (tui_resize_all, tui_adjust_win_heights) (new_height_ok, parse_scrolling_args): Update. * tui/tui-layout.c (show_layout, show_data): Update. * tui/tui-data.h (tui_source_windows, tui_clear_source_windows) (tui_add_to_source_windows): Don't declare. * tui/tui-data.c (source_windows, tui_source_windows) (tui_clear_source_windows, tui_add_to_source_windows): Remove.
2019-08-15Rename the "reset" method to "resize"Tom Tromey1-5/+5
tui_gen_win_info::reset really just resizes the window. This patch renames it to reflect this. gdb/ChangeLog 2019-08-15 Tom Tromey <tom@tromey.com> * tui/tui-winsource.h (struct tui_source_window_base) <resize>: Rename from reset. * tui/tui-winsource.c (tui_source_window_base::resize): Rename. * tui/tui-layout.c (show_source_disasm_command, show_data): Update. (tui_gen_win_info::resize): Rename. (show_source_or_disasm_and_command): Update. * tui/tui-data.h (struct tui_gen_win_info) <resize>: Rename from reset.
2019-08-15Remove tui_clear_source_contentTom Tromey1-22/+3
tui_clear_source_content is not needed. Instead, the callers can call erase_source_content, which is also changed to clear the content vector. gdb/ChangeLog 2019-08-15 Tom Tromey <tom@tromey.com> * tui/tui-winsource.h (tui_clear_source_content): Don't declare. * tui/tui-winsource.c (tui_update_source_window_as_is): Don't call tui_clear_source_content. (tui_clear_source_content): Remove. (tui_source_window_base::do_erase_source_content): Hoist call to content.clear(). * tui/tui-stack.c (tui_show_frame_info): Don't call tui_clear_source_content.
2019-08-15Turn tui_erase_source_content into a methodTom Tromey1-24/+16
This changes tui_erase_source_content into a method on tui_source_window_base. The bulk of the work is moved into a helper method, so that the callers can each pass the string appropriate to the particular window class. gdb/ChangeLog 2019-08-15 Tom Tromey <tom@tromey.com> * tui/tui-winsource.h (struct tui_source_window_base) <do_erase_source_content>: New method. <erase_source_content>: New method. (tui_erase_source_content): Don't declare. * tui/tui-winsource.c (tui_clear_source_content): Update. (tui_source_window_base::do_erase_source_content): Rename from tui_erase_source_content. (tui_source_window_base::show_source_content): Update. * tui/tui-win.c (tui_resize_all, tui_adjust_win_heights): Update. * tui/tui-source.h (struct tui_source_window) <erase_source_content>: New method. * tui/tui-disasm.h (struct tui_disasm_window) <erase_source_content>: New method.
2019-08-15Remove tui_alloc_source_bufferTom Tromey1-20/+0
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-15Change tui_line_is_displayed to be a methodTom Tromey1-28/+0
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-15Change tui_addr_is_displayed into a methodTom Tromey1-28/+0
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-13Don't track the contents of the execution info windowTom Tromey1-48/+8
The curses library keeps track of the contents of each window, and can redraw the screen as needed. This means that in most cases is no need for the TUI windows to also keep track of their contents. This patch removes content tracking from the execution window, leaving that to curses. gdb/ChangeLog 2019-08-13 Tom Tromey <tom@tromey.com> * tui/tui-winsource.h (struct tui_exec_info_window) <~tui_exec_info_window, maybe_allocate_content, get_content, m_content>: Remove. (struct tui_source_window_base) <set_exec_info_content, show_exec_info_content>: Don't declare. * tui/tui-winsource.c (tui_exec_info_window::maybe_allocate_content): Remove. (tui_source_window_base::update_exec_info): Rename from set_exec_info_content. (tui_source_window_base::show_exec_info_content) (tui_source_window_base::update_exec_info): Remove.
2019-08-13Remove tui_clear_exec_info_contentTom Tromey1-17/+7
After the previous patch, all calls to tui_clear_exec_info_content come just after a call to tui_clear_source_content. Because these two windows are linked, I think it makes sense to have tui_clear_source_content simply do the work. So, this patch removes tui_clear_exec_info_content. gdb/ChangeLog 2019-08-13 Tom Tromey <tom@tromey.com> * tui/tui-winsource.h (tui_clear_exec_info_content): Don't declare. * tui/tui-winsource.c (tui_update_source_window_as_is) (tui_update_source_windows_with_addr, tui_erase_source_content): Update. (tui_clear_exec_info_content): Remove.
2019-08-13Remove tui_erase_exec_info_contentTom Tromey1-8/+1
One call to tui_erase_exec_info_content can be removed. This call is not needed because the function in question then immediately sets the execution info window contents. Once this is done, tui_clear_exec_info_content is just a wrapper for the only call to tui_erase_exec_info_content, so tui_erase_exec_info_content can be renamed and the wrapper function removed. gdb/ChangeLog 2019-08-13 Tom Tromey <tom@tromey.com> * tui/tui-winsource.h (tui_erase_exec_info_content): Don't declare. * tui/tui-winsource.c (tui_source_window_base::refresh_all): Don't call tui_erase_exec_info_content. (tui_clear_exec_info_content): Rename from tui_erase_exec_info_content. (tui_clear_exec_info_content): Delete.
2019-08-13Turn tui_show_exec_info_content into a methodTom Tromey1-6/+6
This changes tui_show_exec_info_content to be a method on tui_source_window_base. As it is only called by other methods on this class, it can be private. gdb/ChangeLog 2019-08-13 Tom Tromey <tom@tromey.com> * tui/tui-winsource.h (struct tui_source_window_base) <show_exec_info_content>: Declare. (tui_show_exec_info_content): Don't declare. * tui/tui-winsource.c (tui_source_window_base::show_exec_info_content): Rename from tui_show_exec_info_content. (tui_source_window_base::update_exec_info): Update.
2019-08-13Change tui_update_exec_info to be a methodTom Tromey1-6/+6
This changes tui_update_exec_info to be a method on tui_source_window_base. gdb/ChangeLog 2019-08-13 Tom Tromey <tom@tromey.com> * tui/tui-winsource.h (struct tui_source_window_base) <update_exec_info>: Declare. (tui_update_exec_info): Don't declare. * tui/tui-winsource.c (tui_update_source_window_as_is) (tui_source_window_base::refresh_all) (tui_update_all_breakpoint_info): Update. (tui_source_window_base::update_exec_info): Rename from tui_update_exec_info. * tui/tui-stack.c (tui_show_frame_info): Update.
2019-08-13Change tui_set_exec_info_content to be a methodTom Tromey1-8/+8
This changes tui_set_exec_info_content to bea method on tui_source_window_base. gdb/ChangeLog 2019-08-13 Tom Tromey <tom@tromey.com> * tui/tui-winsource.h (struct tui_source_window_base) <set_exec_info_content>: Declare. (tui_set_exec_info_content): Don't declare. * tui/tui-winsource.c (tui_source_window_base::set_exec_info_content): Rename from tui_set_exec_info_content. (tui_update_exec_info): Update.
2019-08-13Change tui_show_source_content to be a methodTom Tromey1-9/+9
This changes tui_show_source_content to be a method on tui_source_window_base. gdb/ChangeLog 2019-08-13 Tom Tromey <tom@tromey.com> * tui/tui-winsource.h (struct tui_source_window_base) <show_source_content>: Declare. (tui_show_source_content): Don't declare. * tui/tui-winsource.c (tui_update_source_window_as_is): Update. (tui_source_window_base::show_source_content): Rename from tui_show_source_content. (tui_source_window_base::refresh_all): Update. * tui/tui-layout.c (show_source_disasm_command) (show_source_or_disasm_and_command): Update.
2019-08-13Change tui_check_and_display_highlight_if_needed to be a methodTom Tromey1-3/+3
This changes tui_check_and_display_highlight_if_needed to be a method on tui_win_info. This makes it clear that the NULL check in that function is not needed, so it is removed here. gdb/ChangeLog 2019-08-13 Tom Tromey <tom@tromey.com> * tui/tui-winsource.c (tui_erase_source_content) (tui_show_source_content, tui_source_window_base::refresh_all): Update. * tui/tui-wingeneral.h (tui_check_and_display_highlight_if_needed): Don't declare. * tui/tui-wingeneral.c (tui_win_info::check_and_display_highlight_if_needed): Rename from check_and_display_highlight_if_needed. * tui/tui-win.c (tui_rehighlight_all) (tui_win_info::make_visible_with_new_height): Update. * tui/tui-regs.c (tui_data_window::display_registers_from_line) (tui_data_window::erase_data_content) (tui_data_window::display_all_data): Update. * tui/tui-data.h (struct tui_win_info) <check_and_display_highlight_if_needed>: Declare.
2019-07-17Remove unnecessary "return"sTom Tromey1-7/+0
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-17Move source window common to code to tui-winsource.[ch]Tom Tromey1-5/+144
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-17Always create an execution info window for a source windowTom Tromey1-32/+29
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-17Merge refresh and refresh_window methodsTom Tromey1-1/+0
Earlier refactorings introduced the refresh and refresh_window methods, following the previous TUI code. However, these methods are essentially the same, so this patch merges them. It also removes some redundant refresh_window calls, because the execution window is updated automatically by the corresponding source (or disassembly) window. gdb/ChangeLog 2019-07-17 Tom Tromey <tom@tromey.com> * tui/tui-winsource.c (tui_show_exec_info_content): Don't call refresh_window. * tui/tui-wingeneral.c (tui_gen_win_info::refresh_window): Call touchwin. (tui_data_window::refresh_window): Call refresh_window on data items. Always call superclass refresh_window. (tui_win_info::refresh): Remove. (tui_source_window_base::refresh_window): Update. (tui_refresh_all): Update. * tui/tui-layout.c (show_source_disasm_command): Remove call to refresh_window. (show_source_or_disasm_and_command): Likewise. * tui/tui-data.h (struct tui_win_info) <refresh>: Remove. (struct tui_source_window_base) <refresh>: Likewise.
2019-07-17Remove tui_source_window::content_in_useTom Tromey1-2/+0
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-17Simplify source window clearingTom Tromey1-7/+1
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-17Remove unused parameter from two TUI functionsTom Tromey1-32/+29
The "display_prompt" parameter of tui_erase_source_content and tui_clear_source_content was never passed the NO_EMPTY_SOURCE_PROMPT value, so remove the parameter. Once this is done, the EMPTY_SOURCE_PROMPT and NO_EMPTY_SOURCE_PROMPT defines are unused, so remove those as well. gdb/ChangeLog 2019-07-17 Tom Tromey <tom@tromey.com> * tui/tui-winsource.h (tui_erase_source_content) (tui_clear_source_content): Remove "display_prompt" parameter. * tui/tui-winsource.c (tui_update_source_window_as_is) (tui_update_source_windows_with_addr): Update. (tui_clear_source_content): Remove "display_prompt" parameter. (tui_erase_source_content): Likewise. Simplify. (tui_show_source_content): Update. * tui/tui-win.c (tui_resize_all, tui_adjust_win_heights): Update. * tui/tui-stack.c (tui_show_frame_info): Update. * tui/tui-data.h (EMPTY_SOURCE_PROMPT, NO_EMPTY_SOURCE_PROMPT): Remove defines.
2019-07-17Add win_info parameter to tui_set_disassem_contentTom Tromey1-1/+1
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-17Move content_in_use to tui_source_window classTom Tromey1-4/+2
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-17Introduce tui_source_window_base::location_matches_p methodTom Tromey1-10/+1
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-17Remove deleted breakpoint from TUI displayTom Tromey1-13/+16
PR tui/24722 points out that deleting a breakpoint does not cause the "b" to be removed from the breakpoint display. The issue here was that the breakpoint still exists at the moment the breakpoint-deleted observer is notified. This fixes the problem by specially handling the case where a breakpoint is being removed. gdb/ChangeLog 2019-07-17 Tom Tromey <tom@tromey.com> PR tui/24722: * tui/tui-winsource.h (tui_update_all_breakpoint_info) (tui_update_breakpoint_info): Add "being_deleted" parameter. * tui/tui-winsource.c (tui_update_source_window_as_is): Update. (tui_update_all_breakpoint_info): Add "being_deleted" parameter. (tui_update_breakpoint_info): Likewise. * tui/tui-hooks.c (tui_event_create_breakpoint) (tui_event_delete_breakpoint, tui_event_modify_breakpoint): Update.
2019-07-17Remove some uses of TUI_WIN_SRCTom Tromey1-4/+5
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-04Fix TUI use of "has_break" fieldTom Tromey1-9/+8
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-06-25Fix latent bug in set_is_exec_point_atTom Tromey1-1/+1
valgrind pointed out that the TUI was using uninitialized memory in set_is_exec_point_at. The bug is a missing check against LOA_ADDRESS, causing gdb to examine the uninitialized bits of the "addr" field. gdb/ChangeLog 2019-06-25 Tom Tromey <tom@tromey.com> * tui/tui-winsource.c (tui_source_window_base::set_is_exec_point_at): Add check against LOA_ADDRESS.
2019-06-25Remove union tui_which_elementTom Tromey1-48/+41
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-25More type safety for TUI source window functionsTom Tromey1-3/+3
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-25Use bool for is_exec_pointTom Tromey1-6/+6
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-25Separate out execution-info windowTom Tromey1-23/+24
This pulls the EXEC_INFO_WIN case out into its own subclass of tui_gen_win_info. This lets us remove an element from union tui_which_element. gdb/ChangeLog 2019-06-25 Tom Tromey <tom@tromey.com> * tui/tui-winsource.c (tui_exec_info_window::maybe_allocate_content): New method. (tui_set_exec_info_content, tui_show_exec_info_content): Update. * tui/tui-layout.c (init_and_make_win): Add EXEC_INFO_WIN case. (make_source_or_disasm_window): Add cast. * tui/tui-data.h (union tui_which_element) <simple_string>: Remove. (struct tui_source_info): New. (struct tui_source_window_base) <execution_info>: Change type. * tui/tui-data.c (init_content_element): Remove EXEC_INFO_WIN case, and add assert. (tui_alloc_content): Add assert.