diff options
-rw-r--r-- | gdb/ChangeLog | 29 | ||||
-rw-r--r-- | gdb/Makefile.in | 1 | ||||
-rw-r--r-- | gdb/tui/tui-data.c | 10 | ||||
-rw-r--r-- | gdb/tui/tui-data.h | 81 | ||||
-rw-r--r-- | gdb/tui/tui-hooks.c | 1 | ||||
-rw-r--r-- | gdb/tui/tui-layout.c | 1 | ||||
-rw-r--r-- | gdb/tui/tui-regs.c | 213 | ||||
-rw-r--r-- | gdb/tui/tui-regs.h | 84 | ||||
-rw-r--r-- | gdb/tui/tui-win.c | 22 | ||||
-rw-r--r-- | gdb/tui/tui-windata.c | 162 | ||||
-rw-r--r-- | gdb/tui/tui-windata.h | 27 | ||||
-rw-r--r-- | gdb/tui/tui-wingeneral.c | 13 | ||||
-rw-r--r-- | gdb/tui/tui.c | 1 |
13 files changed, 291 insertions, 354 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4890f6f..8ccadef 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,34 @@ 2019-07-17 Tom Tromey <tom@tromey.com> + * tui/tui.c: Update. + * tui/tui-wingeneral.c (tui_data_window::refresh_window): Move to + tui-regs.c. + * tui/tui-windata.h: Remove file. + * tui/tui-windata.c: Remove file. + * tui/tui-win.c (tui_data_window::set_new_height) + (tui_data_window::do_make_visible_with_new_height): Move to + tui-regs.c. + * tui/tui-regs.h (struct tui_data_window): Move from tui-data.h. + * tui/tui-regs.c: Remove "structuring" comments. + (tui_data_window::first_data_item_displayed) + (tui_data_window::delete_data_content_windows) + (tui_data_window::erase_data_content) + (tui_data_window::display_all_data) + (tui_data_window::refresh_all) + (tui_data_window::do_scroll_vertical) + (tui_data_window::clear_detail, tui_data_window::set_new_height) + (tui_data_window::do_make_visible_with_new_height) + (tui_data_window::refresh_window): Move from elsewhere. + (_initialize_tui_regs): Move to end of file. + * tui/tui-layout.c: Update. + * tui/tui-hooks.c: Update. + * tui/tui-data.h (struct tui_data_window): Move to tui-regs.h. + * tui/tui-data.c (tui_data_window::clear_detail): Move to + tui-regs.c. + * Makefile.in (SUBDIR_TUI_SRCS): Remove tui-windata.c. + +2019-07-17 Tom Tromey <tom@tromey.com> + * tui/tui-io.c (tui_puts_internal): Call wrefresh if newline is seen. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index b6680b9..7593653 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -291,7 +291,6 @@ SUBDIR_TUI_SRCS = \ tui/tui-source.c \ tui/tui-stack.c \ tui/tui-win.c \ - tui/tui-windata.c \ tui/tui-wingeneral.c \ tui/tui-winsource.c diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c index ee5b3aa..e861eb2 100644 --- a/gdb/tui/tui-data.c +++ b/gdb/tui/tui-data.c @@ -158,16 +158,6 @@ tui_cmd_window::clear_detail () wmove (handle, 0, 0); } -/* See tui-data.h. */ - -void -tui_data_window::clear_detail () -{ - regs_content.clear (); - regs_column_count = 1; - display_regs = false; -} - /* Accessor for the locator win info. Answers a pointer to the static locator win info struct. */ struct tui_locator_window * diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index cfe2460..ec60efd 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -454,87 +454,6 @@ protected: void do_scroll_vertical (int num_to_scroll) override; }; -struct tui_data_window : public tui_win_info -{ - tui_data_window () - : tui_win_info (DATA_WIN) - { - } - - DISABLE_COPY_AND_ASSIGN (tui_data_window); - - void clear_detail () override; - void refresh_all () override; - - void set_new_height (int height) override; - - void refresh_window () override; - - const char *name () const override - { - return DATA_NAME; - } - - /* Windows that are used to display registers. */ - std::vector<std::unique_ptr<tui_data_item_window>> regs_content; - int regs_column_count = 0; - /* Should regs be displayed at all? */ - bool display_regs = false; - struct reggroup *current_group = nullptr; - - /* Answer the number of the last line in the regs display. If there - 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; - - /* Answer the index of the first element in line_no. If line_no is - past the register area (-1) is returned. */ - int first_reg_element_no_inline (int line_no) const; - - /* Displays the data that is in the data window's content. It does - not set the content. */ - void display_all_data (); - - /* Delete all the item windows in the data window. This is usually - done when the data window is scrolled. */ - void delete_data_content_windows (); - - void erase_data_content (const char *prompt); - - /* Display the registers in the content from 'start_element_no' - until the end of the register content or the end of the display - height. No checking for displaying past the end of the registers - is done here. */ - void display_registers_from (int start_element_no); - - /* Display the registers starting at line line_no in the data - window. Answers the line number that the display actually - started from. If nothing is displayed (-1) is returned. */ - int display_registers_from_line (int line_no); - -protected: - - void do_scroll_vertical (int num_to_scroll) override; - void do_scroll_horizontal (int num_to_scroll) override - { - } - void do_make_visible_with_new_height () override; - - /* Return the index of the first element displayed. If none are - displayed, then return -1. */ - int first_data_item_displayed (); - - /* Display the registers in the content from 'start_element_no' on - 'start_line_no' until the end of the register content or the end - of the display height. This function checks that we won't - display off the end of the register display. */ - void display_reg_element_at_line (int start_element_no, int start_line_no); -}; - struct tui_cmd_window : public tui_win_info { tui_cmd_window () diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c index 84acd3a..a2d06f8 100644 --- a/gdb/tui/tui-hooks.c +++ b/gdb/tui/tui-hooks.c @@ -45,7 +45,6 @@ #include "tui/tui-regs.h" #include "tui/tui-win.h" #include "tui/tui-stack.h" -#include "tui/tui-windata.h" #include "tui/tui-winsource.h" #include "gdb_curses.h" diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index 4869cd9..abc3fd6 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -29,7 +29,6 @@ #include "tui/tui.h" #include "tui/tui-data.h" -#include "tui/tui-windata.h" #include "tui/tui-wingeneral.h" #include "tui/tui-stack.h" #include "tui/tui-regs.h" diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c index 52f6702..2470478 100644 --- a/gdb/tui/tui-regs.c +++ b/gdb/tui/tui-regs.c @@ -32,7 +32,6 @@ #include "target.h" #include "tui/tui-layout.h" #include "tui/tui-win.h" -#include "tui/tui-windata.h" #include "tui/tui-wingeneral.h" #include "tui/tui-file.h" #include "tui/tui-regs.h" @@ -43,10 +42,6 @@ #include "gdb_curses.h" - -/***************************************** -** STATIC LOCAL FUNCTIONS FORWARD DECLS ** -******************************************/ static void tui_display_register (struct tui_data_item_window *data); static void tui_show_register_group (tui_data_window *win_info, @@ -58,13 +53,7 @@ static void tui_get_register (struct frame_info *frame, struct tui_data_item_window *data, int regnum, bool *changedp); - - -/***************************************** -** PUBLIC FUNCTIONS ** -******************************************/ - -/* See tui-data.h. */ +/* See tui-regs.h. */ int tui_data_window::last_regs_line_no () const @@ -80,7 +69,7 @@ tui_data_window::last_regs_line_no () const return num_lines; } -/* See tui-data.h. */ +/* See tui-regs.h. */ int tui_data_window::line_from_reg_element_no (int element_no) const @@ -104,7 +93,7 @@ tui_data_window::line_from_reg_element_no (int element_no) const return (-1); } -/* See tui-data.h. */ +/* See tui-regs.h. */ int tui_data_window::first_reg_element_no_inline (int line_no) const @@ -255,7 +244,7 @@ tui_show_register_group (tui_data_window *win_info, } } -/* See tui-data.h. */ +/* See tui-regs.h. */ void tui_data_window::display_registers_from (int start_element_no) @@ -337,7 +326,7 @@ tui_data_window::display_registers_from (int start_element_no) } } -/* See tui-data.h. */ +/* See tui-regs.h. */ void tui_data_window::display_reg_element_at_line (int start_element_no, @@ -366,7 +355,7 @@ tui_data_window::display_reg_element_at_line (int start_element_no, } } -/* See tui-data.h. */ +/* See tui-regs.h. */ int tui_data_window::display_registers_from_line (int line_no) @@ -403,6 +392,167 @@ tui_data_window::display_registers_from_line (int line_no) } +/* Answer the index first element displayed. If none are displayed, + then return (-1). */ +int +tui_data_window::first_data_item_displayed () +{ + for (int i = 0; i < regs_content.size (); i++) + { + struct tui_gen_win_info *data_item_win; + + data_item_win = regs_content[i].get (); + if (data_item_win->handle != NULL && data_item_win->is_visible) + return i; + } + + return -1; +} + +/* See tui-regs.h. */ + +void +tui_data_window::delete_data_content_windows () +{ + for (auto &&win : regs_content) + { + tui_delete_win (win->handle); + win->handle = NULL; + win->is_visible = false; + } +} + + +void +tui_data_window::erase_data_content (const char *prompt) +{ + werase (handle); + tui_check_and_display_highlight_if_needed (this); + if (prompt != NULL) + { + int half_width = (width - 2) / 2; + int x_pos; + + if (strlen (prompt) >= half_width) + x_pos = 1; + else + x_pos = half_width - strlen (prompt); + mvwaddstr (handle, (height / 2), x_pos, (char *) prompt); + } + wrefresh (handle); +} + +/* See tui-regs.h. */ + +void +tui_data_window::display_all_data () +{ + if (regs_content.empty ()) + erase_data_content (NO_DATA_STRING); + else + { + erase_data_content (NULL); + delete_data_content_windows (); + tui_check_and_display_highlight_if_needed (this); + display_registers_from (0); + } +} + + +/* Function to redisplay the contents of the data window. */ +void +tui_data_window::refresh_all () +{ + erase_data_content (NULL); + if (!regs_content.empty ()) + { + int first_element = first_data_item_displayed (); + + if (first_element >= 0) /* Re-use existing windows. */ + { + int first_line = (-1); + + if (first_element < regs_content.size ()) + first_line = line_from_reg_element_no (first_element); + + if (first_line >= 0) + { + erase_data_content (NULL); + display_registers_from_line (first_line); + } + } + } +} + + +/* Scroll the data window vertically forward or backward. */ +void +tui_data_window::do_scroll_vertical (int num_to_scroll) +{ + int first_element_no; + int first_line = (-1); + + first_element_no = first_data_item_displayed (); + if (first_element_no < regs_content.size ()) + 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. */ + } + + if (first_line >= 0) + { + first_line += num_to_scroll; + erase_data_content (NULL); + delete_data_content_windows (); + display_registers_from_line (first_line); + } +} + +/* See tui-regs.h. */ + +void +tui_data_window::clear_detail () +{ + regs_content.clear (); + regs_column_count = 1; + display_regs = false; +} + +/* See tui-regs.h. */ + +void +tui_data_window::set_new_height (int height) +{ + /* Delete all data item windows. */ + for (auto &&win : regs_content) + { + tui_delete_win (win->handle); + win->handle = NULL; + } +} + +/* See tui-regs.h. */ + +void +tui_data_window::do_make_visible_with_new_height () +{ + display_all_data (); +} + +/* See tui-regs.h. */ + +void +tui_data_window::refresh_window () +{ + tui_gen_win_info::refresh_window (); + for (auto &&win : regs_content) + { + if (win != NULL) + win->refresh_window (); + } +} + /* This function check all displayed registers for changes in values, given a particular frame. If the values have changed, they are updated with the new value and highlighted. */ @@ -600,23 +750,6 @@ tui_reggroup_completer (struct cmd_list_element *ignore, } } -void -_initialize_tui_regs (void) -{ - struct cmd_list_element **tuicmd, *cmd; - - tuicmd = tui_get_cmd_list (); - - cmd = add_cmd ("reg", class_tui, tui_reg_command, _("\ -TUI command to control the register window."), tuicmd); - set_cmd_completer (cmd, tui_reggroup_completer); -} - - -/***************************************** -** STATIC LOCAL FUNCTIONS ** -******************************************/ - /* Get the register from the frame and return a printable representation of it. */ @@ -666,3 +799,15 @@ tui_get_register (struct frame_info *frame, xfree (prev_content); } } + +void +_initialize_tui_regs (void) +{ + struct cmd_list_element **tuicmd, *cmd; + + tuicmd = tui_get_cmd_list (); + + cmd = add_cmd ("reg", class_tui, tui_reg_command, _("\ +TUI command to control the register window."), tuicmd); + set_cmd_completer (cmd, tui_reggroup_completer); +} diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h index 354605c..acefa41 100644 --- a/gdb/tui/tui-regs.h +++ b/gdb/tui/tui-regs.h @@ -22,7 +22,89 @@ #ifndef TUI_TUI_REGS_H #define TUI_TUI_REGS_H -#include "tui/tui-data.h" /* For struct tui_register_display_type. */ +#include "tui/tui-data.h" + +/* The TUI registers window. */ +struct tui_data_window : public tui_win_info +{ + tui_data_window () + : tui_win_info (DATA_WIN) + { + } + + DISABLE_COPY_AND_ASSIGN (tui_data_window); + + void clear_detail () override; + void refresh_all () override; + + void set_new_height (int height) override; + + void refresh_window () override; + + const char *name () const override + { + return DATA_NAME; + } + + /* Windows that are used to display registers. */ + std::vector<std::unique_ptr<tui_data_item_window>> regs_content; + int regs_column_count = 0; + /* Should regs be displayed at all? */ + bool display_regs = false; + struct reggroup *current_group = nullptr; + + /* Answer the number of the last line in the regs display. If there + 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; + + /* Answer the index of the first element in line_no. If line_no is + past the register area (-1) is returned. */ + int first_reg_element_no_inline (int line_no) const; + + /* Displays the data that is in the data window's content. It does + not set the content. */ + void display_all_data (); + + /* Delete all the item windows in the data window. This is usually + done when the data window is scrolled. */ + void delete_data_content_windows (); + + void erase_data_content (const char *prompt); + + /* Display the registers in the content from 'start_element_no' + until the end of the register content or the end of the display + height. No checking for displaying past the end of the registers + is done here. */ + void display_registers_from (int start_element_no); + + /* Display the registers starting at line line_no in the data + window. Answers the line number that the display actually + started from. If nothing is displayed (-1) is returned. */ + int display_registers_from_line (int line_no); + +protected: + + void do_scroll_vertical (int num_to_scroll) override; + void do_scroll_horizontal (int num_to_scroll) override + { + } + void do_make_visible_with_new_height () override; + + /* Return the index of the first element displayed. If none are + displayed, then return -1. */ + int first_data_item_displayed (); + + /* Display the registers in the content from 'start_element_no' on + 'start_line_no' until the end of the register content or the end + of the display height. This function checks that we won't + display off the end of the register display. */ + void display_reg_element_at_line (int start_element_no, int start_line_no); +}; extern void tui_check_register_values (struct frame_info *); extern void tui_show_registers (struct reggroup *group); diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 2fb757a..0c7042e 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -43,7 +43,6 @@ #include "tui/tui-disasm.h" #include "tui/tui-source.h" #include "tui/tui-winsource.h" -#include "tui/tui-windata.h" #include "tui/tui-win.h" #include "gdb_curses.h" @@ -1243,19 +1242,6 @@ tui_source_window_base::set_new_height (int height) } } -/* See tui-data.h. */ - -void -tui_data_window::set_new_height (int height) -{ - /* Delete all data item windows. */ - for (auto &&win : regs_content) - { - tui_delete_win (win->handle); - win->handle = NULL; - } -} - /* Function make the target window (and auxiliary windows associated with the targer) invisible, and set the new height and location. */ @@ -1334,14 +1320,6 @@ tui_source_window_base::do_make_visible_with_new_height () /* See tui-data.h. */ void -tui_data_window::do_make_visible_with_new_height () -{ - display_all_data (); -} - -/* See tui-data.h. */ - -void tui_cmd_window::do_make_visible_with_new_height () { #ifdef HAVE_WRESIZE diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c deleted file mode 100644 index 2ee259e..0000000 --- a/gdb/tui/tui-windata.c +++ /dev/null @@ -1,162 +0,0 @@ -/* Data/register window display. - - Copyright (C) 1998-2019 Free Software Foundation, Inc. - - Contributed by Hewlett-Packard Company. - - This file is part of GDB. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#include "defs.h" -#include "tui/tui.h" -#include "tui/tui-data.h" -#include "tui/tui-wingeneral.h" -#include "tui/tui-regs.h" -#include "tui/tui-windata.h" -#include "gdb_curses.h" - - -/***************************************** -** STATIC LOCAL FUNCTIONS FORWARD DECLS ** -******************************************/ - - - -/***************************************** -** PUBLIC FUNCTIONS ** -******************************************/ - - -/* Answer the index first element displayed. If none are displayed, - then return (-1). */ -int -tui_data_window::first_data_item_displayed () -{ - for (int i = 0; i < regs_content.size (); i++) - { - struct tui_gen_win_info *data_item_win; - - data_item_win = regs_content[i].get (); - if (data_item_win->handle != NULL && data_item_win->is_visible) - return i; - } - - return -1; -} - -/* See tui-data.h. */ - -void -tui_data_window::delete_data_content_windows () -{ - for (auto &&win : regs_content) - { - tui_delete_win (win->handle); - win->handle = NULL; - win->is_visible = false; - } -} - - -void -tui_data_window::erase_data_content (const char *prompt) -{ - werase (handle); - tui_check_and_display_highlight_if_needed (this); - if (prompt != NULL) - { - int half_width = (width - 2) / 2; - int x_pos; - - if (strlen (prompt) >= half_width) - x_pos = 1; - else - x_pos = half_width - strlen (prompt); - mvwaddstr (handle, (height / 2), x_pos, (char *) prompt); - } - wrefresh (handle); -} - -/* See tui-data.h. */ - -void -tui_data_window::display_all_data () -{ - if (regs_content.empty ()) - erase_data_content (NO_DATA_STRING); - else - { - erase_data_content (NULL); - delete_data_content_windows (); - tui_check_and_display_highlight_if_needed (this); - display_registers_from (0); - } -} - - -/* Function to redisplay the contents of the data window. */ -void -tui_data_window::refresh_all () -{ - erase_data_content (NULL); - if (!regs_content.empty ()) - { - int first_element = first_data_item_displayed (); - - if (first_element >= 0) /* Re-use existing windows. */ - { - int first_line = (-1); - - if (first_element < regs_content.size ()) - first_line = line_from_reg_element_no (first_element); - - if (first_line >= 0) - { - erase_data_content (NULL); - display_registers_from_line (first_line); - } - } - } -} - - -/* Scroll the data window vertically forward or backward. */ -void -tui_data_window::do_scroll_vertical (int num_to_scroll) -{ - int first_element_no; - int first_line = (-1); - - first_element_no = first_data_item_displayed (); - if (first_element_no < regs_content.size ()) - 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. */ - } - - if (first_line >= 0) - { - first_line += num_to_scroll; - erase_data_content (NULL); - delete_data_content_windows (); - display_registers_from_line (first_line); - } -} - - -/***************************************** -** STATIC LOCAL FUNCTIONS ** -******************************************/ diff --git a/gdb/tui/tui-windata.h b/gdb/tui/tui-windata.h deleted file mode 100644 index 3b89eef..0000000 --- a/gdb/tui/tui-windata.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Data/register window display. - - Copyright (C) 1998-2019 Free Software Foundation, Inc. - - Contributed by Hewlett-Packard Company. - - This file is part of GDB. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#ifndef TUI_TUI_WINDATA_H -#define TUI_TUI_WINDATA_H - -#include "tui/tui-data.h" - -#endif /* TUI_TUI_WINDATA_H */ diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c index 2fb8d6c..5d632b6 100644 --- a/gdb/tui/tui-wingeneral.c +++ b/gdb/tui/tui-wingeneral.c @@ -43,19 +43,6 @@ tui_gen_win_info::refresh_window () } } -/* See tui-data.h. */ - -void -tui_data_window::refresh_window () -{ - tui_gen_win_info::refresh_window (); - for (auto &&win : regs_content) - { - if (win != NULL) - win->refresh_window (); - } -} - /* Function to delete the curses window, checking for NULL. */ void tui_delete_win (WINDOW *window) diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c index ee2c355..996dbaf 100644 --- a/gdb/tui/tui.c +++ b/gdb/tui/tui.c @@ -30,7 +30,6 @@ #include "tui/tui-stack.h" #include "tui/tui-win.h" #include "tui/tui-winsource.h" -#include "tui/tui-windata.h" #include "target.h" #include "frame.h" #include "breakpoint.h" |