[PATCH 17/66] Remove struct tui_data_info

Tom Tromey
2019-06-23T22:44:05Z

Like the previous two patches, this removes struct tui_data_info in
favor of inlining its contents into tui_data_window. This was the
last member of the tui_win_info detail union, so that is removed.

gdb/ChangeLog
2019-06-23 Tom Tromey <tom@tromey.com>

* tui/tui-windata.c (tui_display_all_data)
(tui_display_data_from_line, tui_display_data_from)
(tui_check_data_values, tui_data_window::do_scroll_vertical):
Update.
* tui/tui-regs.c (tui_last_regs_line_no)
(tui_line_from_reg_element_no, tui_first_reg_element_no_inline)
(tui_show_registers, tui_show_register_group)
(tui_display_registers_from, tui_display_reg_element_at_line)
(tui_display_registers_from_line, tui_check_register_values)
(tui_reg_next, tui_reg_prev): Update.
* tui/tui-layout.c (tui_set_layout, show_data): Update.
* tui/tui-data.h (struct tui_data_info): Remove. Move contents to
tui_data_window.
(struct tui_win_info) <detail>: Remove. Add new fields from
tui_data_info.
(TUI_DATA_WIN): Add cast.
* tui/tui-data.c (tui_data_window::clear_detail, tui_data_window)
(~tui_data_window): Simplify.
---
gdb/ChangeLog | 21 ++++++++
gdb/tui/tui-data.c | 44 ++++++++--------
gdb/tui/tui-data.h | 29 ++++-------
gdb/tui/tui-layout.c | 8 +--
gdb/tui/tui-regs.c | 115 +++++++++++++++++++-----------------------
gdb/tui/tui-windata.c | 17 +++----
6 files changed, 112 insertions(+), 122 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index ef9c9998930..37aee67df0b 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -190,12 +190,12 @@ tui_cmd_window::clear_detail ()
void
tui_data_window::clear_detail ()
{
- detail.data_display_info.data_content = NULL;
- detail.data_display_info.data_content_count = 0;
- detail.data_display_info.regs_content = NULL;
- detail.data_display_info.regs_content_count = 0;
- detail.data_display_info.regs_column_count = 1;
- detail.data_display_info.display_regs = FALSE;
+ data_content = NULL;
+ data_content_count = 0;
+ regs_content = NULL;
+ regs_content_count = 0;
+ regs_column_count = 1;
+ display_regs = FALSE;
}

/* Accessor for the source execution info ptr. */
@@ -498,13 +498,13 @@ tui_source_window_base::tui_source_window_base (enum tui_win_type type)
tui_data_window::tui_data_window ()
: tui_win_info (DATA_WIN)
{
- detail.data_display_info.data_content = (tui_win_content) NULL;
- detail.data_display_info.data_content_count = 0;
- detail.data_display_info.regs_content = (tui_win_content) NULL;
- detail.data_display_info.regs_content_count = 0;
- detail.data_display_info.regs_column_count = 1;
- detail.data_display_info.display_regs = FALSE;
- detail.data_display_info.current_group = 0;
+ data_content = NULL;
+ data_content_count = 0;
+ regs_content = NULL;
+ regs_content_count = 0;
+ regs_column_count = 1;
+ display_regs = FALSE;
+ current_group = 0;
}

tui_cmd_window::tui_cmd_window ()
@@ -614,16 +614,14 @@ tui_data_window::~tui_data_window ()
{
if (generic.content != NULL)
{
- tui_free_data_content (detail.data_display_info.regs_content,
- detail.data_display_info.regs_content_count);
- detail.data_display_info.regs_content = NULL;
- detail.data_display_info.regs_content_count = 0;
- tui_free_data_content (detail.data_display_info.data_content,
- detail.data_display_info.data_content_count);
- detail.data_display_info.data_content = NULL;
- detail.data_display_info.data_content_count = 0;
- detail.data_display_info.regs_column_count = 1;
- detail.data_display_info.display_regs = FALSE;
+ tui_free_data_content (regs_content, regs_content_count);
+ regs_content = NULL;
+ regs_content_count = 0;
+ tui_free_data_content (data_content, data_content_count);
+ data_content = NULL;
+ data_content_count = 0;
+ regs_column_count = 1;
+ display_regs = FALSE;
generic.content = NULL;
generic.content_size = 0;
}
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 4ca3a89b74e..6e50601dd9a 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -224,20 +224,6 @@ struct tui_win_element
union tui_which_element which_element;
};

