From c9033fe839e37a378ff86e614a7d6e939b94f6c9 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 6 Jul 2019 15:09:01 -0600 Subject: [PATCH] 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 * 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) : Declare. * tui/tui-source.c (tui_source_window::line_is_displayed): New method. (tui_source_window::maybe_update): Update. --- gdb/ChangeLog | 11 +++++++++++ gdb/tui/tui-source.c | 21 ++++++++++++++++++++- gdb/tui/tui-source.h | 4 ++++ gdb/tui/tui-winsource.c | 28 ---------------------------- gdb/tui/tui-winsource.h | 3 --- 5 files changed, 35 insertions(+), 32 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6650f58aaff..8ede3e360b0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,14 @@ +2019-08-15 Tom Tromey + + * 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) : + Declare. + * tui/tui-source.c (tui_source_window::line_is_displayed): New + method. + (tui_source_window::maybe_update): Update. + 2019-08-15 Tom Tromey * tui/tui-winsource.h (tui_addr_is_displayed): Don't declare. diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index 34b8f54557d..7c173f8a6f9 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 dc4470e9e5a..42338790947 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 e8e7061d0f2..a85269657cf 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 b03ba2f5d85..237c4daf037 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. */ -- 2.30.2