Commit | Line | Data |
---|---|---|
f377b406 SC |
1 | /* TUI data manipulation routines. |
2 | Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc. | |
3 | Contributed by Hewlett-Packard Company. | |
4 | ||
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, | |
20 | Boston, MA 02111-1307, USA. */ | |
21 | ||
c906108c SS |
22 | #ifndef TUI_DATA_H |
23 | #define TUI_DATA_H | |
24 | ||
2a5127c4 SC |
25 | #if defined (HAVE_NCURSES_H) |
26 | #include <ncurses.h> | |
27 | #elif defined (HAVE_CURSES_H) | |
28 | #include <curses.h> | |
29 | #endif | |
30 | ||
31 | /* Generic window information */ | |
32 | typedef struct _TuiGenWinInfo | |
33 | { | |
34 | WINDOW *handle; /* window handle */ | |
35 | TuiWinType type; /* type of window */ | |
36 | int width; /* window width */ | |
37 | int height; /* window height */ | |
38 | TuiPoint origin; /* origin of window */ | |
39 | OpaquePtr content; /* content of window */ | |
40 | int contentSize; /* Size of content (# of elements) */ | |
41 | int contentInUse; /* Can it be used, or is it already used? */ | |
42 | int viewportHeight; /* viewport height */ | |
43 | int lastVisibleLine; /* index of last visible line */ | |
44 | int isVisible; /* whether the window is visible or not */ | |
45 | } | |
46 | TuiGenWinInfo, *TuiGenWinInfoPtr; | |
47 | ||
c906108c SS |
48 | /* Constant definitions */ |
49 | #define DEFAULT_TAB_LEN 8 | |
50 | #define NO_SRC_STRING "[ No Source Available ]" | |
51 | #define NO_DISASSEM_STRING "[ No Assembly Available ]" | |
52 | #define NO_REGS_STRING "[ Register Values Unavailable ]" | |
53 | #define NO_DATA_STRING "[ No Data Values Displayed ]" | |
54 | #define MAX_CONTENT_COUNT 100 | |
55 | #define SRC_NAME "SRC" | |
56 | #define CMD_NAME "CMD" | |
57 | #define DATA_NAME "REGS" | |
58 | #define DISASSEM_NAME "ASM" | |
59 | #define TUI_NULL_STR "" | |
60 | #define DEFAULT_HISTORY_COUNT 25 | |
61 | #define BOX_WINDOW TRUE | |
62 | #define DONT_BOX_WINDOW FALSE | |
63 | #define HILITE TRUE | |
64 | #define NO_HILITE FALSE | |
65 | #define WITH_LOCATOR TRUE | |
66 | #define NO_LOCATOR FALSE | |
67 | #define EMPTY_SOURCE_PROMPT TRUE | |
68 | #define NO_EMPTY_SOURCE_PROMPT FALSE | |
69 | #define UNDEFINED_ITEM -1 | |
70 | #define MIN_WIN_HEIGHT 3 | |
71 | #define MIN_CMD_WIN_HEIGHT 3 | |
72 | ||
73 | #define FILE_PREFIX "File: " | |
74 | #define PROC_PREFIX "Procedure: " | |
75 | #define LINE_PREFIX "Line: " | |
76 | #define PC_PREFIX "pc: " | |
77 | ||
78 | #define TUI_FLOAT_REGS_NAME "$FREGS" | |
79 | #define TUI_FLOAT_REGS_NAME_LOWER "$fregs" | |
80 | #define TUI_GENERAL_REGS_NAME "$GREGS" | |
81 | #define TUI_GENERAL_REGS_NAME_LOWER "$gregs" | |
82 | #define TUI_SPECIAL_REGS_NAME "$SREGS" | |
83 | #define TUI_SPECIAL_REGS_NAME_LOWER "$sregs" | |
84 | #define TUI_GENERAL_SPECIAL_REGS_NAME "$REGS" | |
85 | #define TUI_GENERAL_SPECIAL_REGS_NAME_LOWER "$regs" | |
86 | ||
87 | /* Scroll direction enum */ | |
c5aa993b JM |
88 | typedef enum |
89 | { | |
c906108c SS |
90 | FORWARD_SCROLL, |
91 | BACKWARD_SCROLL, | |
92 | LEFT_SCROLL, | |
93 | RIGHT_SCROLL | |
c5aa993b JM |
94 | } |
95 | TuiScrollDirection, *TuiScrollDirectionPtr; | |
c906108c SS |
96 | |
97 | ||
98 | /* General list struct */ | |
c5aa993b JM |
99 | typedef struct _TuiList |
100 | { | |
101 | OpaqueList list; | |
102 | int count; | |
103 | } | |
104 | TuiList, *TuiListPtr; | |
c906108c SS |
105 | |
106 | ||
107 | /* The kinds of layouts available */ | |
c5aa993b JM |
108 | typedef enum |
109 | { | |
c906108c SS |
110 | SRC_COMMAND, |
111 | DISASSEM_COMMAND, | |
112 | SRC_DISASSEM_COMMAND, | |
113 | SRC_DATA_COMMAND, | |
114 | DISASSEM_DATA_COMMAND, | |
115 | UNDEFINED_LAYOUT | |
c5aa993b JM |
116 | } |
117 | TuiLayoutType, *TuiLayoutTypePtr; | |
c906108c SS |
118 | |
119 | /* Basic data types that can be displayed in the data window. */ | |
c5aa993b JM |
120 | typedef enum _TuiDataType |
121 | { | |
c906108c SS |
122 | TUI_REGISTER, |
123 | TUI_SCALAR, | |
124 | TUI_COMPLEX, | |
125 | TUI_STRUCT | |
c5aa993b JM |
126 | } |
127 | TuiDataType, TuiDataTypePtr; | |
c906108c SS |
128 | |
129 | /* Types of register displays */ | |
c5aa993b JM |
130 | typedef enum _TuiRegisterDisplayType |
131 | { | |
c906108c SS |
132 | TUI_UNDEFINED_REGS, |
133 | TUI_GENERAL_REGS, | |
134 | TUI_SFLOAT_REGS, | |
135 | TUI_DFLOAT_REGS, | |
136 | TUI_SPECIAL_REGS, | |
137 | TUI_GENERAL_AND_SPECIAL_REGS | |
c5aa993b JM |
138 | } |
139 | TuiRegisterDisplayType, *TuiRegisterDisplayTypePtr; | |
c906108c SS |
140 | |
141 | /* Structure describing source line or line address */ | |
c5aa993b JM |
142 | typedef union _TuiLineOrAddress |
143 | { | |
144 | int lineNo; | |
c774cec6 | 145 | CORE_ADDR addr; |
c5aa993b JM |
146 | } |
147 | TuiLineOrAddress, *TuiLineOrAddressPtr; | |
c906108c SS |
148 | |
149 | /* Current Layout definition */ | |
c5aa993b JM |
150 | typedef struct _TuiLayoutDef |
151 | { | |
152 | TuiWinType displayMode; | |
153 | int split; | |
154 | TuiRegisterDisplayType regsDisplayType; | |
155 | TuiRegisterDisplayType floatRegsDisplayType; | |
156 | } | |
157 | TuiLayoutDef, *TuiLayoutDefPtr; | |
c906108c SS |
158 | |
159 | /* Elements in the Source/Disassembly Window */ | |
160 | typedef struct _TuiSourceElement | |
c5aa993b JM |
161 | { |
162 | char *line; | |
163 | TuiLineOrAddress lineOrAddr; | |
164 | int isExecPoint; | |
165 | int hasBreak; | |
166 | } | |
167 | TuiSourceElement, *TuiSourceElementPtr; | |
c906108c SS |
168 | |
169 | ||
170 | /* Elements in the data display window content */ | |
171 | typedef struct _TuiDataElement | |
c5aa993b | 172 | { |
bc77de56 | 173 | const char *name; |
c5aa993b | 174 | int itemNo; /* the register number, or data display number */ |
c906108c | 175 | TuiDataType type; |
c5aa993b JM |
176 | Opaque value; |
177 | int highlight; | |
178 | } | |
179 | TuiDataElement, *TuiDataElementPtr; | |
c906108c SS |
180 | |
181 | ||
182 | /* Elements in the command window content */ | |
183 | typedef struct _TuiCommandElement | |
c5aa993b JM |
184 | { |
185 | char *line; | |
186 | } | |
187 | TuiCommandElement, *TuiCommandElementPtr; | |
c906108c SS |
188 | |
189 | ||
190 | #define MAX_LOCATOR_ELEMENT_LEN 100 | |
191 | ||
192 | /* Elements in the locator window content */ | |
193 | typedef struct _TuiLocatorElement | |
c5aa993b JM |
194 | { |
195 | char fileName[MAX_LOCATOR_ELEMENT_LEN]; | |
196 | char procName[MAX_LOCATOR_ELEMENT_LEN]; | |
197 | int lineNo; | |
c774cec6 | 198 | CORE_ADDR addr; |
c5aa993b JM |
199 | } |
200 | TuiLocatorElement, *TuiLocatorElementPtr; | |
c906108c SS |
201 | |
202 | ||
203 | /* An content element in a window */ | |
204 | typedef union | |
c5aa993b JM |
205 | { |
206 | TuiSourceElement source; /* the source elements */ | |
207 | TuiGenWinInfo dataWindow; /* data display elements */ | |
208 | TuiDataElement data; /* elements of dataWindow */ | |
209 | TuiCommandElement command; /* command elements */ | |
210 | TuiLocatorElement locator; /* locator elements */ | |
211 | char *simpleString; /* simple char based elements */ | |
212 | } | |
213 | TuiWhichElement, *TuiWhichElementPtr; | |
c906108c SS |
214 | |
215 | typedef struct _TuiWinElement | |
c5aa993b JM |
216 | { |
217 | int highlight; | |
c906108c | 218 | TuiWhichElement whichElement; |
c5aa993b JM |
219 | } |
220 | TuiWinElement, *TuiWinElementPtr; | |
c906108c SS |
221 | |
222 | ||
223 | /* This describes the content of the window. */ | |
c5aa993b | 224 | typedef TuiWinElementPtr *TuiWinContent; |
c906108c SS |
225 | |
226 | ||
227 | /* This struct defines the specific information about a data display window */ | |
c5aa993b JM |
228 | typedef struct _TuiDataInfo |
229 | { | |
230 | TuiWinContent dataContent; /* start of data display content */ | |
231 | int dataContentCount; | |
232 | TuiWinContent regsContent; /* start of regs display content */ | |
233 | int regsContentCount; | |
234 | TuiRegisterDisplayType regsDisplayType; | |
235 | int regsColumnCount; | |
236 | int displayRegs; /* Should regs be displayed at all? */ | |
237 | } | |
238 | TuiDataInfo, *TuiDataInfoPtr; | |
239 | ||
240 | ||
241 | typedef struct _TuiSourceInfo | |
242 | { | |
243 | int hasLocator; /* Does locator belongs to this window? */ | |
244 | TuiGenWinInfoPtr executionInfo; /* execution information window */ | |
245 | int horizontalOffset; /* used for horizontal scroll */ | |
246 | TuiLineOrAddress startLineOrAddr; | |
247 | } | |
248 | TuiSourceInfo, *TuiSourceInfoPtr; | |
249 | ||
250 | ||
251 | typedef struct _TuiCommandInfo | |
252 | { | |
253 | int curLine; /* The current line position */ | |
254 | int curch; /* The current cursor position */ | |
d75e970c | 255 | int start_line; |
c5aa993b JM |
256 | } |
257 | TuiCommandInfo, *TuiCommandInfoPtr; | |
c906108c SS |
258 | |
259 | ||
260 | /* This defines information about each logical window */ | |
c5aa993b JM |
261 | typedef struct _TuiWinInfo |
262 | { | |
263 | TuiGenWinInfo generic; /* general window information */ | |
264 | union | |
265 | { | |
266 | TuiSourceInfo sourceInfo; | |
267 | TuiDataInfo dataDisplayInfo; | |
268 | TuiCommandInfo commandInfo; | |
269 | Opaque opaque; | |
270 | } | |
271 | detail; | |
272 | int canHighlight; /* Can this window ever be highlighted? */ | |
273 | int isHighlighted; /* Is this window highlighted? */ | |
274 | } | |
275 | TuiWinInfo, *TuiWinInfoPtr; | |
c906108c SS |
276 | |
277 | /* MACROS (prefixed with m_) */ | |
278 | ||
279 | /* Testing macros */ | |
280 | #define m_genWinPtrIsNull(winInfo) \ | |
281 | ((winInfo) == (TuiGenWinInfoPtr)NULL) | |
282 | #define m_genWinPtrNotNull(winInfo) \ | |
283 | ((winInfo) != (TuiGenWinInfoPtr)NULL) | |
284 | #define m_winPtrIsNull(winInfo) \ | |
285 | ((winInfo) == (TuiWinInfoPtr)NULL) | |
286 | #define m_winPtrNotNull(winInfo) \ | |
287 | ((winInfo) != (TuiWinInfoPtr)NULL) | |
288 | ||
289 | #define m_winIsSourceType(type) \ | |
290 | (type == SRC_WIN || type == DISASSEM_WIN) | |
291 | #define m_winIsAuxillary(winType) \ | |
292 | (winType > MAX_MAJOR_WINDOWS) | |
293 | #define m_hasLocator(winInfo) \ | |
294 | ( ((winInfo) != (TuiWinInfoPtr)NULL) ? \ | |
295 | (winInfo->detail.sourceInfo.hasLocator) : \ | |
296 | FALSE ) | |
297 | ||
298 | #define m_setWinHighlightOn(winInfo) \ | |
299 | if ((winInfo) != (TuiWinInfoPtr)NULL) \ | |
300 | (winInfo)->isHighlighted = TRUE | |
301 | #define m_setWinHighlightOff(winInfo) \ | |
302 | if ((winInfo) != (TuiWinInfoPtr)NULL) \ | |
303 | (winInfo)->isHighlighted = FALSE | |
304 | ||
305 | ||
306 | /* Global Data */ | |
c5aa993b JM |
307 | extern TuiWinInfoPtr winList[MAX_MAJOR_WINDOWS]; |
308 | extern int tui_version; | |
c906108c SS |
309 | |
310 | /* Macros */ | |
311 | #define srcWin winList[SRC_WIN] | |
312 | #define disassemWin winList[DISASSEM_WIN] | |
313 | #define dataWin winList[DATA_WIN] | |
314 | #define cmdWin winList[CMD_WIN] | |
315 | ||
316 | /* Data Manipulation Functions */ | |
a14ed312 KB |
317 | extern void initializeStaticData (void); |
318 | extern TuiGenWinInfoPtr allocGenericWinInfo (void); | |
319 | extern TuiWinInfoPtr allocWinInfo (TuiWinType); | |
320 | extern void initGenericPart (TuiGenWinInfoPtr); | |
321 | extern void initWinInfo (TuiWinInfoPtr); | |
322 | extern TuiWinContent allocContent (int, TuiWinType); | |
323 | extern int addContentElements (TuiGenWinInfoPtr, int); | |
324 | extern void initContentElement (TuiWinElementPtr, TuiWinType); | |
325 | extern void freeWindow (TuiWinInfoPtr); | |
326 | extern void freeAllWindows (void); | |
327 | extern void freeWinContent (TuiGenWinInfoPtr); | |
328 | extern void freeDataContent (TuiWinContent, int); | |
329 | extern void freeAllSourceWinsContent (void); | |
330 | extern void tuiDelWindow (TuiWinInfoPtr); | |
331 | extern void tuiDelDataWindows (TuiWinContent, int); | |
332 | extern TuiWinInfoPtr winByName (char *); | |
333 | extern TuiWinInfoPtr partialWinByName (char *); | |
334 | extern char *winName (TuiGenWinInfoPtr); | |
335 | extern char *displayableWinContentOf (TuiGenWinInfoPtr, TuiWinElementPtr); | |
336 | extern char *displayableWinContentAt (TuiGenWinInfoPtr, int); | |
337 | extern int winElementHeight (TuiGenWinInfoPtr, TuiWinElementPtr); | |
338 | extern TuiLayoutType currentLayout (void); | |
339 | extern void setCurrentLayoutTo (TuiLayoutType); | |
340 | extern int termHeight (void); | |
2a5127c4 | 341 | extern void setTermHeightTo (int); |
a14ed312 | 342 | extern int termWidth (void); |
2a5127c4 | 343 | extern void setTermWidthTo (int); |
a14ed312 KB |
344 | extern int historyLimit (void); |
345 | extern void setHistoryLimit (int); | |
346 | extern void setGenWinOrigin (TuiGenWinInfoPtr, int, int); | |
347 | extern TuiGenWinInfoPtr locatorWinInfoPtr (void); | |
348 | extern TuiGenWinInfoPtr sourceExecInfoWinPtr (void); | |
349 | extern TuiGenWinInfoPtr disassemExecInfoWinPtr (void); | |
350 | extern char *nullStr (void); | |
351 | extern char *blankStr (void); | |
352 | extern char *locationStr (void); | |
353 | extern char *breakStr (void); | |
354 | extern char *breakLocationStr (void); | |
355 | extern TuiListPtr sourceWindows (void); | |
356 | extern void clearSourceWindows (void); | |
357 | extern void clearSourceWindowsDetail (void); | |
358 | extern void clearWinDetail (TuiWinInfoPtr winInfo); | |
359 | extern void tuiAddToSourceWindows (TuiWinInfoPtr); | |
360 | extern int tuiDefaultTabLen (void); | |
361 | extern void tuiSetDefaultTabLen (int); | |
362 | extern TuiWinInfoPtr tuiWinWithFocus (void); | |
363 | extern void tuiSetWinWithFocus (TuiWinInfoPtr); | |
364 | extern TuiLayoutDefPtr tuiLayoutDef (void); | |
365 | extern int tuiWinResized (void); | |
366 | extern void tuiSetWinResizedTo (int); | |
367 | ||
368 | extern TuiWinInfoPtr tuiNextWin (TuiWinInfoPtr); | |
369 | extern TuiWinInfoPtr tuiPrevWin (TuiWinInfoPtr); | |
c906108c | 370 | |
c7c228ed SC |
371 | extern void addToSourceWindows (TuiWinInfoPtr winInfo); |
372 | ||
c906108c | 373 | #endif /* TUI_DATA_H */ |