+2019-08-16 Tom Tromey <tom@tromey.com>
+
+ * tui/tui-winsource.h (struct tui_source_window_base)
+ <set_contents>: Declare.
+ * tui/tui-winsource.c
+ (tui_source_window_base::update_source_window_as_is): Update.
+ * tui/tui-source.h (struct tui_source_window) <set_contents>:
+ Declare.
+ (tui_set_source_content): Don't declare.
+ * tui/tui-source.c (tui_source_window::set_contents): Rename from
+ tui_set_source_content.
+ * tui/tui-disasm.h (struct tui_disasm_window) <set_contents>:
+ Declare.
+ (tui_set_disassem_content): Don't declare.
+ * tui/tui-disasm.c (tui_disasm_window::set_contents): Rename from
+ tui_set_disassem_content.
+
2019-08-16 Tom Tromey <tom@tromey.com>
* tui/tui-winsource.h (struct tui_source_window_base)
/* Function to set the disassembly window's content. */
enum tui_status
-tui_set_disassem_content (tui_source_window_base *win_info,
- struct gdbarch *gdbarch, CORE_ADDR pc)
+tui_disasm_window::set_contents (struct gdbarch *arch,
+ struct symtab *s,
+ struct tui_line_or_address line_or_addr)
{
int i;
- int offset = win_info->horizontal_offset;
+ int offset = horizontal_offset;
int max_lines, line_width;
CORE_ADDR cur_pc;
struct tui_locator_window *locator = tui_locator_win_info_ptr ();
int addr_size, insn_size;
char *line;
+ gdb_assert (line_or_addr.loa == LOA_ADDRESS);
+ CORE_ADDR pc = line_or_addr.u.addr;
if (pc == 0)
return TUI_FAILURE;
- win_info->gdbarch = gdbarch;
- win_info->start_line_or_addr.loa = LOA_ADDRESS;
- win_info->start_line_or_addr.u.addr = pc;
+ gdbarch = arch;
+ start_line_or_addr.loa = LOA_ADDRESS;
+ start_line_or_addr.u.addr = pc;
cur_pc = locator->addr;
/* Window size, excluding highlight box. */
- max_lines = win_info->height - 2;
- line_width = win_info->width - 2;
+ max_lines = height - 2;
+ line_width = width - 2;
/* Get temporary table that will hold all strings (addr & insn). */
asm_lines = XALLOCAVEC (struct tui_asm_line, max_lines);
line = (char*) alloca (insn_pos + insn_size + 1);
/* Now construct each line. */
- win_info->content.resize (max_lines);
+ content.resize (max_lines);
for (i = 0; i < max_lines; i++)
{
int cur_len;
- tui_source_element *src = &win_info->content[i];
+ tui_source_element *src = &content[i];
strcpy (line, asm_lines[i].addr_string);
cur_len = strlen (line);
memset (line + cur_len, ' ', insn_pos - cur_len);
void do_scroll_vertical (int num_to_scroll) override;
+ enum tui_status set_contents
+ (struct gdbarch *gdbarch,
+ struct symtab *s,
+ struct tui_line_or_address line_or_addr) override;
+
private:
/* Answer whether a particular line number or address is displayed
in the current source window. */
bool addr_is_displayed (CORE_ADDR addr) const;
};
-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 *);
/* Function to display source in the source window. */
enum tui_status
-tui_set_source_content (tui_source_window_base *win_info,
- struct symtab *s,
- int line_no)
+tui_source_window::set_contents (struct gdbarch *arch,
+ struct symtab *s,
+ struct tui_line_or_address line_or_addr)
{
+ gdb_assert (line_or_addr.loa == LOA_LINE);
+ int line_no = line_or_addr.u.line_no;
+
enum tui_status ret = TUI_FAILURE;
if (s != NULL)
int line_width, nlines;
ret = TUI_SUCCESS;
- line_width = win_info->width - 1;
+ line_width = width - 1;
/* Take hilite (window border) into account, when
calculating the number of lines. */
- nlines = (line_no + (win_info->height - 2)) - line_no;
+ nlines = (line_no + (height - 2)) - line_no;
std::string srclines;
if (!g_source_cache.get_source_lines (s, line_no, line_no + nlines,
= tui_locator_win_info_ptr ();
const char *s_filename = symtab_to_filename_for_display (s);
- xfree (win_info->title);
- win_info->title = xstrdup (s_filename);
+ xfree (title);
+ title = xstrdup (s_filename);
- xfree (win_info->fullname);
- win_info->fullname = xstrdup (symtab_to_fullname (s));
+ xfree (fullname);
+ fullname = xstrdup (symtab_to_fullname (s));
cur_line = 0;
- 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;
+ gdbarch = get_objfile_arch (SYMTAB_OBJFILE (s));
+ start_line_or_addr.loa = LOA_LINE;
+ cur_line_no = start_line_or_addr.u.line_no = line_no;
const char *iter = srclines.c_str ();
- win_info->content.resize (nlines);
+ content.resize (nlines);
while (cur_line < nlines)
{
struct tui_source_element *element
- = &win_info->content[cur_line];
+ = &content[cur_line];
std::string text;
if (*iter != '\0')
- text = copy_source_line (&iter, cur_line_no,
- win_info->horizontal_offset,
+ text = copy_source_line (&iter, cur_line_no, horizontal_offset,
line_width);
/* Set whether element is the execution point
symtab_to_fullname (s)) == 0
&& cur_line_no == locator->line_no);
- xfree (win_info->content[cur_line].line);
- win_info->content[cur_line].line
+ xfree (content[cur_line].line);
+ content[cur_line].line
= xstrdup (text.c_str ());
cur_line++;
void do_scroll_vertical (int num_to_scroll) override;
+ enum tui_status set_contents
+ (struct gdbarch *gdbarch,
+ struct symtab *s,
+ struct tui_line_or_address line_or_addr) override;
+
private:
void style_changed ();
gdb::observers::token m_observable;
};
-extern enum tui_status tui_set_source_content (tui_source_window_base *,
- struct symtab *,
- int);
extern void tui_show_symtab_source (tui_source_window_base *,
struct gdbarch *, struct symtab *,
struct tui_line_or_address);
struct symtab *s,
struct tui_line_or_address line_or_addr)
{
- enum tui_status ret;
-
- if (type == SRC_WIN)
- ret = tui_set_source_content (this, s, line_or_addr.u.line_no);
- else
- ret = tui_set_disassem_content (this, gdbarch, line_or_addr.u.addr);
+ enum tui_status ret
+ = set_contents (gdbarch, s, line_or_addr);
if (ret == TUI_FAILURE)
erase_source_content ();
void rerender () override;
+ virtual enum tui_status set_contents
+ (struct gdbarch *gdbarch,
+ struct symtab *s,
+ struct tui_line_or_address line_or_addr) = 0;
+
public:
void clear_detail ();