1 /* GDB variable objects API.
2 Copyright (C) 1999-2014 Free Software Foundation, Inc.
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
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
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.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 /* Enumeration for the format types */
25 enum varobj_display_formats
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 */
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. */
41 /* Enumerator describing if a variable object is in scope. */
42 enum varobj_scope_status
44 VAROBJ_IN_SCOPE = 0, /* Varobj is scope, value available. */
45 VAROBJ_NOT_IN_SCOPE = 1, /* Varobj is not in scope, value not
46 available, but varobj can become in
48 VAROBJ_INVALID = 2, /* Varobj no longer has any value, and never
52 /* String representations of gdb's format codes (defined in varobj.c). */
53 extern char *varobj_format_string[];
55 /* Struct thar describes a variable object instance. */
59 typedef struct varobj *varobj_p;
62 typedef struct varobj_update_result_t
64 struct varobj *varobj;
68 enum varobj_scope_status status;
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
71 be yet installed. Don't use this outside varobj.c. */
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. */
79 } varobj_update_result;
81 DEF_VEC_O (varobj_update_result);
84 struct varobj_dynamic;
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. */
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". */
97 /* Alloc'd expression for this child. Can be used to create a
98 root variable corresponding to this child. */
101 /* The alloc'd name for this variable's object. This is here for
102 convenience when constructing this object's children. */
105 /* Index of this variable in its parent or -1. */
108 /* The type of this variable. This can be NULL
109 for artifial variable objects -- currently, the "accessibility"
110 variable objects in C++. */
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. */
119 /* The number of (immediate) children this variable has. */
122 /* If this object is a child, this points to its immediate parent. */
123 struct varobj *parent;
125 /* Children of this object. */
126 VEC (varobj_p) *children;
128 /* Description of the root variable. Points to root variable for
130 struct varobj_root *root;
132 /* The format of the output for this object. */
133 enum varobj_display_formats format;
135 /* Was this variable updated via a varobj_set_value operation. */
138 /* Last print value. */
141 /* Is this variable frozen. Frozen variables are never implicitly
142 updated by -var-update *
143 or -var-update <direct-or-indirect-parent>. */
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
151 /* Sub-range of children which the MI consumer has requested. If
152 FROM < 0 or TO < 0, means that all children have been
157 /* Dynamic part of varobj. */
158 struct varobj_dynamic *dynamic;
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)
165 /* The language specific vector */
167 struct lang_varobj_ops
169 /* The number of children of PARENT. */
170 int (*number_of_children) (struct varobj *parent);
172 /* The name (expression) of a root varobj. */
173 char *(*name_of_variable) (struct varobj *parent);
175 /* The name of the INDEX'th child of PARENT. */
176 char *(*name_of_child) (struct varobj *parent, int index);
178 /* Returns the rooted expression of CHILD, which is a variable
179 obtain that has some parent. */
180 char *(*path_expr_of_child) (struct varobj *child);
182 /* The ``struct value *'' of the INDEX'th child of PARENT. */
183 struct value *(*value_of_child) (struct varobj *parent, int index);
185 /* The type of the INDEX'th child of PARENT. */
186 struct type *(*type_of_child) (struct varobj *parent, int index);
188 /* The current value of VAR. */
189 char *(*value_of_variable) (struct varobj *var,
190 enum varobj_display_formats format);
192 /* Return non-zero if changes in value of VAR must be detected and
193 reported by -var-update. Return zero if -var-update should never
194 report changes of such values. This makes sense for structures
195 (since the changes in children values will be reported separately),
196 or for artifical objects (like 'public' pseudo-field in C++).
198 Return value of 0 means that gdb need not call value_fetch_lazy
199 for the value of this variable object. */
200 int (*value_is_changeable_p) (struct varobj *var);
202 /* Return nonzero if the type of VAR has mutated.
204 VAR's value is still the varobj's previous value, while NEW_VALUE
205 is VAR's new value and NEW_TYPE is the var's new type. NEW_VALUE
206 may be NULL indicating that there is no value available (the varobj
207 may be out of scope, of may be the child of a null pointer, for
208 instance). NEW_TYPE, on the other hand, must never be NULL.
210 This function should also be able to assume that var's number of
211 children is set (not < 0).
213 Languages where types do not mutate can set this to NULL. */
214 int (*value_has_mutated) (struct varobj *var, struct value *new_value,
215 struct type *new_type);
217 /* Return nonzero if VAR is a suitable path expression parent.
219 For C like languages with anonymous structures and unions an anonymous
220 structure or union is not a suitable parent. */
221 int (*is_path_expr_parent) (struct varobj *var);
224 extern const struct lang_varobj_ops c_varobj_ops;
225 extern const struct lang_varobj_ops cplus_varobj_ops;
226 extern const struct lang_varobj_ops java_varobj_ops;
227 extern const struct lang_varobj_ops ada_varobj_ops;
229 #define default_varobj_ops c_varobj_ops
232 extern struct varobj *varobj_create (char *objname,
233 char *expression, CORE_ADDR frame,
234 enum varobj_type type);
236 extern char *varobj_gen_name (void);
238 extern struct varobj *varobj_get_handle (char *name);
240 extern char *varobj_get_objname (struct varobj *var);
242 extern char *varobj_get_expression (struct varobj *var);
244 extern int varobj_delete (struct varobj *var, char ***dellist,
247 extern enum varobj_display_formats varobj_set_display_format (
249 enum varobj_display_formats format);
251 extern enum varobj_display_formats varobj_get_display_format (
254 extern int varobj_get_thread_id (struct varobj *var);
256 extern void varobj_set_frozen (struct varobj *var, int frozen);
258 extern int varobj_get_frozen (struct varobj *var);
260 extern void varobj_get_child_range (struct varobj *var, int *from, int *to);
262 extern void varobj_set_child_range (struct varobj *var, int from, int to);
264 extern char *varobj_get_display_hint (struct varobj *var);
266 extern int varobj_get_num_children (struct varobj *var);
268 /* Return the list of children of VAR. The returned vector should not
269 be modified in any way. FROM and TO are in/out parameters
270 indicating the range of children to return. If either *FROM or *TO
271 is less than zero on entry, then all children will be returned. On
272 return, *FROM and *TO will be updated to indicate the real range
273 that was returned. The resulting VEC will contain at least the
274 children from *FROM to just before *TO; it might contain more
275 children, depending on whether any more were available. */
276 extern VEC (varobj_p)* varobj_list_children (struct varobj *var,
279 extern char *varobj_get_type (struct varobj *var);
281 extern struct type *varobj_get_gdb_type (struct varobj *var);
283 extern char *varobj_get_path_expr (struct varobj *var);
285 extern const struct language_defn *varobj_get_language (struct varobj *var);
287 extern int varobj_get_attributes (struct varobj *var);
289 extern char *varobj_get_formatted_value (struct varobj *var,
290 enum varobj_display_formats format);
292 extern char *varobj_get_value (struct varobj *var);
294 extern int varobj_set_value (struct varobj *var, char *expression);
296 extern void all_root_varobjs (void (*func) (struct varobj *var, void *data),
299 extern VEC(varobj_update_result) *varobj_update (struct varobj **varp,
302 extern void varobj_invalidate (void);
304 extern int varobj_editable_p (struct varobj *var);
306 extern int varobj_floating_p (struct varobj *var);
308 extern void varobj_set_visualizer (struct varobj *var,
309 const char *visualizer);
311 extern void varobj_enable_pretty_printing (void);
313 extern int varobj_has_more (struct varobj *var, int to);
315 extern int varobj_is_dynamic_p (struct varobj *var);
317 extern struct cleanup *varobj_ensure_python_env (struct varobj *var);
319 extern int varobj_default_value_is_changeable_p (struct varobj *var);
320 extern int varobj_value_is_changeable_p (struct varobj *var);
322 extern struct type *varobj_get_value_type (struct varobj *var);
324 extern int varobj_is_anonymous_child (struct varobj *child);
326 extern struct varobj *varobj_get_path_expr_parent (struct varobj *var);
328 extern char *varobj_value_get_print_value (struct value *value,
329 enum varobj_display_formats format,
332 extern void varobj_formatted_print_options (struct value_print_options *opts,
333 enum varobj_display_formats format);
335 extern void varobj_restrict_range (VEC (varobj_p) *children, int *from,
338 extern int varobj_default_is_path_expr_parent (struct varobj *var);
340 #endif /* VAROBJ_H */