diff options
Diffstat (limited to 'gdb/tui')
-rw-r--r-- | gdb/tui/tui-hooks.c | 14 | ||||
-rw-r--r-- | gdb/tui/tui-winsource.c | 44 | ||||
-rw-r--r-- | gdb/tui/tui-winsource.h | 1 |
3 files changed, 40 insertions, 19 deletions
diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c index 98c6fd6..4a1d79e 100644 --- a/gdb/tui/tui-hooks.c +++ b/gdb/tui/tui-hooks.c @@ -204,6 +204,18 @@ tui_normal_stop (struct bpstats *bs, int print_frame) tui_refresh_frame_and_register_information (/*registers_too_p=*/1); } +/* Observer for source_cache_cleared. */ + +static void +tui_redisplay_source () +{ + if (tui_is_window_visible (SRC_WIN)) + { + /* Force redisplay. */ + tui_refill_source_window (tui_win_list[SRC_WIN]); + } +} + /* Token associated with observers registered while TUI hooks are installed. */ static const gdb::observers::token tui_observers_token {}; @@ -239,6 +251,8 @@ tui_attach_detach_observers (bool attach) tui_normal_stop, attach); attach_or_detach (gdb::observers::register_changed, tui_register_changed, attach); + attach_or_detach (gdb::observers::source_styling_changed, + tui_redisplay_source, attach); } /* Install the TUI specific hooks. */ diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index 9336f7b..7fd460b 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -306,8 +306,32 @@ tui_show_source_content (struct tui_win_info *win_info) win_info->generic.content_in_use = TRUE; } +/* Refill the source window's source cache and update it. If WIN_INFO + is a disassembly window, then just update it. */ + +void +tui_refill_source_window (struct tui_win_info *win_info) +{ + symtab *s = nullptr; + + if (win_info->generic.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); + } + + tui_update_source_window_as_is (win_info, + win_info->detail.source_info.gdbarch, + s, + win_info->generic.content[0] + ->which_element.source.line_or_addr, + FALSE); +} /* Scroll the source forward or backward horizontally. */ + void tui_horizontal_source_scroll (struct tui_win_info *win_info, enum tui_scroll_direction direction, @@ -315,20 +339,7 @@ tui_horizontal_source_scroll (struct tui_win_info *win_info, { if (win_info->generic.content != NULL) { - struct gdbarch *gdbarch = win_info->detail.source_info.gdbarch; int offset; - struct symtab *s = NULL; - - if (win_info->generic.type == SRC_WIN) - { - struct symtab_and_line cursal - = get_current_source_symtab_and_line (); - - if (cursal.symtab == NULL) - s = find_pc_line_symtab (get_frame_pc (get_selected_frame (NULL))); - else - s = cursal.symtab; - } if (direction == LEFT_SCROLL) offset = win_info->detail.source_info.horizontal_offset @@ -341,13 +352,8 @@ tui_horizontal_source_scroll (struct tui_win_info *win_info, offset = 0; } 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); + tui_refill_source_window (win_info); } - - return; } diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h index db33a4f..920032b 100644 --- a/gdb/tui/tui-winsource.h +++ b/gdb/tui/tui-winsource.h @@ -56,6 +56,7 @@ extern void tui_show_source_content (struct tui_win_info *); extern void tui_horizontal_source_scroll (struct tui_win_info *, enum tui_scroll_direction, int); +extern void tui_refill_source_window (struct tui_win_info *); extern enum tui_status tui_set_exec_info_content (struct tui_win_info *); extern void tui_show_exec_info_content (struct tui_win_info *); extern void tui_erase_exec_info_content (struct tui_win_info *); |