From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 06/15] Change tui_addr_is_displayed into a method
Date: Wed, 14 Aug 2019 16:21:00 -0000 [thread overview]
Message-ID: <20190814162132.31424-7-tom@tromey.com> (raw)
In-Reply-To: <20190814162132.31424-1-tom@tromey.com>
This changes tui_addr_is_displayed to be a method on
tui_disasm_window, now that it is obvious that it can only be called
for this type.
gdb/ChangeLog
2019-08-14 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.
* tui/tui-disasm.h (struct tui_disasm_window) <addr_is_displayed>:
Declare.
* tui/tui-disasm.c (tui_disasm_window::addr_is_displayed): New
method.
(tui_disasm_window::maybe_update): Update.
---
gdb/ChangeLog | 11 +++++++++++
gdb/tui/tui-disasm.c | 20 +++++++++++++++++++-
gdb/tui/tui-disasm.h | 4 ++++
gdb/tui/tui-winsource.c | 28 ----------------------------
gdb/tui/tui-winsource.h | 3 ---
5 files changed, 34 insertions(+), 32 deletions(-)
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index fcb33bccfd7..e55f35da214 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -381,6 +381,24 @@ tui_disasm_window::location_matches_p (struct bp_location *loc, int line_no)
&& content[line_no].line_or_addr.u.addr == loc->address);
}
+bool
+tui_disasm_window::addr_is_displayed (CORE_ADDR addr) 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_ADDRESS
+ && content[i].line_or_addr.u.addr == addr);
+ i++;
+ }
+
+ return is_displayed;
+}
+
void
tui_disasm_window::maybe_update (struct frame_info *fi, symtab_and_line sal,
int line_no, CORE_ADDR addr)
@@ -402,7 +420,7 @@ tui_disasm_window::maybe_update (struct frame_info *fi, symtab_and_line sal,
a.loa = LOA_ADDRESS;
a.u.addr = low;
- if (!tui_addr_is_displayed (addr, this, TRUE))
+ if (!addr_is_displayed (addr))
tui_update_source_window (this, get_frame_arch (fi),
sal.symtab, a, TRUE);
else
diff --git a/gdb/tui/tui-disasm.h b/gdb/tui/tui-disasm.h
index 20bc4290ffc..71b911182f8 100644
--- a/gdb/tui/tui-disasm.h
+++ b/gdb/tui/tui-disasm.h
@@ -51,6 +51,10 @@ struct tui_disasm_window : public tui_source_window_base
protected:
void do_scroll_vertical (int num_to_scroll) override;
+
+private:
+ bool addr_is_displayed (CORE_ADDR addr) const;
+
};
extern enum tui_status tui_set_disassem_content (tui_source_window_base *,
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 1b2b4393fd9..e8e7061d0f2 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -668,31 +668,3 @@ tui_line_is_displayed (int line,
return is_displayed;
}
-
-
-/* Answer whether a particular line number or address is displayed
- in the current source window. */
-int
-tui_addr_is_displayed (CORE_ADDR addr,
- 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_ADDRESS
- && win_info->content[i].line_or_addr.u.addr == addr;
- i++;
- }
-
- return is_displayed;
-}
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index ed6cbec7626..fb9c05cadc8 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -175,9 +175,6 @@ extern void tui_alloc_source_buffer (struct tui_source_window_base *);
extern int tui_line_is_displayed (int,
struct tui_source_window_base *,
int);
-extern int tui_addr_is_displayed (CORE_ADDR,
- struct tui_source_window_base *,
- int);
/* Constant definitions. */
--
2.17.2
next prev parent reply other threads:[~2019-08-14 16:21 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-14 16:21 [PATCH 00/15] Another round of TUI refactoring Tom Tromey
2019-08-14 16:21 ` [PATCH 01/15] Simplify TUI boxing Tom Tromey
2019-08-14 16:21 ` [PATCH 10/15] Remove tui_clear_source_content Tom Tromey
2019-08-14 16:21 ` [PATCH 09/15] Turn tui_erase_source_content into a method Tom Tromey
2019-08-14 16:21 ` [PATCH 14/15] Change TUI source window iteration Tom Tromey
2019-08-14 16:21 ` [PATCH 12/15] Remove tui_initialize_static_data Tom Tromey
2019-08-14 16:21 ` [PATCH 03/15] Move locator code to tui-stack.c Tom Tromey
2019-08-14 16:21 ` [PATCH 07/15] Change tui_line_is_displayed to be a method Tom Tromey
2019-08-14 16:21 ` [PATCH 13/15] Rename the "reset" method to "resize" Tom Tromey
2019-08-14 16:21 ` [PATCH 08/15] Remove tui_alloc_source_buffer Tom Tromey
2019-08-14 16:21 ` [PATCH 15/15] TUI window resize should not need invisibility Tom Tromey
2019-08-14 16:21 ` Tom Tromey [this message]
2019-08-15 16:28 ` [PATCH 06/15] Change tui_addr_is_displayed into a method Pedro Alves
2019-08-14 16:21 ` [PATCH 02/15] Remove FIXMEs from tui-layout.c Tom Tromey
2019-08-14 16:21 ` [PATCH 05/15] Move contents of tui_show_frame_info to new method Tom Tromey
2019-08-15 16:28 ` Pedro Alves
2019-08-14 16:21 ` [PATCH 11/15] Minor simplification in tui_default_win_viewport_height Tom Tromey
2019-08-14 16:23 ` [PATCH 04/15] Avoid string_file in tui_make_status_line Tom Tromey
2019-08-15 16:29 ` [PATCH 00/15] Another round of TUI refactoring Pedro Alves
2019-08-15 18:28 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190814162132.31424-7-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).