From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 14/14] Update TUI register window when the inferior exits
Date: Sun, 17 Dec 2023 12:50:39 -0700 [thread overview]
Message-ID: <20231217-tui-regs-cleanup-v1-14-67bd0ea1e8be@tromey.com> (raw)
In-Reply-To: <20231217-tui-regs-cleanup-v1-0-67bd0ea1e8be@tromey.com>
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
---
gdb/testsuite/gdb.tui/regs.exp | 8 +++++++
gdb/tui/tui-hooks.c | 17 +++++++++------
gdb/tui/tui-regs.c | 48 ++++++++++++++++++++++++++----------------
gdb/tui/tui-regs.h | 4 ++++
4 files changed, 53 insertions(+), 24 deletions(-)
diff --git a/gdb/testsuite/gdb.tui/regs.exp b/gdb/testsuite/gdb.tui/regs.exp
index 0be99625b9f..c9e7cac72b7 100644
--- a/gdb/testsuite/gdb.tui/regs.exp
+++ b/gdb/testsuite/gdb.tui/regs.exp
@@ -30,6 +30,9 @@ if {![runto_main]} {
return
}
+# This is convenient later on.
+gdb_test_no_output "set confirm off"
+
if {![Term::enter_tui]} {
unsupported "TUI not supported"
return
@@ -48,6 +51,11 @@ gdb_assert \
{ ![Term::check_region_contents_p 0 0 80 8 $re_reg_vals_unavailable] } \
"Register values available"
+Term::command "kill"
+gdb_assert \
+ { [Term::check_region_contents_p 0 0 80 8 $re_reg_vals_unavailable] } \
+ "Register values no longer available"
+
# Check that we can successfully cause the register window to appear
# using the 'tui reg next' and 'tui reg prev' commands.
foreach_with_prefix cmd { next prev } {
diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c
index f1e4978a40a..3b5dd527fac 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 248e6395cd7..feaf3b5abb8 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, regno);
- highlight = content != new_content;
- content = std::move (new_content);
- }
+ std::string new_content = tui_register_format (frame, regno);
+ highlight = content != new_content;
+ content = std::move (new_content);
}
/* See tui-regs.h. */
@@ -186,13 +183,22 @@ tui_data_window::update_register_data (const reggroup *group)
{
set_title ("");
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 ()));
@@ -200,7 +206,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++)
@@ -404,24 +409,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.y > 0)
- 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.y > 0)
+ 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 a5cd30b7160..6c62938259f 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -137,6 +137,10 @@ struct tui_data_window : public tui_win_info
/* 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 */
--
2.43.0
next prev parent reply other threads:[~2023-12-17 19:50 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-17 19:50 [PATCH 00/14] Cleanups for the TUi register window Tom Tromey
2023-12-17 19:50 ` [PATCH 01/14] Use pop_back in tui_register_format Tom Tromey
2023-12-17 19:50 ` [PATCH 02/14] Minor C++ cleanups in tui-regs.c Tom Tromey
2023-12-17 19:50 ` [PATCH 03/14] Simplify tui_data_window::show_register_group Tom Tromey
2023-12-18 15:42 ` Andrew Burgess
2024-01-20 17:11 ` Tom Tromey
2023-12-17 19:50 ` [PATCH 04/14] Rename tui_data_item_window -> tui_register_info Tom Tromey
2023-12-17 19:50 ` [PATCH 05/14] Remove tui_register_info::visible Tom Tromey
2023-12-18 17:29 ` Hannes Domani
2024-01-20 17:02 ` Tom Tromey
2023-12-18 19:00 ` Andrew Burgess
2024-01-20 17:05 ` Tom Tromey
2023-12-17 19:50 ` [PATCH 06/14] Move scrollok call in register window Tom Tromey
2023-12-18 19:28 ` Andrew Burgess
2023-12-18 23:33 ` Tom Tromey
2023-12-17 19:50 ` [PATCH 07/14] Simplify update_register_data Tom Tromey
2023-12-18 19:48 ` Andrew Burgess
2024-01-20 17:06 ` Tom Tromey
2023-12-17 19:50 ` [PATCH 08/14] Remove the TUI register window rerender overload Tom Tromey
2023-12-18 19:54 ` Andrew Burgess
2024-01-20 17:17 ` Tom Tromey
2023-12-17 19:50 ` [PATCH 09/14] Simplify tui_data_win::erase_data_content Tom Tromey
2023-12-17 19:50 ` [PATCH 10/14] Remove tui_refreshing_registers Tom Tromey
2023-12-17 19:50 ` [PATCH 11/14] Remove redundant check from tui_refresh_frame_and_register_information Tom Tromey
2023-12-18 17:32 ` Hannes Domani
2023-12-18 23:35 ` Tom Tromey
2023-12-19 10:26 ` Andrew Burgess
2024-01-20 18:21 ` Tom Tromey
2023-12-17 19:50 ` [PATCH 12/14] Return void from tui_show_frame_info Tom Tromey
2023-12-17 19:50 ` [PATCH 13/14] Rename show_registers -> set_register_group Tom Tromey
2023-12-17 19:50 ` Tom Tromey [this message]
2023-12-18 14:07 ` [PATCH 00/14] Cleanups for the TUi register window Tom de Vries
2023-12-19 10:31 ` Andrew Burgess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231217-tui-regs-cleanup-v1-14-67bd0ea1e8be@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).