From 3add462fff33beb0e6f1480d3853eb56d664b438 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 20 Jun 2019 20:16:07 -0600 Subject: Separate out locator window This introduces a new subclass of tui_gen_win_info for the locator, letting us remove another element from union tui_which_element. gdb/ChangeLog 2019-06-25 Tom Tromey * tui/tui-wingeneral.c (tui_refresh_all): Update. * tui/tui-win.c (tui_resize_all, tui_adjust_win_heights) (tui_source_window_base::set_new_height): Update. * tui/tui-stack.c (tui_make_status_line): Change parameter type. Update. (tui_set_locator_fullname, tui_set_locator_info) (tui_show_frame_info): Update. * tui/tui-source.c (tui_set_source_content) (tui_source_is_displayed): Update. * tui/tui-layout.c (show_source_disasm_command, show_data) (show_source_or_disasm_and_command): Update. * tui/tui-disasm.c (tui_set_disassem_content) (tui_get_begin_asm_address): Update. * tui/tui-data.h (struct tui_locator_element): Remove. (union tui_which_element) : Remove. (struct tui_locator_window): New. (tui_locator_win_info_ptr): Change return type. * tui/tui-data.c (_locator): Change type. (tui_locator_win_info_ptr): Change return type. (init_content_element): Remove LOCATOR_WIN case. Add assert. (tui_alloc_content): Add assert. --- gdb/tui/tui-stack.c | 74 +++++++++++++++++------------------------------------ 1 file changed, 24 insertions(+), 50 deletions(-) (limited to 'gdb/tui/tui-stack.c') diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c index efa2445..f761ac1 100644 --- a/gdb/tui/tui-stack.c +++ b/gdb/tui/tui-stack.c @@ -59,8 +59,8 @@ static void tui_update_command (const char *, int); /* Create the status line to display as much information as we can on this single line: target name, process number, current function, current line, current PC, SingleKey mode. */ -static char* -tui_make_status_line (struct tui_locator_element *loc) +static char * +tui_make_status_line (struct tui_locator_window *loc) { char *string; char line_buf[50], *pname; @@ -246,17 +246,13 @@ void tui_show_locator_content (void) { char *string; - struct tui_gen_win_info *locator; + struct tui_locator_window *locator; locator = tui_locator_win_info_ptr (); if (locator != NULL && locator->handle != NULL) { - struct tui_win_element *element; - - element = locator->content[0]; - - string = tui_make_status_line (&element->which_element.locator); + string = tui_make_status_line (locator); wmove (locator->handle, 0, 0); /* We ignore the return value from wstandout and wstandend, casting them to void in order to avoid a compiler warning. The warning @@ -279,18 +275,10 @@ tui_show_locator_content (void) static void tui_set_locator_fullname (const char *fullname) { - struct tui_gen_win_info *locator = tui_locator_win_info_ptr (); - struct tui_locator_element *element; - - if (locator->content[0] == NULL) - { - tui_set_locator_info (NULL, fullname, NULL, 0, 0); - return; - } + struct tui_locator_window *locator = tui_locator_win_info_ptr (); - element = &locator->content[0]->which_element.locator; - element->full_name[0] = 0; - strcat_to_buf (element->full_name, MAX_LOCATOR_ELEMENT_LEN, fullname); + locator->full_name[0] = 0; + strcat_to_buf (locator->full_name, MAX_LOCATOR_ELEMENT_LEN, fullname); } /* Update the locator, with the provided arguments. @@ -305,39 +293,28 @@ tui_set_locator_info (struct gdbarch *gdbarch, int lineno, CORE_ADDR addr) { - struct tui_gen_win_info *locator = tui_locator_win_info_ptr (); - struct tui_locator_element *element; + struct tui_locator_window *locator = tui_locator_win_info_ptr (); int locator_changed_p = 0; - /* Allocate the locator content if necessary. */ - if (locator->content_size <= 0) - { - locator->content = tui_alloc_content (1, LOCATOR_WIN); - locator->content_size = 1; - locator_changed_p = 1; - } - if (procname == NULL) procname = ""; if (fullname == NULL) fullname = ""; - element = &locator->content[0]->which_element.locator; - - locator_changed_p |= strncmp (element->proc_name, procname, + locator_changed_p |= strncmp (locator->proc_name, procname, MAX_LOCATOR_ELEMENT_LEN) != 0; - locator_changed_p |= lineno != element->line_no; - locator_changed_p |= addr != element->addr; - locator_changed_p |= gdbarch != element->gdbarch; - locator_changed_p |= strncmp (element->full_name, fullname, + locator_changed_p |= lineno != locator->line_no; + locator_changed_p |= addr != locator->addr; + locator_changed_p |= gdbarch != locator->gdbarch; + locator_changed_p |= strncmp (locator->full_name, fullname, MAX_LOCATOR_ELEMENT_LEN) != 0; - element->proc_name[0] = (char) 0; - strcat_to_buf (element->proc_name, MAX_LOCATOR_ELEMENT_LEN, procname); - element->line_no = lineno; - element->addr = addr; - element->gdbarch = gdbarch; + locator->proc_name[0] = (char) 0; + strcat_to_buf (locator->proc_name, MAX_LOCATOR_ELEMENT_LEN, procname); + locator->line_no = lineno; + locator->addr = addr; + locator->gdbarch = gdbarch; tui_set_locator_fullname (fullname); return locator_changed_p; @@ -366,7 +343,7 @@ tui_show_frame_info (struct frame_info *fi) { int start_line; CORE_ADDR low; - struct tui_gen_win_info *locator = tui_locator_win_info_ptr (); + struct tui_locator_window *locator = tui_locator_win_info_ptr (); int source_already_displayed; CORE_ADDR pc; @@ -398,12 +375,9 @@ tui_show_frame_info (struct frame_info *fi) start_line = 0; for (struct tui_source_window_base *win_info : tui_source_windows ()) { - union tui_which_element *item; - - item = &locator->content[0]->which_element; if (win_info == TUI_SRC_WIN) { - start_line = (item->locator.line_no - + start_line = (locator->line_no - (win_info->viewport_height / 2)) + 1; if (start_line <= 0) start_line = 1; @@ -429,13 +403,13 @@ tui_show_frame_info (struct frame_info *fi) l.loa = LOA_LINE; l.u.line_no = start_line; if (!(source_already_displayed - && tui_line_is_displayed (item->locator.line_no, + && tui_line_is_displayed (locator->line_no, win_info, TRUE))) tui_update_source_window (win_info, get_frame_arch (fi), sal.symtab, l, TRUE); else { - l.u.line_no = item->locator.line_no; + l.u.line_no = locator->line_no; win_info->set_is_exec_point_at (l); } } @@ -447,13 +421,13 @@ tui_show_frame_info (struct frame_info *fi) a.loa = LOA_ADDRESS; a.u.addr = low; - if (!tui_addr_is_displayed (item->locator.addr, + if (!tui_addr_is_displayed (locator->addr, win_info, TRUE)) tui_update_source_window (win_info, get_frame_arch (fi), sal.symtab, a, TRUE); else { - a.u.addr = item->locator.addr; + a.u.addr = locator->addr; win_info->set_is_exec_point_at (a); } } -- cgit v1.1