diff options
author | Tom Tromey <tom@tromey.com> | 2023-12-17 12:38:15 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2024-02-08 12:16:07 -0700 |
commit | 66ab1a14e196a5ad1f5fd8d225647bd48ff02a25 (patch) | |
tree | 0e6d8d13f6ef1638724d5ee76a967c4c2d9360a2 /gdb/tui | |
parent | 09df3a10d942e4bcce40a03e4668a287fe4297fa (diff) | |
download | binutils-66ab1a14e196a5ad1f5fd8d225647bd48ff02a25.zip binutils-66ab1a14e196a5ad1f5fd8d225647bd48ff02a25.tar.gz binutils-66ab1a14e196a5ad1f5fd8d225647bd48ff02a25.tar.bz2 |
Update TUI register window when the inferior exits
When the inferior exits, the TUI register window should clear.
Fixing this was mostly a matter of sticking an assignment into
tui_inferior_exit. However, some changes to the register window
itself were also needed.
While working on this, I realized that the TUI register window would
not work correctly when moving between frames of different
architectures. This patch attempts to fix this as well, though I have
no way to test it.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28600
Tested-By: Tom de Vries <tdevries@suse.de>
Reviewed-By: Andrew Burgess <aburgess@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
Diffstat (limited to 'gdb/tui')
-rw-r--r-- | gdb/tui/tui-hooks.c | 17 | ||||
-rw-r--r-- | gdb/tui/tui-regs.c | 48 | ||||
-rw-r--r-- | gdb/tui/tui-regs.h | 4 |
3 files changed, 45 insertions, 24 deletions
diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c index fc7ffb4..28d0b74 100644 --- a/gdb/tui/tui-hooks.c +++ b/gdb/tui/tui-hooks.c @@ -126,19 +126,23 @@ tui_refresh_frame_and_register_information () target_terminal::scoped_restore_terminal_state term_state; target_terminal::ours_for_output (); - if (from_stack && has_stack_frames ()) + if (from_stack) { - frame_info_ptr fi = get_selected_frame (NULL); + frame_info_ptr fi; + if (has_stack_frames ()) + { + fi = get_selected_frame (NULL); - /* Display the frame position (even if there is no symbols or - the PC is not known). */ - tui_show_frame_info (fi); + /* Display the frame position (even if there is no symbols or + the PC is not known). */ + tui_show_frame_info (fi); + } /* Refresh the register window if it's visible. */ if (tui_is_window_visible (DATA_WIN)) TUI_DATA_WIN->check_register_values (fi); } - else if (!from_stack) + else { /* Make sure that the source window is displayed. */ tui_add_win_to_layout (SRC_WIN); @@ -169,6 +173,7 @@ tui_inferior_exit (struct inferior *inf) tui_set_key_mode (TUI_COMMAND_MODE); tui_show_frame_info (0); tui_display_main (); + from_stack = true; } /* Observer for the before_prompt notification. */ diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c index fa4d10d..504aed4 100644 --- a/gdb/tui/tui-regs.c +++ b/gdb/tui/tui-regs.c @@ -107,12 +107,9 @@ tui_register_format (frame_info_ptr frame, int regnum) void tui_register_info::update (const frame_info_ptr &frame) { - if (target_has_registers ()) - { - std::string new_content = tui_register_format (frame, m_regno); - highlight = content != new_content; - content = std::move (new_content); - } + std::string new_content = tui_register_format (frame, m_regno); + highlight = content != new_content; + content = std::move (new_content); } /* See tui-regs.h. */ @@ -185,13 +182,22 @@ tui_data_window::update_register_data (const reggroup *group) { set_title (_("Registers")); m_current_group = nullptr; + m_gdbarch = nullptr; m_regs_content.clear (); return; } frame_info_ptr frame = get_selected_frame (nullptr); + struct gdbarch *gdbarch = get_frame_arch (frame); + + if (m_current_group == group && m_gdbarch == gdbarch) + { + /* Nothing to do here. */ + return; + } m_current_group = group; + m_gdbarch = gdbarch; /* Make a new title showing which group we display. */ this->set_title (string_printf ("Register group: %s", group->name ())); @@ -199,7 +205,6 @@ tui_data_window::update_register_data (const reggroup *group) /* Create the registers. */ m_regs_content.clear (); - struct gdbarch *gdbarch = get_frame_arch (frame); for (int regnum = 0; regnum < gdbarch_num_cooked_regs (gdbarch); regnum++) @@ -403,24 +408,31 @@ tui_data_window::do_scroll_vertical (int num_to_scroll) void tui_data_window::check_register_values (frame_info_ptr frame) { - if (m_regs_content.empty ()) - set_register_group (m_current_group); + if (frame == nullptr) + set_register_group (nullptr); else { - for (tui_register_info &data_item_win : m_regs_content) + /* If the frame architecture changed, we need to reset the + register group. */ + struct gdbarch *gdbarch = get_frame_arch (frame); + if (gdbarch != m_gdbarch) + set_register_group (nullptr); + else { - bool was_hilighted = data_item_win.highlight; + for (tui_register_info &data_item_win : m_regs_content) + { + bool was_hilighted = data_item_win.highlight; - data_item_win.update (frame); + data_item_win.update (frame); - /* Register windows whose y == 0 are outside the visible area. */ - if ((data_item_win.highlight || was_hilighted) - && data_item_win.visible ()) - data_item_win.rerender (handle.get (), m_item_width); + /* Register windows whose y == 0 are outside the visible area. */ + if ((data_item_win.highlight || was_hilighted) + && data_item_win.visible ()) + data_item_win.rerender (handle.get (), m_item_width); + } } + tui_wrefresh (handle.get ()); } - - tui_wrefresh (handle.get ()); } /* Display a register in a window. If hilite is TRUE, then the value diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h index caa9d39..9d9cae4 100644 --- a/gdb/tui/tui-regs.h +++ b/gdb/tui/tui-regs.h @@ -139,6 +139,10 @@ private: /* Width of each register's display area. */ int m_item_width = 0; + + /* Architecture of frame whose registers are being displayed, or + nullptr if the display is empty (i.e., there is no frame). */ + gdbarch *m_gdbarch = nullptr; }; #endif /* TUI_TUI_REGS_H */ |