Skip to content

Commit

Permalink
Fix scrolling in TUI
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbssa committed Feb 6, 2019
1 parent 435c31e commit a70c5ef
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 39 deletions.
6 changes: 3 additions & 3 deletions gdb/tui/tui-disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ tui_show_disassem (struct gdbarch *gdbarch, CORE_ADDR start_addr)
val.loa = LOA_ADDRESS;
val.u.addr = start_addr;
tui_add_win_to_layout (DISASSEM_WIN);
tui_update_source_window (TUI_DISASM_WIN, gdbarch, s, val, FALSE);
tui_update_source_window (TUI_DISASM_WIN, gdbarch, s, val);

/* If the focus was in the src win, put it in the asm win, if the
source view isn't split. */
Expand Down Expand Up @@ -302,7 +302,7 @@ tui_show_disassem_and_update_source (struct gdbarch *gdbarch,
sal = find_pc_line (start_addr, 0);
val.loa = LOA_LINE;
val.u.line_no = sal.line;
tui_update_source_window (TUI_SRC_WIN, gdbarch, sal.symtab, val, TRUE);
tui_update_source_window (TUI_SRC_WIN, gdbarch, sal.symtab, val);
if (sal.symtab)
{
set_current_source_symtab_and_line (sal);
Expand Down Expand Up @@ -394,6 +394,6 @@ tui_vertical_disassem_scroll (enum tui_scroll_direction scroll_direction,
val.loa = LOA_ADDRESS;
val.u.addr = tui_find_disassembly_address (gdbarch, pc, dir);
tui_update_source_window_as_is (TUI_DISASM_WIN, gdbarch,
NULL, val, FALSE);
NULL, val);
}
}
20 changes: 5 additions & 15 deletions gdb/tui/tui-source.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,7 @@ tui_syntax_highlight (enum language lang,
/* Function to display source in the source window. */
enum tui_status
tui_set_source_content (struct symtab *s,
int line_no,
int noerror)
int line_no)
{
enum tui_status ret = TUI_FAILURE;

Expand All @@ -606,14 +605,6 @@ tui_set_source_content (struct symtab *s,
desc = open_source_file (s);
if (desc < 0)
{
if (!noerror)
{
const char *filename = symtab_to_filename_for_display (s);
char *name = (char *) alloca (strlen (filename) + 100);

sprintf (name, "%s:%d", filename, line_no);
print_sys_errmsg (name, errno);
}
ret = TUI_FAILURE;
}
else
Expand Down Expand Up @@ -918,11 +909,10 @@ tui_set_source_content_nil (struct tui_win_info *win_info,
initializes the horizontal scroll to 0. */
void
tui_show_symtab_source (struct gdbarch *gdbarch, struct symtab *s,
struct tui_line_or_address line,
int noerror)
struct tui_line_or_address line)
{
TUI_SRC_WIN->detail.source_info.horizontal_offset = 0;
tui_update_source_window_as_is (TUI_SRC_WIN, gdbarch, s, line, noerror);
tui_update_source_window_as_is (TUI_SRC_WIN, gdbarch, s, line);
}


Expand Down Expand Up @@ -971,9 +961,9 @@ tui_vertical_source_scroll (enum tui_scroll_direction scroll_direction,
{
l.u.line_no = content[0]->which_element.source.line_or_addr.u.line_no
- num_to_scroll;
if (l.u.line_no <= 0)
l.u.line_no = 1;
}
if (l.u.line_no <= 0)
l.u.line_no = 1;

print_source_lines (s, l.u.line_no, l.u.line_no + 1, 0);
}
Expand Down
5 changes: 2 additions & 3 deletions gdb/tui/tui-source.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ extern void tui_set_source_content_nil (struct tui_win_info *,
const char *);

extern enum tui_status tui_set_source_content (struct symtab *,
int, int);
int);
extern void tui_show_symtab_source (struct gdbarch *, struct symtab *,
struct tui_line_or_address,
int);
struct tui_line_or_address);
extern int tui_source_is_displayed (const char *);
extern void tui_vertical_source_scroll (enum tui_scroll_direction,
int);
Expand Down
4 changes: 2 additions & 2 deletions gdb/tui/tui-stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ tui_show_frame_info (struct frame_info *fi)
&& tui_line_is_displayed (item->locator.line_no,
win_info, TRUE)))
tui_update_source_window (win_info, get_frame_arch (fi),
sal.symtab, l, TRUE);
sal.symtab, l);
else
{
l.u.line_no = item->locator.line_no;
Expand All @@ -450,7 +450,7 @@ tui_show_frame_info (struct frame_info *fi)
if (!tui_addr_is_displayed (item->locator.addr,
win_info, TRUE))
tui_update_source_window (win_info, get_frame_arch (fi),
sal.symtab, a, TRUE);
sal.symtab, a);
else
{
a.u.addr = item->locator.addr;
Expand Down
4 changes: 2 additions & 2 deletions gdb/tui/tui-win.c
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,7 @@ make_visible_with_new_height (struct tui_win_info *win_info)
line_or_addr = win_info->detail.source_info.start_line_or_addr;
tui_free_win_content (&win_info->generic);
tui_update_source_window (win_info, gdbarch,
cursal.symtab, line_or_addr, TRUE);
cursal.symtab, line_or_addr);
}
else if (deprecated_safe_get_selected_frame () != NULL)
{
Expand All @@ -1500,7 +1500,7 @@ make_visible_with_new_height (struct tui_win_info *win_info)
line.loa = LOA_ADDRESS;
find_line_pc (s, cursal.line, &line.u.addr);
}
tui_update_source_window (win_info, gdbarch, s, line, TRUE);
tui_update_source_window (win_info, gdbarch, s, line);
}
if (tui_win_has_locator (win_info))
{
Expand Down
17 changes: 7 additions & 10 deletions gdb/tui/tui-winsource.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,10 @@ void
tui_update_source_window (struct tui_win_info *win_info,
struct gdbarch *gdbarch,
struct symtab *s,
struct tui_line_or_address line_or_addr,
int noerror)
struct tui_line_or_address line_or_addr)
{
win_info->detail.source_info.horizontal_offset = 0;
tui_update_source_window_as_is (win_info, gdbarch, s, line_or_addr, noerror);
tui_update_source_window_as_is (win_info, gdbarch, s, line_or_addr);

return;
}
Expand All @@ -87,13 +86,12 @@ void
tui_update_source_window_as_is (struct tui_win_info *win_info,
struct gdbarch *gdbarch,
struct symtab *s,
struct tui_line_or_address line_or_addr,
int noerror)
struct tui_line_or_address line_or_addr)
{
enum tui_status ret;

if (win_info->generic.type == SRC_WIN)
ret = tui_set_source_content (s, line_or_addr.u.line_no, noerror);
ret = tui_set_source_content (s, line_or_addr.u.line_no);
else
ret = tui_set_disassem_content (gdbarch, line_or_addr.u.addr);

Expand Down Expand Up @@ -152,7 +150,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 (gdbarch, sal.symtab, l);
break;
}
}
Expand Down Expand Up @@ -194,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 (gdbarch, s, l);
if (tui_current_layout () == SRC_DISASSEM_COMMAND)
{
find_line_pc (s, line, &pc);
Expand Down Expand Up @@ -400,8 +398,7 @@ tui_horizontal_source_scroll (struct tui_win_info *win_info,
win_info->detail.source_info.horizontal_offset = offset;
tui_update_source_window_as_is (win_info, gdbarch, s,
win_info->generic.content[0]
->which_element.source.line_or_addr,
FALSE);
->which_element.source.line_or_addr);
}

return;
Expand Down
6 changes: 2 additions & 4 deletions gdb/tui/tui-winsource.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ extern int tui_update_breakpoint_info (struct tui_win_info *win,
extern void tui_display_main (void);
extern void tui_update_source_window (struct tui_win_info *,
struct gdbarch *, struct symtab *,
struct tui_line_or_address,
int);
struct tui_line_or_address);
extern void tui_update_source_window_as_is (struct tui_win_info *,
struct gdbarch *, struct symtab *,
struct tui_line_or_address,
int);
struct tui_line_or_address);
extern void tui_update_source_windows_with_addr (struct gdbarch *, CORE_ADDR);
extern void tui_update_source_windows_with_line (struct symtab *,
int);
Expand Down

0 comments on commit a70c5ef

Please sign in to comment.