xref: /openbsd/gnu/usr.bin/binutils/gdb/tui/tui-data.h (revision b725ae77)
1*b725ae77Skettenis /* TUI data manipulation routines.
2*b725ae77Skettenis 
3*b725ae77Skettenis    Copyright 1998, 1999, 2000, 2001, 2002, 2004 Free Software
4*b725ae77Skettenis    Foundation, Inc.
5*b725ae77Skettenis 
6*b725ae77Skettenis    Contributed by Hewlett-Packard Company.
7*b725ae77Skettenis 
8*b725ae77Skettenis    This file is part of GDB.
9*b725ae77Skettenis 
10*b725ae77Skettenis    This program is free software; you can redistribute it and/or modify
11*b725ae77Skettenis    it under the terms of the GNU General Public License as published by
12*b725ae77Skettenis    the Free Software Foundation; either version 2 of the License, or
13*b725ae77Skettenis    (at your option) any later version.
14*b725ae77Skettenis 
15*b725ae77Skettenis    This program is distributed in the hope that it will be useful,
16*b725ae77Skettenis    but WITHOUT ANY WARRANTY; without even the implied warranty of
17*b725ae77Skettenis    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*b725ae77Skettenis    GNU General Public License for more details.
19*b725ae77Skettenis 
20*b725ae77Skettenis    You should have received a copy of the GNU General Public License
21*b725ae77Skettenis    along with this program; if not, write to the Free Software
22*b725ae77Skettenis    Foundation, Inc., 59 Temple Place - Suite 330,
23*b725ae77Skettenis    Boston, MA 02111-1307, USA.  */
24*b725ae77Skettenis 
25*b725ae77Skettenis #ifndef TUI_DATA_H
26*b725ae77Skettenis #define TUI_DATA_H
27*b725ae77Skettenis 
28*b725ae77Skettenis #include "tui/tui.h"	/* For enum tui_win_type.  */
29*b725ae77Skettenis #include "gdb_curses.h"	/* For WINDOW.  */
30*b725ae77Skettenis 
31*b725ae77Skettenis /* This is a point definition.  */
32*b725ae77Skettenis struct tui_point
33*b725ae77Skettenis {
34*b725ae77Skettenis   int x, y;
35*b725ae77Skettenis };
36*b725ae77Skettenis 
37*b725ae77Skettenis /* Generic window information */
38*b725ae77Skettenis struct tui_gen_win_info
39*b725ae77Skettenis {
40*b725ae77Skettenis   WINDOW *handle;	/* window handle */
41*b725ae77Skettenis   enum tui_win_type type;	/* type of window */
42*b725ae77Skettenis   int width;		/* window width */
43*b725ae77Skettenis   int height;		/* window height */
44*b725ae77Skettenis   struct tui_point origin;	/* origin of window */
45*b725ae77Skettenis   void **content;	/* content of window */
46*b725ae77Skettenis   int content_size;	/* Size of content (# of elements) */
47*b725ae77Skettenis   int content_in_use;	/* Can it be used, or is it already used? */
48*b725ae77Skettenis   int viewport_height;	/* viewport height */
49*b725ae77Skettenis   int last_visible_line;	/* index of last visible line */
50*b725ae77Skettenis   int is_visible;		/* whether the window is visible or not */
51*b725ae77Skettenis   char *title;          /* Window title to display.  */
52*b725ae77Skettenis };
53*b725ae77Skettenis 
54*b725ae77Skettenis /* Constant definitions */
55*b725ae77Skettenis #define DEFAULT_TAB_LEN                8
56*b725ae77Skettenis #define NO_SRC_STRING                  "[ No Source Available ]"
57*b725ae77Skettenis #define NO_DISASSEM_STRING             "[ No Assembly Available ]"
58*b725ae77Skettenis #define NO_REGS_STRING                 "[ Register Values Unavailable ]"
59*b725ae77Skettenis #define NO_DATA_STRING                 "[ No Data Values Displayed ]"
60*b725ae77Skettenis #define MAX_CONTENT_COUNT              100
61*b725ae77Skettenis #define SRC_NAME                       "SRC"
62*b725ae77Skettenis #define CMD_NAME                       "CMD"
63*b725ae77Skettenis #define DATA_NAME                      "REGS"
64*b725ae77Skettenis #define DISASSEM_NAME                  "ASM"
65*b725ae77Skettenis #define TUI_NULL_STR                   ""
66*b725ae77Skettenis #define DEFAULT_HISTORY_COUNT          25
67*b725ae77Skettenis #define BOX_WINDOW                     TRUE
68*b725ae77Skettenis #define DONT_BOX_WINDOW                FALSE
69*b725ae77Skettenis #define HILITE                         TRUE
70*b725ae77Skettenis #define NO_HILITE                      FALSE
71*b725ae77Skettenis #define WITH_LOCATOR                   TRUE
72*b725ae77Skettenis #define NO_LOCATOR                     FALSE
73*b725ae77Skettenis #define EMPTY_SOURCE_PROMPT            TRUE
74*b725ae77Skettenis #define NO_EMPTY_SOURCE_PROMPT         FALSE
75*b725ae77Skettenis #define UNDEFINED_ITEM                 -1
76*b725ae77Skettenis #define MIN_WIN_HEIGHT                 3
77*b725ae77Skettenis #define MIN_CMD_WIN_HEIGHT             3
78*b725ae77Skettenis 
79*b725ae77Skettenis /* Strings to display in the TUI status line.  */
80*b725ae77Skettenis #define PROC_PREFIX                    "In: "
81*b725ae77Skettenis #define LINE_PREFIX                    "Line: "
82*b725ae77Skettenis #define PC_PREFIX                      "PC: "
83*b725ae77Skettenis #define SINGLE_KEY                     "(SingleKey)"
84*b725ae77Skettenis 
85*b725ae77Skettenis /* Minimum/Maximum length of some fields displayed in the TUI status line.  */
86*b725ae77Skettenis #define MIN_LINE_WIDTH     4 /* Use at least 4 digits for line numbers.  */
87*b725ae77Skettenis #define MIN_PROC_WIDTH    12
88*b725ae77Skettenis #define MAX_TARGET_WIDTH  10
89*b725ae77Skettenis #define MAX_PID_WIDTH     14
90*b725ae77Skettenis 
91*b725ae77Skettenis #define TUI_FLOAT_REGS_NAME                  "$FREGS"
92*b725ae77Skettenis #define TUI_FLOAT_REGS_NAME_LOWER            "$fregs"
93*b725ae77Skettenis #define TUI_GENERAL_REGS_NAME                "$GREGS"
94*b725ae77Skettenis #define TUI_GENERAL_REGS_NAME_LOWER          "$gregs"
95*b725ae77Skettenis #define TUI_SPECIAL_REGS_NAME                "$SREGS"
96*b725ae77Skettenis #define TUI_SPECIAL_REGS_NAME_LOWER          "$sregs"
97*b725ae77Skettenis #define TUI_GENERAL_SPECIAL_REGS_NAME        "$REGS"
98*b725ae77Skettenis #define TUI_GENERAL_SPECIAL_REGS_NAME_LOWER  "$regs"
99*b725ae77Skettenis 
100*b725ae77Skettenis /* Scroll direction enum.  */
101*b725ae77Skettenis enum tui_scroll_direction
102*b725ae77Skettenis {
103*b725ae77Skettenis   FORWARD_SCROLL,
104*b725ae77Skettenis   BACKWARD_SCROLL,
105*b725ae77Skettenis   LEFT_SCROLL,
106*b725ae77Skettenis   RIGHT_SCROLL
107*b725ae77Skettenis };
108*b725ae77Skettenis 
109*b725ae77Skettenis 
110*b725ae77Skettenis /* General list struct.  */
111*b725ae77Skettenis struct tui_list
112*b725ae77Skettenis {
113*b725ae77Skettenis   void **list;
114*b725ae77Skettenis   int count;
115*b725ae77Skettenis };
116*b725ae77Skettenis 
117*b725ae77Skettenis 
118*b725ae77Skettenis /* The kinds of layouts available */
119*b725ae77Skettenis enum tui_layout_type
120*b725ae77Skettenis {
121*b725ae77Skettenis   SRC_COMMAND,
122*b725ae77Skettenis   DISASSEM_COMMAND,
123*b725ae77Skettenis   SRC_DISASSEM_COMMAND,
124*b725ae77Skettenis   SRC_DATA_COMMAND,
125*b725ae77Skettenis   DISASSEM_DATA_COMMAND,
126*b725ae77Skettenis   UNDEFINED_LAYOUT
127*b725ae77Skettenis };
128*b725ae77Skettenis 
129*b725ae77Skettenis /* Basic data types that can be displayed in the data window. */
130*b725ae77Skettenis enum tui_data_type
131*b725ae77Skettenis {
132*b725ae77Skettenis   TUI_REGISTER,
133*b725ae77Skettenis   TUI_SCALAR,
134*b725ae77Skettenis   TUI_COMPLEX,
135*b725ae77Skettenis   TUI_STRUCT
136*b725ae77Skettenis };
137*b725ae77Skettenis 
138*b725ae77Skettenis /* Types of register displays */
139*b725ae77Skettenis enum tui_register_display_type
140*b725ae77Skettenis {
141*b725ae77Skettenis   TUI_UNDEFINED_REGS,
142*b725ae77Skettenis   TUI_GENERAL_REGS,
143*b725ae77Skettenis   TUI_SFLOAT_REGS,
144*b725ae77Skettenis   TUI_DFLOAT_REGS,
145*b725ae77Skettenis   TUI_SPECIAL_REGS,
146*b725ae77Skettenis   TUI_GENERAL_AND_SPECIAL_REGS
147*b725ae77Skettenis };
148*b725ae77Skettenis 
149*b725ae77Skettenis /* Structure describing source line or line address */
150*b725ae77Skettenis union tui_line_or_address
151*b725ae77Skettenis {
152*b725ae77Skettenis   int line_no;
153*b725ae77Skettenis   CORE_ADDR addr;
154*b725ae77Skettenis };
155*b725ae77Skettenis 
156*b725ae77Skettenis /* Current Layout definition */
157*b725ae77Skettenis struct tui_layout_def
158*b725ae77Skettenis {
159*b725ae77Skettenis   enum tui_win_type display_mode;
160*b725ae77Skettenis   int split;
161*b725ae77Skettenis   enum tui_register_display_type regs_display_type;
162*b725ae77Skettenis   enum tui_register_display_type float_regs_display_type;
163*b725ae77Skettenis };
164*b725ae77Skettenis 
165*b725ae77Skettenis /* Elements in the Source/Disassembly Window */
166*b725ae77Skettenis struct tui_source_element
167*b725ae77Skettenis {
168*b725ae77Skettenis   char *line;
169*b725ae77Skettenis   union tui_line_or_address line_or_addr;
170*b725ae77Skettenis   int is_exec_point;
171*b725ae77Skettenis   int has_break;
172*b725ae77Skettenis };
173*b725ae77Skettenis 
174*b725ae77Skettenis 
175*b725ae77Skettenis /* Elements in the data display window content */
176*b725ae77Skettenis struct tui_data_element
177*b725ae77Skettenis {
178*b725ae77Skettenis   const char *name;
179*b725ae77Skettenis   int item_no;			/* the register number, or data display number */
180*b725ae77Skettenis   enum tui_data_type type;
181*b725ae77Skettenis   void *value;
182*b725ae77Skettenis   int highlight;
183*b725ae77Skettenis   char *content;
184*b725ae77Skettenis };
185*b725ae77Skettenis 
186*b725ae77Skettenis 
187*b725ae77Skettenis /* Elements in the command window content */
188*b725ae77Skettenis struct tui_command_element
189*b725ae77Skettenis {
190*b725ae77Skettenis   char *line;
191*b725ae77Skettenis };
192*b725ae77Skettenis 
193*b725ae77Skettenis 
194*b725ae77Skettenis #define MAX_LOCATOR_ELEMENT_LEN        100
195*b725ae77Skettenis 
196*b725ae77Skettenis /* Elements in the locator window content */
197*b725ae77Skettenis struct tui_locator_element
198*b725ae77Skettenis {
199*b725ae77Skettenis   char file_name[MAX_LOCATOR_ELEMENT_LEN];
200*b725ae77Skettenis   char proc_name[MAX_LOCATOR_ELEMENT_LEN];
201*b725ae77Skettenis   int line_no;
202*b725ae77Skettenis   CORE_ADDR addr;
203*b725ae77Skettenis };
204*b725ae77Skettenis 
205*b725ae77Skettenis /* Flags to tell what kind of breakpoint is at current line.  */
206*b725ae77Skettenis #define TUI_BP_ENABLED      0x01
207*b725ae77Skettenis #define TUI_BP_DISABLED     0x02
208*b725ae77Skettenis #define TUI_BP_HIT          0x04
209*b725ae77Skettenis #define TUI_BP_CONDITIONAL  0x08
210*b725ae77Skettenis #define TUI_BP_HARDWARE     0x10
211*b725ae77Skettenis 
212*b725ae77Skettenis /* Position of breakpoint markers in the exec info string.  */
213*b725ae77Skettenis #define TUI_BP_HIT_POS      0
214*b725ae77Skettenis #define TUI_BP_BREAK_POS    1
215*b725ae77Skettenis #define TUI_EXEC_POS        2
216*b725ae77Skettenis #define TUI_EXECINFO_SIZE   4
217*b725ae77Skettenis 
218*b725ae77Skettenis typedef char tui_exec_info_content[TUI_EXECINFO_SIZE];
219*b725ae77Skettenis 
220*b725ae77Skettenis /* An content element in a window */
221*b725ae77Skettenis union tui_which_element
222*b725ae77Skettenis {
223*b725ae77Skettenis   struct tui_source_element source;	/* the source elements */
224*b725ae77Skettenis   struct tui_gen_win_info data_window;	/* data display elements */
225*b725ae77Skettenis   struct tui_data_element data;	/* elements of data_window */
226*b725ae77Skettenis   struct tui_command_element command;	/* command elements */
227*b725ae77Skettenis   struct tui_locator_element locator;	/* locator elements */
228*b725ae77Skettenis   tui_exec_info_content simple_string;	/* simple char based elements */
229*b725ae77Skettenis };
230*b725ae77Skettenis 
231*b725ae77Skettenis struct tui_win_element
232*b725ae77Skettenis {
233*b725ae77Skettenis   int highlight;
234*b725ae77Skettenis   union tui_which_element which_element;
235*b725ae77Skettenis };
236*b725ae77Skettenis 
237*b725ae77Skettenis 
238*b725ae77Skettenis /* This describes the content of the window. */
239*b725ae77Skettenis typedef struct tui_win_element **tui_win_content;
240*b725ae77Skettenis 
241*b725ae77Skettenis 
242*b725ae77Skettenis /* This struct defines the specific information about a data display window */
243*b725ae77Skettenis struct tui_data_info
244*b725ae77Skettenis {
245*b725ae77Skettenis   tui_win_content data_content;	/* start of data display content */
246*b725ae77Skettenis   int data_content_count;
247*b725ae77Skettenis   tui_win_content regs_content;	/* start of regs display content */
248*b725ae77Skettenis   int regs_content_count;
249*b725ae77Skettenis   enum tui_register_display_type regs_display_type;
250*b725ae77Skettenis   int regs_column_count;
251*b725ae77Skettenis   int display_regs;		/* Should regs be displayed at all? */
252*b725ae77Skettenis   struct reggroup *current_group;
253*b725ae77Skettenis };
254*b725ae77Skettenis 
255*b725ae77Skettenis 
256*b725ae77Skettenis struct tui_source_info
257*b725ae77Skettenis {
258*b725ae77Skettenis   int has_locator;		/* Does locator belongs to this window? */
259*b725ae77Skettenis   /* Execution information window.  */
260*b725ae77Skettenis   struct tui_gen_win_info *execution_info;
261*b725ae77Skettenis   int horizontal_offset;	/* used for horizontal scroll */
262*b725ae77Skettenis   union tui_line_or_address start_line_or_addr;
263*b725ae77Skettenis   char* filename;
264*b725ae77Skettenis };
265*b725ae77Skettenis 
266*b725ae77Skettenis 
267*b725ae77Skettenis struct tui_command_info
268*b725ae77Skettenis {
269*b725ae77Skettenis   int cur_line;		/* The current line position */
270*b725ae77Skettenis   int curch;			/* The current cursor position */
271*b725ae77Skettenis   int start_line;
272*b725ae77Skettenis };
273*b725ae77Skettenis 
274*b725ae77Skettenis 
275*b725ae77Skettenis /* This defines information about each logical window */
276*b725ae77Skettenis struct tui_win_info
277*b725ae77Skettenis {
278*b725ae77Skettenis   struct tui_gen_win_info generic;	/* general window information */
279*b725ae77Skettenis   union
280*b725ae77Skettenis   {
281*b725ae77Skettenis     struct tui_source_info source_info;
282*b725ae77Skettenis     struct tui_data_info data_display_info;
283*b725ae77Skettenis     struct tui_command_info command_info;
284*b725ae77Skettenis     void *opaque;
285*b725ae77Skettenis   }
286*b725ae77Skettenis   detail;
287*b725ae77Skettenis   int can_highlight;		/* Can this window ever be highlighted? */
288*b725ae77Skettenis   int is_highlighted;		/* Is this window highlighted? */
289*b725ae77Skettenis };
290*b725ae77Skettenis 
291*b725ae77Skettenis extern int tui_win_is_source_type (enum tui_win_type win_type);
292*b725ae77Skettenis extern int tui_win_is_auxillary (enum tui_win_type win_type);
293*b725ae77Skettenis extern int tui_win_has_locator (struct tui_win_info *win_info);
294*b725ae77Skettenis extern void tui_set_win_highlight (struct tui_win_info *win_info,
295*b725ae77Skettenis 				   int highlight);
296*b725ae77Skettenis 
297*b725ae77Skettenis 
298*b725ae77Skettenis /* Global Data */
299*b725ae77Skettenis extern struct tui_win_info *(tui_win_list[MAX_MAJOR_WINDOWS]);
300*b725ae77Skettenis 
301*b725ae77Skettenis #define TUI_SRC_WIN            tui_win_list[SRC_WIN]
302*b725ae77Skettenis #define TUI_DISASM_WIN       tui_win_list[DISASSEM_WIN]
303*b725ae77Skettenis #define TUI_DATA_WIN           tui_win_list[DATA_WIN]
304*b725ae77Skettenis #define TUI_CMD_WIN            tui_win_list[CMD_WIN]
305*b725ae77Skettenis 
306*b725ae77Skettenis /* Data Manipulation Functions */
307*b725ae77Skettenis extern void tui_initialize_static_data (void);
308*b725ae77Skettenis extern struct tui_gen_win_info *tui_alloc_generic_win_info (void);
309*b725ae77Skettenis extern struct tui_win_info *tui_alloc_win_info (enum tui_win_type);
310*b725ae77Skettenis extern void tui_init_generic_part (struct tui_gen_win_info *);
311*b725ae77Skettenis extern void tui_init_win_info (struct tui_win_info *);
312*b725ae77Skettenis extern tui_win_content tui_alloc_content (int, enum tui_win_type);
313*b725ae77Skettenis extern int tui_add_content_elements (struct tui_gen_win_info *, int);
314*b725ae77Skettenis extern void tui_init_content_element (struct tui_win_element *, enum tui_win_type);
315*b725ae77Skettenis extern void tui_free_window (struct tui_win_info *);
316*b725ae77Skettenis extern void tui_free_win_content (struct tui_gen_win_info *);
317*b725ae77Skettenis extern void tui_free_data_content (tui_win_content, int);
318*b725ae77Skettenis extern void tui_free_all_source_wins_content (void);
319*b725ae77Skettenis extern void tui_del_window (struct tui_win_info *);
320*b725ae77Skettenis extern void tui_del_data_windows (tui_win_content, int);
321*b725ae77Skettenis extern struct tui_win_info *tui_partial_win_by_name (char *);
322*b725ae77Skettenis extern char *tui_win_name (struct tui_gen_win_info *);
323*b725ae77Skettenis extern enum tui_layout_type tui_current_layout (void);
324*b725ae77Skettenis extern void tui_set_current_layout_to (enum tui_layout_type);
325*b725ae77Skettenis extern int tui_term_height (void);
326*b725ae77Skettenis extern void tui_set_term_height_to (int);
327*b725ae77Skettenis extern int tui_term_width (void);
328*b725ae77Skettenis extern void tui_set_term_width_to (int);
329*b725ae77Skettenis extern void tui_set_gen_win_origin (struct tui_gen_win_info *, int, int);
330*b725ae77Skettenis extern struct tui_gen_win_info *tui_locator_win_info_ptr (void);
331*b725ae77Skettenis extern struct tui_gen_win_info *tui_source_exec_info_win_ptr (void);
332*b725ae77Skettenis extern struct tui_gen_win_info *tui_disassem_exec_info_win_ptr (void);
333*b725ae77Skettenis extern struct tui_list * tui_source_windows (void);
334*b725ae77Skettenis extern void tui_clear_source_windows (void);
335*b725ae77Skettenis extern void tui_clear_source_windows_detail (void);
336*b725ae77Skettenis extern void tui_clear_win_detail (struct tui_win_info * win_info);
337*b725ae77Skettenis extern void tui_add_to_source_windows (struct tui_win_info *);
338*b725ae77Skettenis extern int tui_default_tab_len (void);
339*b725ae77Skettenis extern void tui_set_default_tab_len (int);
340*b725ae77Skettenis extern struct tui_win_info *tui_win_with_focus (void);
341*b725ae77Skettenis extern void tui_set_win_with_focus (struct tui_win_info *);
342*b725ae77Skettenis extern struct tui_layout_def * tui_layout_def (void);
343*b725ae77Skettenis extern int tui_win_resized (void);
344*b725ae77Skettenis extern void tui_set_win_resized_to (int);
345*b725ae77Skettenis 
346*b725ae77Skettenis extern struct tui_win_info *tui_next_win (struct tui_win_info *);
347*b725ae77Skettenis extern struct tui_win_info *tui_prev_win (struct tui_win_info *);
348*b725ae77Skettenis 
349*b725ae77Skettenis extern void tui_add_to_source_windows (struct tui_win_info * win_info);
350*b725ae77Skettenis 
351*b725ae77Skettenis #endif /* TUI_DATA_H */
352