From 9d391078d1238e1be9dea5a775982a00a2497a57 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 28 Jun 2019 16:58:16 -0600 Subject: [PATCH] Add win_info parameter to tui_set_disassem_content This adds a win_info parameter to tui_set_disassem_content, removing uses of the TUI_DISASM_WIN global. gdb/ChangeLog 2019-07-17 Tom Tromey * tui/tui-winsource.c (tui_update_source_window_as_is): Update. * tui/tui-disasm.h (tui_set_disassem_content): Add win_info parameter. * tui/tui-disasm.c (tui_set_disassem_content): Add win_info parameter. --- gdb/ChangeLog | 8 ++++++++ gdb/tui/tui-disasm.c | 22 +++++++++++----------- gdb/tui/tui-disasm.h | 3 ++- gdb/tui/tui-winsource.c | 2 +- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8a2a71c4bac..cc372655525 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2019-07-17 Tom Tromey + + * tui/tui-winsource.c (tui_update_source_window_as_is): Update. + * tui/tui-disasm.h (tui_set_disassem_content): Add win_info + parameter. + * tui/tui-disasm.c (tui_set_disassem_content): Add win_info + parameter. + 2019-07-17 Tom Tromey * tui/tui-winsource.c (tui_clear_source_content) diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index af1a7406be8..a644c287cab 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -161,10 +161,11 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from) /* Function to set the disassembly window's content. */ enum tui_status -tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc) +tui_set_disassem_content (tui_source_window_base *win_info, + struct gdbarch *gdbarch, CORE_ADDR pc) { int i; - int offset = TUI_DISASM_WIN->horizontal_offset; + int offset = win_info->horizontal_offset; int max_lines, line_width; CORE_ADDR cur_pc; struct tui_locator_window *locator = tui_locator_win_info_ptr (); @@ -177,17 +178,16 @@ tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc) if (pc == 0) return TUI_FAILURE; - tui_alloc_source_buffer (TUI_DISASM_WIN); + tui_alloc_source_buffer (win_info); - tui_source_window_base *base = TUI_DISASM_WIN; - base->gdbarch = gdbarch; - base->start_line_or_addr.loa = LOA_ADDRESS; - base->start_line_or_addr.u.addr = pc; + win_info->gdbarch = gdbarch; + win_info->start_line_or_addr.loa = LOA_ADDRESS; + win_info->start_line_or_addr.u.addr = pc; cur_pc = locator->addr; /* Window size, excluding highlight box. */ - max_lines = TUI_DISASM_WIN->height - 2; - line_width = TUI_DISASM_WIN->width - 2; + max_lines = win_info->height - 2; + line_width = win_info->width - 2; /* Get temporary table that will hold all strings (addr & insn). */ asm_lines = XALLOCAVEC (struct tui_asm_line, max_lines); @@ -217,12 +217,12 @@ 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); + win_info->content.resize (max_lines); for (i = 0; i < max_lines; i++) { int cur_len; - tui_source_element *src = &TUI_DISASM_WIN->content[i]; + tui_source_element *src = &win_info->content[i]; strcpy (line, asm_lines[i].addr_string); cur_len = strlen (line); memset (line + cur_len, ' ', insn_pos - cur_len); diff --git a/gdb/tui/tui-disasm.h b/gdb/tui/tui-disasm.h index 925c7495947..59822c70c5c 100644 --- a/gdb/tui/tui-disasm.h +++ b/gdb/tui/tui-disasm.h @@ -25,7 +25,8 @@ #include "tui/tui.h" /* For enum tui_status. */ #include "tui/tui-data.h" /* For enum tui_scroll_direction. */ -extern enum tui_status tui_set_disassem_content (struct gdbarch *, CORE_ADDR); +extern enum tui_status tui_set_disassem_content (tui_source_window_base *, + struct gdbarch *, CORE_ADDR); extern void tui_show_disassem (struct gdbarch *, CORE_ADDR); extern void tui_show_disassem_and_update_source (struct gdbarch *, CORE_ADDR); extern void tui_get_begin_asm_address (struct gdbarch **, CORE_ADDR *); diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index 27edc4ed29c..a72ba360185 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -97,7 +97,7 @@ tui_update_source_window_as_is (struct tui_source_window_base *win_info, 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); + ret = tui_set_disassem_content (win_info, gdbarch, line_or_addr.u.addr); if (ret == TUI_FAILURE) { -- 2.30.2