2004-02-06 Andrew Cagney <cagney@redhat.com>
[platform/upstream/binutils.git] / gdb / tui / tui-data.h
1 /* TUI data manipulation routines.
2
3    Copyright 1998, 1999, 2000, 2001, 2002, 2004 Free Software
4    Foundation, Inc.
5
6    Contributed by Hewlett-Packard Company.
7
8    This file is part of GDB.
9
10    This program is free software; you can redistribute it and/or modify
11    it under the terms of the GNU General Public License as published by
12    the Free Software Foundation; either version 2 of the License, or
13    (at your option) any later version.
14
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 59 Temple Place - Suite 330,
23    Boston, MA 02111-1307, USA.  */
24
25 #ifndef TUI_DATA_H
26 #define TUI_DATA_H
27
28 #if defined (HAVE_NCURSES_H)
29 #include <ncurses.h>
30 #elif defined (HAVE_CURSES_H)
31 #include <curses.h>
32 #endif
33
34 /* Generic window information */
35      typedef struct tui_gen_win_info
36        {
37          WINDOW *handle;        /* window handle */
38          TuiWinType type;       /* type of window */
39          int width;             /* window width */
40          int height;            /* window height */
41          TuiPoint origin;       /* origin of window */
42          OpaquePtr content;     /* content of window */
43          int contentSize;       /* Size of content (# of elements) */
44          int contentInUse;      /* Can it be used, or is it already used? */
45          int viewportHeight;    /* viewport height */
46          int lastVisibleLine;   /* index of last visible line */
47          int isVisible;         /* whether the window is visible or not */
48          char* title;          /* Window title to display.  */
49        }
50 TuiGenWinInfo, *TuiGenWinInfoPtr;
51
52 /* Constant definitions */
53 #define DEFAULT_TAB_LEN                8
54 #define NO_SRC_STRING                  "[ No Source Available ]"
55 #define NO_DISASSEM_STRING             "[ No Assembly Available ]"
56 #define NO_REGS_STRING                 "[ Register Values Unavailable ]"
57 #define NO_DATA_STRING                 "[ No Data Values Displayed ]"
58 #define MAX_CONTENT_COUNT              100
59 #define SRC_NAME                       "SRC"
60 #define CMD_NAME                       "CMD"
61 #define DATA_NAME                      "REGS"
62 #define DISASSEM_NAME                  "ASM"
63 #define TUI_NULL_STR                   ""
64 #define DEFAULT_HISTORY_COUNT          25
65 #define BOX_WINDOW                     TRUE
66 #define DONT_BOX_WINDOW                FALSE
67 #define HILITE                         TRUE
68 #define NO_HILITE                      FALSE
69 #define WITH_LOCATOR                   TRUE
70 #define NO_LOCATOR                     FALSE
71 #define EMPTY_SOURCE_PROMPT            TRUE
72 #define NO_EMPTY_SOURCE_PROMPT         FALSE
73 #define UNDEFINED_ITEM                 -1
74 #define MIN_WIN_HEIGHT                 3
75 #define MIN_CMD_WIN_HEIGHT             3
76
77 /* Strings to display in the TUI status line.  */
78 #define PROC_PREFIX                    "In: "
79 #define LINE_PREFIX                    "Line: "
80 #define PC_PREFIX                      "PC: "
81 #define SINGLE_KEY                     "(SingleKey)"
82
83 /* Minimum/Maximum length of some fields displayed in the TUI status line.  */
84 #define MIN_LINE_WIDTH     4 /* Use at least 4 digits for line numbers.  */
85 #define MIN_PROC_WIDTH    12
86 #define MAX_TARGET_WIDTH  10
87 #define MAX_PID_WIDTH     14
88
89 #define TUI_FLOAT_REGS_NAME                  "$FREGS"
90 #define TUI_FLOAT_REGS_NAME_LOWER            "$fregs"
91 #define TUI_GENERAL_REGS_NAME                "$GREGS"
92 #define TUI_GENERAL_REGS_NAME_LOWER          "$gregs"
93 #define TUI_SPECIAL_REGS_NAME                "$SREGS"
94 #define TUI_SPECIAL_REGS_NAME_LOWER          "$sregs"
95 #define TUI_GENERAL_SPECIAL_REGS_NAME        "$REGS"
96 #define TUI_GENERAL_SPECIAL_REGS_NAME_LOWER  "$regs"
97
98 /* Scroll direction enum */
99 typedef enum tui_scroll_direction
100   {
101     FORWARD_SCROLL,
102     BACKWARD_SCROLL,
103     LEFT_SCROLL,
104     RIGHT_SCROLL
105   }
106 TuiScrollDirection, *TuiScrollDirectionPtr;
107
108
109 /* General list struct */
110 typedef struct tui_list
111   {
112     OpaqueList list;
113     int count;
114   }
115 TuiList, *TuiListPtr;
116
117
118 /* The kinds of layouts available */
119 typedef enum tui_layout_type
120   {
121     SRC_COMMAND,
122     DISASSEM_COMMAND,
123     SRC_DISASSEM_COMMAND,
124     SRC_DATA_COMMAND,
125     DISASSEM_DATA_COMMAND,
126     UNDEFINED_LAYOUT
127   }
128 TuiLayoutType, *TuiLayoutTypePtr;
129
130 /* Basic data types that can be displayed in the data window. */
131 typedef enum tui_data_type
132   {
133     TUI_REGISTER,
134     TUI_SCALAR,
135     TUI_COMPLEX,
136     TUI_STRUCT
137   }
138 TuiDataType, TuiDataTypePtr;
139
140 /* Types of register displays */
141 typedef enum tui_register_display_type
142   {
143     TUI_UNDEFINED_REGS,
144     TUI_GENERAL_REGS,
145     TUI_SFLOAT_REGS,
146     TUI_DFLOAT_REGS,
147     TUI_SPECIAL_REGS,
148     TUI_GENERAL_AND_SPECIAL_REGS
149   }
150 TuiRegisterDisplayType, *TuiRegisterDisplayTypePtr;
151
152 /* Structure describing source line or line address */
153 typedef union tui_line_or_address
154   {
155     int lineNo;
156     CORE_ADDR addr;
157   }
158 TuiLineOrAddress, *TuiLineOrAddressPtr;
159
160 /* Current Layout definition */
161 typedef struct tui_layout_def
162   {
163     TuiWinType displayMode;
164     int split;
165     TuiRegisterDisplayType regsDisplayType;
166     TuiRegisterDisplayType floatRegsDisplayType;
167   }
168 TuiLayoutDef, *TuiLayoutDefPtr;
169
170 /* Elements in the Source/Disassembly Window */
171 typedef struct tui_source_element
172   {
173     char *line;
174     TuiLineOrAddress lineOrAddr;
175     int isExecPoint;
176     int hasBreak;
177   }
178 TuiSourceElement, *TuiSourceElementPtr;
179
180
181 /* Elements in the data display window content */
182 typedef struct tui_data_element
183   {
184     const char *name;
185     int itemNo;                 /* the register number, or data display number */
186     TuiDataType type;
187     Opaque value;
188     int highlight;
189   }
190 TuiDataElement, *TuiDataElementPtr;
191
192
193 /* Elements in the command window content */
194 typedef struct tui_command_element
195   {
196     char *line;
197   }
198 TuiCommandElement, *TuiCommandElementPtr;
199
200
201 #define MAX_LOCATOR_ELEMENT_LEN        100
202
203 /* Elements in the locator window content */
204 typedef struct tui_locator_element
205   {
206     char fileName[MAX_LOCATOR_ELEMENT_LEN];
207     char procName[MAX_LOCATOR_ELEMENT_LEN];
208     int lineNo;
209     CORE_ADDR addr;
210   }
211 TuiLocatorElement, *TuiLocatorElementPtr;
212
213 /* Flags to tell what kind of breakpoint is at current line.  */
214 #define TUI_BP_ENABLED      0x01
215 #define TUI_BP_DISABLED     0x02
216 #define TUI_BP_HIT          0x04
217 #define TUI_BP_CONDITIONAL  0x08
218 #define TUI_BP_HARDWARE     0x10
219
220 /* Position of breakpoint markers in the exec info string.  */
221 #define TUI_BP_HIT_POS      0
222 #define TUI_BP_BREAK_POS    1
223 #define TUI_EXEC_POS        2
224 #define TUI_EXECINFO_SIZE   4
225
226 typedef char TuiExecInfoContent[TUI_EXECINFO_SIZE];
227
228 /* An content element in a window */
229 typedef union tui_which_element
230   {
231     TuiSourceElement source;    /* the source elements */
232     TuiGenWinInfo dataWindow;   /* data display elements */
233     TuiDataElement data;        /* elements of dataWindow */
234     TuiCommandElement command;  /* command elements */
235     TuiLocatorElement locator;  /* locator elements */
236     TuiExecInfoContent simpleString;    /* simple char based elements */
237   }
238 TuiWhichElement, *TuiWhichElementPtr;
239
240 typedef struct tui_win_element
241   {
242     int highlight;
243     TuiWhichElement whichElement;
244   }
245 TuiWinElement, *TuiWinElementPtr;
246
247
248 /* This describes the content of the window. */
249 typedef TuiWinElementPtr *TuiWinContent;
250
251
252 /* This struct defines the specific information about a data display window */
253 typedef struct tui_data_info
254   {
255     TuiWinContent dataContent;  /* start of data display content */
256     int dataContentCount;
257     TuiWinContent regsContent;  /* start of regs display content */
258     int regsContentCount;
259     TuiRegisterDisplayType regsDisplayType;
260     int regsColumnCount;
261     int displayRegs;            /* Should regs be displayed at all? */
262   }
263 TuiDataInfo, *TuiDataInfoPtr;
264
265
266 typedef struct tui_source_info
267   {
268     int hasLocator;             /* Does locator belongs to this window? */
269     TuiGenWinInfoPtr executionInfo;     /* execution information window */
270     int horizontalOffset;       /* used for horizontal scroll */
271     TuiLineOrAddress startLineOrAddr;
272     char* filename;
273   }
274 TuiSourceInfo, *TuiSourceInfoPtr;
275
276
277 typedef struct tui_command_info
278   {
279     int curLine;                /* The current line position */
280     int curch;                  /* The current cursor position */
281     int start_line;
282   }
283 TuiCommandInfo, *TuiCommandInfoPtr;
284
285
286 /* This defines information about each logical window */
287 typedef struct tui_win_info
288   {
289     TuiGenWinInfo generic;      /* general window information */
290     union
291       {
292         TuiSourceInfo sourceInfo;
293         TuiDataInfo dataDisplayInfo;
294         TuiCommandInfo commandInfo;
295         Opaque opaque;
296       }
297     detail;
298     int canHighlight;           /* Can this window ever be highlighted? */
299     int isHighlighted;          /* Is this window highlighted? */
300   }
301 TuiWinInfo, *TuiWinInfoPtr;
302
303 /* MACROS (prefixed with m_) */
304
305 /* Testing macros */
306 #define        m_genWinPtrIsNull(winInfo) \
307                 ((winInfo) == (TuiGenWinInfoPtr)NULL)
308 #define        m_genWinPtrNotNull(winInfo) \
309                 ((winInfo) != (TuiGenWinInfoPtr)NULL)
310 #define        m_winPtrIsNull(winInfo) \
311                 ((winInfo) == (TuiWinInfoPtr)NULL)
312 #define        m_winPtrNotNull(winInfo) \
313                 ((winInfo) != (TuiWinInfoPtr)NULL)
314
315 #define        m_winIsSourceType(type) \
316                 (type == SRC_WIN || type == DISASSEM_WIN)
317 #define        m_winIsAuxillary(winType) \
318                 (winType > MAX_MAJOR_WINDOWS)
319 #define        m_hasLocator(winInfo) \
320                 ( ((winInfo) != (TuiWinInfoPtr)NULL) ? \
321                     (winInfo->detail.sourceInfo.hasLocator) : \
322                     FALSE )
323
324 #define     m_setWinHighlightOn(winInfo) \
325                 if ((winInfo) != (TuiWinInfoPtr)NULL) \
326                               (winInfo)->isHighlighted = TRUE
327 #define     m_setWinHighlightOff(winInfo) \
328                 if ((winInfo) != (TuiWinInfoPtr)NULL) \
329                               (winInfo)->isHighlighted = FALSE
330
331
332 /* Global Data */
333 extern TuiWinInfoPtr winList[MAX_MAJOR_WINDOWS];
334
335 /* Macros */
336 #define srcWin            winList[SRC_WIN]
337 #define disassemWin       winList[DISASSEM_WIN]
338 #define dataWin           winList[DATA_WIN]
339 #define cmdWin            winList[CMD_WIN]
340
341 /* Data Manipulation Functions */
342 extern void tui_initialize_static_data (void);
343 extern struct tui_gen_win_info *tui_alloc_generic_win_info (void);
344 extern struct tui_win_info *tui_alloc_win_info (TuiWinType);
345 extern void tui_init_generic_part (struct tui_gen_win_info *);
346 extern void tui_init_win_info (struct tui_win_info *);
347 extern TuiWinContent tui_alloc_content (int, enum tui_win_type);
348 extern int tui_add_content_elements (struct tui_gen_win_info *, int);
349 extern void tui_init_content_element (struct tui_win_element *, enum tui_win_type);
350 extern void tui_free_window (struct tui_win_info *);
351 extern void tui_free_win_content (struct tui_gen_win_info *);
352 extern void tui_free_data_content (TuiWinContent, int);
353 extern void tui_free_all_source_wins_content (void);
354 extern void tui_del_window (struct tui_win_info *);
355 extern void tui_del_data_windows (TuiWinContent, int);
356 extern struct tui_win_info *tui_partial_win_by_name (char *);
357 extern char *tui_win_name (struct tui_gen_win_info *);
358 extern TuiLayoutType tui_current_layout (void);
359 extern void tui_set_current_layout_to (TuiLayoutType);
360 extern int tui_term_height (void);
361 extern void tui_set_term_height_to (int);
362 extern int tui_term_width (void);
363 extern void tui_set_term_width_to (int);
364 extern void tui_set_gen_win_origin (struct tui_gen_win_info *, int, int);
365 extern struct tui_gen_win_info *tui_locator_win_info_ptr (void);
366 extern struct tui_gen_win_info *tui_source_exec_info_win_ptr (void);
367 extern struct tui_gen_win_info *tui_disassem_exec_info_win_ptr (void);
368 extern TuiListPtr tui_source_windows (void);
369 extern void tui_clear_source_windows (void);
370 extern void tui_clear_source_windows_detail (void);
371 extern void tui_clear_win_detail (struct tui_win_info * winInfo);
372 extern void tui_add_to_source_windows (struct tui_win_info *);
373 extern int tui_default_tab_len (void);
374 extern void tui_set_default_tab_len (int);
375 extern struct tui_win_info *tui_win_with_focus (void);
376 extern void tui_set_win_with_focus (struct tui_win_info *);
377 extern TuiLayoutDefPtr tui_layout_def (void);
378 extern int tui_win_resized (void);
379 extern void tui_set_win_resized_to (int);
380
381 extern struct tui_win_info *tui_next_win (struct tui_win_info *);
382 extern struct tui_win_info *tui_prev_win (struct tui_win_info *);
383
384 extern void tui_add_to_source_windows (struct tui_win_info * winInfo);
385
386 #endif /* TUI_DATA_H */