aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-07-06 15:09:01 -0600
committerTom Tromey <tom@tromey.com>2019-08-15 12:29:28 -0600
commitc9033fe839e37a378ff86e614a7d6e939b94f6c9 (patch)
treef40043e9df2726d275000b41b03f072c3947452c /gdb
parent088f37dd90eecb647347c1aa53d36b3f5be64b21 (diff)
downloadgdb-c9033fe839e37a378ff86e614a7d6e939b94f6c9.zip
gdb-c9033fe839e37a378ff86e614a7d6e939b94f6c9.tar.gz
gdb-c9033fe839e37a378ff86e614a7d6e939b94f6c9.tar.bz2
Change tui_line_is_displayed to be a method
This changes tui_line_is_displayed to be a method on tui_source_window, now that it is obvious that it can only be called for this type. gdb/ChangeLog 2019-08-15 Tom Tromey <tom@tromey.com> * tui/tui-winsource.h (tui_line_is_displayed): Don't declare. * tui/tui-winsource.c (tui_line_is_displayed): Move to tui-source.c. * tui/tui-source.h (struct tui_source_window) <line_is_displayed>: Declare. * tui/tui-source.c (tui_source_window::line_is_displayed): New method. (tui_source_window::maybe_update): Update.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog11
-rw-r--r--gdb/tui/tui-source.c21
-rw-r--r--gdb/tui/tui-source.h4
-rw-r--r--gdb/tui/tui-winsource.c28
-rw-r--r--gdb/tui/tui-winsource.h3
5 files changed, 35 insertions, 32 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6650f58..8ede3e3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,16 @@
2019-08-15 Tom Tromey <tom@tromey.com>
+ * tui/tui-winsource.h (tui_line_is_displayed): Don't declare.
+ * tui/tui-winsource.c (tui_line_is_displayed): Move to
+ tui-source.c.
+ * tui/tui-source.h (struct tui_source_window) <line_is_displayed>:
+ Declare.
+ * tui/tui-source.c (tui_source_window::line_is_displayed): New
+ method.
+ (tui_source_window::maybe_update): Update.
+
+2019-08-15 Tom Tromey <tom@tromey.com>
+
* tui/tui-winsource.h (tui_addr_is_displayed): Don't declare.
* tui/tui-winsource.c (tui_addr_is_displayed): Move to
tui-disasm.c.
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 34b8f54..7c173f8 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -294,6 +294,25 @@ tui_source_window::location_matches_p (struct bp_location *loc, int line_no)
symtab_to_fullname (loc->symtab)) == 0);
}
+/* See tui-source.h. */
+
+bool
+tui_source_window::line_is_displayed (int line) const
+{
+ bool is_displayed = false;
+ int threshold = SCROLL_THRESHOLD;
+ int i = 0;
+ while (i < content.size () - threshold && !is_displayed)
+ {
+ is_displayed
+ = (content[i].line_or_addr.loa == LOA_LINE
+ && content[i].line_or_addr.u.line_no == line);
+ i++;
+ }
+
+ return is_displayed;
+}
+
void
tui_source_window::maybe_update (struct frame_info *fi, symtab_and_line sal,
int line_no, CORE_ADDR addr)
@@ -310,7 +329,7 @@ tui_source_window::maybe_update (struct frame_info *fi, symtab_and_line sal,
l.loa = LOA_LINE;
l.u.line_no = start_line;
if (!(source_already_displayed
- && tui_line_is_displayed (line_no, this, TRUE)))
+ && line_is_displayed (line_no)))
tui_update_source_window (this, get_frame_arch (fi),
sal.symtab, l, TRUE);
else
diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h
index dc4470e..4233879 100644
--- a/gdb/tui/tui-source.h
+++ b/gdb/tui/tui-source.h
@@ -59,6 +59,10 @@ private:
void style_changed ();
+ /* Answer whether a particular line number or address is displayed
+ in the current source window. */
+ bool line_is_displayed (int line) const;
+
/* A token used to register and unregister an observer. */
gdb::observers::token m_observable;
};
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index e8e7061..a852696 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -640,31 +640,3 @@ tui_alloc_source_buffer (struct tui_source_window_base *win_info)
win_info->content[i].line = (char *) xmalloc (line_width);
}
}
-
-
-/* Answer whether a particular line number or address is displayed
- in the current source window. */
-int
-tui_line_is_displayed (int line,
- struct tui_source_window_base *win_info,
- int check_threshold)
-{
- int is_displayed = FALSE;
- int i, threshold;
-
- if (check_threshold)
- threshold = SCROLL_THRESHOLD;
- else
- threshold = 0;
- i = 0;
- while (i < win_info->content.size () - threshold
- && !is_displayed)
- {
- is_displayed
- = win_info->content[i].line_or_addr.loa == LOA_LINE
- && win_info->content[i].line_or_addr.u.line_no == line;
- i++;
- }
-
- return is_displayed;
-}
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index b03ba2f..237c4da 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -174,9 +174,6 @@ extern void tui_clear_source_content (struct tui_source_window_base *);
extern void tui_erase_source_content (struct tui_source_window_base *);
extern void tui_alloc_source_buffer (struct tui_source_window_base *);
-extern int tui_line_is_displayed (int,
- struct tui_source_window_base *,
- int);
/* Constant definitions. */