]>
Commit | Line | Data |
---|---|---|
f377b406 | 1 | /* TUI data manipulation routines. |
bc6b7f04 | 2 | Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. |
f377b406 SC |
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 */ | |
bc6b7f04 | 45 | char* title; /* Window title to display. */ |
2a5127c4 SC |
46 | } |
47 | TuiGenWinInfo, *TuiGenWinInfoPtr; | |
48 | ||
c906108c SS |
49 | /* Constant definitions */ |
50 | #define DEFAULT_TAB_LEN 8 | |
51 | #define NO_SRC_STRING "[ No Source Available ]" | |
52 | #define NO_DISASSEM_STRING "[ No Assembly Available ]" | |
53 | #define NO_REGS_STRING "[ Register Values Unavailable ]" | |
54 | #define NO_DATA_STRING "[ No Data Values Displayed ]" | |
55 | #define MAX_CONTENT_COUNT 100 | |
56 | #define SRC_NAME "SRC" | |
57 | #define CMD_NAME "CMD" | |
58 | #define DATA_NAME "REGS" | |
59 | #define DISASSEM_NAME "ASM" | |
60 | #define TUI_NULL_STR "" | |
61 | #define DEFAULT_HISTORY_COUNT 25 | |
62 | #define BOX_WINDOW TRUE | |
63 | #define DONT_BOX_WINDOW FALSE | |
64 | #define HILITE TRUE | |
65 | #define NO_HILITE FALSE | |
66 | #define WITH_LOCATOR TRUE | |
67 | #define NO_LOCATOR FALSE | |
68 | #define EMPTY_SOURCE_PROMPT TRUE | |
69 | #define NO_EMPTY_SOURCE_PROMPT FALSE | |
70 | #define UNDEFINED_ITEM -1 | |
71 | #define MIN_WIN_HEIGHT 3 | |
72 | #define MIN_CMD_WIN_HEIGHT 3 | |
73 | ||
50265402 | 74 | /* Strings to display in the TUI status line. */ |
50265402 | 75 | #define PROC_PREFIX "In: " |
c906108c | 76 | #define LINE_PREFIX "Line: " |
50265402 SC |
77 | #define PC_PREFIX "PC: " |
78 | #define SINGLE_KEY "(SingleKey)" | |
79 | ||
80 | /* Minimum/Maximum length of some fields displayed in the TUI status line. */ | |
81 | #define MIN_LINE_WIDTH 4 /* Use at least 4 digits for line numbers. */ | |
82 | #define MIN_PROC_WIDTH 12 | |
83 | #define MAX_TARGET_WIDTH 10 | |
84 | #define MAX_PID_WIDTH 14 | |
c906108c SS |
85 | |
86 | #define TUI_FLOAT_REGS_NAME "$FREGS" | |
87 | #define TUI_FLOAT_REGS_NAME_LOWER "$fregs" | |
88 | #define TUI_GENERAL_REGS_NAME "$GREGS" | |
89 | #define TUI_GENERAL_REGS_NAME_LOWER "$gregs" | |
90 | #define TUI_SPECIAL_REGS_NAME "$SREGS" | |
91 | #define TUI_SPECIAL_REGS_NAME_LOWER "$sregs" | |
92 | #define TUI_GENERAL_SPECIAL_REGS_NAME "$REGS" | |
93 | #define TUI_GENERAL_SPECIAL_REGS_NAME_LOWER "$regs" | |
94 | ||
95 | /* Scroll direction enum */ | |
c5aa993b JM |
96 | typedef enum |
97 | { | |
c906108c SS |
98 | FORWARD_SCROLL, |
99 | BACKWARD_SCROLL, | |
100 | LEFT_SCROLL, | |
101 | RIGHT_SCROLL | |
c5aa993b JM |
102 | } |
103 | TuiScrollDirection, *TuiScrollDirectionPtr; | |
c906108c SS |
104 | |
105 | ||
106 | /* General list struct */ | |
c5aa993b JM |
107 | typedef struct _TuiList |
108 | { | |
109 | OpaqueList list; | |
110 | int count; | |
111 | } | |
112 | TuiList, *TuiListPtr; | |
c906108c SS |
113 | |
114 | ||
115 | /* The kinds of layouts available */ | |
c5aa993b JM |
116 | typedef enum |
117 | { | |
c906108c SS |
118 | SRC_COMMAND, |
119 | DISASSEM_COMMAND, | |
120 | SRC_DISASSEM_COMMAND, | |
121 | SRC_DATA_COMMAND, | |
122 | DISASSEM_DATA_COMMAND, | |
123 | UNDEFINED_LAYOUT | |
c5aa993b JM |
124 | } |
125 | TuiLayoutType, *TuiLayoutTypePtr; | |
c906108c SS |
126 | |
127 | /* Basic data types that can be displayed in the data window. */ | |
c5aa993b JM |
128 | typedef enum _TuiDataType |
129 | { | |
c906108c SS |
130 | TUI_REGISTER, |
131 | TUI_SCALAR, | |
132 | TUI_COMPLEX, | |
133 | TUI_STRUCT | |
c5aa993b JM |
134 | } |
135 | TuiDataType, TuiDataTypePtr; | |
c906108c SS |
136 | |
137 | /* Types of register displays */ | |
c5aa993b JM |
138 | typedef enum _TuiRegisterDisplayType |
139 | { | |
c906108c SS |
140 | TUI_UNDEFINED_REGS, |
141 | TUI_GENERAL_REGS, | |
142 | TUI_SFLOAT_REGS, | |
143 | TUI_DFLOAT_REGS, | |
144 | TUI_SPECIAL_REGS, | |
145 | TUI_GENERAL_AND_SPECIAL_REGS | |
c5aa993b JM |
146 | } |
147 | TuiRegisterDisplayType, *TuiRegisterDisplayTypePtr; | |
c906108c SS |
148 | |
149 | /* Structure describing source line or line address */ | |
c5aa993b JM |
150 | typedef union _TuiLineOrAddress |
151 | { | |
152 | int lineNo; | |
c774cec6 | 153 | CORE_ADDR addr; |
c5aa993b JM |
154 | } |
155 | TuiLineOrAddress, *TuiLineOrAddressPtr; | |
c906108c SS |
156 | |
157 | /* Current Layout definition */ | |
c5aa993b JM |
158 | typedef struct _TuiLayoutDef |
159 | { | |
160 | TuiWinType displayMode; | |
161 | int split; | |
162 | TuiRegisterDisplayType regsDisplayType; | |
163 | TuiRegisterDisplayType floatRegsDisplayType; | |
164 | } | |
165 | TuiLayoutDef, *TuiLayoutDefPtr; | |
c906108c SS |
166 | |
167 | /* Elements in the Source/Disassembly Window */ | |
168 | typedef struct _TuiSourceElement | |
c5aa993b JM |
169 | { |
170 | char *line; | |
171 | TuiLineOrAddress lineOrAddr; | |
172 | int isExecPoint; | |
173 | int hasBreak; | |
174 | } | |
175 | TuiSourceElement, *TuiSourceElementPtr; | |
c906108c SS |
176 | |
177 | ||
178 | /* Elements in the data display window content */ | |
179 | typedef struct _TuiDataElement | |
c5aa993b | 180 | { |
bc77de56 | 181 | const char *name; |
c5aa993b | 182 | int itemNo; /* the register number, or data display number */ |
c906108c | 183 | TuiDataType type; |
c5aa993b JM |
184 | Opaque value; |
185 | int highlight; | |
186 | } | |
187 | TuiDataElement, *TuiDataElementPtr; | |
c906108c SS |
188 | |
189 | ||
190 | /* Elements in the command window content */ | |
191 | typedef struct _TuiCommandElement | |
c5aa993b JM |
192 | { |
193 | char *line; | |
194 | } | |
195 | TuiCommandElement, *TuiCommandElementPtr; | |
c906108c SS |
196 | |
197 | ||
198 | #define MAX_LOCATOR_ELEMENT_LEN 100 | |
199 | ||
200 | /* Elements in the locator window content */ | |
201 | typedef struct _TuiLocatorElement | |
c5aa993b JM |
202 | { |
203 | char fileName[MAX_LOCATOR_ELEMENT_LEN]; | |
204 | char procName[MAX_LOCATOR_ELEMENT_LEN]; | |
205 | int lineNo; | |
c774cec6 | 206 | CORE_ADDR addr; |
c5aa993b JM |
207 | } |
208 | TuiLocatorElement, *TuiLocatorElementPtr; | |
c906108c | 209 | |
00b2bad4 SC |
210 | /* Flags to tell what kind of breakpoint is at current line. */ |
211 | #define TUI_BP_ENABLED 0x01 | |
212 | #define TUI_BP_DISABLED 0x02 | |
213 | #define TUI_BP_HIT 0x04 | |
214 | #define TUI_BP_CONDITIONAL 0x08 | |
215 | #define TUI_BP_HARDWARE 0x10 | |
216 | ||
217 | /* Position of breakpoint markers in the exec info string. */ | |
218 | #define TUI_BP_HIT_POS 0 | |
219 | #define TUI_BP_BREAK_POS 1 | |
220 | #define TUI_EXEC_POS 2 | |
221 | #define TUI_EXECINFO_SIZE 4 | |
222 | ||
223 | typedef char TuiExecInfoContent[TUI_EXECINFO_SIZE]; | |
c906108c SS |
224 | |
225 | /* An content element in a window */ | |
226 | typedef union | |
c5aa993b JM |
227 | { |
228 | TuiSourceElement source; /* the source elements */ | |
229 | TuiGenWinInfo dataWindow; /* data display elements */ | |
230 | TuiDataElement data; /* elements of dataWindow */ | |
231 | TuiCommandElement command; /* command elements */ | |
232 | TuiLocatorElement locator; /* locator elements */ | |
00b2bad4 | 233 | TuiExecInfoContent simpleString; /* simple char based elements */ |
c5aa993b JM |
234 | } |
235 | TuiWhichElement, *TuiWhichElementPtr; | |
c906108c SS |
236 | |
237 | typedef struct _TuiWinElement | |
c5aa993b JM |
238 | { |
239 | int highlight; | |
c906108c | 240 | TuiWhichElement whichElement; |
c5aa993b JM |
241 | } |
242 | TuiWinElement, *TuiWinElementPtr; | |
c906108c SS |
243 | |
244 | ||
245 | /* This describes the content of the window. */ | |
c5aa993b | 246 | typedef TuiWinElementPtr *TuiWinContent; |
c906108c SS |
247 | |
248 | ||
249 | /* This struct defines the specific information about a data display window */ | |
c5aa993b JM |
250 | typedef struct _TuiDataInfo |
251 | { | |
252 | TuiWinContent dataContent; /* start of data display content */ | |
253 | int dataContentCount; | |
254 | TuiWinContent regsContent; /* start of regs display content */ | |
255 | int regsContentCount; | |
256 | TuiRegisterDisplayType regsDisplayType; | |
257 | int regsColumnCount; | |
258 | int displayRegs; /* Should regs be displayed at all? */ | |
259 | } | |
260 | TuiDataInfo, *TuiDataInfoPtr; | |
261 | ||
262 | ||
263 | typedef struct _TuiSourceInfo | |
264 | { | |
265 | int hasLocator; /* Does locator belongs to this window? */ | |
266 | TuiGenWinInfoPtr executionInfo; /* execution information window */ | |
267 | int horizontalOffset; /* used for horizontal scroll */ | |
268 | TuiLineOrAddress startLineOrAddr; | |
bc6b7f04 | 269 | char* filename; |
c5aa993b JM |
270 | } |
271 | TuiSourceInfo, *TuiSourceInfoPtr; | |
272 | ||
273 | ||
274 | typedef struct _TuiCommandInfo | |
275 | { | |
276 | int curLine; /* The current line position */ | |
277 | int curch; /* The current cursor position */ | |
d75e970c | 278 | int start_line; |
c5aa993b JM |
279 | } |
280 | TuiCommandInfo, *TuiCommandInfoPtr; | |
c906108c SS |
281 | |
282 | ||
283 | /* This defines information about each logical window */ | |
c5aa993b JM |
284 | typedef struct _TuiWinInfo |
285 | { | |
286 | TuiGenWinInfo generic; /* general window information */ | |
287 | union | |
288 | { | |
289 | TuiSourceInfo sourceInfo; | |
290 | TuiDataInfo dataDisplayInfo; | |
291 | TuiCommandInfo commandInfo; | |
292 | Opaque opaque; | |
293 | } | |
294 | detail; | |
295 | int canHighlight; /* Can this window ever be highlighted? */ | |
296 | int isHighlighted; /* Is this window highlighted? */ | |
297 | } | |
298 | TuiWinInfo, *TuiWinInfoPtr; | |
c906108c SS |
299 | |
300 | /* MACROS (prefixed with m_) */ | |
301 | ||
302 | /* Testing macros */ | |
303 | #define m_genWinPtrIsNull(winInfo) \ | |
304 | ((winInfo) == (TuiGenWinInfoPtr)NULL) | |
305 | #define m_genWinPtrNotNull(winInfo) \ | |
306 | ((winInfo) != (TuiGenWinInfoPtr)NULL) | |
307 | #define m_winPtrIsNull(winInfo) \ | |
308 | ((winInfo) == (TuiWinInfoPtr)NULL) | |
309 | #define m_winPtrNotNull(winInfo) \ | |
310 | ((winInfo) != (TuiWinInfoPtr)NULL) | |
311 | ||
312 | #define m_winIsSourceType(type) \ | |
313 | (type == SRC_WIN || type == DISASSEM_WIN) | |
314 | #define m_winIsAuxillary(winType) \ | |
315 | (winType > MAX_MAJOR_WINDOWS) | |
316 | #define m_hasLocator(winInfo) \ | |
317 | ( ((winInfo) != (TuiWinInfoPtr)NULL) ? \ | |
318 | (winInfo->detail.sourceInfo.hasLocator) : \ | |
319 | FALSE ) | |
320 | ||
321 | #define m_setWinHighlightOn(winInfo) \ | |
322 | if ((winInfo) != (TuiWinInfoPtr)NULL) \ | |
323 | (winInfo)->isHighlighted = TRUE | |
324 | #define m_setWinHighlightOff(winInfo) \ | |
325 | if ((winInfo) != (TuiWinInfoPtr)NULL) \ | |
326 | (winInfo)->isHighlighted = FALSE | |
327 | ||
328 | ||
329 | /* Global Data */ | |
c5aa993b | 330 | extern TuiWinInfoPtr winList[MAX_MAJOR_WINDOWS]; |
c906108c SS |
331 | |
332 | /* Macros */ | |
333 | #define srcWin winList[SRC_WIN] | |
334 | #define disassemWin winList[DISASSEM_WIN] | |
335 | #define dataWin winList[DATA_WIN] | |
336 | #define cmdWin winList[CMD_WIN] | |
337 | ||
338 | /* Data Manipulation Functions */ | |
a14ed312 KB |
339 | extern void initializeStaticData (void); |
340 | extern TuiGenWinInfoPtr allocGenericWinInfo (void); | |
341 | extern TuiWinInfoPtr allocWinInfo (TuiWinType); | |
342 | extern void initGenericPart (TuiGenWinInfoPtr); | |
343 | extern void initWinInfo (TuiWinInfoPtr); | |
344 | extern TuiWinContent allocContent (int, TuiWinType); | |
345 | extern int addContentElements (TuiGenWinInfoPtr, int); | |
346 | extern void initContentElement (TuiWinElementPtr, TuiWinType); | |
347 | extern void freeWindow (TuiWinInfoPtr); | |
a14ed312 KB |
348 | extern void freeWinContent (TuiGenWinInfoPtr); |
349 | extern void freeDataContent (TuiWinContent, int); | |
350 | extern void freeAllSourceWinsContent (void); | |
351 | extern void tuiDelWindow (TuiWinInfoPtr); | |
352 | extern void tuiDelDataWindows (TuiWinContent, int); | |
a14ed312 KB |
353 | extern TuiWinInfoPtr partialWinByName (char *); |
354 | extern char *winName (TuiGenWinInfoPtr); | |
a14ed312 KB |
355 | extern TuiLayoutType currentLayout (void); |
356 | extern void setCurrentLayoutTo (TuiLayoutType); | |
357 | extern int termHeight (void); | |
2a5127c4 | 358 | extern void setTermHeightTo (int); |
a14ed312 | 359 | extern int termWidth (void); |
2a5127c4 | 360 | extern void setTermWidthTo (int); |
a14ed312 KB |
361 | extern void setGenWinOrigin (TuiGenWinInfoPtr, int, int); |
362 | extern TuiGenWinInfoPtr locatorWinInfoPtr (void); | |
363 | extern TuiGenWinInfoPtr sourceExecInfoWinPtr (void); | |
364 | extern TuiGenWinInfoPtr disassemExecInfoWinPtr (void); | |
a14ed312 KB |
365 | extern TuiListPtr sourceWindows (void); |
366 | extern void clearSourceWindows (void); | |
367 | extern void clearSourceWindowsDetail (void); | |
368 | extern void clearWinDetail (TuiWinInfoPtr winInfo); | |
369 | extern void tuiAddToSourceWindows (TuiWinInfoPtr); | |
370 | extern int tuiDefaultTabLen (void); | |
371 | extern void tuiSetDefaultTabLen (int); | |
372 | extern TuiWinInfoPtr tuiWinWithFocus (void); | |
373 | extern void tuiSetWinWithFocus (TuiWinInfoPtr); | |
374 | extern TuiLayoutDefPtr tuiLayoutDef (void); | |
375 | extern int tuiWinResized (void); | |
376 | extern void tuiSetWinResizedTo (int); | |
377 | ||
378 | extern TuiWinInfoPtr tuiNextWin (TuiWinInfoPtr); | |
379 | extern TuiWinInfoPtr tuiPrevWin (TuiWinInfoPtr); | |
c906108c | 380 | |
c7c228ed SC |
381 | extern void addToSourceWindows (TuiWinInfoPtr winInfo); |
382 | ||
c906108c | 383 | #endif /* TUI_DATA_H */ |