void
tui_data_window::clear_detail ()
{
- regs_content = NULL;
- regs_content_count = 0;
+ regs_content.clear ();
regs_column_count = 1;
display_regs = false;
}
gdb_assert (type != LOCATOR_WIN);
gdb_assert (type != CMD_WIN);
gdb_assert (type != DATA_ITEM_WIN);
+ gdb_assert (type != DATA_WIN);
switch (type)
{
element->which_element.source.is_exec_point = FALSE;
element->which_element.source.has_break = FALSE;
break;
- case DATA_WIN:
- element->which_element.data_window = new tui_data_item_window ();
- break;
default:
break;
}
}
-/* Adds the input number of elements to the windows's content. If no
- content has been allocated yet, alloc_content() is called to do
- this. The index of the first element added is returned, unless
- there is a memory allocation error, in which case, (-1) is
- returned. */
-int
-tui_add_content_elements (struct tui_gen_win_info *win_info,
- int num_elements)
-{
- struct tui_win_element *element_ptr;
- int i, index_start;
-
- if (win_info->content == NULL)
- {
- win_info->content = tui_alloc_content (num_elements, win_info->type);
- index_start = 0;
- }
- else
- index_start = win_info->content_size;
- if (win_info->content != NULL)
- {
- for (i = index_start; (i < num_elements + index_start); i++)
- {
- element_ptr = XNEW (struct tui_win_element);
- win_info->content[i] = element_ptr;
- init_content_element (element_ptr, win_info->type);
- win_info->content_size++;
- }
- }
-
- return index_start;
-}
-
tui_gen_win_info::~tui_gen_win_info ()
{
if (handle != NULL)
{
if (content != NULL)
{
- tui_free_data_content (regs_content, regs_content_count);
- regs_content = NULL;
- regs_content_count = 0;
regs_column_count = 1;
display_regs = false;
content = NULL;
}
-void
-tui_free_data_content (tui_win_content content,
- int content_size)
-{
- int i;
-
- /* Remember that data window content elements are of type struct
- tui_gen_win_info *, each of which whose single element is a data
- element. */
- for (i = 0; i < content_size; i++)
- {
- struct tui_gen_win_info *generic_win
- = content[i]->which_element.data_window;
-
- if (generic_win != NULL)
- {
- tui_delete_win (generic_win->handle);
- generic_win->handle = NULL;
- tui_free_win_content (generic_win);
- }
- }
- free_content (content,
- content_size,
- DATA_WIN);
-}
-
-
/**********************************
** LOCAL STATIC FUNCTIONS **
**********************************/
case SRC_WIN:
xfree (element->which_element.source.line);
break;
- case DATA_WIN:
- delete element->which_element.data_window;
- xfree (element);
- break;
default:
break;
}
******************************************/
static void tui_display_register (struct tui_data_item_window *data);
-static enum tui_status tui_show_register_group (struct reggroup *group,
- struct frame_info *frame,
- int refresh_values_only);
+static void tui_show_register_group (struct reggroup *group,
+ struct frame_info *frame,
+ int refresh_values_only);
static enum tui_status tui_get_register (struct frame_info *frame,
struct tui_data_item_window *data,
{
int num_lines = (-1);
- if (TUI_DATA_WIN->regs_content_count > 0)
+ if (!TUI_DATA_WIN->regs_content.empty ())
{
- num_lines = (TUI_DATA_WIN->regs_content_count
+ num_lines = (TUI_DATA_WIN->regs_content.size ()
/ TUI_DATA_WIN->regs_column_count);
- if (TUI_DATA_WIN->regs_content_count % TUI_DATA_WIN->regs_column_count)
+ if (TUI_DATA_WIN->regs_content.size () % TUI_DATA_WIN->regs_column_count)
num_lines++;
}
return num_lines;
int
tui_line_from_reg_element_no (int element_no)
{
- if (element_no < TUI_DATA_WIN->regs_content_count)
+ if (element_no < TUI_DATA_WIN->regs_content.size ())
{
int i, line = (-1);
tui_first_reg_element_no_inline (int line_no)
{
if ((line_no * TUI_DATA_WIN->regs_column_count)
- <= TUI_DATA_WIN->regs_content_count)
+ <= TUI_DATA_WIN->regs_content.size ())
return (((line_no + 1) * TUI_DATA_WIN->regs_column_count)
- TUI_DATA_WIN->regs_column_count);
else
if (target_has_registers && target_has_stack && target_has_memory)
{
- ret = tui_show_register_group (group, get_selected_frame (NULL),
- group == TUI_DATA_WIN->current_group);
+ tui_show_register_group (group, get_selected_frame (NULL),
+ group == TUI_DATA_WIN->current_group);
+ ret = TUI_SUCCESS;
}
if (ret == TUI_FAILURE)
{
}
else
{
- int i;
-
/* Clear all notation of changed values. */
- for (i = 0; i < TUI_DATA_WIN->regs_content_count; i++)
+ for (auto &&data_item_win : TUI_DATA_WIN->regs_content)
{
- struct tui_data_item_window *data_item_win;
-
- data_item_win = TUI_DATA_WIN->regs_content[i]
- ->which_element.data_window;
- data_item_win->highlight = false;
+ if (data_item_win != nullptr)
+ data_item_win->highlight = false;
}
TUI_DATA_WIN->current_group = group;
tui_display_all_data ();
using the given frame. Values are refreshed only when
refresh_values_only is TRUE. */
-static enum tui_status
+static void
tui_show_register_group (struct reggroup *group,
struct frame_info *frame,
int refresh_values_only)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
- enum tui_status ret = TUI_FAILURE;
int nr_regs;
- int allocated_here = FALSE;
int regnum, pos;
char title[80];
nr_regs++;
}
- if (TUI_DATA_WIN->regs_content_count > 0 && !refresh_values_only)
- {
- tui_free_data_content (TUI_DATA_WIN->regs_content,
- TUI_DATA_WIN->regs_content_count);
- TUI_DATA_WIN->regs_content_count = 0;
- }
+ if (!refresh_values_only)
+ TUI_DATA_WIN->regs_content.clear ();
- if (TUI_DATA_WIN->regs_content_count <= 0)
+ if (nr_regs < TUI_DATA_WIN->regs_content.size ())
+ TUI_DATA_WIN->regs_content.resize (nr_regs);
+ else
{
- TUI_DATA_WIN->regs_content = tui_alloc_content (nr_regs, DATA_WIN);
- allocated_here = TRUE;
- refresh_values_only = FALSE;
+ for (int i = TUI_DATA_WIN->regs_content.size (); i < nr_regs; ++i)
+ TUI_DATA_WIN->regs_content.emplace_back (new tui_data_item_window ());
}
- if (TUI_DATA_WIN->regs_content != NULL)
+ /* Now set the register names and values. */
+ pos = 0;
+ for (regnum = 0; regnum < gdbarch_num_cooked_regs (gdbarch); regnum++)
{
- if (!refresh_values_only || allocated_here)
- {
- TUI_DATA_WIN->content = NULL;
- TUI_DATA_WIN->content_size = 0;
- tui_add_content_elements (TUI_DATA_WIN, nr_regs);
- TUI_DATA_WIN->regs_content = TUI_DATA_WIN->content;
- TUI_DATA_WIN->regs_content_count = nr_regs;
- }
+ struct tui_data_item_window *data_item_win;
+ const char *name;
- /* Now set the register names and values. */
- pos = 0;
- for (regnum = 0; regnum < gdbarch_num_cooked_regs (gdbarch); regnum++)
- {
- struct tui_data_item_window *data_item_win;
- const char *name;
-
- /* Must be in the group. */
- if (!gdbarch_register_reggroup_p (gdbarch, regnum, group))
- continue;
-
- /* If the register name is empty, it is undefined for this
- processor, so don't display anything. */
- name = gdbarch_register_name (gdbarch, regnum);
- if (name == 0 || *name == '\0')
- continue;
-
- data_item_win =
- TUI_DATA_WIN->regs_content[pos]->which_element.data_window;
- if (data_item_win)
- {
- if (!refresh_values_only)
- {
- data_item_win->item_no = regnum;
- data_item_win->name = name;
- data_item_win->highlight = false;
- }
- tui_get_register (frame, data_item_win, regnum, 0);
- }
- pos++;
- }
+ /* Must be in the group. */
+ if (!gdbarch_register_reggroup_p (gdbarch, regnum, group))
+ continue;
- TUI_DATA_WIN->content_size = TUI_DATA_WIN->regs_content_count;
- ret = TUI_SUCCESS;
- }
+ /* If the register name is empty, it is undefined for this
+ processor, so don't display anything. */
+ name = gdbarch_register_name (gdbarch, regnum);
+ if (name == 0 || *name == '\0')
+ continue;
- return ret;
+ data_item_win = TUI_DATA_WIN->regs_content[pos].get ();
+ if (data_item_win)
+ {
+ if (!refresh_values_only)
+ {
+ data_item_win->item_no = regnum;
+ data_item_win->name = name;
+ data_item_win->highlight = false;
+ }
+ tui_get_register (frame, data_item_win, regnum, 0);
+ }
+ pos++;
+ }
}
/* Function to display the registers in the content from
void
tui_display_registers_from (int start_element_no)
{
- if (TUI_DATA_WIN->regs_content != NULL
- && TUI_DATA_WIN->regs_content_count > 0)
+ if (!TUI_DATA_WIN->regs_content.empty ())
{
- int i = start_element_no;
int j, item_win_width, cur_y;
int max_len = 0;
- for (i = 0; i < TUI_DATA_WIN->regs_content_count; i++)
+ for (auto &&data_item_win : TUI_DATA_WIN->regs_content)
{
- struct tui_data_item_window *data_item_win;
char *p;
int len;
- data_item_win
- = TUI_DATA_WIN->regs_content[i]->which_element.data_window;
len = 0;
p = data_item_win->content;
if (p != 0)
max_len = len;
}
item_win_width = max_len + 1;
- i = start_element_no;
+ int i = start_element_no;
TUI_DATA_WIN->regs_column_count =
(TUI_DATA_WIN->width - 2) / item_win_width;
/* Now create each data "sub" window, and write the display into
it. */
cur_y = 1;
- while (i < TUI_DATA_WIN->regs_content_count
+ while (i < TUI_DATA_WIN->regs_content.size ()
&& cur_y <= TUI_DATA_WIN->viewport_height)
{
for (j = 0;
j < TUI_DATA_WIN->regs_column_count
- && i < TUI_DATA_WIN->regs_content_count;
+ && i < TUI_DATA_WIN->regs_content.size ();
j++)
{
struct tui_data_item_window *data_item_win;
/* Create the window if necessary. */
- data_item_win = TUI_DATA_WIN->regs_content[i]
- ->which_element.data_window;
+ data_item_win = TUI_DATA_WIN->regs_content[i].get ();
if (data_item_win->handle != NULL
&& (data_item_win->height != 1
|| data_item_win->width != item_win_width
tui_display_reg_element_at_line (int start_element_no,
int start_line_no)
{
- if (TUI_DATA_WIN->regs_content != NULL
- && TUI_DATA_WIN->regs_content_count > 0)
+ if (!TUI_DATA_WIN->regs_content.empty ())
{
int element_no = start_element_no;
tui_display_registers_from_line (int line_no,
int force_display)
{
- if (TUI_DATA_WIN->regs_content_count > 0)
+ if (!TUI_DATA_WIN->regs_content.empty ())
{
int line, element_no;
if (line_no >= tui_last_regs_line_no ())
{
if ((line = tui_line_from_reg_element_no (
- TUI_DATA_WIN->regs_content_count - 1)) < 0)
+ TUI_DATA_WIN->regs_content.size () - 1)) < 0)
line = 0;
}
else
line = line_no;
element_no = tui_first_reg_element_no_inline (line);
- if (element_no
- < TUI_DATA_WIN->regs_content_count)
+ if (element_no < TUI_DATA_WIN->regs_content.size ())
tui_display_reg_element_at_line (element_no, line);
else
line = (-1);
if (TUI_DATA_WIN != NULL
&& TUI_DATA_WIN->is_visible)
{
- if (TUI_DATA_WIN->regs_content_count <= 0
+ if (TUI_DATA_WIN->regs_content.empty ()
&& TUI_DATA_WIN->display_regs)
tui_show_registers (TUI_DATA_WIN->current_group);
else
{
- int i;
-
- for (i = 0; (i < TUI_DATA_WIN->regs_content_count); i++)
+ for (auto &&data_item_win_ptr : TUI_DATA_WIN->regs_content)
{
- struct tui_data_item_window *data_item_win_ptr;
int was_hilighted;
- data_item_win_ptr = TUI_DATA_WIN->regs_content[i]->
- which_element.data_window;
was_hilighted = data_item_win_ptr->highlight;
- tui_get_register (frame, data_item_win_ptr,
+ tui_get_register (frame, data_item_win_ptr.get (),
data_item_win_ptr->item_no,
&data_item_win_ptr->highlight);
if (data_item_win_ptr->highlight || was_hilighted)
- {
- tui_display_register (data_item_win_ptr);
- }
+ tui_display_register (data_item_win_ptr.get ());
}
}
}