-/* This struct defines the specific information about a data display
- window. */
-struct tui_data_info
-{
- tui_win_content data_content; /* Start of data display content. */
- int data_content_count;
- tui_win_content regs_content; /* Start of regs display content. */
- int regs_content_count;
- int regs_column_count;
- int display_regs; /* Should regs be displayed at all? */
- struct reggroup *current_group;
-};
-
-
/* This defines information about each logical window. */
struct tui_win_info
{
@@ -278,11 +264,6 @@ public:
void right_scroll (int num_to_scroll);

struct tui_gen_win_info generic; /* General window information. */
- union
- {
- struct tui_data_info data_display_info;
- }
- detail;

/* Can this window ever be highlighted? */
int can_highlight = 0;
@@ -371,6 +352,14 @@ struct tui_data_window : public tui_win_info

void clear_detail () override;

+ tui_win_content data_content; /* Start of data display content. */
+ int data_content_count;
+ tui_win_content regs_content; /* Start of regs display content. */
+ int regs_content_count;
+ int regs_column_count;
+ int display_regs; /* Should regs be displayed at all? */
+ struct reggroup *current_group;
+
protected:

void do_scroll_vertical (enum tui_scroll_direction,
@@ -414,7 +403,7 @@ extern struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];

#define TUI_SRC_WIN ((tui_source_window_base *) tui_win_list[SRC_WIN])
#define TUI_DISASM_WIN ((tui_source_window_base *) tui_win_list[DISASSEM_WIN])
-#define TUI_DATA_WIN tui_win_list[DATA_WIN]
+#define TUI_DATA_WIN ((tui_data_window *) tui_win_list[DATA_WIN])
#define TUI_CMD_WIN ((tui_cmd_window *) tui_win_list[CMD_WIN])

/* Data Manipulation Functions. */
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 95b89f8583a..72ec924f72c 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -227,11 +227,7 @@ tui_set_layout (enum tui_layout_type layout_type)
tui_update_source_windows_with_addr (gdbarch, addr);

if (regs_populate)
- {
- struct reggroup *group =
- TUI_DATA_WIN->detail.data_display_info.current_group;
- tui_show_registers (group);
- }
+ tui_show_registers (TUI_DATA_WIN->current_group);
}
}
else
@@ -726,7 +722,7 @@ show_data (enum tui_layout_type new_layout)
src_height = total_height - data_height;
tui_make_all_invisible ();
tui_make_invisible (locator);
- make_data_window (&TUI_DATA_WIN, data_height, 0);
+ make_data_window (&tui_win_list[DATA_WIN], data_height, 0);
TUI_DATA_WIN->can_highlight = TRUE;
if (new_layout == SRC_DATA_COMMAND)
win_type = SRC_WIN;
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index b3456113369..451bcdfb364 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -72,12 +72,11 @@ tui_last_regs_line_no (void)
{
int num_lines = (-1);

- if (TUI_DATA_WIN->detail.data_display_info.regs_content_count > 0)
+ if (TUI_DATA_WIN->regs_content_count > 0)
{
- num_lines = (TUI_DATA_WIN->detail.data_display_info.regs_content_count /
- TUI_DATA_WIN->detail.data_display_info.regs_column_count);
- if (TUI_DATA_WIN->detail.data_display_info.regs_content_count %
- TUI_DATA_WIN->detail.data_display_info.regs_column_count)
+ num_lines = (TUI_DATA_WIN->regs_content_count
+ / TUI_DATA_WIN->regs_column_count);
+ if (TUI_DATA_WIN->regs_content_count % TUI_DATA_WIN->regs_column_count)
num_lines++;
}
return num_lines;
@@ -90,15 +89,14 @@ tui_last_regs_line_no (void)
int
tui_line_from_reg_element_no (int element_no)
{
- if (element_no < TUI_DATA_WIN->detail.data_display_info.regs_content_count)
+ if (element_no < TUI_DATA_WIN->regs_content_count)
{
int i, line = (-1);

i = 1;
while (line == (-1))
{
- if (element_no <
- (TUI_DATA_WIN->detail.data_display_info.regs_column_count * i))
+ if (element_no < TUI_DATA_WIN->regs_column_count * i)
line = i - 1;
else
i++;
@@ -116,11 +114,10 @@ tui_line_from_reg_element_no (int element_no)
int
tui_first_reg_element_no_inline (int line_no)
{
- if ((line_no * TUI_DATA_WIN->detail.data_display_info.regs_column_count)
- <= TUI_DATA_WIN->detail.data_display_info.regs_content_count)
- return ((line_no + 1) *
- TUI_DATA_WIN->detail.data_display_info.regs_column_count) -
- TUI_DATA_WIN->detail.data_display_info.regs_column_count;
+ if ((line_no * TUI_DATA_WIN->regs_column_count)
+ <= TUI_DATA_WIN->regs_content_count)
+ return (((line_no + 1) * TUI_DATA_WIN->regs_column_count)
+ - TUI_DATA_WIN->regs_column_count);
else
return (-1);
}
@@ -132,7 +129,6 @@ void
tui_show_registers (struct reggroup *group)
{
enum tui_status ret = TUI_FAILURE;
- struct tui_data_info *display_info;

/* Make sure the curses mode is enabled. */
tui_enable ();
@@ -142,22 +138,21 @@ tui_show_registers (struct reggroup *group)
if (TUI_DATA_WIN == NULL || !TUI_DATA_WIN->generic.is_visible)
tui_set_layout_by_name (DATA_NAME);

- display_info = &TUI_DATA_WIN->detail.data_display_info;
if (group == 0)
group = general_reggroup;

/* Say that registers should be displayed, even if there is a
problem. */
- display_info->display_regs = TRUE;
+ TUI_DATA_WIN->display_regs = TRUE;

if (target_has_registers && target_has_stack && target_has_memory)
{
ret = tui_show_register_group (group, get_selected_frame (NULL),
- group == display_info->current_group);
+ group == TUI_DATA_WIN->current_group);
}
if (ret == TUI_FAILURE)
{
- display_info->current_group = 0;
+ TUI_DATA_WIN->current_group = 0;
tui_erase_data_content (NO_REGS_STRING);
}
else
@@ -165,17 +160,17 @@ tui_show_registers (struct reggroup *group)
int i;

/* Clear all notation of changed values. */
- for (i = 0; i < display_info->regs_content_count; i++)
+ for (i = 0; i < TUI_DATA_WIN->regs_content_count; i++)
{
struct tui_gen_win_info *data_item_win;
struct tui_win_element *win;

- data_item_win = &display_info->regs_content[i]
+ data_item_win = &TUI_DATA_WIN->regs_content[i]
->which_element.data_window;
win = data_item_win->content[0];
win->which_element.data.highlight = FALSE;
}
- display_info->current_group = group;
+ TUI_DATA_WIN->current_group = group;
tui_display_all_data ();
}
}
@@ -196,7 +191,6 @@ tui_show_register_group (struct reggroup *group,
int allocated_here = FALSE;
int regnum, pos;
char title[80];
- struct tui_data_info *display_info = &TUI_DATA_WIN->detail.data_display_info;

/* Make a new title showing which group we display. */
snprintf (title, sizeof (title) - 1, "Register group: %s",
@@ -223,29 +217,29 @@ tui_show_register_group (struct reggroup *group,
nr_regs++;
}

- if (display_info->regs_content_count > 0 && !refresh_values_only)
+ if (TUI_DATA_WIN->regs_content_count > 0 && !refresh_values_only)
{
- tui_free_data_content (display_info->regs_content,
- display_info->regs_content_count);
- display_info->regs_content_count = 0;
+ tui_free_data_content (TUI_DATA_WIN->regs_content,
+ TUI_DATA_WIN->regs_content_count);
+ TUI_DATA_WIN->regs_content_count = 0;
}

- if (display_info->regs_content_count <= 0)
+ if (TUI_DATA_WIN->regs_content_count <= 0)
{
- display_info->regs_content = tui_alloc_content (nr_regs, DATA_WIN);
+ TUI_DATA_WIN->regs_content = tui_alloc_content (nr_regs, DATA_WIN);
allocated_here = TRUE;
refresh_values_only = FALSE;
}

- if (display_info->regs_content != NULL)
+ if (TUI_DATA_WIN->regs_content != NULL)
{
if (!refresh_values_only || allocated_here)
{
TUI_DATA_WIN->generic.content = NULL;
TUI_DATA_WIN->generic.content_size = 0;
tui_add_content_elements (&TUI_DATA_WIN->generic, nr_regs);
- display_info->regs_content = TUI_DATA_WIN->generic.content;
- display_info->regs_content_count = nr_regs;
+ TUI_DATA_WIN->regs_content = TUI_DATA_WIN->generic.content;
+ TUI_DATA_WIN->regs_content_count = nr_regs;
}

/* Now set the register names and values. */
@@ -267,7 +261,7 @@ tui_show_register_group (struct reggroup *group,
continue;

data_item_win =
- &display_info->regs_content[pos]->which_element.data_window;
+ &TUI_DATA_WIN->regs_content[pos]->which_element.data_window;
data = &data_item_win->content[0]->which_element.data;
if (data)
{
@@ -283,7 +277,7 @@ tui_show_register_group (struct reggroup *group,
}

TUI_DATA_WIN->generic.content_size =
- display_info->regs_content_count + display_info->data_content_count;
+ TUI_DATA_WIN->regs_content_count + TUI_DATA_WIN->data_content_count;
ret = TUI_SUCCESS;
}

@@ -297,16 +291,14 @@ tui_show_register_group (struct reggroup *group,
void
tui_display_registers_from (int start_element_no)
{
- struct tui_data_info *display_info = &TUI_DATA_WIN->detail.data_display_info;
-
- if (display_info->regs_content != NULL
- && display_info->regs_content_count > 0)
+ if (TUI_DATA_WIN->regs_content != NULL
+ && TUI_DATA_WIN->regs_content_count > 0)
{
int i = start_element_no;
int j, item_win_width, cur_y;

int max_len = 0;
- for (i = 0; i < display_info->regs_content_count; i++)
+ for (i = 0; i < TUI_DATA_WIN->regs_content_count; i++)
{
struct tui_data_element *data;
struct tui_gen_win_info *data_item_win;
@@ -314,7 +306,7 @@ tui_display_registers_from (int start_element_no)
int len;

data_item_win
- = &display_info->regs_content[i]->which_element.data_window;
+ = &TUI_DATA_WIN->regs_content[i]->which_element.data_window;
data = &data_item_win->content[0]->which_element.data;
len = 0;
p = data->content;
@@ -333,29 +325,29 @@ tui_display_registers_from (int start_element_no)
item_win_width = max_len + 1;
i = start_element_no;

- display_info->regs_column_count =
+ TUI_DATA_WIN->regs_column_count =
(TUI_DATA_WIN->generic.width - 2) / item_win_width;
- if (display_info->regs_column_count == 0)
- display_info->regs_column_count = 1;
+ if (TUI_DATA_WIN->regs_column_count == 0)
+ TUI_DATA_WIN->regs_column_count = 1;
item_win_width =
- (TUI_DATA_WIN->generic.width - 2) / display_info->regs_column_count;
+ (TUI_DATA_WIN->generic.width - 2) / TUI_DATA_WIN->regs_column_count;

/* Now create each data "sub" window, and write the display into
it. */
cur_y = 1;
- while (i < display_info->regs_content_count
+ while (i < TUI_DATA_WIN->regs_content_count
&& cur_y <= TUI_DATA_WIN->generic.viewport_height)
{
for (j = 0;
- j < display_info->regs_column_count
- && i < display_info->regs_content_count;
+ j < TUI_DATA_WIN->regs_column_count
+ && i < TUI_DATA_WIN->regs_content_count;
j++)
{
struct tui_gen_win_info *data_item_win;
struct tui_data_element *data_element_ptr;

/* Create the window if necessary. */
- data_item_win = &display_info->regs_content[i]
+ data_item_win = &TUI_DATA_WIN->regs_content[i]
->which_element.data_window;
data_element_ptr = &data_item_win->content[0]->which_element.data;
if (data_item_win->handle != NULL
@@ -398,8 +390,8 @@ static void
tui_display_reg_element_at_line (int start_element_no,
int start_line_no)
{
- if (TUI_DATA_WIN->detail.data_display_info.regs_content != NULL
- && TUI_DATA_WIN->detail.data_display_info.regs_content_count > 0)
+ if (TUI_DATA_WIN->regs_content != NULL
+ && TUI_DATA_WIN->regs_content_count > 0)
{
int element_no = start_element_no;

@@ -417,7 +409,7 @@ tui_display_reg_element_at_line (int start_element_no,
the element_no causes us to scroll past the end of the
registers, adjust what element to really start the
display at. */
- if (TUI_DATA_WIN->detail.data_display_info.data_content_count <= 0
+ if (TUI_DATA_WIN->data_content_count <= 0
&& start_line_no > first_line_on_last_page)
element_no
= tui_first_reg_element_no_inline (first_line_on_last_page);
@@ -435,7 +427,7 @@ int
tui_display_registers_from_line (int line_no,
int force_display)
{
- if (TUI_DATA_WIN->detail.data_display_info.regs_content_count > 0)
+ if (TUI_DATA_WIN->regs_content_count > 0)
{
int line, element_no;

@@ -448,7 +440,7 @@ tui_display_registers_from_line (int line_no,
if (line_no >= tui_last_regs_line_no ())
{
if ((line = tui_line_from_reg_element_no (
- TUI_DATA_WIN->detail.data_display_info.regs_content_count - 1)) < 0)
+ TUI_DATA_WIN->regs_content_count - 1)) < 0)
line = 0;
}
else
@@ -459,7 +451,7 @@ tui_display_registers_from_line (int line_no,

element_no = tui_first_reg_element_no_inline (line);
if (element_no
- < TUI_DATA_WIN->detail.data_display_info.regs_content_count)
+ < TUI_DATA_WIN->regs_content_count)
tui_display_reg_element_at_line (element_no, line);
else
line = (-1);
@@ -480,23 +472,20 @@ tui_check_register_values (struct frame_info *frame)
if (TUI_DATA_WIN != NULL
&& TUI_DATA_WIN->generic.is_visible)
{
- struct tui_data_info *display_info
- = &TUI_DATA_WIN->detail.data_display_info;
-
- if (display_info->regs_content_count <= 0
- && display_info->display_regs)
- tui_show_registers (display_info->current_group);
+ if (TUI_DATA_WIN->regs_content_count <= 0
+ && TUI_DATA_WIN->display_regs)
+ tui_show_registers (TUI_DATA_WIN->current_group);
else
{
int i;

- for (i = 0; (i < display_info->regs_content_count); i++)
+ for (i = 0; (i < TUI_DATA_WIN->regs_content_count); i++)
{
struct tui_data_element *data;
struct tui_gen_win_info *data_item_win_ptr;
int was_hilighted;

- data_item_win_ptr = &display_info->regs_content[i]->
+ data_item_win_ptr = &TUI_DATA_WIN->regs_content[i]->
which_element.data_window;
data = &data_item_win_ptr->content[0]->which_element.data;
was_hilighted = data->highlight;
@@ -560,7 +549,7 @@ tui_reg_next (struct gdbarch *gdbarch)

if (TUI_DATA_WIN != NULL)
{
- group = TUI_DATA_WIN->detail.data_display_info.current_group;
+ group = TUI_DATA_WIN->current_group;
group = reggroup_next (gdbarch, group);
if (group == NULL)
group = reggroup_next (gdbarch, NULL);
@@ -579,7 +568,7 @@ tui_reg_prev (struct gdbarch *gdbarch)

if (TUI_DATA_WIN != NULL)
{
- group = TUI_DATA_WIN->detail.data_display_info.current_group;
+ group = TUI_DATA_WIN->current_group;
group = reggroup_prev (gdbarch, group);
if (group == NULL)
group = reggroup_prev (gdbarch, NULL);
diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
index 0c9661f1cbe..a0f20c309e1 100644
--- a/gdb/tui/tui-windata.c
+++ b/gdb/tui/tui-windata.c
@@ -121,8 +121,8 @@ tui_display_all_data (void)
tui_display_registers_from (0);

/* Then display the other data. */
- if (TUI_DATA_WIN->detail.data_display_info.data_content != NULL
- && TUI_DATA_WIN->detail.data_display_info.data_content_count > 0)
+ if (TUI_DATA_WIN->data_content != NULL
+ && TUI_DATA_WIN->data_content_count > 0)
{
}
}
@@ -143,7 +143,7 @@ tui_display_data_from_line (int line_no)

/* There is no general data, force regs to display (if there are
any). */
- if (TUI_DATA_WIN->detail.data_display_info.data_content_count <= 0)
+ if (TUI_DATA_WIN->data_content_count <= 0)
tui_display_registers_from_line (_line_no, TRUE);
else
{
@@ -175,7 +175,7 @@ tui_display_data_from (int element_no, int reuse_windows)
{
int first_line = (-1);

- if (element_no < TUI_DATA_WIN->detail.data_display_info.regs_content_count)
+ if (element_no < TUI_DATA_WIN->regs_content_count)
first_line = tui_line_from_reg_element_no (element_no);
else
{ /* Calculate the first_line from the element number. */
@@ -218,16 +218,14 @@ tui_check_data_values (struct frame_info *frame)
{
int i;

- for (i = 0;
- TUI_DATA_WIN->detail.data_display_info.data_content_count;
- i++)
+ for (i = 0; TUI_DATA_WIN->data_content_count; i++)
{
#ifdef LATER
tui_data_element_ptr data_element_ptr;
struct tui_gen_win_info *data_item_win_ptr;
Opaque new_value;

- data_item_ptr = &TUI_DATA_WIN->detail.data_display_info.
+ data_item_ptr = &TUI_DATA_WIN->
data_content[i]->which_element.data_window;
data_element_ptr = &((tui_win_content)
data_item_win_ptr->content)[0]->which_element.data;
@@ -252,8 +250,7 @@ tui_data_window::do_scroll_vertical
int first_line = (-1);

first_element_no = tui_first_data_item_displayed ();
- if (first_element_no
- < detail.data_display_info.regs_content_count)
+ if (first_element_no < regs_content_count)
first_line = tui_line_from_reg_element_no (first_element_no);
else
{ /* Calculate the first line from the element number which is in
--
2.17.2