diff options
author | Tom Tromey <tom@tromey.com> | 2019-06-23 14:27:04 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-06-25 07:48:50 -0600 |
commit | 53e7cdbaa1d8c0c53038226de07d8160d7f66d82 (patch) | |
tree | 5a7bb07390157fe841fc65034a7bd7fa843a59bc /gdb/tui/tui-data.c | |
parent | 7908abbf18dde6d3163758e447d72d6d2b267927 (diff) | |
download | gdb-53e7cdbaa1d8c0c53038226de07d8160d7f66d82.zip gdb-53e7cdbaa1d8c0c53038226de07d8160d7f66d82.tar.gz gdb-53e7cdbaa1d8c0c53038226de07d8160d7f66d82.tar.bz2 |
Remove union tui_which_element
This removes union tui_which_element, instead moving the content
directly into tui_source_window_base. This allows for the deletion of
a fair amount of code. Now the TUI window hierarchy is more
type-safe. In particular, there is never any confusion now about
which members are in use by which subtype.
gdb/ChangeLog
2019-06-25 Tom Tromey <tom@tromey.com>
* tui/tui-winsource.h (tui_update_source_window_as_is)
(tui_alloc_source_buffer, tui_line_is_displayed)
(tui_addr_is_displayed): Change type of win_info.
* tui/tui-winsource.c (tui_update_source_window_as_is)
(tui_clear_source_content, tui_show_source_line)
(tui_show_source_content, tui_source_window_base::refill)
(tui_source_window_base::set_is_exec_point_at)
(tui_source_window_base::set_is_exec_point_at)
(tui_update_breakpoint_info, tui_set_exec_info_content): Update.
(tui_alloc_source_buffer, tui_line_is_displayed)
(tui_addr_is_displayed): Change type of win_info. Update.
* tui/tui-win.c (tui_resize_all, tui_adjust_win_heights)
(tui_source_window_base::do_make_visible_with_new_height):
Update.
* tui/tui-source.c (tui_set_source_content)
(tui_set_source_content_nil)
(tui_source_window::do_scroll_vertical): Update.
* tui/tui-layout.c (show_layout): Update.
* tui/tui-disasm.c (tui_set_disassem_content)
(tui_disasm_window::do_scroll_vertical): Update.
* tui/tui-data.h (tui_win_content): Remove.
(struct tui_gen_win_info) <content, content_size>: Remove.
(struct tui_source_element): Add initializers and destructor.
(union tui_which_element, struct tui_win_element): Remove.
(struct tui_source_window_base) <content>: New field.
(struct tui_data_window): Remove destructor.
(tui_alloc_content, tui_free_win_content)
(tui_free_all_source_wins_content): Don't declare.
* tui/tui-data.c (tui_initialize_static_data): Update.
(init_content_element, tui_alloc_content): Remove.
(~tui_gen_win_info): Update.
(~tui_data_window, tui_free_all_source_wins_content)
(tui_free_win_content, free_content, free_content_elements):
Remove.
Diffstat (limited to 'gdb/tui/tui-data.c')
-rw-r--r-- | gdb/tui/tui-data.c | 166 |
1 files changed, 0 insertions, 166 deletions
diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c index 5addd2d..a018a4b 100644 --- a/gdb/tui/tui-data.c +++ b/gdb/tui/tui-data.c @@ -47,18 +47,6 @@ static int win_resized = FALSE; /********************************* -** Static function forward decls -**********************************/ -static void free_content (tui_win_content, - int, - enum tui_win_type); -static void free_content_elements (tui_win_content, - int, - enum tui_win_type); - - - -/********************************* ** PUBLIC FUNCTIONS **********************************/ @@ -339,43 +327,14 @@ tui_initialize_static_data () win->origin.x = win->origin.y = win->viewport_height = - win->content_size = win->last_visible_line = 0; win->handle = NULL; - win->content = NULL; win->content_in_use = FALSE; win->is_visible = false; win->title = 0; } -/* init_content_element(). - */ -static void -init_content_element (struct tui_win_element *element, - enum tui_win_type type) -{ - gdb_assert (type != EXEC_INFO_WIN); - gdb_assert (type != LOCATOR_WIN); - gdb_assert (type != CMD_WIN); - gdb_assert (type != DATA_ITEM_WIN); - gdb_assert (type != DATA_WIN); - - switch (type) - { - case SRC_WIN: - case DISASSEM_WIN: - element->which_element.source.line = NULL; - element->which_element.source.line_or_addr.loa = LOA_LINE; - element->which_element.source.line_or_addr.u.line_no = 0; - element->which_element.source.is_exec_point = false; - element->which_element.source.has_break = FALSE; - break; - default: - break; - } -} - tui_win_info::tui_win_info (enum tui_win_type type) : tui_gen_win_info (type) { @@ -389,47 +348,12 @@ tui_source_window_base::tui_source_window_base (enum tui_win_type type) start_line_or_addr.u.addr = 0; } -/* Allocates the content and elements in a block. */ -tui_win_content -tui_alloc_content (int num_elements, enum tui_win_type type) -{ - tui_win_content content; - struct tui_win_element *element_block_ptr; - int i; - - gdb_assert (type != EXEC_INFO_WIN); - gdb_assert (type != LOCATOR_WIN); - - content = XNEWVEC (struct tui_win_element *, num_elements); - - /* - * All windows, except the data window, can allocate the - * elements in a chunk. The data window cannot because items - * can be added/removed from the data display by the user at any - * time. - */ - if (type != DATA_WIN) - { - element_block_ptr = XNEWVEC (struct tui_win_element, num_elements); - for (i = 0; i < num_elements; i++) - { - content[i] = element_block_ptr; - init_content_element (content[i], type); - element_block_ptr++; - } - } - - return content; -} - - tui_gen_win_info::~tui_gen_win_info () { if (handle != NULL) { tui_delete_win (handle); handle = NULL; - tui_free_win_content (this); } xfree (title); } @@ -440,103 +364,13 @@ tui_source_window_base::~tui_source_window_base () delete execution_info; } -tui_data_window::~tui_data_window () -{ - if (content != NULL) - { - regs_column_count = 1; - display_regs = false; - content = NULL; - content_size = 0; - } -} - -void -tui_free_all_source_wins_content () -{ - for (tui_source_window_base *win_info : tui_source_windows ()) - { - tui_free_win_content (win_info); - tui_free_win_content (win_info->execution_info); - } -} - - -void -tui_free_win_content (struct tui_gen_win_info *win_info) -{ - if (win_info->content != NULL) - { - free_content (win_info->content, - win_info->content_size, - win_info->type); - win_info->content = NULL; - } - win_info->content_size = 0; -} - - /********************************** ** LOCAL STATIC FUNCTIONS ** **********************************/ -static void -free_content (tui_win_content content, - int content_size, - enum tui_win_type win_type) -{ - if (content != NULL) - { - free_content_elements (content, content_size, win_type); - xfree (content); - } -} - - tui_data_item_window::~tui_data_item_window () { xfree (value); xfree (content); } - -/* free_content_elements(). - */ -static void -free_content_elements (tui_win_content content, - int content_size, - enum tui_win_type type) -{ - if (content != NULL) - { - int i; - - if (type == DISASSEM_WIN) - { - /* Free whole source block. */ - xfree (content[0]->which_element.source.line); - } - else - { - for (i = 0; i < content_size; i++) - { - struct tui_win_element *element; - - element = content[i]; - if (element != NULL) - { - switch (type) - { - case SRC_WIN: - xfree (element->which_element.source.line); - break; - default: - break; - } - } - } - } - if (type != DATA_WIN && type != DATA_ITEM_WIN) - xfree (content[0]); /* Free the element block. */ - } -} |