s390-vregs.exp: Avoid compile errors with older GCCs and on 31-bit targets
[binutils-gdb.git] / gdb / c-varobj.c
blob59d8b0f781a3c97f942d30422d5cf3cbf1a0a4f9
1 /* varobj support for C and C++.
3 Copyright (C) 1999-2015 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 #include "defs.h"
19 #include "value.h"
20 #include "varobj.h"
21 #include "gdbthread.h"
22 #include "valprint.h"
24 static void cplus_class_num_children (struct type *type, int children[3]);
26 /* The names of varobjs representing anonymous structs or unions. */
27 #define ANONYMOUS_STRUCT_NAME _("<anonymous struct>")
28 #define ANONYMOUS_UNION_NAME _("<anonymous union>")
30 /* Does CHILD represent a child with no name? This happens when
31 the child is an anonmous struct or union and it has no field name
32 in its parent variable.
34 This has already been determined by *_describe_child. The easiest
35 thing to do is to compare the child's name with ANONYMOUS_*_NAME. */
37 int
38 varobj_is_anonymous_child (const struct varobj *child)
40 return (strcmp (child->name, ANONYMOUS_STRUCT_NAME) == 0
41 || strcmp (child->name, ANONYMOUS_UNION_NAME) == 0);
44 /* Given the value and the type of a variable object,
45 adjust the value and type to those necessary
46 for getting children of the variable object.
47 This includes dereferencing top-level references
48 to all types and dereferencing pointers to
49 structures.
51 If LOOKUP_ACTUAL_TYPE is set the enclosing type of the
52 value will be fetched and if it differs from static type
53 the value will be casted to it.
55 Both TYPE and *TYPE should be non-null. VALUE
56 can be null if we want to only translate type.
57 *VALUE can be null as well -- if the parent
58 value is not known.
60 If WAS_PTR is not NULL, set *WAS_PTR to 0 or 1
61 depending on whether pointer was dereferenced
62 in this function. */
64 static void
65 adjust_value_for_child_access (struct value **value,
66 struct type **type,
67 int *was_ptr,
68 int lookup_actual_type)
70 gdb_assert (type && *type);
72 if (was_ptr)
73 *was_ptr = 0;
75 *type = check_typedef (*type);
77 /* The type of value stored in varobj, that is passed
78 to us, is already supposed to be
79 reference-stripped. */
81 gdb_assert (TYPE_CODE (*type) != TYPE_CODE_REF);
83 /* Pointers to structures are treated just like
84 structures when accessing children. Don't
85 dererences pointers to other types. */
86 if (TYPE_CODE (*type) == TYPE_CODE_PTR)
88 struct type *target_type = get_target_type (*type);
89 if (TYPE_CODE (target_type) == TYPE_CODE_STRUCT
90 || TYPE_CODE (target_type) == TYPE_CODE_UNION)
92 if (value && *value)
95 TRY
97 *value = value_ind (*value);
100 CATCH (except, RETURN_MASK_ERROR)
102 *value = NULL;
104 END_CATCH
106 *type = target_type;
107 if (was_ptr)
108 *was_ptr = 1;
112 /* The 'get_target_type' function calls check_typedef on
113 result, so we can immediately check type code. No
114 need to call check_typedef here. */
116 /* Access a real type of the value (if necessary and possible). */
117 if (value && *value && lookup_actual_type)
119 struct type *enclosing_type;
120 int real_type_found = 0;
122 enclosing_type = value_actual_type (*value, 1, &real_type_found);
123 if (real_type_found)
125 *type = enclosing_type;
126 *value = value_cast (enclosing_type, *value);
131 /* Is VAR a path expression parent, i.e., can it be used to construct
132 a valid path expression? */
134 static int
135 c_is_path_expr_parent (const struct varobj *var)
137 struct type *type;
139 /* "Fake" children are not path_expr parents. */
140 if (CPLUS_FAKE_CHILD (var))
141 return 0;
143 type = varobj_get_gdb_type (var);
145 /* Anonymous unions and structs are also not path_expr parents. */
146 if ((TYPE_CODE (type) == TYPE_CODE_STRUCT
147 || TYPE_CODE (type) == TYPE_CODE_UNION)
148 && TYPE_NAME (type) == NULL
149 && TYPE_TAG_NAME (type) == NULL)
151 const struct varobj *parent = var->parent;
153 while (parent != NULL && CPLUS_FAKE_CHILD (parent))
154 parent = parent->parent;
156 if (parent != NULL)
158 struct type *parent_type;
159 int was_ptr;
161 parent_type = varobj_get_value_type (parent);
162 adjust_value_for_child_access (NULL, &parent_type, &was_ptr, 0);
164 if (TYPE_CODE (parent_type) == TYPE_CODE_STRUCT
165 || TYPE_CODE (parent_type) == TYPE_CODE_UNION)
167 const char *field_name;
169 gdb_assert (var->index < TYPE_NFIELDS (parent_type));
170 field_name = TYPE_FIELD_NAME (parent_type, var->index);
171 return !(field_name == NULL || *field_name == '\0');
175 return 0;
178 return 1;
181 /* C */
183 static int
184 c_number_of_children (const struct varobj *var)
186 struct type *type = varobj_get_value_type (var);
187 int children = 0;
188 struct type *target;
190 adjust_value_for_child_access (NULL, &type, NULL, 0);
191 target = get_target_type (type);
193 switch (TYPE_CODE (type))
195 case TYPE_CODE_ARRAY:
196 if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (target) > 0
197 && !TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
198 children = TYPE_LENGTH (type) / TYPE_LENGTH (target);
199 else
200 /* If we don't know how many elements there are, don't display
201 any. */
202 children = 0;
203 break;
205 case TYPE_CODE_STRUCT:
206 case TYPE_CODE_UNION:
207 children = TYPE_NFIELDS (type);
208 break;
210 case TYPE_CODE_PTR:
211 /* The type here is a pointer to non-struct. Typically, pointers
212 have one child, except for function ptrs, which have no children,
213 and except for void*, as we don't know what to show.
215 We can show char* so we allow it to be dereferenced. If you decide
216 to test for it, please mind that a little magic is necessary to
217 properly identify it: char* has TYPE_CODE == TYPE_CODE_INT and
218 TYPE_NAME == "char". */
219 if (TYPE_CODE (target) == TYPE_CODE_FUNC
220 || TYPE_CODE (target) == TYPE_CODE_VOID)
221 children = 0;
222 else
223 children = 1;
224 break;
226 default:
227 /* Other types have no children. */
228 break;
231 return children;
234 static char *
235 c_name_of_variable (const struct varobj *parent)
237 return xstrdup (parent->name);
240 /* Return the value of element TYPE_INDEX of a structure
241 value VALUE. VALUE's type should be a structure,
242 or union, or a typedef to struct/union.
244 Returns NULL if getting the value fails. Never throws. */
246 static struct value *
247 value_struct_element_index (struct value *value, int type_index)
249 struct value *result = NULL;
250 struct type *type = value_type (value);
252 type = check_typedef (type);
254 gdb_assert (TYPE_CODE (type) == TYPE_CODE_STRUCT
255 || TYPE_CODE (type) == TYPE_CODE_UNION);
259 if (field_is_static (&TYPE_FIELD (type, type_index)))
260 result = value_static_field (type, type_index);
261 else
262 result = value_primitive_field (value, 0, type_index, type);
264 CATCH (e, RETURN_MASK_ERROR)
266 return NULL;
268 END_CATCH
270 return result;
273 /* Obtain the information about child INDEX of the variable
274 object PARENT.
275 If CNAME is not null, sets *CNAME to the name of the child relative
276 to the parent.
277 If CVALUE is not null, sets *CVALUE to the value of the child.
278 If CTYPE is not null, sets *CTYPE to the type of the child.
280 If any of CNAME, CVALUE, or CTYPE is not null, but the corresponding
281 information cannot be determined, set *CNAME, *CVALUE, or *CTYPE
282 to NULL. */
284 static void
285 c_describe_child (const struct varobj *parent, int index,
286 char **cname, struct value **cvalue, struct type **ctype,
287 char **cfull_expression)
289 struct value *value = parent->value;
290 struct type *type = varobj_get_value_type (parent);
291 char *parent_expression = NULL;
292 int was_ptr;
294 if (cname)
295 *cname = NULL;
296 if (cvalue)
297 *cvalue = NULL;
298 if (ctype)
299 *ctype = NULL;
300 if (cfull_expression)
302 *cfull_expression = NULL;
303 parent_expression
304 = varobj_get_path_expr (varobj_get_path_expr_parent (parent));
306 adjust_value_for_child_access (&value, &type, &was_ptr, 0);
308 switch (TYPE_CODE (type))
310 case TYPE_CODE_ARRAY:
311 if (cname)
312 *cname
313 = xstrdup (int_string (index
314 + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)),
315 10, 1, 0, 0));
317 if (cvalue && value)
319 int real_index = index + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type));
323 *cvalue = value_subscript (value, real_index);
325 CATCH (except, RETURN_MASK_ERROR)
328 END_CATCH
331 if (ctype)
332 *ctype = get_target_type (type);
334 if (cfull_expression)
335 *cfull_expression =
336 xstrprintf ("(%s)[%s]", parent_expression,
337 int_string (index
338 + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)),
339 10, 1, 0, 0));
342 break;
344 case TYPE_CODE_STRUCT:
345 case TYPE_CODE_UNION:
347 const char *field_name;
349 /* If the type is anonymous and the field has no name,
350 set an appropriate name. */
351 field_name = TYPE_FIELD_NAME (type, index);
352 if (field_name == NULL || *field_name == '\0')
354 if (cname)
356 if (TYPE_CODE (TYPE_FIELD_TYPE (type, index))
357 == TYPE_CODE_STRUCT)
358 *cname = xstrdup (ANONYMOUS_STRUCT_NAME);
359 else
360 *cname = xstrdup (ANONYMOUS_UNION_NAME);
363 if (cfull_expression)
364 *cfull_expression = xstrdup ("");
366 else
368 if (cname)
369 *cname = xstrdup (field_name);
371 if (cfull_expression)
373 char *join = was_ptr ? "->" : ".";
375 *cfull_expression = xstrprintf ("(%s)%s%s", parent_expression,
376 join, field_name);
380 if (cvalue && value)
382 /* For C, varobj index is the same as type index. */
383 *cvalue = value_struct_element_index (value, index);
386 if (ctype)
387 *ctype = TYPE_FIELD_TYPE (type, index);
389 break;
391 case TYPE_CODE_PTR:
392 if (cname)
393 *cname = xstrprintf ("*%s", parent->name);
395 if (cvalue && value)
399 *cvalue = value_ind (value);
402 CATCH (except, RETURN_MASK_ERROR)
404 *cvalue = NULL;
406 END_CATCH
409 /* Don't use get_target_type because it calls
410 check_typedef and here, we want to show the true
411 declared type of the variable. */
412 if (ctype)
413 *ctype = TYPE_TARGET_TYPE (type);
415 if (cfull_expression)
416 *cfull_expression = xstrprintf ("*(%s)", parent_expression);
418 break;
420 default:
421 /* This should not happen. */
422 if (cname)
423 *cname = xstrdup ("???");
424 if (cfull_expression)
425 *cfull_expression = xstrdup ("???");
426 /* Don't set value and type, we don't know then. */
430 static char *
431 c_name_of_child (const struct varobj *parent, int index)
433 char *name;
435 c_describe_child (parent, index, &name, NULL, NULL, NULL);
436 return name;
439 static char *
440 c_path_expr_of_child (const struct varobj *child)
442 char *path_expr;
444 c_describe_child (child->parent, child->index, NULL, NULL, NULL,
445 &path_expr);
446 return path_expr;
449 static struct value *
450 c_value_of_child (const struct varobj *parent, int index)
452 struct value *value = NULL;
454 c_describe_child (parent, index, NULL, &value, NULL, NULL);
455 return value;
458 static struct type *
459 c_type_of_child (const struct varobj *parent, int index)
461 struct type *type = NULL;
463 c_describe_child (parent, index, NULL, NULL, &type, NULL);
464 return type;
467 /* This returns the type of the variable. It also skips past typedefs
468 to return the real type of the variable. */
470 static struct type *
471 get_type (const struct varobj *var)
473 struct type *type;
475 type = var->type;
476 if (type != NULL)
477 type = check_typedef (type);
479 return type;
482 static char *
483 c_value_of_variable (const struct varobj *var,
484 enum varobj_display_formats format)
486 /* BOGUS: if val_print sees a struct/class, or a reference to one,
487 it will print out its children instead of "{...}". So we need to
488 catch that case explicitly. */
489 struct type *type = get_type (var);
491 /* Strip top-level references. */
492 while (TYPE_CODE (type) == TYPE_CODE_REF)
493 type = check_typedef (TYPE_TARGET_TYPE (type));
495 switch (TYPE_CODE (type))
497 case TYPE_CODE_STRUCT:
498 case TYPE_CODE_UNION:
499 return xstrdup ("{...}");
500 /* break; */
502 case TYPE_CODE_ARRAY:
504 char *number;
506 number = xstrprintf ("[%d]", var->num_children);
507 return (number);
509 /* break; */
511 default:
513 if (var->value == NULL)
515 /* This can happen if we attempt to get the value of a struct
516 member when the parent is an invalid pointer. This is an
517 error condition, so we should tell the caller. */
518 return NULL;
520 else
522 if (var->not_fetched && value_lazy (var->value))
523 /* Frozen variable and no value yet. We don't
524 implicitly fetch the value. MI response will
525 use empty string for the value, which is OK. */
526 return NULL;
528 gdb_assert (varobj_value_is_changeable_p (var));
529 gdb_assert (!value_lazy (var->value));
531 /* If the specified format is the current one,
532 we can reuse print_value. */
533 if (format == var->format)
534 return xstrdup (var->print_value);
535 else
536 return varobj_value_get_print_value (var->value, format, var);
543 /* varobj operations for c. */
545 const struct lang_varobj_ops c_varobj_ops =
547 c_number_of_children,
548 c_name_of_variable,
549 c_name_of_child,
550 c_path_expr_of_child,
551 c_value_of_child,
552 c_type_of_child,
553 c_value_of_variable,
554 varobj_default_value_is_changeable_p,
555 NULL, /* value_has_mutated */
556 c_is_path_expr_parent /* is_path_expr_parent */
559 /* A little convenience enum for dealing with C++/Java. */
560 enum vsections
562 v_public = 0, v_private, v_protected
565 /* C++ */
567 static int
568 cplus_number_of_children (const struct varobj *var)
570 struct value *value = NULL;
571 struct type *type;
572 int children, dont_know;
573 int lookup_actual_type = 0;
574 struct value_print_options opts;
576 dont_know = 1;
577 children = 0;
579 get_user_print_options (&opts);
581 if (!CPLUS_FAKE_CHILD (var))
583 type = varobj_get_value_type (var);
585 /* It is necessary to access a real type (via RTTI). */
586 if (opts.objectprint)
588 value = var->value;
589 lookup_actual_type = (TYPE_CODE (var->type) == TYPE_CODE_REF
590 || TYPE_CODE (var->type) == TYPE_CODE_PTR);
592 adjust_value_for_child_access (&value, &type, NULL, lookup_actual_type);
594 if (((TYPE_CODE (type)) == TYPE_CODE_STRUCT)
595 || ((TYPE_CODE (type)) == TYPE_CODE_UNION))
597 int kids[3];
599 cplus_class_num_children (type, kids);
600 if (kids[v_public] != 0)
601 children++;
602 if (kids[v_private] != 0)
603 children++;
604 if (kids[v_protected] != 0)
605 children++;
607 /* Add any baseclasses. */
608 children += TYPE_N_BASECLASSES (type);
609 dont_know = 0;
611 /* FIXME: save children in var. */
614 else
616 int kids[3];
618 type = varobj_get_value_type (var->parent);
620 /* It is necessary to access a real type (via RTTI). */
621 if (opts.objectprint)
623 const struct varobj *parent = var->parent;
625 value = parent->value;
626 lookup_actual_type = (TYPE_CODE (parent->type) == TYPE_CODE_REF
627 || TYPE_CODE (parent->type) == TYPE_CODE_PTR);
629 adjust_value_for_child_access (&value, &type, NULL, lookup_actual_type);
631 cplus_class_num_children (type, kids);
632 if (strcmp (var->name, "public") == 0)
633 children = kids[v_public];
634 else if (strcmp (var->name, "private") == 0)
635 children = kids[v_private];
636 else
637 children = kids[v_protected];
638 dont_know = 0;
641 if (dont_know)
642 children = c_number_of_children (var);
644 return children;
647 /* Compute # of public, private, and protected variables in this class.
648 That means we need to descend into all baseclasses and find out
649 how many are there, too. */
651 static void
652 cplus_class_num_children (struct type *type, int children[3])
654 int i, vptr_fieldno;
655 struct type *basetype = NULL;
657 children[v_public] = 0;
658 children[v_private] = 0;
659 children[v_protected] = 0;
661 vptr_fieldno = get_vptr_fieldno (type, &basetype);
662 for (i = TYPE_N_BASECLASSES (type); i < TYPE_NFIELDS (type); i++)
664 /* If we have a virtual table pointer, omit it. Even if virtual
665 table pointers are not specifically marked in the debug info,
666 they should be artificial. */
667 if ((type == basetype && i == vptr_fieldno)
668 || TYPE_FIELD_ARTIFICIAL (type, i))
669 continue;
671 if (TYPE_FIELD_PROTECTED (type, i))
672 children[v_protected]++;
673 else if (TYPE_FIELD_PRIVATE (type, i))
674 children[v_private]++;
675 else
676 children[v_public]++;
680 static char *
681 cplus_name_of_variable (const struct varobj *parent)
683 return c_name_of_variable (parent);
686 enum accessibility { private_field, protected_field, public_field };
688 /* Check if field INDEX of TYPE has the specified accessibility.
689 Return 0 if so and 1 otherwise. */
691 static int
692 match_accessibility (struct type *type, int index, enum accessibility acc)
694 if (acc == private_field && TYPE_FIELD_PRIVATE (type, index))
695 return 1;
696 else if (acc == protected_field && TYPE_FIELD_PROTECTED (type, index))
697 return 1;
698 else if (acc == public_field && !TYPE_FIELD_PRIVATE (type, index)
699 && !TYPE_FIELD_PROTECTED (type, index))
700 return 1;
701 else
702 return 0;
705 static void
706 cplus_describe_child (const struct varobj *parent, int index,
707 char **cname, struct value **cvalue, struct type **ctype,
708 char **cfull_expression)
710 struct value *value;
711 struct type *type;
712 int was_ptr;
713 int lookup_actual_type = 0;
714 char *parent_expression = NULL;
715 const struct varobj *var;
716 struct value_print_options opts;
718 if (cname)
719 *cname = NULL;
720 if (cvalue)
721 *cvalue = NULL;
722 if (ctype)
723 *ctype = NULL;
724 if (cfull_expression)
725 *cfull_expression = NULL;
727 get_user_print_options (&opts);
729 var = (CPLUS_FAKE_CHILD (parent)) ? parent->parent : parent;
730 if (opts.objectprint)
731 lookup_actual_type = (TYPE_CODE (var->type) == TYPE_CODE_REF
732 || TYPE_CODE (var->type) == TYPE_CODE_PTR);
733 value = var->value;
734 type = varobj_get_value_type (var);
735 if (cfull_expression)
736 parent_expression
737 = varobj_get_path_expr (varobj_get_path_expr_parent (var));
739 adjust_value_for_child_access (&value, &type, &was_ptr, lookup_actual_type);
741 if (TYPE_CODE (type) == TYPE_CODE_STRUCT
742 || TYPE_CODE (type) == TYPE_CODE_UNION)
744 char *join = was_ptr ? "->" : ".";
746 if (CPLUS_FAKE_CHILD (parent))
748 /* The fields of the class type are ordered as they
749 appear in the class. We are given an index for a
750 particular access control type ("public","protected",
751 or "private"). We must skip over fields that don't
752 have the access control we are looking for to properly
753 find the indexed field. */
754 int type_index = TYPE_N_BASECLASSES (type);
755 enum accessibility acc = public_field;
756 int vptr_fieldno;
757 struct type *basetype = NULL;
758 const char *field_name;
760 vptr_fieldno = get_vptr_fieldno (type, &basetype);
761 if (strcmp (parent->name, "private") == 0)
762 acc = private_field;
763 else if (strcmp (parent->name, "protected") == 0)
764 acc = protected_field;
766 while (index >= 0)
768 if ((type == basetype && type_index == vptr_fieldno)
769 || TYPE_FIELD_ARTIFICIAL (type, type_index))
770 ; /* ignore vptr */
771 else if (match_accessibility (type, type_index, acc))
772 --index;
773 ++type_index;
775 --type_index;
777 /* If the type is anonymous and the field has no name,
778 set an appopriate name. */
779 field_name = TYPE_FIELD_NAME (type, type_index);
780 if (field_name == NULL || *field_name == '\0')
782 if (cname)
784 if (TYPE_CODE (TYPE_FIELD_TYPE (type, type_index))
785 == TYPE_CODE_STRUCT)
786 *cname = xstrdup (ANONYMOUS_STRUCT_NAME);
787 else if (TYPE_CODE (TYPE_FIELD_TYPE (type, type_index))
788 == TYPE_CODE_UNION)
789 *cname = xstrdup (ANONYMOUS_UNION_NAME);
792 if (cfull_expression)
793 *cfull_expression = xstrdup ("");
795 else
797 if (cname)
798 *cname = xstrdup (TYPE_FIELD_NAME (type, type_index));
800 if (cfull_expression)
801 *cfull_expression
802 = xstrprintf ("((%s)%s%s)", parent_expression, join,
803 field_name);
806 if (cvalue && value)
807 *cvalue = value_struct_element_index (value, type_index);
809 if (ctype)
810 *ctype = TYPE_FIELD_TYPE (type, type_index);
812 else if (index < TYPE_N_BASECLASSES (type))
814 /* This is a baseclass. */
815 if (cname)
816 *cname = xstrdup (TYPE_FIELD_NAME (type, index));
818 if (cvalue && value)
819 *cvalue = value_cast (TYPE_FIELD_TYPE (type, index), value);
821 if (ctype)
823 *ctype = TYPE_FIELD_TYPE (type, index);
826 if (cfull_expression)
828 char *ptr = was_ptr ? "*" : "";
830 /* Cast the parent to the base' type. Note that in gdb,
831 expression like
832 (Base1)d
833 will create an lvalue, for all appearences, so we don't
834 need to use more fancy:
835 *(Base1*)(&d)
836 construct.
838 When we are in the scope of the base class or of one
839 of its children, the type field name will be interpreted
840 as a constructor, if it exists. Therefore, we must
841 indicate that the name is a class name by using the
842 'class' keyword. See PR mi/11912 */
843 *cfull_expression = xstrprintf ("(%s(class %s%s) %s)",
844 ptr,
845 TYPE_FIELD_NAME (type, index),
846 ptr,
847 parent_expression);
850 else
852 char *access = NULL;
853 int children[3];
855 cplus_class_num_children (type, children);
857 /* Everything beyond the baseclasses can
858 only be "public", "private", or "protected"
860 The special "fake" children are always output by varobj in
861 this order. So if INDEX == 2, it MUST be "protected". */
862 index -= TYPE_N_BASECLASSES (type);
863 switch (index)
865 case 0:
866 if (children[v_public] > 0)
867 access = "public";
868 else if (children[v_private] > 0)
869 access = "private";
870 else
871 access = "protected";
872 break;
873 case 1:
874 if (children[v_public] > 0)
876 if (children[v_private] > 0)
877 access = "private";
878 else
879 access = "protected";
881 else if (children[v_private] > 0)
882 access = "protected";
883 break;
884 case 2:
885 /* Must be protected. */
886 access = "protected";
887 break;
888 default:
889 /* error! */
890 break;
893 gdb_assert (access);
894 if (cname)
895 *cname = xstrdup (access);
897 /* Value and type and full expression are null here. */
900 else
902 c_describe_child (parent, index, cname, cvalue, ctype, cfull_expression);
906 static char *
907 cplus_name_of_child (const struct varobj *parent, int index)
909 char *name = NULL;
911 cplus_describe_child (parent, index, &name, NULL, NULL, NULL);
912 return name;
915 static char *
916 cplus_path_expr_of_child (const struct varobj *child)
918 char *path_expr;
920 cplus_describe_child (child->parent, child->index, NULL, NULL, NULL,
921 &path_expr);
922 return path_expr;
925 static struct value *
926 cplus_value_of_child (const struct varobj *parent, int index)
928 struct value *value = NULL;
930 cplus_describe_child (parent, index, NULL, &value, NULL, NULL);
931 return value;
934 static struct type *
935 cplus_type_of_child (const struct varobj *parent, int index)
937 struct type *type = NULL;
939 cplus_describe_child (parent, index, NULL, NULL, &type, NULL);
940 return type;
943 static char *
944 cplus_value_of_variable (const struct varobj *var,
945 enum varobj_display_formats format)
948 /* If we have one of our special types, don't print out
949 any value. */
950 if (CPLUS_FAKE_CHILD (var))
951 return xstrdup ("");
953 return c_value_of_variable (var, format);
957 /* varobj operations for c++. */
959 const struct lang_varobj_ops cplus_varobj_ops =
961 cplus_number_of_children,
962 cplus_name_of_variable,
963 cplus_name_of_child,
964 cplus_path_expr_of_child,
965 cplus_value_of_child,
966 cplus_type_of_child,
967 cplus_value_of_variable,
968 varobj_default_value_is_changeable_p,
969 NULL, /* value_has_mutated */
970 c_is_path_expr_parent /* is_path_expr_parent */