testsuite: Fix gdb.base/bang.exp for remote stubs without exit
[deliverable/binutils-gdb.git] / gdb / varobj.h
CommitLineData
8b93c638 1/* GDB variable objects API.
8acc9f48 2 Copyright (C) 1999-2013 Free Software Foundation, Inc.
8b93c638
JM
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
a9762ec7 6 the Free Software Foundation; either version 3 of the License, or
8b93c638
JM
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
a9762ec7 15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
8b93c638
JM
16
17#ifndef VAROBJ_H
18#define VAROBJ_H 1
19
20#include "symtab.h"
21#include "gdbtypes.h"
d56d46f5 22#include "vec.h"
8b93c638
JM
23
24/* Enumeration for the format types */
25enum varobj_display_formats
26 {
27 FORMAT_NATURAL, /* What gdb actually calls 'natural' */
28 FORMAT_BINARY, /* Binary display */
29 FORMAT_DECIMAL, /* Decimal display */
30 FORMAT_HEXADECIMAL, /* Hex display */
31 FORMAT_OCTAL /* Octal display */
32 };
33
73a93a32
JI
34enum varobj_type
35 {
581e13c1
MS
36 USE_SPECIFIED_FRAME, /* Use the frame passed to varobj_create. */
37 USE_CURRENT_FRAME, /* Use the current frame. */
38 USE_SELECTED_FRAME /* Always reevaluate in selected frame. */
73a93a32 39 };
8756216b 40
f7f9ae2c
VP
41/* Enumerator describing if a variable object is in scope. */
42enum varobj_scope_status
8756216b 43 {
f7f9ae2c 44 VAROBJ_IN_SCOPE = 0, /* Varobj is scope, value available. */
3e43a32a
MS
45 VAROBJ_NOT_IN_SCOPE = 1, /* Varobj is not in scope, value not
46 available, but varobj can become in
47 scope later. */
f7f9ae2c
VP
48 VAROBJ_INVALID = 2, /* Varobj no longer has any value, and never
49 will. */
8756216b
DP
50 };
51
581e13c1 52/* String representations of gdb's format codes (defined in varobj.c). */
8b93c638
JM
53extern char *varobj_format_string[];
54
1cc47d81
YQ
55/* Languages supported by this variable objects system. This enum is used
56 to index arrays so we make its first enum explicitly zero. */
8b93c638
JM
57enum varobj_languages
58 {
c573f273 59 vlang_c = 0, vlang_cplus, vlang_java, vlang_ada, vlang_end
8b93c638
JM
60 };
61
581e13c1 62/* String representations of gdb's known languages (defined in varobj.c). */
8b93c638
JM
63extern char *varobj_language_string[];
64
581e13c1 65/* Struct thar describes a variable object instance. */
bb5ce47a 66
8b93c638
JM
67struct varobj;
68
d56d46f5
VP
69typedef struct varobj *varobj_p;
70DEF_VEC_P (varobj_p);
71
f7f9ae2c
VP
72typedef struct varobj_update_result_t
73{
74 struct varobj *varobj;
75 int type_changed;
b6313243 76 int children_changed;
f7f9ae2c
VP
77 int changed;
78 enum varobj_scope_status status;
b6313243
TT
79 /* This variable is used internally by varobj_update to indicate if the
80 new value of varobj is already computed and installed, or has to
581e13c1 81 be yet installed. Don't use this outside varobj.c. */
b6313243 82 int value_installed;
0cc7d26f
TT
83
84 /* This will be non-NULL when new children were added to the varobj.
85 It lists the new children (which must necessarily come at the end
86 of the child list) added during an update. The caller is
87 responsible for freeing this vector. */
88 VEC (varobj_p) *new;
f7f9ae2c
VP
89} varobj_update_result;
90
91DEF_VEC_O (varobj_update_result);
92
bb5ce47a
YQ
93struct varobj_root;
94struct varobj_dynamic;
95
96/* Every variable in the system has a structure of this type defined
97 for it. This structure holds all information necessary to manipulate
98 a particular object variable. Members which must be freed are noted. */
99struct varobj
100{
101 /* Alloc'd name of the variable for this object. If this variable is a
102 child, then this name will be the child's source name.
103 (bar, not foo.bar). */
104 /* NOTE: This is the "expression". */
105 char *name;
106
107 /* Alloc'd expression for this child. Can be used to create a
108 root variable corresponding to this child. */
109 char *path_expr;
110
111 /* The alloc'd name for this variable's object. This is here for
112 convenience when constructing this object's children. */
113 char *obj_name;
114
115 /* Index of this variable in its parent or -1. */
116 int index;
117
118 /* The type of this variable. This can be NULL
119 for artifial variable objects -- currently, the "accessibility"
120 variable objects in C++. */
121 struct type *type;
122
123 /* The value of this expression or subexpression. A NULL value
124 indicates there was an error getting this value.
125 Invariant: if varobj_value_is_changeable_p (this) is non-zero,
126 the value is either NULL, or not lazy. */
127 struct value *value;
128
129 /* The number of (immediate) children this variable has. */
130 int num_children;
131
132 /* If this object is a child, this points to its immediate parent. */
133 struct varobj *parent;
134
135 /* Children of this object. */
136 VEC (varobj_p) *children;
137
138 /* Description of the root variable. Points to root variable for
139 children. */
140 struct varobj_root *root;
141
142 /* The format of the output for this object. */
143 enum varobj_display_formats format;
144
145 /* Was this variable updated via a varobj_set_value operation. */
146 int updated;
147
148 /* Last print value. */
149 char *print_value;
150
151 /* Is this variable frozen. Frozen variables are never implicitly
152 updated by -var-update *
153 or -var-update <direct-or-indirect-parent>. */
154 int frozen;
155
156 /* Is the value of this variable intentionally not fetched? It is
157 not fetched if either the variable is frozen, or any parents is
158 frozen. */
159 int not_fetched;
160
161 /* Sub-range of children which the MI consumer has requested. If
162 FROM < 0 or TO < 0, means that all children have been
163 requested. */
164 int from;
165 int to;
166
167 /* Dynamic part of varobj. */
168 struct varobj_dynamic *dynamic;
169};
170
99ad9427
YQ
171/* Is the variable X one of our "fake" children? */
172#define CPLUS_FAKE_CHILD(x) \
173((x) != NULL && (x)->type == NULL && (x)->value == NULL)
174
175/* The language specific vector */
176
177struct lang_varobj_ops
178{
179 /* The number of children of PARENT. */
6ba1f115 180 int (*number_of_children) (struct varobj *parent);
99ad9427
YQ
181
182 /* The name (expression) of a root varobj. */
6ba1f115 183 char *(*name_of_variable) (struct varobj *parent);
99ad9427
YQ
184
185 /* The name of the INDEX'th child of PARENT. */
6ba1f115 186 char *(*name_of_child) (struct varobj *parent, int index);
99ad9427
YQ
187
188 /* Returns the rooted expression of CHILD, which is a variable
189 obtain that has some parent. */
6ba1f115 190 char *(*path_expr_of_child) (struct varobj *child);
99ad9427
YQ
191
192 /* The ``struct value *'' of the INDEX'th child of PARENT. */
6ba1f115 193 struct value *(*value_of_child) (struct varobj *parent, int index);
99ad9427
YQ
194
195 /* The type of the INDEX'th child of PARENT. */
6ba1f115 196 struct type *(*type_of_child) (struct varobj *parent, int index);
99ad9427
YQ
197
198 /* The current value of VAR. */
6ba1f115 199 char *(*value_of_variable) (struct varobj *var,
99ad9427
YQ
200 enum varobj_display_formats format);
201
202 /* Return non-zero if changes in value of VAR must be detected and
203 reported by -var-update. Return zero if -var-update should never
204 report changes of such values. This makes sense for structures
205 (since the changes in children values will be reported separately),
206 or for artifical objects (like 'public' pseudo-field in C++).
207
208 Return value of 0 means that gdb need not call value_fetch_lazy
209 for the value of this variable object. */
210 int (*value_is_changeable_p) (struct varobj *var);
211
212 /* Return nonzero if the type of VAR has mutated.
213
214 VAR's value is still the varobj's previous value, while NEW_VALUE
215 is VAR's new value and NEW_TYPE is the var's new type. NEW_VALUE
216 may be NULL indicating that there is no value available (the varobj
217 may be out of scope, of may be the child of a null pointer, for
218 instance). NEW_TYPE, on the other hand, must never be NULL.
219
220 This function should also be able to assume that var's number of
221 children is set (not < 0).
222
223 Languages where types do not mutate can set this to NULL. */
224 int (*value_has_mutated) (struct varobj *var, struct value *new_value,
225 struct type *new_type);
226};
227
228const struct lang_varobj_ops c_varobj_ops;
229const struct lang_varobj_ops cplus_varobj_ops;
230const struct lang_varobj_ops java_varobj_ops;
231const struct lang_varobj_ops ada_varobj_ops;
232
8b93c638
JM
233/* API functions */
234
235extern struct varobj *varobj_create (char *objname,
73a93a32
JI
236 char *expression, CORE_ADDR frame,
237 enum varobj_type type);
8b93c638
JM
238
239extern char *varobj_gen_name (void);
240
241extern struct varobj *varobj_get_handle (char *name);
242
243extern char *varobj_get_objname (struct varobj *var);
244
245extern char *varobj_get_expression (struct varobj *var);
246
247extern int varobj_delete (struct varobj *var, char ***dellist,
248 int only_children);
249
250extern enum varobj_display_formats varobj_set_display_format (
251 struct varobj *var,
252 enum varobj_display_formats format);
253
254extern enum varobj_display_formats varobj_get_display_format (
255 struct varobj *var);
256
c5b48eac
VP
257extern int varobj_get_thread_id (struct varobj *var);
258
25d5ea92
VP
259extern void varobj_set_frozen (struct varobj *var, int frozen);
260
261extern int varobj_get_frozen (struct varobj *var);
262
0cc7d26f
TT
263extern void varobj_get_child_range (struct varobj *var, int *from, int *to);
264
265extern void varobj_set_child_range (struct varobj *var, int from, int to);
266
b6313243
TT
267extern char *varobj_get_display_hint (struct varobj *var);
268
8b93c638
JM
269extern int varobj_get_num_children (struct varobj *var);
270
0cc7d26f
TT
271/* Return the list of children of VAR. The returned vector should not
272 be modified in any way. FROM and TO are in/out parameters
273 indicating the range of children to return. If either *FROM or *TO
274 is less than zero on entry, then all children will be returned. On
275 return, *FROM and *TO will be updated to indicate the real range
276 that was returned. The resulting VEC will contain at least the
277 children from *FROM to just before *TO; it might contain more
278 children, depending on whether any more were available. */
279extern VEC (varobj_p)* varobj_list_children (struct varobj *var,
280 int *from, int *to);
8b93c638
JM
281
282extern char *varobj_get_type (struct varobj *var);
283
1ecb4ee0
DJ
284extern struct type *varobj_get_gdb_type (struct varobj *var);
285
02142340
VP
286extern char *varobj_get_path_expr (struct varobj *var);
287
8b93c638
JM
288extern enum varobj_languages varobj_get_language (struct varobj *var);
289
290extern int varobj_get_attributes (struct varobj *var);
291
de051565
MK
292extern char *varobj_get_formatted_value (struct varobj *var,
293 enum varobj_display_formats format);
294
8b93c638
JM
295extern char *varobj_get_value (struct varobj *var);
296
297extern int varobj_set_value (struct varobj *var, char *expression);
298
54333c3b
JK
299extern void all_root_varobjs (void (*func) (struct varobj *var, void *data),
300 void *data);
8b93c638 301
f7f9ae2c
VP
302extern VEC(varobj_update_result) *varobj_update (struct varobj **varp,
303 int explicit);
8b93c638 304
8756216b
DP
305extern void varobj_invalidate (void);
306
c203027e
NR
307extern int varobj_editable_p (struct varobj *var);
308
5a413362
VP
309extern int varobj_floating_p (struct varobj *var);
310
2021ad3a
PM
311extern void varobj_set_visualizer (struct varobj *var,
312 const char *visualizer);
0cc7d26f
TT
313
314extern void varobj_enable_pretty_printing (void);
315
316extern int varobj_has_more (struct varobj *var, int to);
317
318extern int varobj_pretty_printed_p (struct varobj *var);
b6313243 319
99ad9427
YQ
320extern int varobj_default_value_is_changeable_p (struct varobj *var);
321extern int varobj_value_is_changeable_p (struct varobj *var);
322
323extern struct type *varobj_get_value_type (struct varobj *var);
324
325extern int varobj_is_anonymous_child (struct varobj *child);
326
327extern struct varobj *varobj_get_path_expr_parent (struct varobj *var);
328
329extern char *varobj_value_get_print_value (struct value *value,
330 enum varobj_display_formats format,
331 struct varobj *var);
332
333extern void varobj_formatted_print_options (struct value_print_options *opts,
334 enum varobj_display_formats format);
335
336extern void varobj_restrict_range (VEC (varobj_p) *children, int *from,
337 int *to);
8b93c638 338#endif /* VAROBJ_H */
This page took 1.58903 seconds and 4 git commands to generate.