+2019-12-20 Tom Tromey <tom@tromey.com>
+
+ * tui/tui-winsource.h (struct tui_source_window_base)
+ <set_contents, update_source_window_as_is, update_source_window>:
+ Take a sal, not a separate symtab and tui_line_or_address.
+ * tui/tui-winsource.c (tui_source_window_base::update_source_window)
+ (tui_source_window_base::update_source_window_as_is): Take a sal,
+ not a separate symtab and tui_line_or_address.
+ (tui_update_source_windows_with_addr)
+ (tui_update_source_windows_with_line)
+ (tui_source_window_base::rerender)
+ (tui_source_window_base::refill): Update.
+ * tui/tui-source.h (struct tui_source_window) <set_contents>: Take
+ a sal, not a separate symtab and tui_line_or_address.
+ * tui/tui-source.c (tui_source_window::set_contents): Take a sal,
+ not a separate symtab and tui_line_or_address.
+ (tui_source_window::maybe_update): Update.
+ * tui/tui-disasm.h (struct tui_disasm_window) <set_contents>: Take
+ a sal, not a separate symtab and tui_line_or_address.
+ * tui/tui-disasm.c (tui_disasm_window::set_contents): Take a sal,
+ not a separate symtab and tui_line_or_address.
+ (tui_disasm_window::do_scroll_vertical)
+ (tui_disasm_window::maybe_update): Update.
+
2019-12-20 Tom Tromey <tom@tromey.com>
* tui/tui-winsource.c (tui_source_window_base::refill): Use
/* Function to set the disassembly window's content. */
bool
tui_disasm_window::set_contents (struct gdbarch *arch,
- struct symtab *s,
- struct tui_line_or_address line_or_addr)
+ const struct symtab_and_line &sal)
{
int i;
int offset = horizontal_offset;
int tab_len = tui_tab_width;
int insn_pos;
- gdb_assert (line_or_addr.loa == LOA_ADDRESS);
- CORE_ADDR pc = line_or_addr.u.addr;
+ CORE_ADDR pc = sal.pc;
if (pc == 0)
return false;
if (!content.empty ())
{
CORE_ADDR pc;
- struct tui_line_or_address val;
pc = start_line_or_addr.u.addr;
if (num_to_scroll >= 0)
else
--num_to_scroll;
- val.loa = LOA_ADDRESS;
- val.u.addr = tui_find_disassembly_address (gdbarch, pc, num_to_scroll);
- update_source_window_as_is (gdbarch, NULL, val);
+ symtab_and_line sal {};
+ sal.pspace = current_program_space;
+ sal.pc = tui_find_disassembly_address (gdbarch, pc, num_to_scroll);
+ update_source_window_as_is (gdbarch, sal);
}
}
a.loa = LOA_ADDRESS;
a.u.addr = low;
if (!addr_is_displayed (sal.pc))
- update_source_window (frame_arch, sal.symtab, a);
+ {
+ sal.pc = low;
+ update_source_window (frame_arch, sal);
+ }
else
{
a.u.addr = sal.pc;
/* Function to display source in the source window. */
bool
tui_source_window::set_contents (struct gdbarch *arch,
- struct symtab *s,
- struct tui_line_or_address line_or_addr)
+ const struct symtab_and_line &sal)
{
- gdb_assert (line_or_addr.loa == LOA_LINE);
- int line_no = line_or_addr.u.line_no;
+ struct symtab *s = sal.symtab;
+ int line_no = sal.line;
if (s == NULL)
return false;
bool source_already_displayed = (sal.symtab != 0
&& showing_source_p (m_fullname.get ()));
- struct tui_line_or_address l;
-
- l.loa = LOA_LINE;
- l.u.line_no = start_line;
if (!(source_already_displayed && line_is_displayed (sal.line)))
- update_source_window (get_frame_arch (fi), sal.symtab, l);
+ {
+ sal.line = start_line;
+ update_source_window (get_frame_arch (fi), sal);
+ }
else
{
+ struct tui_line_or_address l;
+
+ l.loa = LOA_LINE;
l.u.line_no = sal.line;
set_is_exec_point_at (l);
}
void
tui_source_window_base::update_source_window
(struct gdbarch *gdbarch,
- struct symtab *s,
- struct tui_line_or_address line_or_addr)
+ const struct symtab_and_line &sal)
{
horizontal_offset = 0;
- update_source_window_as_is (gdbarch, s, line_or_addr);
+ update_source_window_as_is (gdbarch, sal);
}
void
tui_source_window_base::update_source_window_as_is
(struct gdbarch *gdbarch,
- struct symtab *s,
- struct tui_line_or_address line_or_addr)
+ const struct symtab_and_line &sal)
{
- bool ret = set_contents (gdbarch, s, line_or_addr);
+ bool ret = set_contents (gdbarch, sal);
if (!ret)
erase_source_content ();
update_exec_info ();
if (type == SRC_WIN)
{
- symtab_and_line sal;
+ symtab_and_line new_sal = sal;
- sal.line = line_or_addr.u.line_no + (content.size () - 2);
- sal.symtab = s;
- sal.pspace = SYMTAB_PSPACE (s);
- set_current_source_symtab_and_line (sal);
+ new_sal.line = sal.line + (content.size () - 2);
+ set_current_source_symtab_and_line (new_sal);
}
}
}
if (addr != 0)
{
struct symtab_and_line sal = find_pc_line (addr, 0);
- struct tui_line_or_address l;
if (TUI_DISASM_WIN != nullptr)
- {
- l.loa = LOA_ADDRESS;
- l.u.addr = addr;
- TUI_DISASM_WIN->update_source_window (gdbarch, sal.symtab, l);
- }
+ TUI_DISASM_WIN->update_source_window (gdbarch, sal);
if (TUI_SRC_WIN != nullptr)
- {
- l.loa = LOA_LINE;
- l.u.line_no = sal.line;
- TUI_SRC_WIN->update_source_window (gdbarch, sal.symtab, l);
- }
+ TUI_SRC_WIN->update_source_window (gdbarch, sal);
}
else
{
{
struct gdbarch *gdbarch;
CORE_ADDR pc;
- struct tui_line_or_address l;
+ struct symtab_and_line sal;
if (!s)
return;
+ sal.pspace = current_program_space;
+ sal.symtab = s;
+ sal.line = line;
+
gdbarch = get_objfile_arch (SYMTAB_OBJFILE (s));
switch (tui_current_layout ())
tui_update_source_windows_with_addr (gdbarch, pc);
break;
default:
- l.loa = LOA_LINE;
- l.u.line_no = line;
- TUI_SRC_WIN->update_source_window (gdbarch, s, l);
+ find_line_pc (s, line, &pc);
+ sal.pc = pc;
+ TUI_SRC_WIN->update_source_window (gdbarch, sal);
if (tui_current_layout () == SRC_DISASSEM_COMMAND)
- {
- find_line_pc (s, line, &pc);
- l.loa = LOA_ADDRESS;
- l.u.addr = pc;
- TUI_DISASM_WIN->update_source_window (gdbarch, s, l);
- }
+ TUI_DISASM_WIN->update_source_window (gdbarch, sal);
break;
}
}
{
if (!content.empty ())
{
- struct tui_line_or_address line_or_addr;
struct symtab_and_line cursal
= get_current_source_symtab_and_line ();
- line_or_addr = start_line_or_addr;
- update_source_window (gdbarch, cursal.symtab, line_or_addr);
+ if (start_line_or_addr.loa == LOA_LINE)
+ cursal.line = start_line_or_addr.u.line_no;
+ else
+ cursal.pc = start_line_or_addr.u.addr;
+ update_source_window (gdbarch, cursal);
}
else if (deprecated_safe_get_selected_frame () != NULL)
{
- struct tui_line_or_address line;
struct symtab_and_line cursal
= get_current_source_symtab_and_line ();
struct frame_info *frame = deprecated_safe_get_selected_frame ();
struct gdbarch *gdbarch = get_frame_arch (frame);
struct symtab *s = find_pc_line_symtab (get_frame_pc (frame));
- if (type == SRC_WIN)
- {
- line.loa = LOA_LINE;
- line.u.line_no = cursal.line;
- }
- else
- {
- line.loa = LOA_ADDRESS;
- find_line_pc (s, cursal.line, &line.u.addr);
- }
- update_source_window (gdbarch, s, line);
+ if (type != SRC_WIN)
+ find_line_pc (s, cursal.line, &cursal.pc);
+ update_source_window (gdbarch, cursal);
}
else
erase_source_content ();
void
tui_source_window_base::refill ()
{
- symtab *s = nullptr;
+ symtab_and_line sal {};
if (type == SRC_WIN)
{
- symtab_and_line cursal = get_current_source_symtab_and_line ();
- s = (cursal.symtab == NULL
- ? find_pc_line_symtab (get_frame_pc (get_selected_frame (NULL)))
- : cursal.symtab);
+ sal = get_current_source_symtab_and_line ();
+ if (sal.symtab == NULL)
+ sal = find_pc_line (get_frame_pc (get_selected_frame (NULL)), 0);
}
- update_source_window_as_is (gdbarch, s, start_line_or_addr);
+ if (sal.pspace == nullptr)
+ sal.pspace = current_program_space;
+
+ if (start_line_or_addr.loa == LOA_LINE)
+ sal.line = start_line_or_addr.u.line_no;
+ else
+ sal.pc = start_line_or_addr.u.addr;
+
+ update_source_window_as_is (gdbarch, sal);
}
/* Scroll the source forward or backward horizontally. */