]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/varobj.h
C++ keyword cleanliness, mostly auto-generated
[thirdparty/binutils-gdb.git] / gdb / varobj.h
CommitLineData
8b93c638 1/* GDB variable objects API.
32d0add0 2 Copyright (C) 1999-2015 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
581e13c1 55/* Struct thar describes a variable object instance. */
bb5ce47a 56
8b93c638
JM
57struct varobj;
58
d56d46f5
VP
59typedef struct varobj *varobj_p;
60DEF_VEC_P (varobj_p);
61
f7f9ae2c
VP
62typedef struct varobj_update_result_t
63{
64 struct varobj *varobj;
65 int type_changed;
b6313243 66 int children_changed;
f7f9ae2c
VP
67 int changed;
68 enum varobj_scope_status status;
b6313243
TT
69 /* This variable is used internally by varobj_update to indicate if the
70 new value of varobj is already computed and installed, or has to
581e13c1 71 be yet installed. Don't use this outside varobj.c. */
b6313243 72 int value_installed;
0cc7d26f
TT
73
74 /* This will be non-NULL when new children were added to the varobj.
75 It lists the new children (which must necessarily come at the end
76 of the child list) added during an update. The caller is
77 responsible for freeing this vector. */
fe978cb0 78 VEC (varobj_p) *newobj;
f7f9ae2c
VP
79} varobj_update_result;
80
81DEF_VEC_O (varobj_update_result);
82
bb5ce47a
YQ
83struct varobj_root;
84struct varobj_dynamic;
85
86/* Every variable in the system has a structure of this type defined
87 for it. This structure holds all information necessary to manipulate
88 a particular object variable. Members which must be freed are noted. */
89struct varobj
90{
91 /* Alloc'd name of the variable for this object. If this variable is a
92 child, then this name will be the child's source name.
93 (bar, not foo.bar). */
94 /* NOTE: This is the "expression". */
95 char *name;
96
97 /* Alloc'd expression for this child. Can be used to create a
98 root variable corresponding to this child. */
99 char *path_expr;
100
101 /* The alloc'd name for this variable's object. This is here for
102 convenience when constructing this object's children. */
103 char *obj_name;
104
105 /* Index of this variable in its parent or -1. */
106 int index;
107
108 /* The type of this variable. This can be NULL
109 for artifial variable objects -- currently, the "accessibility"
110 variable objects in C++. */
111 struct type *type;
112
113 /* The value of this expression or subexpression. A NULL value
114 indicates there was an error getting this value.
115 Invariant: if varobj_value_is_changeable_p (this) is non-zero,
116 the value is either NULL, or not lazy. */
117 struct value *value;
118
119 /* The number of (immediate) children this variable has. */
120 int num_children;
121
122 /* If this object is a child, this points to its immediate parent. */
c1cc6152 123 const struct varobj *parent;
bb5ce47a
YQ
124
125 /* Children of this object. */
126 VEC (varobj_p) *children;
127
128 /* Description of the root variable. Points to root variable for
129 children. */
130 struct varobj_root *root;
131
132 /* The format of the output for this object. */
133 enum varobj_display_formats format;
134
135 /* Was this variable updated via a varobj_set_value operation. */
136 int updated;
137
138 /* Last print value. */
139 char *print_value;
140
141 /* Is this variable frozen. Frozen variables are never implicitly
142 updated by -var-update *
143 or -var-update <direct-or-indirect-parent>. */
144 int frozen;
145
146 /* Is the value of this variable intentionally not fetched? It is
147 not fetched if either the variable is frozen, or any parents is
148 frozen. */
149 int not_fetched;
150
151 /* Sub-range of children which the MI consumer has requested. If
152 FROM < 0 or TO < 0, means that all children have been
153 requested. */
154 int from;
155 int to;
156
157 /* Dynamic part of varobj. */
158 struct varobj_dynamic *dynamic;
159};
160
99ad9427
YQ
161/* Is the variable X one of our "fake" children? */
162#define CPLUS_FAKE_CHILD(x) \
163((x) != NULL && (x)->type == NULL && (x)->value == NULL)
164
165/* The language specific vector */
166
167struct lang_varobj_ops
168{
169 /* The number of children of PARENT. */
b09e2c59 170 int (*number_of_children) (const struct varobj *parent);
99ad9427 171
aa3de267
SM
172 /* The name (expression) of a root varobj. The returned value must be freed
173 by the caller. */
b09e2c59 174 char *(*name_of_variable) (const struct varobj *parent);
99ad9427 175
aa3de267
SM
176 /* The name of the INDEX'th child of PARENT. The returned value must be
177 freed by the caller. */
c1cc6152 178 char *(*name_of_child) (const struct varobj *parent, int index);
99ad9427
YQ
179
180 /* Returns the rooted expression of CHILD, which is a variable
aa3de267
SM
181 obtain that has some parent. The returned value must be freed by the
182 caller. */
b09e2c59 183 char *(*path_expr_of_child) (const struct varobj *child);
99ad9427
YQ
184
185 /* The ``struct value *'' of the INDEX'th child of PARENT. */
c1cc6152 186 struct value *(*value_of_child) (const struct varobj *parent, int index);
99ad9427
YQ
187
188 /* The type of the INDEX'th child of PARENT. */
c1cc6152 189 struct type *(*type_of_child) (const struct varobj *parent, int index);
99ad9427 190
aa3de267
SM
191 /* The current value of VAR. The returned value must be freed by the
192 caller. */
b09e2c59 193 char *(*value_of_variable) (const struct varobj *var,
99ad9427
YQ
194 enum varobj_display_formats format);
195
196 /* Return non-zero if changes in value of VAR must be detected and
197 reported by -var-update. Return zero if -var-update should never
198 report changes of such values. This makes sense for structures
199 (since the changes in children values will be reported separately),
200 or for artifical objects (like 'public' pseudo-field in C++).
201
202 Return value of 0 means that gdb need not call value_fetch_lazy
203 for the value of this variable object. */
b09e2c59 204 int (*value_is_changeable_p) (const struct varobj *var);
99ad9427
YQ
205
206 /* Return nonzero if the type of VAR has mutated.
207
208 VAR's value is still the varobj's previous value, while NEW_VALUE
209 is VAR's new value and NEW_TYPE is the var's new type. NEW_VALUE
210 may be NULL indicating that there is no value available (the varobj
211 may be out of scope, of may be the child of a null pointer, for
212 instance). NEW_TYPE, on the other hand, must never be NULL.
213
214 This function should also be able to assume that var's number of
215 children is set (not < 0).
216
217 Languages where types do not mutate can set this to NULL. */
b09e2c59 218 int (*value_has_mutated) (const struct varobj *var, struct value *new_value,
99ad9427 219 struct type *new_type);
9a9a7608
AB
220
221 /* Return nonzero if VAR is a suitable path expression parent.
222
223 For C like languages with anonymous structures and unions an anonymous
224 structure or union is not a suitable parent. */
b09e2c59 225 int (*is_path_expr_parent) (const struct varobj *var);
99ad9427
YQ
226};
227
8838afaf
TT
228extern const struct lang_varobj_ops c_varobj_ops;
229extern const struct lang_varobj_ops cplus_varobj_ops;
230extern const struct lang_varobj_ops java_varobj_ops;
231extern const struct lang_varobj_ops ada_varobj_ops;
99ad9427 232
a53b64ea 233#define default_varobj_ops c_varobj_ops
8b93c638
JM
234/* API functions */
235
236extern struct varobj *varobj_create (char *objname,
73a93a32
JI
237 char *expression, CORE_ADDR frame,
238 enum varobj_type type);
8b93c638
JM
239
240extern char *varobj_gen_name (void);
241
242extern struct varobj *varobj_get_handle (char *name);
243
b09e2c59 244extern char *varobj_get_objname (const struct varobj *var);
8b93c638 245
b09e2c59 246extern char *varobj_get_expression (const struct varobj *var);
8b93c638
JM
247
248extern int varobj_delete (struct varobj *var, char ***dellist,
249 int only_children);
250
251extern enum varobj_display_formats varobj_set_display_format (
252 struct varobj *var,
253 enum varobj_display_formats format);
254
255extern enum varobj_display_formats varobj_get_display_format (
b09e2c59 256 const struct varobj *var);
8b93c638 257
b09e2c59 258extern int varobj_get_thread_id (const struct varobj *var);
c5b48eac 259
25d5ea92
VP
260extern void varobj_set_frozen (struct varobj *var, int frozen);
261
b09e2c59 262extern int varobj_get_frozen (const struct varobj *var);
25d5ea92 263
b09e2c59
SM
264extern void varobj_get_child_range (const struct varobj *var, int *from,
265 int *to);
0cc7d26f
TT
266
267extern void varobj_set_child_range (struct varobj *var, int from, int to);
268
b09e2c59 269extern char *varobj_get_display_hint (const struct varobj *var);
b6313243 270
8b93c638
JM
271extern int varobj_get_num_children (struct varobj *var);
272
0cc7d26f
TT
273/* Return the list of children of VAR. The returned vector should not
274 be modified in any way. FROM and TO are in/out parameters
275 indicating the range of children to return. If either *FROM or *TO
276 is less than zero on entry, then all children will be returned. On
277 return, *FROM and *TO will be updated to indicate the real range
278 that was returned. The resulting VEC will contain at least the
279 children from *FROM to just before *TO; it might contain more
280 children, depending on whether any more were available. */
281extern VEC (varobj_p)* varobj_list_children (struct varobj *var,
282 int *from, int *to);
8b93c638
JM
283
284extern char *varobj_get_type (struct varobj *var);
285
b09e2c59 286extern struct type *varobj_get_gdb_type (const struct varobj *var);
1ecb4ee0 287
c1cc6152 288extern char *varobj_get_path_expr (const struct varobj *var);
02142340 289
b09e2c59
SM
290extern const struct language_defn *
291 varobj_get_language (const struct varobj *var);
8b93c638 292
b09e2c59 293extern int varobj_get_attributes (const struct varobj *var);
8b93c638 294
de051565
MK
295extern char *varobj_get_formatted_value (struct varobj *var,
296 enum varobj_display_formats format);
297
8b93c638
JM
298extern char *varobj_get_value (struct varobj *var);
299
300extern int varobj_set_value (struct varobj *var, char *expression);
301
54333c3b
JK
302extern void all_root_varobjs (void (*func) (struct varobj *var, void *data),
303 void *data);
8b93c638 304
f7f9ae2c 305extern VEC(varobj_update_result) *varobj_update (struct varobj **varp,
fe978cb0 306 int is_explicit);
8b93c638 307
8756216b
DP
308extern void varobj_invalidate (void);
309
b09e2c59 310extern int varobj_editable_p (const struct varobj *var);
c203027e 311
b09e2c59 312extern int varobj_floating_p (const struct varobj *var);
5a413362 313
2021ad3a
PM
314extern void varobj_set_visualizer (struct varobj *var,
315 const char *visualizer);
0cc7d26f
TT
316
317extern void varobj_enable_pretty_printing (void);
318
b09e2c59 319extern int varobj_has_more (const struct varobj *var, int to);
0cc7d26f 320
b09e2c59 321extern int varobj_is_dynamic_p (const struct varobj *var);
b6313243 322
b09e2c59 323extern struct cleanup *varobj_ensure_python_env (const struct varobj *var);
e5250216 324
b09e2c59
SM
325extern int varobj_default_value_is_changeable_p (const struct varobj *var);
326extern int varobj_value_is_changeable_p (const struct varobj *var);
99ad9427 327
b09e2c59 328extern struct type *varobj_get_value_type (const struct varobj *var);
99ad9427 329
b09e2c59 330extern int varobj_is_anonymous_child (const struct varobj *child);
99ad9427 331
c1cc6152
SM
332extern const struct varobj *
333 varobj_get_path_expr_parent (const struct varobj *var);
99ad9427
YQ
334
335extern char *varobj_value_get_print_value (struct value *value,
336 enum varobj_display_formats format,
b09e2c59 337 const struct varobj *var);
99ad9427
YQ
338
339extern void varobj_formatted_print_options (struct value_print_options *opts,
340 enum varobj_display_formats format);
341
342extern void varobj_restrict_range (VEC (varobj_p) *children, int *from,
343 int *to);
9a9a7608 344
b09e2c59 345extern int varobj_default_is_path_expr_parent (const struct varobj *var);
9a9a7608 346
8b93c638 347#endif /* VAROBJ_H */