aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-06-28 15:19:10 -0600
committerTom Tromey <tom@tromey.com>2019-07-17 12:19:05 -0600
commitc2cd8994669f63eb415522352a5d5006d0fbfb48 (patch)
treea82d261431329dcffd107a687f7016bed4ad6a5c /gdb
parent4dde7b34f4e40ee6e0ea596357e4def60bd67d20 (diff)
downloadgdb-c2cd8994669f63eb415522352a5d5006d0fbfb48.zip
gdb-c2cd8994669f63eb415522352a5d5006d0fbfb48.tar.gz
gdb-c2cd8994669f63eb415522352a5d5006d0fbfb48.tar.bz2
Introduce tui_source_window_base::location_matches_p method
This introduces the location_matches_p method, removing a spot that explicitly examines a window's type. gdb/ChangeLog 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 method. * tui/tui-disasm.c (tui_disasm_window::location_matches_p): New method. * tui/tui-data.h (struct tui_source_window_base) <location_matches_p>: New method. (struct tui_source_window, struct tui_disasm_window) <location_matches_p>: Likewise.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog13
-rw-r--r--gdb/tui/tui-data.h8
-rw-r--r--gdb/tui/tui-disasm.c7
-rw-r--r--gdb/tui/tui-source.c10
-rw-r--r--gdb/tui/tui-winsource.c11
5 files changed, 39 insertions, 10 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9844ec1..496819d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,18 @@
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
+ method.
+ * tui/tui-disasm.c (tui_disasm_window::location_matches_p): New
+ method.
+ * tui/tui-data.h (struct tui_source_window_base)
+ <location_matches_p>: New method.
+ (struct tui_source_window, struct tui_disasm_window)
+ <location_matches_p>: Likewise.
+
+2019-07-17 Tom Tromey <tom@tromey.com>
+
* tui/tui-win.c (tui_set_win_height_command): Rename from
tui_set_win_height.
(tui_set_win_height_command): Remove.
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index be951b4..472fa2e 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -404,6 +404,10 @@ public:
void update_tab_width () override;
+ /* Return true if the location LOC corresponds to the line number
+ LINE_NO in this source window; false otherwise. */
+ virtual bool location_matches_p (struct bp_location *loc, int line_no) = 0;
+
/* Does the locator belong to this window? */
bool m_has_locator = false;
/* Execution information window. */
@@ -435,6 +439,8 @@ struct tui_source_window : public tui_source_window_base
return SRC_NAME;
}
+ bool location_matches_p (struct bp_location *loc, int line_no) override;
+
protected:
void do_scroll_vertical (int num_to_scroll) override;
@@ -463,6 +469,8 @@ struct tui_disasm_window : public tui_source_window_base
return DISASSEM_NAME;
}
+ bool location_matches_p (struct bp_location *loc, int line_no) override;
+
protected:
void do_scroll_vertical (int num_to_scroll) override;
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index b22368e..af1a740 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -375,3 +375,10 @@ tui_disasm_window::do_scroll_vertical (int num_to_scroll)
NULL, val, FALSE);
}
}
+
+bool
+tui_disasm_window::location_matches_p (struct bp_location *loc, int line_no)
+{
+ return (content[line_no].line_or_addr.loa == LOA_ADDRESS
+ && content[line_no].line_or_addr.u.addr == loc->address);
+}
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 34cb38b..2ca21dc 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -345,3 +345,13 @@ tui_source_window::style_changed ()
if (tui_active && is_visible)
refill ();
}
+
+bool
+tui_source_window::location_matches_p (struct bp_location *loc, int line_no)
+{
+ return (content[line_no].line_or_addr.loa == LOA_LINE
+ && content[line_no].line_or_addr.u.line_no == loc->line_number
+ && loc->symtab != NULL
+ && filename_cmp (fullname,
+ symtab_to_fullname (loc->symtab)) == 0);
+}
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 22cd54e..03dd1b4 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -410,7 +410,6 @@ tui_update_breakpoint_info (struct tui_source_window_base *win,
{
int i;
bool need_refresh = false;
- tui_source_window_base *src = (tui_source_window_base *) win;
for (i = 0; i < win->content.size (); i++)
{
@@ -440,15 +439,7 @@ tui_update_breakpoint_info (struct tui_source_window_base *win,
for (loc = bp->loc; loc != NULL; loc = loc->next)
{
- if ((win == TUI_SRC_WIN
- && loc->symtab != NULL
- && filename_cmp (src->fullname,
- symtab_to_fullname (loc->symtab)) == 0
- && line->line_or_addr.loa == LOA_LINE
- && loc->line_number == line->line_or_addr.u.line_no)
- || (win == TUI_DISASM_WIN
- && line->line_or_addr.loa == LOA_ADDRESS
- && loc->address == line->line_or_addr.u.addr))
+ if (win->location_matches_p (loc, i))
{
if (bp->enable_state == bp_disabled)
mode |= TUI_BP_DISABLED;