GDB (API)
|
00001 /* Data/register window display. 00002 00003 Copyright (C) 1998-2013 Free Software Foundation, Inc. 00004 00005 Contributed by Hewlett-Packard Company. 00006 00007 This file is part of GDB. 00008 00009 This program is free software; you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation; either version 3 of the License, or 00012 (at your option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00021 00022 #include "defs.h" 00023 #include "tui/tui.h" 00024 #include "tui/tui-data.h" 00025 #include "tui/tui-wingeneral.h" 00026 #include "tui/tui-regs.h" 00027 #include "tui/tui-windata.h" 00028 00029 #include "gdb_string.h" 00030 #include "gdb_curses.h" 00031 00032 00033 /***************************************** 00034 ** STATIC LOCAL FUNCTIONS FORWARD DECLS ** 00035 ******************************************/ 00036 00037 00038 00039 /***************************************** 00040 ** PUBLIC FUNCTIONS ** 00041 ******************************************/ 00042 00043 00044 /* Answer the index first element displayed. If none are displayed, 00045 then return (-1). */ 00046 int 00047 tui_first_data_item_displayed (void) 00048 { 00049 int element_no = (-1); 00050 int i; 00051 00052 for (i = 0; 00053 i < TUI_DATA_WIN->generic.content_size && element_no < 0; 00054 i++) 00055 { 00056 struct tui_gen_win_info *data_item_win; 00057 00058 data_item_win = &((tui_win_content) 00059 TUI_DATA_WIN->generic.content)[i]->which_element.data_window; 00060 if (data_item_win->handle != (WINDOW *) NULL 00061 && data_item_win->is_visible) 00062 element_no = i; 00063 } 00064 00065 return element_no; 00066 } 00067 00068 00069 /* Answer the index of the first element in line_no. If line_no is 00070 past the data area (-1) is returned. */ 00071 int 00072 tui_first_data_element_no_in_line (int line_no) 00073 { 00074 int first_element_no = (-1); 00075 00076 /* First see if there is a register on line_no, and if so, set the 00077 first element number. */ 00078 if ((first_element_no = tui_first_reg_element_no_inline (line_no)) == -1) 00079 { /* Looking at the general data, the 1st element on line_no. */ 00080 } 00081 00082 return first_element_no; 00083 } 00084 00085 00086 /* Function to delete all the item windows in the data window. This 00087 is usually done when the data window is scrolled. */ 00088 void 00089 tui_delete_data_content_windows (void) 00090 { 00091 int i; 00092 struct tui_gen_win_info *data_item_win_ptr; 00093 00094 for (i = 0; (i < TUI_DATA_WIN->generic.content_size); i++) 00095 { 00096 data_item_win_ptr = &((tui_win_content) 00097 TUI_DATA_WIN->generic.content)[i]->which_element.data_window; 00098 tui_delete_win (data_item_win_ptr->handle); 00099 data_item_win_ptr->handle = (WINDOW *) NULL; 00100 data_item_win_ptr->is_visible = FALSE; 00101 } 00102 } 00103 00104 00105 void 00106 tui_erase_data_content (char *prompt) 00107 { 00108 werase (TUI_DATA_WIN->generic.handle); 00109 tui_check_and_display_highlight_if_needed (TUI_DATA_WIN); 00110 if (prompt != (char *) NULL) 00111 { 00112 int half_width = (TUI_DATA_WIN->generic.width - 2) / 2; 00113 int x_pos; 00114 00115 if (strlen (prompt) >= half_width) 00116 x_pos = 1; 00117 else 00118 x_pos = half_width - strlen (prompt); 00119 mvwaddstr (TUI_DATA_WIN->generic.handle, 00120 (TUI_DATA_WIN->generic.height / 2), 00121 x_pos, 00122 prompt); 00123 } 00124 wrefresh (TUI_DATA_WIN->generic.handle); 00125 } 00126 00127 00128 /* This function displays the data that is in the data window's 00129 content. It does not set the content. */ 00130 void 00131 tui_display_all_data (void) 00132 { 00133 if (TUI_DATA_WIN->generic.content_size <= 0) 00134 tui_erase_data_content (NO_DATA_STRING); 00135 else 00136 { 00137 tui_erase_data_content ((char *) NULL); 00138 tui_delete_data_content_windows (); 00139 tui_check_and_display_highlight_if_needed (TUI_DATA_WIN); 00140 tui_display_registers_from (0); 00141 00142 /* Then display the other data. */ 00143 if (TUI_DATA_WIN->detail.data_display_info.data_content != 00144 (tui_win_content) NULL 00145 && TUI_DATA_WIN->detail.data_display_info.data_content_count > 0) 00146 { 00147 } 00148 } 00149 } 00150 00151 00152 /* Function to display the data starting at line, line_no, in the data 00153 window. */ 00154 void 00155 tui_display_data_from_line (int line_no) 00156 { 00157 int _line_no = line_no; 00158 00159 if (line_no < 0) 00160 _line_no = 0; 00161 00162 tui_check_and_display_highlight_if_needed (TUI_DATA_WIN); 00163 00164 /* There is no general data, force regs to display (if there are 00165 any). */ 00166 if (TUI_DATA_WIN->detail.data_display_info.data_content_count <= 0) 00167 tui_display_registers_from_line (_line_no, TRUE); 00168 else 00169 { 00170 int regs_last_line = tui_last_regs_line_no (); 00171 00172 00173 /* Display regs if we can. */ 00174 if (tui_display_registers_from_line (_line_no, FALSE) < 0) 00175 { /* _line_no is past the regs display, so calc where the 00176 start data element is. */ 00177 if (regs_last_line < _line_no) 00178 { /* Figure out how many lines each element is to obtain 00179 the start element_no. */ 00180 } 00181 } 00182 else 00183 { /* Calculate the starting element of the data display, given 00184 regs_last_line and how many lines each element is, up to 00185 _line_no. */ 00186 } 00187 /* Now display the data , starting at element_no. */ 00188 } 00189 } 00190 00191 00192 /* Display data starting at element element_no. */ 00193 void 00194 tui_display_data_from (int element_no, int reuse_windows) 00195 { 00196 int first_line = (-1); 00197 00198 if (element_no < TUI_DATA_WIN->detail.data_display_info.regs_content_count) 00199 first_line = tui_line_from_reg_element_no (element_no); 00200 else 00201 { /* Calculate the first_line from the element number. */ 00202 } 00203 00204 if (first_line >= 0) 00205 { 00206 tui_erase_data_content ((char *) NULL); 00207 if (!reuse_windows) 00208 tui_delete_data_content_windows (); 00209 tui_display_data_from_line (first_line); 00210 } 00211 } 00212 00213 00214 /* Function to redisplay the contents of the data window. */ 00215 void 00216 tui_refresh_data_win (void) 00217 { 00218 tui_erase_data_content ((char *) NULL); 00219 if (TUI_DATA_WIN->generic.content_size > 0) 00220 { 00221 int first_element = tui_first_data_item_displayed (); 00222 00223 if (first_element >= 0) /* Re-use existing windows. */ 00224 tui_display_data_from (first_element, TRUE); 00225 } 00226 } 00227 00228 00229 /* Function to check the data values and hilite any that have 00230 changed. */ 00231 void 00232 tui_check_data_values (struct frame_info *frame) 00233 { 00234 tui_check_register_values (frame); 00235 00236 /* Now check any other data values that there are. */ 00237 if (TUI_DATA_WIN != NULL && TUI_DATA_WIN->generic.is_visible) 00238 { 00239 int i; 00240 00241 for (i = 0; 00242 TUI_DATA_WIN->detail.data_display_info.data_content_count; 00243 i++) 00244 { 00245 #ifdef LATER 00246 tui_data_element_ptr data_element_ptr; 00247 struct tui_gen_win_info *data_item_win_ptr; 00248 Opaque new_value; 00249 00250 data_item_ptr = &TUI_DATA_WIN->detail.data_display_info. 00251 data_content[i]->which_element.data_window; 00252 data_element_ptr = &((tui_win_content) 00253 data_item_win_ptr->content)[0]->which_element.data; 00254 if value 00255 has changed (data_element_ptr, frame, &new_value) 00256 { 00257 data_element_ptr->value = new_value; 00258 update the display with the new value, hiliting it. 00259 } 00260 #endif 00261 } 00262 } 00263 } 00264 00265 00266 /* Scroll the data window vertically forward or backward. */ 00267 void 00268 tui_vertical_data_scroll (enum tui_scroll_direction scroll_direction, 00269 int num_to_scroll) 00270 { 00271 int first_element_no; 00272 int first_line = (-1); 00273 00274 first_element_no = tui_first_data_item_displayed (); 00275 if (first_element_no 00276 < TUI_DATA_WIN->detail.data_display_info.regs_content_count) 00277 first_line = tui_line_from_reg_element_no (first_element_no); 00278 else 00279 { /* Calculate the first line from the element number which is in 00280 the general data content. */ 00281 } 00282 00283 if (first_line >= 0) 00284 { 00285 if (scroll_direction == FORWARD_SCROLL) 00286 first_line += num_to_scroll; 00287 else 00288 first_line -= num_to_scroll; 00289 tui_erase_data_content ((char *) NULL); 00290 tui_delete_data_content_windows (); 00291 tui_display_data_from_line (first_line); 00292 } 00293 } 00294 00295 00296 /***************************************** 00297 ** STATIC LOCAL FUNCTIONS ** 00298 ******************************************/