aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-06-28 16:44:23 -0600
committerTom Tromey <tom@tromey.com>2019-07-17 12:19:06 -0600
commita38da35d7bc89e4c2191d4f042912038c585f36d (patch)
tree412a0b17840b5e9b325b14ff6a63f9a560fdf75f
parentc2cd8994669f63eb415522352a5d5006d0fbfb48 (diff)
downloadgdb-a38da35d7bc89e4c2191d4f042912038c585f36d.zip
gdb-a38da35d7bc89e4c2191d4f042912038c585f36d.tar.gz
gdb-a38da35d7bc89e4c2191d4f042912038c585f36d.tar.bz2
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 <tom@tromey.com> * 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) <content_in_use>: Remove field. (struct tui_source_window_base) <content_in_use>: New field. Now bool. (struct tui_source_window) <showing_source_p>: New method. (TUI_SRC_WIN): Change cast. * tui/tui-data.c (tui_initialize_static_data): Update.
-rw-r--r--gdb/ChangeLog18
-rw-r--r--gdb/tui/tui-data.c1
-rw-r--r--gdb/tui/tui-data.h8
-rw-r--r--gdb/tui/tui-source.c7
-rw-r--r--gdb/tui/tui-source.h1
-rw-r--r--gdb/tui/tui-stack.c12
-rw-r--r--gdb/tui/tui-winsource.c6
7 files changed, 36 insertions, 17 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 496819d..8a2a71c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,23 @@
2019-07-17 Tom Tromey <tom@tromey.com>
+ * 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) <content_in_use>:
+ Remove field.
+ (struct tui_source_window_base) <content_in_use>: New field. Now
+ bool.
+ (struct tui_source_window) <showing_source_p>: New method.
+ (TUI_SRC_WIN): Change cast.
+ * tui/tui-data.c (tui_initialize_static_data): Update.
+
+2019-07-17 Tom Tromey <tom@tromey.com>
+
* tui/tui-winsource.c (tui_update_breakpoint_info): Use
location_matches_p.
* tui/tui-source.c (tui_source_window::location_matches_p): New
diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 70c14ef..396635b 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 472fa2e..48c5614 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 2ca21dc..2fcb42d 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 8ceb194..e4b2313 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 e1b996d..b466b5f 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 03dd1b4..27edc4e 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);
}