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-disasm.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-disasm.c')
-rw-r--r-- | gdb/tui/tui-disasm.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index 6b88d96..d3d53d7 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -219,27 +219,23 @@ tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc) line = (char*) alloca (insn_pos + insn_size + 1); /* Now construct each line. */ + TUI_DISASM_WIN->content.resize (max_lines); for (i = 0; i < max_lines; i++) { - struct tui_win_element *element; - struct tui_source_element *src; int cur_len; - element = TUI_DISASM_WIN->content[i]; - src = &element->which_element.source; + tui_source_element *src = &TUI_DISASM_WIN->content[i]; strcpy (line, asm_lines[i].addr_string); cur_len = strlen (line); memset (line + cur_len, ' ', insn_pos - cur_len); strcpy (line + insn_pos, asm_lines[i].insn); /* Now copy the line taking the offset into account. */ + xfree (src->line); if (strlen (line) > offset) - { - strncpy (src->line, &line[offset], line_width); - src->line[line_width] = '\0'; - } + src->line = xstrndup (&line[offset], line_width); else - src->line[0] = '\0'; + src->line = xstrdup (""); src->line_or_addr.loa = LOA_ADDRESS; src->line_or_addr.u.addr = asm_lines[i].addr; @@ -254,7 +250,6 @@ tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc) xfree (asm_lines[i].addr_string); xfree (asm_lines[i].insn); } - TUI_DISASM_WIN->content_size = i; return TUI_SUCCESS; } @@ -371,12 +366,12 @@ tui_get_low_disassembly_address (struct gdbarch *gdbarch, void tui_disasm_window::do_scroll_vertical (int num_to_scroll) { - if (content != NULL) + if (!content.empty ()) { CORE_ADDR pc; struct tui_line_or_address val; - pc = content[0]->which_element.source.line_or_addr.u.addr; + pc = content[0].line_or_addr.u.addr; if (num_to_scroll >= 0) num_to_scroll++; else |