From: Tom Tromey Date: Mon, 24 Jun 2019 02:57:09 +0000 (-0600) Subject: Remove some uses of TUI_WIN_SRC X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5813316fa4aeaf52f374c20c7fdb9747b88fa8ca;p=binutils-gdb.git Remove some uses of TUI_WIN_SRC This adds a 'win_info' parameter to a couple of functions. This reduces the number of references to the TUI_WIN_SRC global. gdb/ChangeLog 2019-07-17 Tom Tromey * tui/tui-winsource.c (tui_update_source_window_as_is) (tui_update_source_windows_with_addr): Update. * tui/tui-source.h (tui_set_source_content) (tui_show_symtab_source): Add "win_info" parameter. * tui/tui-source.c (tui_set_source_content): Add "win_info" parameter. (tui_show_symtab_source): Likewise. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0648d3767cb..f3cd6e98264 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2019-07-17 Tom Tromey + + * tui/tui-winsource.c (tui_update_source_window_as_is) + (tui_update_source_windows_with_addr): Update. + * tui/tui-source.h (tui_set_source_content) + (tui_show_symtab_source): Add "win_info" parameter. + * tui/tui-source.c (tui_set_source_content): Add "win_info" + parameter. + (tui_show_symtab_source): Likewise. + 2019-07-17 Tom Tromey * tui/tui-wingeneral.c diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index 81ede061570..e62ee4ea5f9 100644 --- a/gdb/tui/tui-source.c +++ b/gdb/tui/tui-source.c @@ -123,7 +123,8 @@ copy_source_line (const char **ptr, int line_no, int first_col, /* Function to display source in the source window. */ enum tui_status -tui_set_source_content (struct symtab *s, +tui_set_source_content (tui_source_window_base *win_info, + struct symtab *s, int line_no, int noerror) { @@ -134,11 +135,11 @@ tui_set_source_content (struct symtab *s, int line_width, nlines; ret = TUI_SUCCESS; - tui_alloc_source_buffer (TUI_SRC_WIN); - line_width = TUI_SRC_WIN->width - 1; + tui_alloc_source_buffer (win_info); + line_width = win_info->width - 1; /* Take hilite (window border) into account, when calculating the number of lines. */ - nlines = (line_no + (TUI_SRC_WIN->height - 2)) - line_no; + nlines = (line_no + (win_info->height - 2)) - line_no; std::string srclines; if (!g_source_cache.get_source_lines (s, line_no, line_no + nlines, @@ -159,32 +160,30 @@ tui_set_source_content (struct symtab *s, int cur_line_no, cur_line; struct tui_locator_window *locator = tui_locator_win_info_ptr (); - struct tui_source_window_base *src - = (struct tui_source_window_base *) TUI_SRC_WIN; const char *s_filename = symtab_to_filename_for_display (s); - xfree (TUI_SRC_WIN->title); - TUI_SRC_WIN->title = xstrdup (s_filename); + xfree (win_info->title); + win_info->title = xstrdup (s_filename); - xfree (src->fullname); - src->fullname = xstrdup (symtab_to_fullname (s)); + xfree (win_info->fullname); + win_info->fullname = xstrdup (symtab_to_fullname (s)); cur_line = 0; - src->gdbarch = get_objfile_arch (SYMTAB_OBJFILE (s)); - src->start_line_or_addr.loa = LOA_LINE; - cur_line_no = src->start_line_or_addr.u.line_no = line_no; + win_info->gdbarch = get_objfile_arch (SYMTAB_OBJFILE (s)); + win_info->start_line_or_addr.loa = LOA_LINE; + cur_line_no = win_info->start_line_or_addr.u.line_no = line_no; const char *iter = srclines.c_str (); - TUI_SRC_WIN->content.resize (nlines); + win_info->content.resize (nlines); while (cur_line < nlines) { struct tui_source_element *element - = &TUI_SRC_WIN->content[cur_line]; + = &win_info->content[cur_line]; std::string text; if (*iter != '\0') text = copy_source_line (&iter, cur_line_no, - src->horizontal_offset, + win_info->horizontal_offset, line_width); /* Set whether element is the execution point @@ -196,8 +195,8 @@ tui_set_source_content (struct symtab *s, symtab_to_fullname (s)) == 0 && cur_line_no == locator->line_no); - xfree (TUI_SRC_WIN->content[cur_line].line); - TUI_SRC_WIN->content[cur_line].line + xfree (win_info->content[cur_line].line); + win_info->content[cur_line].line = xstrdup (text.c_str ()); cur_line++; @@ -276,12 +275,13 @@ tui_set_source_content_nil (struct tui_source_window_base *win_info, /* Function to display source in the source window. This function initializes the horizontal scroll to 0. */ void -tui_show_symtab_source (struct gdbarch *gdbarch, struct symtab *s, +tui_show_symtab_source (tui_source_window_base *win_info, + struct gdbarch *gdbarch, struct symtab *s, struct tui_line_or_address line, int noerror) { - TUI_SRC_WIN->horizontal_offset = 0; - tui_update_source_window_as_is (TUI_SRC_WIN, gdbarch, s, line, noerror); + win_info->horizontal_offset = 0; + tui_update_source_window_as_is (win_info, gdbarch, s, line, noerror); } diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h index 9e1dc1a6e10..8ceb194e392 100644 --- a/gdb/tui/tui-source.h +++ b/gdb/tui/tui-source.h @@ -30,9 +30,11 @@ struct tui_win_info; extern void tui_set_source_content_nil (struct tui_source_window_base *, const char *); -extern enum tui_status tui_set_source_content (struct symtab *, +extern enum tui_status tui_set_source_content (tui_source_window_base *, + struct symtab *, int, int); -extern void tui_show_symtab_source (struct gdbarch *, struct symtab *, +extern void tui_show_symtab_source (tui_source_window_base *, + struct gdbarch *, struct symtab *, struct tui_line_or_address, int); extern int tui_source_is_displayed (const char *); diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index dbede410278..c7c04dfe816 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -94,7 +94,8 @@ tui_update_source_window_as_is (struct tui_source_window_base *win_info, enum tui_status ret; if (win_info->type == SRC_WIN) - ret = tui_set_source_content (s, line_or_addr.u.line_no, noerror); + ret = tui_set_source_content (win_info, s, line_or_addr.u.line_no, + noerror); else ret = tui_set_disassem_content (gdbarch, line_or_addr.u.addr); @@ -121,7 +122,7 @@ tui_update_source_window_as_is (struct tui_source_window_base *win_info, we don't have a split layout. */ if (tui_win_with_focus () == TUI_DISASM_WIN && tui_current_layout () != SRC_DISASSEM_COMMAND) - tui_set_win_focus_to (TUI_SRC_WIN); + tui_set_win_focus_to (win_info); } } @@ -153,7 +154,7 @@ tui_update_source_windows_with_addr (struct gdbarch *gdbarch, CORE_ADDR addr) sal = find_pc_line (addr, 0); l.loa = LOA_LINE; l.u.line_no = sal.line; - tui_show_symtab_source (gdbarch, sal.symtab, l, FALSE); + tui_show_symtab_source (TUI_SRC_WIN, gdbarch, sal.symtab, l, FALSE); break; } } @@ -191,7 +192,7 @@ tui_update_source_windows_with_line (struct symtab *s, int line) default: l.loa = LOA_LINE; l.u.line_no = line; - tui_show_symtab_source (gdbarch, s, l, FALSE); + tui_show_symtab_source (TUI_SRC_WIN, gdbarch, s, l, FALSE); if (tui_current_layout () == SRC_DISASSEM_COMMAND) { find_line_pc (s, line, &pc);