aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-06-26 15:46:38 -0600
committerTom Tromey <tom@tromey.com>2019-07-17 12:18:53 -0600
commit3b23c5f2662d3240cdc586d3d2e5fb6eb8cba4c7 (patch)
tree3181cb32b78e06f3b3fdbf8f0913261040739802 /gdb
parent0b5ec21882bcc27e93144882b84935497da6e7fe (diff)
downloadgdb-3b23c5f2662d3240cdc586d3d2e5fb6eb8cba4c7.zip
gdb-3b23c5f2662d3240cdc586d3d2e5fb6eb8cba4c7.tar.gz
gdb-3b23c5f2662d3240cdc586d3d2e5fb6eb8cba4c7.tar.bz2
Introduce tui_data_window::line_from_reg_element_no method
This changes tui_line_from_reg_element_no to be a method on tui_data_window, allowing for the removal of some uses of the TUI_DATA_WIN global. (Actually, in this particular patch, the number of uses is not decreased, but rather the uses are moved to spots that are already using the global, i.e., increasing the clustering.) gdb/ChangeLog 2019-07-17 Tom Tromey <tom@tromey.com> * tui/tui-windata.c (tui_display_data_from) (tui_data_window::do_scroll_vertical): Update. * tui/tui-regs.h (tui_line_from_reg_element_no): Don't declare. * tui/tui-regs.c (tui_data_window::line_from_reg_element_no): Rename from tui_line_from_reg_element_no. (tui_display_registers_from_line): Update. * tui/tui-data.h (struct tui_data_window) <line_from_reg_element_no>: New method.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog11
-rw-r--r--gdb/tui/tui-data.h5
-rw-r--r--gdb/tui/tui-regs.c12
-rw-r--r--gdb/tui/tui-regs.h1
-rw-r--r--gdb/tui/tui-windata.c4
5 files changed, 23 insertions, 10 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b63b9e9..9177dfd 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,16 @@
2019-07-17 Tom Tromey <tom@tromey.com>
+ * tui/tui-windata.c (tui_display_data_from)
+ (tui_data_window::do_scroll_vertical): Update.
+ * tui/tui-regs.h (tui_line_from_reg_element_no): Don't declare.
+ * tui/tui-regs.c (tui_data_window::line_from_reg_element_no):
+ Rename from tui_line_from_reg_element_no.
+ (tui_display_registers_from_line): Update.
+ * tui/tui-data.h (struct tui_data_window)
+ <line_from_reg_element_no>: New method.
+
+2019-07-17 Tom Tromey <tom@tromey.com>
+
* tui/tui-regs.h (tui_last_regs_line_no): Don't declare.
* tui/tui-regs.c (tui_data_window::last_regs_line_no): Rename from
tui_last_regs_line_no.
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 9b1e892..081d0df 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -494,6 +494,11 @@ struct tui_data_window : public tui_win_info
are no registers (-1) is returned. */
int last_regs_line_no () const;
+ /* Answer the line number that the register element at element_no is
+ on. If element_no is greater than the number of register
+ elements there are, -1 is returned. */
+ int line_from_reg_element_no (int element_no) const;
+
protected:
void do_scroll_vertical (int num_to_scroll) override;
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index e9fbf4b..03e9149 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -79,21 +79,19 @@ tui_data_window::last_regs_line_no () const
return num_lines;
}
+/* See tui-data.h. */
-/* Answer the line number that the register element at element_no is
- on. If element_no is greater than the number of register elements
- there are, -1 is returned. */
int
-tui_line_from_reg_element_no (int element_no)
+tui_data_window::line_from_reg_element_no (int element_no) const
{
- if (element_no < TUI_DATA_WIN->regs_content.size ())
+ if (element_no < regs_content.size ())
{
int i, line = (-1);
i = 1;
while (line == (-1))
{
- if (element_no < TUI_DATA_WIN->regs_column_count * i)
+ if (element_no < regs_column_count * i)
line = i - 1;
else
i++;
@@ -391,7 +389,7 @@ tui_display_registers_from_line (int line_no,
registers. */
if (line_no >= TUI_DATA_WIN->last_regs_line_no ())
{
- if ((line = tui_line_from_reg_element_no (
+ if ((line = TUI_DATA_WIN->line_from_reg_element_no (
TUI_DATA_WIN->regs_content.size () - 1)) < 0)
line = 0;
}
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index fcb440d..f6ed862 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -29,7 +29,6 @@ extern void tui_show_registers (struct reggroup *group);
extern void tui_display_registers_from (int);
extern int tui_display_registers_from_line (int, int);
extern int tui_first_reg_element_inline (int);
-extern int tui_line_from_reg_element_no (int);
extern int tui_first_reg_element_no_inline (int lineno);
#endif /* TUI_TUI_REGS_H */
diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
index 7ff50a0..ac3e6d6 100644
--- a/gdb/tui/tui-windata.c
+++ b/gdb/tui/tui-windata.c
@@ -134,7 +134,7 @@ tui_display_data_from (int element_no, int reuse_windows)
int first_line = (-1);
if (element_no < TUI_DATA_WIN->regs_content.size ())
- first_line = tui_line_from_reg_element_no (element_no);
+ first_line = TUI_DATA_WIN->line_from_reg_element_no (element_no);
else
{ /* Calculate the first_line from the element number. */
}
@@ -173,7 +173,7 @@ tui_data_window::do_scroll_vertical (int num_to_scroll)
first_element_no = first_data_item_displayed ();
if (first_element_no < regs_content.size ())
- first_line = tui_line_from_reg_element_no (first_element_no);
+ first_line = line_from_reg_element_no (first_element_no);
else
{ /* Calculate the first line from the element number which is in
the general data content. */