From: Tom Tromey Date: Fri, 28 Jun 2019 22:44:23 +0000 (-0600) Subject: Move content_in_use to tui_source_window class X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a38da35d7bc89e4c2191d4f042912038c585f36d;p=binutils-gdb.git Move content_in_use to tui_source_window class From scanning the source now, it's clear that the content_in_use field is only used for the source window. This patch moves the field there, and changes it to be a bool at the same time. (A future patch will clean this up further, removing the field entirely.) gdb/ChangeLog 2019-07-17 Tom Tromey * tui/tui-winsource.c (tui_clear_source_content) (tui_show_source_content, tui_show_exec_info_content) (tui_clear_exec_info_content): Update. * tui/tui-stack.c (tui_show_locator_content): Update. (tui_show_frame_info): Update. * tui/tui-source.h (tui_source_window): Don't declare. * tui/tui-source.c (tui_source_window::showing_source_p): Rename from tui_source_is_displayed. * tui/tui-data.h (struct tui_gen_win_info) : Remove field. (struct tui_source_window_base) : New field. Now bool. (struct tui_source_window) : New method. (TUI_SRC_WIN): Change cast. * tui/tui-data.c (tui_initialize_static_data): Update. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 496819da47a..8a2a71c4bac 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,21 @@ +2019-07-17 Tom Tromey + + * tui/tui-winsource.c (tui_clear_source_content) + (tui_show_source_content, tui_show_exec_info_content) + (tui_clear_exec_info_content): Update. + * tui/tui-stack.c (tui_show_locator_content): Update. + (tui_show_frame_info): Update. + * tui/tui-source.h (tui_source_window): Don't declare. + * tui/tui-source.c (tui_source_window::showing_source_p): Rename + from tui_source_is_displayed. + * tui/tui-data.h (struct tui_gen_win_info) : + Remove field. + (struct tui_source_window_base) : New field. Now + bool. + (struct tui_source_window) : New method. + (TUI_SRC_WIN): Change cast. + * tui/tui-data.c (tui_initialize_static_data): Update. + 2019-07-17 Tom Tromey * tui/tui-winsource.c (tui_update_breakpoint_info): Use diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c index 70c14ef67ba..396635b779c 100644 --- a/gdb/tui/tui-data.c +++ b/gdb/tui/tui-data.c @@ -321,7 +321,6 @@ tui_initialize_static_data () win->viewport_height = win->last_visible_line = 0; win->handle = NULL; - win->content_in_use = FALSE; win->is_visible = false; win->title = 0; } diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index 472fa2ed7f6..48c5614b8d9 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -75,8 +75,6 @@ public: int height = 0; /* Origin of window. */ struct tui_point origin = {0, 0}; - /* Can it be used, or is it already used? */ - int content_in_use = FALSE; /* Viewport height. */ int viewport_height = 0; /* Index of last visible line. */ @@ -408,6 +406,8 @@ public: LINE_NO in this source window; false otherwise. */ virtual bool location_matches_p (struct bp_location *loc, int line_no) = 0; + /* Can it be used, or is it already used? */ + bool content_in_use = false; /* Does the locator belong to this window? */ bool m_has_locator = false; /* Execution information window. */ @@ -441,6 +441,8 @@ struct tui_source_window : public tui_source_window_base bool location_matches_p (struct bp_location *loc, int line_no) override; + bool showing_source_p (const char *filename) const; + protected: void do_scroll_vertical (int num_to_scroll) override; @@ -610,7 +612,7 @@ extern int tui_win_is_auxiliary (enum tui_win_type win_type); /* Global Data. */ extern struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS]; -#define TUI_SRC_WIN ((tui_source_window_base *) tui_win_list[SRC_WIN]) +#define TUI_SRC_WIN ((tui_source_window *) tui_win_list[SRC_WIN]) #define TUI_DISASM_WIN ((tui_source_window_base *) tui_win_list[DISASSEM_WIN]) #define TUI_DATA_WIN ((tui_data_window *) tui_win_list[DATA_WIN]) #define TUI_CMD_WIN ((tui_cmd_window *) tui_win_list[CMD_WIN]) diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index 2ca21dcc845..2fcb42d9299 100644 --- a/gdb/tui/tui-source.c +++ b/gdb/tui/tui-source.c @@ -287,11 +287,10 @@ tui_show_symtab_source (tui_source_window_base *win_info, /* Answer whether the source is currently displayed in the source window. */ -int -tui_source_is_displayed (const char *fullname) +bool +tui_source_window::showing_source_p (const char *fullname) const { - return (TUI_SRC_WIN != NULL - && TUI_SRC_WIN->content_in_use + return (content_in_use && (filename_cmp (tui_locator_win_info_ptr ()->full_name, fullname) == 0)); } diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h index 8ceb194e392..e4b23133af9 100644 --- a/gdb/tui/tui-source.h +++ b/gdb/tui/tui-source.h @@ -37,6 +37,5 @@ extern void tui_show_symtab_source (tui_source_window_base *, struct gdbarch *, struct symtab *, struct tui_line_or_address, int); -extern int tui_source_is_displayed (const char *); #endif /* TUI_TUI_SOURCE_H */ diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c index e1b996d7e6c..b466b5fe7f8 100644 --- a/gdb/tui/tui-stack.c +++ b/gdb/tui/tui-stack.c @@ -266,7 +266,6 @@ tui_show_locator_content (void) locator->refresh_window (); wmove (locator->handle, 0, 0); xfree (string); - locator->content_in_use = TRUE; } } @@ -347,14 +346,19 @@ tui_show_frame_info (struct frame_info *fi) symtab_and_line sal = find_frame_sal (fi); - source_already_displayed = sal.symtab != 0 - && tui_source_is_displayed (symtab_to_fullname (sal.symtab)); + const char *fullname = nullptr; + if (sal.symtab != nullptr) + fullname = symtab_to_fullname (sal.symtab); + + source_already_displayed = (sal.symtab != 0 + && TUI_SRC_WIN != nullptr + && TUI_SRC_WIN->showing_source_p (fullname)); if (get_frame_pc_if_available (fi, &pc)) locator_changed_p = tui_set_locator_info (get_frame_arch (fi), (sal.symtab == 0 - ? "??" : symtab_to_fullname (sal.symtab)), + ? "??" : fullname), tui_get_function_from_frame (fi), sal.line, pc); diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index 03dd1b4af81..27edc4ed29c 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -212,7 +212,7 @@ tui_clear_source_content (struct tui_source_window_base *win_info, { int i; - win_info->content_in_use = FALSE; + win_info->content_in_use = false; tui_erase_source_content (win_info, display_prompt); for (i = 0; i < win_info->content.size (); i++) { @@ -306,7 +306,7 @@ tui_show_source_content (struct tui_source_window_base *win_info) tui_check_and_display_highlight_if_needed (win_info); win_info->refresh_window (); - win_info->content_in_use = TRUE; + win_info->content_in_use = true; } /* See tui-data.h. */ @@ -531,7 +531,6 @@ tui_show_exec_info_content (struct tui_source_window_base *win_info) 0, content[cur_line - 1]); exec_info->refresh_window (); - exec_info->content_in_use = TRUE; } @@ -547,7 +546,6 @@ tui_erase_exec_info_content (struct tui_source_window_base *win_info) void tui_clear_exec_info_content (struct tui_source_window_base *win_info) { - win_info->execution_info->content_in_use = FALSE; tui_erase_exec_info_content (win_info); }