[v2,08/14] Remove the TUI register window rerender overload
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Testing passed
|
Commit Message
After these restructurings, it should be clear that the rerender
overload can be removed from the TUI register window. This is done by
moving a bit more logic from show_registers into update_register_data.
After this, update_register_data simply updates the internal state,
and rerender will write to the screen. All the actual rendering work
is done, ultimately, by display_registers_from. This split between
updating the mode and rendering makes it clear that the recursive case
can't happen any longer.
Tested-By: Tom de Vries <tdevries@suse.de>
Reviewed-By: Andrew Burgess <aburgess@redhat.com>
---
gdb/tui/tui-regs.c | 51 ++++++++++++++++++++++-----------------------------
gdb/tui/tui-regs.h | 14 ++++++--------
2 files changed, 28 insertions(+), 37 deletions(-)
Comments
Tom Tromey <tom@tromey.com> writes:
> After these restructurings, it should be clear that the rerender
> overload can be removed from the TUI register window. This is done by
> moving a bit more logic from show_registers into update_register_data.
> After this, update_register_data simply updates the internal state,
> and rerender will write to the screen. All the actual rendering work
> is done, ultimately, by display_registers_from. This split between
> updating the mode and rendering makes it clear that the recursive case
I think you mean 'updating the model' here?
Thanks,
Andrew
> can't happen any longer.
>
> Tested-By: Tom de Vries <tdevries@suse.de>
> Reviewed-By: Andrew Burgess <aburgess@redhat.com>
> ---
> gdb/tui/tui-regs.c | 51 ++++++++++++++++++++++-----------------------------
> gdb/tui/tui-regs.h | 14 ++++++--------
> 2 files changed, 28 insertions(+), 37 deletions(-)
>
> diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
> index 7af572c9da4..52cf6b7efdf 100644
> --- a/gdb/tui/tui-regs.c
> +++ b/gdb/tui/tui-regs.c
> @@ -165,30 +165,32 @@ tui_data_window::first_reg_element_no_inline (int line_no) const
> and refresh the window. */
> void
> tui_data_window::show_registers (const reggroup *group)
> +{
> + update_register_data (group);
> + rerender ();
> +}
> +
> +/* Set the data window to display the registers of the register group
> + using the given frame. */
> +
> +void
> +tui_data_window::update_register_data (const reggroup *group)
> {
> if (group == nullptr)
> group = general_reggroup;
>
> - if (target_has_registers () && target_has_stack () && target_has_memory ())
> - update_register_data (group, get_selected_frame (nullptr));
> - else
> + if (!target_has_registers ()
> + || !target_has_stack ()
> + || !target_has_memory ())
> {
> set_title (_("Registers"));
> m_current_group = nullptr;
> m_regs_content.clear ();
> + return;
> }
>
> - rerender (false);
> -}
> -
> + frame_info_ptr frame = get_selected_frame (nullptr);
>
> -/* Set the data window to display the registers of the register group
> - using the given frame. */
> -
> -void
> -tui_data_window::update_register_data (const reggroup *group,
> - frame_info_ptr frame)
> -{
> m_current_group = group;
>
> /* Make a new title showing which group we display. */
> @@ -221,6 +223,9 @@ tui_data_window::update_register_data (const reggroup *group,
> void
> tui_data_window::display_registers_from (int start_element_no)
> {
> + werase (handle.get ());
> + check_and_display_highlight_if_needed ();
> +
> /* In case the regs window is not boxed, we'll write the last char in the
> last line here, causing a scroll, so prevent that. */
> scrollok (handle.get (), FALSE);
> @@ -357,29 +362,18 @@ tui_data_window::erase_data_content (const char *prompt)
> x_pos = half_width - strlen (prompt);
> display_string (height / 2, x_pos, prompt);
> }
> - tui_wrefresh (handle.get ());
> }
>
> /* See tui-regs.h. */
>
> void
> -tui_data_window::rerender (bool toplevel)
> +tui_data_window::rerender ()
> {
> if (m_regs_content.empty ())
> - {
> - if (toplevel && has_stack_frames ())
> - {
> - frame_info_ptr fi = get_selected_frame (NULL);
> - check_register_values (fi);
> - }
> - else
> - erase_data_content (_("[ Register Values Unavailable ]"));
> - }
> + erase_data_content (_("[ Register Values Unavailable ]"));
> else
> - {
> - erase_data_content (NULL);
> - display_registers_from (0);
> - }
> + display_registers_from (0);
> + tui_wrefresh (handle.get ());
> }
>
>
> @@ -401,7 +395,6 @@ tui_data_window::do_scroll_vertical (int num_to_scroll)
> if (first_line >= 0)
> {
> first_line += num_to_scroll;
> - erase_data_content (NULL);
> display_registers_from_line (first_line);
> }
> }
> diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
> index 1b0eaa2033b..7f1c30ca5d6 100644
> --- a/gdb/tui/tui-regs.h
> +++ b/gdb/tui/tui-regs.h
> @@ -62,7 +62,10 @@ struct tui_register_info
> /* The TUI registers window. */
> struct tui_data_window : public tui_win_info
> {
> - tui_data_window () = default;
> + tui_data_window ()
> + {
> + update_register_data (nullptr);
> + }
>
> DISABLE_COPY_AND_ASSIGN (tui_data_window);
>
> @@ -87,11 +90,7 @@ struct tui_data_window : public tui_win_info
> {
> }
>
> - void rerender (bool toplevel);
> - void rerender () override
> - {
> - rerender (true);
> - }
> + void rerender () override;
>
> private:
>
> @@ -116,8 +115,7 @@ struct tui_data_window : public tui_win_info
> display off the end of the register display. */
> void display_reg_element_at_line (int start_element_no, int start_line_no);
>
> - void update_register_data (const reggroup *group,
> - frame_info_ptr frame);
> + void update_register_data (const reggroup *group);
>
> /* Answer the number of the last line in the regs display. If there
> are no registers (-1) is returned. */
>
> --
> 2.43.0
@@ -165,30 +165,32 @@ tui_data_window::first_reg_element_no_inline (int line_no) const
and refresh the window. */
void
tui_data_window::show_registers (const reggroup *group)
+{
+ update_register_data (group);
+ rerender ();
+}
+
+/* Set the data window to display the registers of the register group
+ using the given frame. */
+
+void
+tui_data_window::update_register_data (const reggroup *group)
{
if (group == nullptr)
group = general_reggroup;
- if (target_has_registers () && target_has_stack () && target_has_memory ())
- update_register_data (group, get_selected_frame (nullptr));
- else
+ if (!target_has_registers ()
+ || !target_has_stack ()
+ || !target_has_memory ())
{
set_title (_("Registers"));
m_current_group = nullptr;
m_regs_content.clear ();
+ return;
}
- rerender (false);
-}
-
+ frame_info_ptr frame = get_selected_frame (nullptr);
-/* Set the data window to display the registers of the register group
- using the given frame. */
-
-void
-tui_data_window::update_register_data (const reggroup *group,
- frame_info_ptr frame)
-{
m_current_group = group;
/* Make a new title showing which group we display. */
@@ -221,6 +223,9 @@ tui_data_window::update_register_data (const reggroup *group,
void
tui_data_window::display_registers_from (int start_element_no)
{
+ werase (handle.get ());
+ check_and_display_highlight_if_needed ();
+
/* In case the regs window is not boxed, we'll write the last char in the
last line here, causing a scroll, so prevent that. */
scrollok (handle.get (), FALSE);
@@ -357,29 +362,18 @@ tui_data_window::erase_data_content (const char *prompt)
x_pos = half_width - strlen (prompt);
display_string (height / 2, x_pos, prompt);
}
- tui_wrefresh (handle.get ());
}
/* See tui-regs.h. */
void
-tui_data_window::rerender (bool toplevel)
+tui_data_window::rerender ()
{
if (m_regs_content.empty ())
- {
- if (toplevel && has_stack_frames ())
- {
- frame_info_ptr fi = get_selected_frame (NULL);
- check_register_values (fi);
- }
- else
- erase_data_content (_("[ Register Values Unavailable ]"));
- }
+ erase_data_content (_("[ Register Values Unavailable ]"));
else
- {
- erase_data_content (NULL);
- display_registers_from (0);
- }
+ display_registers_from (0);
+ tui_wrefresh (handle.get ());
}
@@ -401,7 +395,6 @@ tui_data_window::do_scroll_vertical (int num_to_scroll)
if (first_line >= 0)
{
first_line += num_to_scroll;
- erase_data_content (NULL);
display_registers_from_line (first_line);
}
}
@@ -62,7 +62,10 @@ struct tui_register_info
/* The TUI registers window. */
struct tui_data_window : public tui_win_info
{
- tui_data_window () = default;
+ tui_data_window ()
+ {
+ update_register_data (nullptr);
+ }
DISABLE_COPY_AND_ASSIGN (tui_data_window);
@@ -87,11 +90,7 @@ struct tui_data_window : public tui_win_info
{
}
- void rerender (bool toplevel);
- void rerender () override
- {
- rerender (true);
- }
+ void rerender () override;
private:
@@ -116,8 +115,7 @@ struct tui_data_window : public tui_win_info
display off the end of the register display. */
void display_reg_element_at_line (int start_element_no, int start_line_no);
- void update_register_data (const reggroup *group,
- frame_info_ptr frame);
+ void update_register_data (const reggroup *group);
/* Answer the number of the last line in the regs display. If there
are no registers (-1) is returned. */