GDB (xrefs)

/tmp/gdb-8.1/gdb/varobj.h
Go to the documentation of this file.
1 /* GDB variable objects API.
2 Copyright (C) 1999-2018 Free Software Foundation, Inc.
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
6 the Free Software Foundation; either version 3 of the License, or
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
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17 #ifndef VAROBJ_H
18 #define VAROBJ_H 1
19
20 #include "symtab.h"
21 #include "gdbtypes.h"
22 #include "vec.h"
23
24 /* Enumeration for the format types */
25 enum 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 FORMAT_ZHEXADECIMAL /* Zero padded hexadecimal */
33 };
34
35 enum varobj_type
36 {
37 USE_SPECIFIED_FRAME, /* Use the frame passed to varobj_create. */
38 USE_CURRENT_FRAME, /* Use the current frame. */
39 USE_SELECTED_FRAME /* Always reevaluate in selected frame. */
40 };
41
42 /* Enumerator describing if a variable object is in scope. */
43 enum varobj_scope_status
44 {
45 VAROBJ_IN_SCOPE = 0, /* Varobj is scope, value available. */
46 VAROBJ_NOT_IN_SCOPE = 1, /* Varobj is not in scope, value not
47 available, but varobj can become in
48 scope later. */
49 VAROBJ_INVALID = 2, /* Varobj no longer has any value, and never
50 will. */
51 };
52
53 /* String representations of gdb's format codes (defined in varobj.c). */
54 extern const char *varobj_format_string[];
55
56 /* Struct that describes a variable object instance. */
57
58 struct varobj;
59
60 struct varobj_update_result
61 {
62 varobj_update_result (struct varobj *varobj_,
63 varobj_scope_status status_ = VAROBJ_IN_SCOPE)
64 : varobj (varobj_), status (status_)
65 {}
66
67 varobj_update_result (varobj_update_result &&other) = default;
68
69 DISABLE_COPY_AND_ASSIGN (varobj_update_result);
70
71 struct varobj *varobj;
72 bool type_changed = false;
73 bool children_changed = false;
74 bool changed = false;
75 enum varobj_scope_status status;
76 /* This variable is used internally by varobj_update to indicate if the
77 new value of varobj is already computed and installed, or has to
78 be yet installed. Don't use this outside varobj.c. */
79 bool value_installed = false;
80
81 /* This will be non-NULL when new children were added to the varobj.
82 It lists the new children (which must necessarily come at the end
83 of the child list) added during an update. The caller is
84 responsible for freeing this vector. */
85 std::vector<struct varobj *> newobj;
86 };
87
88 struct varobj_root;
89 struct varobj_dynamic;
90
91 /* Every variable in the system has a structure of this type defined
92 for it. This structure holds all information necessary to manipulate
93 a particular object variable. */
94 struct varobj
95 {
96 explicit varobj (varobj_root *root_);
97 ~varobj ();
98
99 /* Name of the variable for this object. If this variable is a
100 child, then this name will be the child's source name.
101 (bar, not foo.bar). */
102 /* NOTE: This is the "expression". */
103 std::string name;
104
105 /* Expression for this child. Can be used to create a root variable
106 corresponding to this child. */
107 std::string path_expr;
108
109 /* The name for this variable's object. This is here for
110 convenience when constructing this object's children. */
111 std::string obj_name;
112
113 /* Index of this variable in its parent or -1. */
114 int index = -1;
115
116 /* The type of this variable. This can be NULL
117 for artificial variable objects -- currently, the "accessibility"
118 variable objects in C++. */
119 struct type *type = NULL;
120
121 /* The value of this expression or subexpression. A NULL value
122 indicates there was an error getting this value.
123 Invariant: if varobj_value_is_changeable_p (this) is non-zero,
124 the value is either NULL, or not lazy. */
125 struct value *value = NULL;
126
127 /* The number of (immediate) children this variable has. */
128 int num_children = -1;
129
130 /* If this object is a child, this points to its immediate parent. */
131 struct varobj *parent = NULL;
132
133 /* Children of this object. */
134 std::vector<varobj *> children;
135
136 /* Description of the root variable. Points to root variable for
137 children. */
138 struct varobj_root *root;
139
140 /* The format of the output for this object. */
141 enum varobj_display_formats format = FORMAT_NATURAL;
142
143 /* Was this variable updated via a varobj_set_value operation. */
144 bool updated = false;
145
146 /* Last print value. */
147 std::string print_value;
148
149 /* Is this variable frozen. Frozen variables are never implicitly
150 updated by -var-update *
151 or -var-update <direct-or-indirect-parent>. */
152 bool frozen = false;
153
154 /* Is the value of this variable intentionally not fetched? It is
155 not fetched if either the variable is frozen, or any parents is
156 frozen. */
157 bool not_fetched = false;
158
159 /* Sub-range of children which the MI consumer has requested. If
160 FROM < 0 or TO < 0, means that all children have been
161 requested. */
162 int from = -1;
163 int to = -1;
164
165 /* Dynamic part of varobj. */
166 struct varobj_dynamic *dynamic;
167 };
168
169 /* Is the variable X one of our "fake" children? */
170 #define CPLUS_FAKE_CHILD(x) \
171 ((x) != NULL && (x)->type == NULL && (x)->value == NULL)
172
173 /* The language specific vector */
174
175 struct lang_varobj_ops
176 {
177 /* The number of children of PARENT. */
178 int (*number_of_children) (const struct varobj *parent);
179
180 /* The name (expression) of a root varobj. */
181 std::string (*name_of_variable) (const struct varobj *parent);
182
183 /* The name of the INDEX'th child of PARENT. */
184 std::string (*name_of_child) (const struct varobj *parent, int index);
185
186 /* Returns the rooted expression of CHILD, which is a variable
187 obtain that has some parent. */
188 std::string (*path_expr_of_child) (const struct varobj *child);
189
190 /* The ``struct value *'' of the INDEX'th child of PARENT. */
191 struct value *(*value_of_child) (const struct varobj *parent, int index);
192
193 /* The type of the INDEX'th child of PARENT. */
194 struct type *(*type_of_child) (const struct varobj *parent, int index);
195
196 /* The current value of VAR. */
197 std::string (*value_of_variable) (const struct varobj *var,
198 enum varobj_display_formats format);
199
200 /* Return true if changes in value of VAR must be detected and
201 reported by -var-update. Return false if -var-update should never
202 report changes of such values. This makes sense for structures
203 (since the changes in children values will be reported separately),
204 or for artificial objects (like 'public' pseudo-field in C++).
205
206 Return value of false means that gdb need not call value_fetch_lazy
207 for the value of this variable object. */
208 bool (*value_is_changeable_p) (const struct varobj *var);
209
210 /* Return true if the type of VAR has mutated.
211
212 VAR's value is still the varobj's previous value, while NEW_VALUE
213 is VAR's new value and NEW_TYPE is the var's new type. NEW_VALUE
214 may be NULL indicating that there is no value available (the varobj
215 may be out of scope, of may be the child of a null pointer, for
216 instance). NEW_TYPE, on the other hand, must never be NULL.
217
218 This function should also be able to assume that var's number of
219 children is set (not < 0).
220
221 Languages where types do not mutate can set this to NULL. */
222 bool (*value_has_mutated) (const struct varobj *var, struct value *new_value,
223 struct type *new_type);
224
225 /* Return true if VAR is a suitable path expression parent.
226
227 For C like languages with anonymous structures and unions an anonymous
228 structure or union is not a suitable parent. */
229 bool (*is_path_expr_parent) (const struct varobj *var);
230 };
231
232 extern const struct lang_varobj_ops c_varobj_ops;
233 extern const struct lang_varobj_ops cplus_varobj_ops;
234 extern const struct lang_varobj_ops ada_varobj_ops;
235
236 #define default_varobj_ops c_varobj_ops
237 /* API functions */
238
239 extern struct varobj *varobj_create (const char *objname,
240 const char *expression, CORE_ADDR frame,
241 enum varobj_type type);
242
243 extern std::string varobj_gen_name (void);
244
245 extern struct varobj *varobj_get_handle (const char *name);
246
247 extern const char *varobj_get_objname (const struct varobj *var);
248
249 extern std::string varobj_get_expression (const struct varobj *var);
250
251 /* Delete a varobj and all its children if only_children is false, otherwise
252 delete only the children. Return the number of deleted variables. */
253
254 extern int varobj_delete (struct varobj *var, bool only_children);
255
256 extern enum varobj_display_formats varobj_set_display_format (
257 struct varobj *var,
258 enum varobj_display_formats format);
259
260 extern enum varobj_display_formats varobj_get_display_format (
261 const struct varobj *var);
262
263 extern int varobj_get_thread_id (const struct varobj *var);
264
265 extern void varobj_set_frozen (struct varobj *var, bool frozen);
266
267 extern bool varobj_get_frozen (const struct varobj *var);
268
269 extern void varobj_get_child_range (const struct varobj *var, int *from,
270 int *to);
271
272 extern void varobj_set_child_range (struct varobj *var, int from, int to);
273
274 extern gdb::unique_xmalloc_ptr<char>
275 varobj_get_display_hint (const struct varobj *var);
276
277 extern int varobj_get_num_children (struct varobj *var);
278
279 /* Return the list of children of VAR. The returned vector should not
280 be modified in any way. FROM and TO are in/out parameters
281 indicating the range of children to return. If either *FROM or *TO
282 is less than zero on entry, then all children will be returned. On
283 return, *FROM and *TO will be updated to indicate the real range
284 that was returned. The resulting VEC will contain at least the
285 children from *FROM to just before *TO; it might contain more
286 children, depending on whether any more were available. */
287 extern const std::vector<varobj *> &
288 varobj_list_children (struct varobj *var, int *from, int *to);
289
290 extern std::string varobj_get_type (struct varobj *var);
291
292 extern struct type *varobj_get_gdb_type (const struct varobj *var);
293
294 extern const char *varobj_get_path_expr (const struct varobj *var);
295
296 extern const struct language_defn *
297 varobj_get_language (const struct varobj *var);
298
299 extern int varobj_get_attributes (const struct varobj *var);
300
301 extern std::string
302 varobj_get_formatted_value (struct varobj *var,
303 enum varobj_display_formats format);
304
305 extern std::string varobj_get_value (struct varobj *var);
306
307 extern bool varobj_set_value (struct varobj *var, const char *expression);
308
309 extern void all_root_varobjs (void (*func) (struct varobj *var, void *data),
310 void *data);
311
312 extern std::vector<varobj_update_result>
313 varobj_update (struct varobj **varp, bool is_explicit);
314
315 extern void varobj_invalidate (void);
316
317 extern bool varobj_editable_p (const struct varobj *var);
318
319 extern bool varobj_floating_p (const struct varobj *var);
320
321 extern void varobj_set_visualizer (struct varobj *var,
322 const char *visualizer);
323
324 extern void varobj_enable_pretty_printing (void);
325
326 extern bool varobj_has_more (const struct varobj *var, int to);
327
328 extern bool varobj_is_dynamic_p (const struct varobj *var);
329
330 extern bool varobj_default_value_is_changeable_p (const struct varobj *var);
331 extern bool varobj_value_is_changeable_p (const struct varobj *var);
332
333 extern struct type *varobj_get_value_type (const struct varobj *var);
334
335 extern bool varobj_is_anonymous_child (const struct varobj *child);
336
337 extern const struct varobj *
338 varobj_get_path_expr_parent (const struct varobj *var);
339
340 extern std::string
341 varobj_value_get_print_value (struct value *value,
342 enum varobj_display_formats format,
343 const struct varobj *var);
344
345 extern void varobj_formatted_print_options (struct value_print_options *opts,
346 enum varobj_display_formats format);
347
348 extern void varobj_restrict_range (const std::vector<varobj *> &children,
349 int *from, int *to);
350
351 extern bool varobj_default_is_path_expr_parent (const struct varobj *var);
352
353 #endif /* VAROBJ_H */
string
const char * string
Definition: signals.c:50
varobj_set_visualizer
void varobj_set_visualizer(struct varobj *var, const char *visualizer)
Definition: varobj.c:1445
varobj_get_type
std::string varobj_get_type(struct varobj *var)
Definition: varobj.c:900
varobj_update_result::varobj
struct varobj * varobj
Definition: varobj.h:71
varobj::name
std::string name
Definition: varobj.h:103
varobj::index
int index
Definition: varobj.h:114
varobj
Definition: varobj.h:94
varobj::frozen
bool frozen
Definition: varobj.h:152
varobj_get_formatted_value
std::string varobj_get_formatted_value(struct varobj *var, enum varobj_display_formats format)
Definition: varobj.c:999
varobj_default_value_is_changeable_p
bool varobj_default_value_is_changeable_p(const struct varobj *var)
Definition: varobj.c:2440
CORE_ADDR
bfd_vma CORE_ADDR
Definition: common-types.h:41
lang_varobj_ops::name_of_variable
std::string(* name_of_variable)(const struct varobj *parent)
Definition: varobj.h:181
FORMAT_ZHEXADECIMAL
Definition: varobj.h:32
cplus_varobj_ops
const struct lang_varobj_ops cplus_varobj_ops
Definition: c-varobj.c:953
lang_varobj_ops::value_has_mutated
bool(* value_has_mutated)(const struct varobj *var, struct value *new_value, struct type *new_type)
Definition: varobj.h:222
func
void(* func)(char *)
Definition: remote-fileio.c:1104
varobj_update_result::status
enum varobj_scope_status status
Definition: varobj.h:75
varobj_get_value
std::string varobj_get_value(struct varobj *var)
Definition: varobj.c:1006
varobj_value_get_print_value
std::string varobj_value_get_print_value(struct value *value, enum varobj_display_formats format, const struct varobj *var)
Definition: varobj.c:2279
varobj_set_frozen
void varobj_set_frozen(struct varobj *var, bool frozen)
Definition: varobj.c:582
varobj_gen_name
std::string varobj_gen_name(void)
Definition: varobj.c:420
varobj_get_path_expr
const char * varobj_get_path_expr(const struct varobj *var)
Definition: varobj.c:956
varobj_restrict_range
void varobj_restrict_range(const std::vector< varobj *> &children, int *from, int *to)
Definition: varobj.c:606
varobj_list_children
const std::vector< varobj * > & varobj_list_children(struct varobj *var, int *from, int *to)
Definition: varobj.c:840
varobj_is_anonymous_child
bool varobj_is_anonymous_child(const struct varobj *child)
Definition: c-varobj.c:38
varobj_update
std::vector< varobj_update_result > varobj_update(struct varobj **varp, bool is_explicit)
Definition: varobj.c:1527
lang_varobj_ops
Definition: varobj.h:175
USE_SPECIFIED_FRAME
Definition: varobj.h:37
all_root_varobjs
void all_root_varobjs(void(*func)(struct varobj *var, void *data), void *data)
Definition: varobj.c:2469
varobj_update_result::children_changed
bool children_changed
Definition: varobj.h:73
lang_varobj_ops::is_path_expr_parent
bool(* is_path_expr_parent)(const struct varobj *var)
Definition: varobj.h:229
varobj::path_expr
std::string path_expr
Definition: varobj.h:107
new_type
static struct type * new_type(char *)
Definition: mdebugread.c:4852
language_defn
Definition: language.h:132
varobj_set_value
bool varobj_set_value(struct varobj *var, const char *expression)
Definition: varobj.c:1016
varobj_has_more
bool varobj_has_more(const struct varobj *var, int to)
Definition: varobj.c:559
varobj::~varobj
~varobj()
Definition: varobj.c:1975
varobj_scope_status
varobj_scope_status
Definition: varobj.h:43
symtab.h
lang_varobj_ops::number_of_children
int(* number_of_children)(const struct varobj *parent)
Definition: varobj.h:178
name
const char *const name
Definition: aarch64-tdep.c:76
value_print_options
Definition: valprint.h:25
gdb::unique_xmalloc_ptr
std::unique_ptr< T, xfree_deleter< T > > unique_xmalloc_ptr
Definition: gdb_unique_ptr.h:48
varobj::obj_name
std::string obj_name
Definition: varobj.h:111
varobj_dynamic
Definition: varobj.c:110
varobj_get_language
const struct language_defn * varobj_get_language(const struct varobj *var)
Definition: varobj.c:973
FORMAT_NATURAL
Definition: varobj.h:27
varobj_enable_pretty_printing
void varobj_enable_pretty_printing(void)
Definition: varobj.c:60
varobj::updated
bool updated
Definition: varobj.h:144
expression
Definition: expression.h:78
varobj_update_result::DISABLE_COPY_AND_ASSIGN
DISABLE_COPY_AND_ASSIGN(varobj_update_result)
varobj::print_value
std::string print_value
Definition: varobj.h:147
FORMAT_DECIMAL
Definition: varobj.h:29
type
Definition: gdbtypes.h:749
varobj::from
int from
Definition: varobj.h:162
varobj_get_frozen
bool varobj_get_frozen(const struct varobj *var)
Definition: varobj.c:595
varobj_update_result::newobj
std::vector< struct varobj * > newobj
Definition: varobj.h:85
varobj_delete
int varobj_delete(struct varobj *var, bool only_children)
Definition: varobj.c:475
varobj_value_is_changeable_p
bool varobj_value_is_changeable_p(const struct varobj *var)
Definition: varobj.c:2422
varobj_update_result::value_installed
bool value_installed
Definition: varobj.h:79
varobj::dynamic
struct varobj_dynamic * dynamic
Definition: varobj.h:166
varobj_format_string
const char * varobj_format_string[]
Definition: varobj.c:53
lang_varobj_ops::name_of_child
std::string(* name_of_child)(const struct varobj *parent, int index)
Definition: varobj.h:184
ada_varobj_ops
const struct lang_varobj_ops ada_varobj_ops
Definition: ada-varobj.c:995
varobj_set_child_range
void varobj_set_child_range(struct varobj *var, int from, int to)
Definition: varobj.c:1438
varobj::root
struct varobj_root * root
Definition: varobj.h:138
varobj_get_handle
struct varobj * varobj_get_handle(const char *name)
Definition: varobj.c:433
lang_varobj_ops::value_of_variable
std::string(* value_of_variable)(const struct varobj *var, enum varobj_display_formats format)
Definition: varobj.h:197
USE_CURRENT_FRAME
Definition: varobj.h:38
USE_SELECTED_FRAME
Definition: varobj.h:39
value
Definition: value.c:169
varobj_root
Definition: varobj.c:69
varobj_get_value_type
struct type * varobj_get_value_type(const struct varobj *var)
Definition: varobj.c:2011
varobj::num_children
int num_children
Definition: varobj.h:128
varobj_invalidate
void varobj_invalidate(void)
Definition: varobj.c:2520
varobj_get_expression
std::string varobj_get_expression(const struct varobj *var)
Definition: varobj.c:467
varobj::varobj
varobj(varobj_root *root_)
Definition: varobj.c:1968
VAROBJ_INVALID
Definition: varobj.h:49
VAROBJ_NOT_IN_SCOPE
Definition: varobj.h:46
varobj_default_is_path_expr_parent
bool varobj_default_is_path_expr_parent(const struct varobj *var)
Definition: varobj.c:934
varobj_get_display_format
enum varobj_display_formats varobj_get_display_format(const struct varobj *var)
Definition: varobj.c:533
lang_varobj_ops::value_is_changeable_p
bool(* value_is_changeable_p)(const struct varobj *var)
Definition: varobj.h:208
varobj::children
std::vector< varobj * > children
Definition: varobj.h:134
FORMAT_OCTAL
Definition: varobj.h:31
varobj_get_child_range
void varobj_get_child_range(const struct varobj *var, int *from, int *to)
Definition: varobj.c:1428
varobj_formatted_print_options
void varobj_formatted_print_options(struct value_print_options *opts, enum varobj_display_formats format)
Definition: varobj.c:2270
varobj_get_attributes
int varobj_get_attributes(const struct varobj *var)
Definition: varobj.c:979
c_varobj_ops
const struct lang_varobj_ops c_varobj_ops
Definition: c-varobj.c:539
gdbtypes.h
varobj_editable_p
bool varobj_editable_p(const struct varobj *var)
Definition: varobj.c:2394
varobj::not_fetched
bool not_fetched
Definition: varobj.h:157
varobj_update_result
Definition: varobj.h:60
varobj_get_gdb_type
struct type * varobj_get_gdb_type(const struct varobj *var)
Definition: varobj.c:914
FORMAT_HEXADECIMAL
Definition: varobj.h:30
varobj::parent
struct varobj * parent
Definition: varobj.h:131
varobj_get_path_expr_parent
const struct varobj * varobj_get_path_expr_parent(const struct varobj *var)
Definition: varobj.c:942
varobj_get_display_hint
gdb::unique_xmalloc_ptr< char > varobj_get_display_hint(const struct varobj *var)
Definition: varobj.c:539
varobj_type
varobj_type
Definition: varobj.h:35
varobj_is_dynamic_p
bool varobj_is_dynamic_p(const struct varobj *var)
Definition: varobj.c:993
varobj_update_result::varobj_update_result
varobj_update_result(struct varobj *varobj_, varobj_scope_status status_=VAROBJ_IN_SCOPE)
Definition: varobj.h:62
varobj_get_objname
const char * varobj_get_objname(const struct varobj *var)
Definition: varobj.c:458
varobj_floating_p
bool varobj_floating_p(const struct varobj *var)
Definition: varobj.c:2431
VAROBJ_IN_SCOPE
Definition: varobj.h:45
varobj::format
enum varobj_display_formats format
Definition: varobj.h:141
FORMAT_BINARY
Definition: varobj.h:28
varobj_set_display_format
enum varobj_display_formats varobj_set_display_format(struct varobj *var, enum varobj_display_formats format)
Definition: varobj.c:504
varobj_update_result::changed
bool changed
Definition: varobj.h:74
varobj_get_thread_id
int varobj_get_thread_id(const struct varobj *var)
Definition: varobj.c:573
lang_varobj_ops::path_expr_of_child
std::string(* path_expr_of_child)(const struct varobj *child)
Definition: varobj.h:188
varobj_update_result::type_changed
bool type_changed
Definition: varobj.h:72
varobj_get_num_children
int varobj_get_num_children(struct varobj *var)
Definition: varobj.c:816
varobj::to
int to
Definition: varobj.h:163
vec.h
varobj_create
struct varobj * varobj_create(const char *objname, const char *expression, CORE_ADDR frame, enum varobj_type type)
Definition: varobj.c:264
varobj_display_formats
varobj_display_formats
Definition: varobj.h:25