1 /* Implementation of the GDB variable objects API.
2 Copyright 1999, 2000 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 2 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, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
21 #include "expression.h"
31 /* Non-zero if we want to see trace of varobj level stuff. */
35 /* String representations of gdb's format codes */
36 char *varobj_format_string[] =
37 {"natural", "binary", "decimal", "hexadecimal", "octal"};
39 /* String representations of gdb's known languages */
40 char *varobj_language_string[] =
41 {"unknown", "C", "C++", "Java"};
45 /* Every root variable has one of these structures saved in its
46 varobj. Members which must be free'd are noted. */
50 /* Alloc'd expression for this parent. */
51 struct expression *exp;
53 /* Block for which this expression is valid */
54 struct block *valid_block;
56 /* The frame for this expression */
59 /* If 1, "update" always recomputes the frame & valid block
60 using the currently selected frame. */
61 int use_selected_frame;
63 /* Language info for this variable and its children */
64 struct language_specific *lang;
66 /* The varobj for this root node. */
67 struct varobj *rootvar;
69 /* Next root variable */
70 struct varobj_root *next;
73 /* Every variable in the system has a structure of this type defined
74 for it. This structure holds all information necessary to manipulate
75 a particular object variable. Members which must be freed are noted. */
79 /* Alloc'd name of the variable for this object.. If this variable is a
80 child, then this name will be the child's source name.
82 /* NOTE: This is the "expression" */
85 /* The alloc'd name for this variable's object. This is here for
86 convenience when constructing this object's children. */
89 /* Index of this variable in its parent or -1 */
92 /* The type of this variable. This may NEVER be NULL. */
95 /* The value of this expression or subexpression. This may be NULL. */
98 /* Did an error occur evaluating the expression or getting its value? */
101 /* The number of (immediate) children this variable has */
104 /* If this object is a child, this points to its immediate parent. */
105 struct varobj *parent;
107 /* A list of this object's children */
108 struct varobj_child *children;
110 /* Description of the root variable. Points to root variable for children. */
111 struct varobj_root *root;
113 /* The format of the output for this object */
114 enum varobj_display_formats format;
117 /* Every variable keeps a linked list of its children, described
118 by the following structure. */
119 /* FIXME: Deprecated. All should use vlist instead */
124 /* Pointer to the child's data */
125 struct varobj *child;
127 /* Pointer to the next child */
128 struct varobj_child *next;
131 /* A stack of varobjs */
132 /* FIXME: Deprecated. All should use vlist instead */
143 struct cpstack *next;
146 /* A list of varobjs */
154 /* Private function prototypes */
156 /* Helper functions for the above subcommands. */
158 static int delete_variable (struct cpstack **, struct varobj *, int);
160 static void delete_variable_1 (struct cpstack **, int *,
161 struct varobj *, int, int);
163 static int install_variable (struct varobj *);
165 static void uninstall_variable (struct varobj *);
167 static struct varobj *child_exists (struct varobj *, char *);
169 static struct varobj *create_child (struct varobj *, int, char *);
171 static void save_child_in_parent (struct varobj *, struct varobj *);
173 static void remove_child_from_parent (struct varobj *, struct varobj *);
175 /* Utility routines */
177 static struct varobj *new_variable (void);
179 static struct varobj *new_root_variable (void);
181 static void free_variable (struct varobj *var);
183 static struct cleanup *make_cleanup_free_variable (struct varobj *var);
185 static struct type *get_type (struct varobj *var);
187 static struct type *get_type_deref (struct varobj *var);
189 static struct type *get_target_type (struct type *);
191 static enum varobj_display_formats variable_default_display (struct varobj *);
193 static int my_value_equal (value_ptr, value_ptr, int *);
195 static void vpush (struct vstack **pstack, struct varobj *var);
197 static struct varobj *vpop (struct vstack **pstack);
199 static void cppush (struct cpstack **pstack, char *name);
201 static char *cppop (struct cpstack **pstack);
203 /* Language-specific routines. */
205 static enum varobj_languages variable_language (struct varobj *var);
207 static int number_of_children (struct varobj *);
209 static char *name_of_variable (struct varobj *);
211 static char *name_of_child (struct varobj *, int);
213 static value_ptr value_of_root (struct varobj **var_handle, int *);
215 static value_ptr value_of_child (struct varobj *parent, int index);
217 static struct type *type_of_child (struct varobj *var);
219 static int variable_editable (struct varobj *var);
221 static char *my_value_of_variable (struct varobj *var);
223 static int type_changeable (struct varobj *var);
225 /* C implementation */
227 static int c_number_of_children (struct varobj *var);
229 static char *c_name_of_variable (struct varobj *parent);
231 static char *c_name_of_child (struct varobj *parent, int index);
233 static value_ptr c_value_of_root (struct varobj **var_handle);
235 static value_ptr c_value_of_child (struct varobj *parent, int index);
237 static struct type *c_type_of_child (struct varobj *parent, int index);
239 static int c_variable_editable (struct varobj *var);
241 static char *c_value_of_variable (struct varobj *var);
243 /* C++ implementation */
245 static int cplus_number_of_children (struct varobj *var);
247 static void cplus_class_num_children (struct type *type, int children[3]);
249 static char *cplus_name_of_variable (struct varobj *parent);
251 static char *cplus_name_of_child (struct varobj *parent, int index);
253 static value_ptr cplus_value_of_root (struct varobj **var_handle);
255 static value_ptr cplus_value_of_child (struct varobj *parent, int index);
257 static struct type *cplus_type_of_child (struct varobj *parent, int index);
259 static int cplus_variable_editable (struct varobj *var);
261 static char *cplus_value_of_variable (struct varobj *var);
263 /* Java implementation */
265 static int java_number_of_children (struct varobj *var);
267 static char *java_name_of_variable (struct varobj *parent);
269 static char *java_name_of_child (struct varobj *parent, int index);
271 static value_ptr java_value_of_root (struct varobj **var_handle);
273 static value_ptr java_value_of_child (struct varobj *parent, int index);
275 static struct type *java_type_of_child (struct varobj *parent, int index);
277 static int java_variable_editable (struct varobj *var);
279 static char *java_value_of_variable (struct varobj *var);
281 /* The language specific vector */
283 struct language_specific
286 /* The language of this variable */
287 enum varobj_languages language;
289 /* The number of children of PARENT. */
290 int (*number_of_children) (struct varobj * parent);
292 /* The name (expression) of a root varobj. */
293 char *(*name_of_variable) (struct varobj * parent);
295 /* The name of the INDEX'th child of PARENT. */
296 char *(*name_of_child) (struct varobj * parent, int index);
298 /* The value_ptr of the root variable ROOT. */
299 value_ptr (*value_of_root) (struct varobj ** root_handle);
301 /* The value_ptr of the INDEX'th child of PARENT. */
302 value_ptr (*value_of_child) (struct varobj * parent, int index);
304 /* The type of the INDEX'th child of PARENT. */
305 struct type *(*type_of_child) (struct varobj * parent, int index);
307 /* Is VAR editable? */
308 int (*variable_editable) (struct varobj * var);
310 /* The current value of VAR. */
311 char *(*value_of_variable) (struct varobj * var);
314 /* Array of known source language routines. */
315 static struct language_specific
316 languages[vlang_end][sizeof (struct language_specific)] =
318 /* Unknown (try treating as C */
321 c_number_of_children,
334 c_number_of_children,
347 cplus_number_of_children,
348 cplus_name_of_variable,
351 cplus_value_of_child,
353 cplus_variable_editable,
354 cplus_value_of_variable
360 java_number_of_children,
361 java_name_of_variable,
366 java_variable_editable,
367 java_value_of_variable
371 /* A little convenience enum for dealing with C++/Java */
374 v_public = 0, v_private, v_protected
379 /* Mappings of varobj_display_formats enums to gdb's format codes */
380 static int format_code[] =
381 {0, 't', 'd', 'x', 'o'};
383 /* Header of the list of root variable objects */
384 static struct varobj_root *rootlist;
385 static int rootcount = 0; /* number of root varobjs in the list */
387 /* Prime number indicating the number of buckets in the hash table */
388 /* A prime large enough to avoid too many colisions */
389 #define VAROBJ_TABLE_SIZE 227
391 /* Pointer to the varobj hash table (built at run time) */
392 static struct vlist **varobj_table;
397 #define FREEIF(x) if (x != NULL) free((char *) (x))
399 /* Is the variable X one of our "fake" children? */
400 #define CPLUS_FAKE_CHILD(x) \
401 ((x) != NULL && (x)->type == NULL && (x)->value == NULL)
404 /* API Implementation */
406 /* Creates a varobj (not its children) */
409 varobj_create (char *objname,
410 char *expression, CORE_ADDR frame,
411 enum varobj_type type)
414 struct frame_info *fi, *old_fi;
416 struct cleanup *old_chain;
418 /* Fill out a varobj structure for the (root) variable being constructed. */
419 var = new_root_variable ();
420 old_chain = make_cleanup_free_variable (var);
422 if (expression != NULL)
425 enum varobj_languages lang;
427 /* Parse and evaluate the expression, filling in as much
428 of the variable's data as possible */
430 /* Allow creator to specify context of variable */
431 if ((type == USE_CURRENT_FRAME)
432 || (type == USE_SELECTED_FRAME))
435 fi = find_frame_addr_in_frame_chain (frame);
437 /* frame = -2 means always use selected frame */
438 if (type == USE_SELECTED_FRAME)
439 var->root->use_selected_frame = 1;
443 block = get_frame_block (fi);
446 innermost_block = NULL;
447 /* Wrap the call to parse expression, so we can
448 return a sensible error. */
449 if (!gdb_parse_exp_1 (&p, block, 0, &var->root->exp))
454 /* Don't allow variables to be created for types. */
455 if (var->root->exp->elts[0].opcode == OP_TYPE)
457 do_cleanups (old_chain);
458 fprintf_unfiltered (gdb_stderr,
459 "Attempt to use a type name as an expression.");
463 var->format = variable_default_display (var);
464 var->root->valid_block = innermost_block;
465 var->name = savestring (expression, strlen (expression));
467 /* When the frame is different from the current frame,
468 we must select the appropriate frame before parsing
469 the expression, otherwise the value will not be current.
470 Since select_frame is so benign, just call it for all cases. */
473 var->root->frame = FRAME_FP (fi);
474 old_fi = selected_frame;
475 select_frame (fi, -1);
478 /* We definitively need to catch errors here.
479 If evaluate_expression succeeds we got the value we wanted.
480 But if it fails, we still go on with a call to evaluate_type() */
481 if (gdb_evaluate_expression (var->root->exp, &var->value))
484 release_value (var->value);
485 if (VALUE_LAZY (var->value))
486 gdb_value_fetch_lazy (var->value);
489 var->value = evaluate_type (var->root->exp);
491 var->type = VALUE_TYPE (var->value);
493 /* Set language info */
494 lang = variable_language (var);
495 var->root->lang = languages[lang];
497 /* Set ourselves as our root */
498 var->root->rootvar = var;
500 /* Reset the selected frame */
502 select_frame (old_fi, -1);
505 /* If the variable object name is null, that means this
506 is a temporary variable, so don't install it. */
508 if ((var != NULL) && (objname != NULL))
510 var->obj_name = savestring (objname, strlen (objname));
512 /* If a varobj name is duplicated, the install will fail so
514 if (!install_variable (var))
516 do_cleanups (old_chain);
521 discard_cleanups (old_chain);
525 /* Generates an unique name that can be used for a varobj */
528 varobj_gen_name (void)
533 /* generate a name for this object */
535 sprintf (obj_name, "var%d", id);
537 return xstrdup (obj_name);
540 /* Given an "objname", returns the pointer to the corresponding varobj
541 or NULL if not found */
544 varobj_get_handle (char *objname)
548 unsigned int index = 0;
551 for (chp = objname; *chp; chp++)
553 index = (index + (i++ * (unsigned int) *chp)) % VAROBJ_TABLE_SIZE;
556 cv = *(varobj_table + index);
557 while ((cv != NULL) && (strcmp (cv->var->obj_name, objname) != 0))
561 error ("Variable object not found");
566 /* Given the handle, return the name of the object */
569 varobj_get_objname (struct varobj *var)
571 return var->obj_name;
574 /* Given the handle, return the expression represented by the object */
577 varobj_get_expression (struct varobj *var)
579 return name_of_variable (var);
582 /* Deletes a varobj and all its children if only_children == 0,
583 otherwise deletes only the children; returns a malloc'ed list of all the
584 (malloc'ed) names of the variables that have been deleted (NULL terminated) */
587 varobj_delete (struct varobj *var, char ***dellist, int only_children)
591 struct cpstack *result = NULL;
594 /* Initialize a stack for temporary results */
595 cppush (&result, NULL);
598 /* Delete only the variable children */
599 delcount = delete_variable (&result, var, 1 /* only the children */ );
601 /* Delete the variable and all its children */
602 delcount = delete_variable (&result, var, 0 /* parent+children */ );
604 /* We may have been asked to return a list of what has been deleted */
607 *dellist = xmalloc ((delcount + 1) * sizeof (char *));
611 *cp = cppop (&result);
612 while ((*cp != NULL) && (mycount > 0))
616 *cp = cppop (&result);
619 if (mycount || (*cp != NULL))
620 warning ("varobj_delete: assertion failed - mycount(=%d) <> 0", mycount);
626 /* Set/Get variable object display format */
628 enum varobj_display_formats
629 varobj_set_display_format (struct varobj *var,
630 enum varobj_display_formats format)
637 case FORMAT_HEXADECIMAL:
639 var->format = format;
643 var->format = variable_default_display (var);
649 enum varobj_display_formats
650 varobj_get_display_format (struct varobj *var)
656 varobj_get_num_children (struct varobj *var)
658 if (var->num_children == -1)
659 var->num_children = number_of_children (var);
661 return var->num_children;
664 /* Creates a list of the immediate children of a variable object;
665 the return code is the number of such children or -1 on error */
668 varobj_list_children (struct varobj *var, struct varobj ***childlist)
670 struct varobj *child;
674 /* sanity check: have we been passed a pointer? */
675 if (childlist == NULL)
680 if (var->num_children == -1)
681 var->num_children = number_of_children (var);
683 /* List of children */
684 *childlist = xmalloc ((var->num_children + 1) * sizeof (struct varobj *));
686 for (i = 0; i < var->num_children; i++)
688 /* Mark as the end in case we bail out */
689 *((*childlist) + i) = NULL;
691 /* check if child exists, if not create */
692 name = name_of_child (var, i);
693 child = child_exists (var, name);
695 child = create_child (var, i, name);
697 *((*childlist) + i) = child;
700 /* End of list is marked by a NULL pointer */
701 *((*childlist) + i) = NULL;
703 return var->num_children;
706 /* Obtain the type of an object Variable as a string similar to the one gdb
707 prints on the console */
710 varobj_get_type (struct varobj *var)
713 struct cleanup *old_chain;
718 /* For the "fake" variables, do not return a type. (It's type is
720 if (CPLUS_FAKE_CHILD (var))
723 stb = mem_fileopen ();
724 old_chain = make_cleanup_ui_file_delete (stb);
726 /* To print the type, we simply create a zero value_ptr and
727 cast it to our type. We then typeprint this variable. */
728 val = value_zero (var->type, not_lval);
729 type_print (VALUE_TYPE (val), "", stb, -1);
731 thetype = ui_file_xstrdup (stb, &length);
732 do_cleanups (old_chain);
736 enum varobj_languages
737 varobj_get_language (struct varobj *var)
739 return variable_language (var);
743 varobj_get_attributes (struct varobj *var)
747 if (variable_editable (var))
748 /* FIXME: define masks for attributes */
749 attributes |= 0x00000001; /* Editable */
755 varobj_get_value (struct varobj *var)
757 return my_value_of_variable (var);
760 /* Set the value of an object variable (if it is editable) to the
761 value of the given expression */
762 /* Note: Invokes functions that can call error() */
765 varobj_set_value (struct varobj *var, char *expression)
770 /* The argument "expression" contains the variable's new value.
771 We need to first construct a legal expression for this -- ugh! */
772 /* Does this cover all the bases? */
773 struct expression *exp;
775 int saved_input_radix = input_radix;
777 if (variable_editable (var) && !var->error)
779 char *s = expression;
783 input_radix = 10; /* ALWAYS reset to decimal temporarily */
784 /* FIXME: Callee may longjump */
785 exp = parse_exp_1 (&s, 0, 0);
786 if (!gdb_evaluate_expression (exp, &value))
788 /* We cannot proceed without a valid expression. */
793 /* If our parent is "public", "private", or "protected", we could
794 be asking to modify the value of a baseclass. If so, we need to
795 adjust our address by the offset of our baseclass in the subclass,
796 since VALUE_ADDRESS (var->value) points at the start of the subclass.
797 For some reason, value_cast doesn't take care of this properly. */
799 if (var->parent != NULL && CPLUS_FAKE_CHILD (var->parent))
801 struct varobj *super, *sub;
803 super = var->parent->parent;
807 /* Yes, it is a baseclass */
808 type = get_type_deref (sub);
810 if (super->index < TYPE_N_BASECLASSES (type))
812 temp = value_copy (var->value);
813 for (i = 0; i < super->index; i++)
814 offset += TYPE_LENGTH (TYPE_FIELD_TYPE (type, i));
819 VALUE_ADDRESS (temp) += offset;
820 val = value_assign (temp, value);
821 VALUE_ADDRESS (val) -= offset;
822 value_free (var->value);
825 input_radix = saved_input_radix;
832 /* Returns a malloc'ed list with all root variable objects */
834 varobj_list (struct varobj ***varlist)
837 struct varobj_root *croot;
838 int mycount = rootcount;
840 /* Alloc (rootcount + 1) entries for the result */
841 *varlist = xmalloc ((rootcount + 1) * sizeof (struct varobj *));
845 while ((croot != NULL) && (mycount > 0))
847 *cv = croot->rootvar;
852 /* Mark the end of the list */
855 if (mycount || (croot != NULL))
856 warning ("varobj_list: assertion failed - wrong tally of root vars (%d:%d)",
862 /* Update the values for a variable and its children. This is a
863 two-pronged attack. First, re-parse the value for the root's
864 expression to see if it's changed. Then go all the way
865 through its children, reconstructing them and noting if they've
868 -1 if there was an error updating the varobj
869 -2 if the type changed
870 Otherwise it is the number of children + parent changed
872 Only root variables can be updated... */
875 varobj_update (struct varobj *var, struct varobj ***changelist)
884 struct varobj **templist;
886 struct vstack *stack = NULL;
887 struct vstack *result = NULL;
888 struct frame_info *old_fi;
890 /* sanity check: have we been passed a pointer? */
891 if (changelist == NULL)
894 /* Only root variables can be updated... */
895 if (var->root->rootvar != var)
899 /* Save the selected stack frame, since we will need to change it
900 in order to evaluate expressions. */
901 old_fi = selected_frame;
903 /* Update the root variable. value_of_root can return NULL
904 if the variable is no longer around, i.e. we stepped out of
905 the frame in which a local existed. We are letting the
906 value_of_root variable dispose of the varobj if the type
909 new = value_of_root (&var, &type_changed);
916 /* Initialize a stack for temporary results */
917 vpush (&result, NULL);
919 if (type_changed || !my_value_equal (var->value, new, &error2))
921 /* Note that it's changed There a couple of exceptions here,
922 though. We don't want some types to be reported as
923 "changed". The exception to this is if this is a
924 "use_selected_frame" varobj, and its type has changed. */
925 if (type_changed || type_changeable (var))
927 vpush (&result, var);
931 /* error2 replaces var->error since this new value
932 WILL replace the old one. */
935 /* We must always keep around the new value for this root
936 variable expression, or we lose the updated children! */
937 value_free (var->value);
940 /* Initialize a stack */
941 vpush (&stack, NULL);
943 /* Push the root's children */
944 if (var->children != NULL)
946 struct varobj_child *c;
947 for (c = var->children; c != NULL; c = c->next)
948 vpush (&stack, c->child);
951 /* Walk through the children, reconstructing them all. */
955 /* Push any children */
956 if (v->children != NULL)
958 struct varobj_child *c;
959 for (c = v->children; c != NULL; c = c->next)
960 vpush (&stack, c->child);
963 /* Update this variable */
964 new = value_of_child (v->parent, v->index);
965 if (type_changeable (v) && !my_value_equal (v->value, new, &error2))
967 /* Note that it's changed */
971 /* error2 replaces v->error since this new value
972 WILL replace the old one. */
975 /* We must always keep new values, since children depend on it. */
976 if (v->value != NULL)
977 value_free (v->value);
984 /* Alloc (changed + 1) list entries */
985 /* FIXME: add a cleanup for the allocated list(s)
986 because one day the select_frame called below can longjump */
987 *changelist = xmalloc ((changed + 1) * sizeof (struct varobj *));
990 templist = xmalloc ((changed + 1) * sizeof (struct varobj *));
996 /* Copy from result stack to list */
998 *cv = vpop (&result);
999 while ((*cv != NULL) && (vleft > 0))
1003 *cv = vpop (&result);
1006 warning ("varobj_update: assertion failed - vleft <> 0");
1010 /* Now we revert the order. */
1011 for (i=0; i < changed; i++)
1012 *(*changelist + i) = *(templist + changed -1 - i);
1013 *(*changelist + changed) = NULL;
1016 /* Restore selected frame */
1017 select_frame (old_fi, -1);
1026 /* Helper functions */
1029 * Variable object construction/destruction
1033 delete_variable (resultp, var, only_children_p)
1034 struct cpstack **resultp;
1036 int only_children_p;
1040 delete_variable_1 (resultp, &delcount, var,
1041 only_children_p, 1 /* remove_from_parent_p */ );
1046 /* Delete the variable object VAR and its children */
1047 /* IMPORTANT NOTE: If we delete a variable which is a child
1048 and the parent is not removed we dump core. It must be always
1049 initially called with remove_from_parent_p set */
1051 delete_variable_1 (resultp, delcountp, var,
1052 only_children_p, remove_from_parent_p)
1053 struct cpstack **resultp;
1056 int only_children_p;
1057 int remove_from_parent_p;
1059 struct varobj_child *vc;
1060 struct varobj_child *next;
1062 /* Delete any children of this variable, too. */
1063 for (vc = var->children; vc != NULL; vc = next)
1065 if (!remove_from_parent_p)
1066 vc->child->parent = NULL;
1067 delete_variable_1 (resultp, delcountp, vc->child, 0, only_children_p);
1072 /* if we were called to delete only the children we are done here */
1073 if (only_children_p)
1076 /* Otherwise, add it to the list of deleted ones and proceed to do so */
1077 /* If the name is null, this is a temporary variable, that has not
1078 yet been installed, don't report it, it belongs to the caller... */
1079 if (var->obj_name != NULL)
1081 cppush (resultp, strdup (var->obj_name));
1082 *delcountp = *delcountp + 1;
1085 /* If this variable has a parent, remove it from its parent's list */
1086 /* OPTIMIZATION: if the parent of this variable is also being deleted,
1087 (as indicated by remove_from_parent_p) we don't bother doing an
1088 expensive list search to find the element to remove when we are
1089 discarding the list afterwards */
1090 if ((remove_from_parent_p) &&
1091 (var->parent != NULL))
1093 remove_child_from_parent (var->parent, var);
1096 if (var->obj_name != NULL)
1097 uninstall_variable (var);
1099 /* Free memory associated with this variable */
1100 free_variable (var);
1103 /* Install the given variable VAR with the object name VAR->OBJ_NAME. */
1105 install_variable (var)
1109 struct vlist *newvl;
1111 unsigned int index = 0;
1114 for (chp = var->obj_name; *chp; chp++)
1116 index = (index + (i++ * (unsigned int) *chp)) % VAROBJ_TABLE_SIZE;
1119 cv = *(varobj_table + index);
1120 while ((cv != NULL) && (strcmp (cv->var->obj_name, var->obj_name) != 0))
1124 error ("Duplicate variable object name");
1126 /* Add varobj to hash table */
1127 newvl = xmalloc (sizeof (struct vlist));
1128 newvl->next = *(varobj_table + index);
1130 *(varobj_table + index) = newvl;
1132 /* If root, add varobj to root list */
1133 if (var->root->rootvar == var)
1135 /* Add to list of root variables */
1136 if (rootlist == NULL)
1137 var->root->next = NULL;
1139 var->root->next = rootlist;
1140 rootlist = var->root;
1147 /* Unistall the object VAR. */
1149 uninstall_variable (var)
1154 struct varobj_root *cr;
1155 struct varobj_root *prer;
1157 unsigned int index = 0;
1160 /* Remove varobj from hash table */
1161 for (chp = var->obj_name; *chp; chp++)
1163 index = (index + (i++ * (unsigned int) *chp)) % VAROBJ_TABLE_SIZE;
1166 cv = *(varobj_table + index);
1168 while ((cv != NULL) && (strcmp (cv->var->obj_name, var->obj_name) != 0))
1175 fprintf_unfiltered (gdb_stdlog, "Deleting %s\n", var->obj_name);
1179 warning ("Assertion failed: Could not find variable object \"%s\" to delete", var->obj_name);
1184 *(varobj_table + index) = cv->next;
1186 prev->next = cv->next;
1190 /* If root, remove varobj from root list */
1191 if (var->root->rootvar == var)
1193 /* Remove from list of root variables */
1194 if (rootlist == var->root)
1195 rootlist = var->root->next;
1200 while ((cr != NULL) && (cr->rootvar != var))
1207 warning ("Assertion failed: Could not find varobj \"%s\" in root list", var->obj_name);
1213 prer->next = cr->next;
1220 /* Does a child with the name NAME exist in VAR? If so, return its data.
1221 If not, return NULL. */
1222 static struct varobj *
1223 child_exists (var, name)
1224 struct varobj *var; /* Parent */
1225 char *name; /* name of child */
1227 struct varobj_child *vc;
1229 for (vc = var->children; vc != NULL; vc = vc->next)
1231 if (STREQ (vc->child->name, name))
1238 /* Create and install a child of the parent of the given name */
1239 static struct varobj *
1240 create_child (parent, index, name)
1241 struct varobj *parent;
1245 struct varobj *child;
1248 child = new_variable ();
1250 /* name is allocated by name_of_child */
1252 child->index = index;
1253 child->value = value_of_child (parent, index);
1254 if (child->value == NULL || parent->error)
1256 child->parent = parent;
1257 child->root = parent->root;
1258 childs_name = (char *) xmalloc ((strlen (parent->obj_name) + strlen (name) + 2)
1260 sprintf (childs_name, "%s.%s", parent->obj_name, name);
1261 child->obj_name = childs_name;
1262 install_variable (child);
1264 /* Save a pointer to this child in the parent */
1265 save_child_in_parent (parent, child);
1267 /* Note the type of this child */
1268 child->type = type_of_child (child);
1273 /* FIXME: This should be a generic add to list */
1274 /* Save CHILD in the PARENT's data. */
1276 save_child_in_parent (parent, child)
1277 struct varobj *parent;
1278 struct varobj *child;
1280 struct varobj_child *vc;
1282 /* Insert the child at the top */
1283 vc = parent->children;
1285 (struct varobj_child *) xmalloc (sizeof (struct varobj_child));
1287 parent->children->next = vc;
1288 parent->children->child = child;
1291 /* FIXME: This should be a generic remove from list */
1292 /* Remove the CHILD from the PARENT's list of children. */
1294 remove_child_from_parent (parent, child)
1295 struct varobj *parent;
1296 struct varobj *child;
1298 struct varobj_child *vc, *prev;
1300 /* Find the child in the parent's list */
1302 for (vc = parent->children; vc != NULL;)
1304 if (vc->child == child)
1311 parent->children = vc->next;
1313 prev->next = vc->next;
1319 * Miscellaneous utility functions.
1322 /* Allocate memory and initialize a new variable */
1323 static struct varobj *
1328 var = (struct varobj *) xmalloc (sizeof (struct varobj));
1330 var->obj_name = NULL;
1335 var->num_children = -1;
1337 var->children = NULL;
1344 /* Allocate memory and initialize a new root variable */
1345 static struct varobj *
1346 new_root_variable (void)
1348 struct varobj *var = new_variable ();
1349 var->root = (struct varobj_root *) xmalloc (sizeof (struct varobj_root));;
1350 var->root->lang = NULL;
1351 var->root->exp = NULL;
1352 var->root->valid_block = NULL;
1353 var->root->frame = (CORE_ADDR) -1;
1354 var->root->use_selected_frame = 0;
1355 var->root->rootvar = NULL;
1360 /* Free any allocated memory associated with VAR. */
1365 /* Free the expression if this is a root variable. */
1366 if (var->root->rootvar == var)
1368 free_current_contents ((char **) &var->root->exp);
1373 FREEIF (var->obj_name);
1378 do_free_variable_cleanup (void *var)
1380 free_variable (var);
1383 static struct cleanup *
1384 make_cleanup_free_variable (struct varobj *var)
1386 return make_cleanup (do_free_variable_cleanup, var);
1389 /* This returns the type of the variable. This skips past typedefs
1390 and returns the real type of the variable. It also dereferences
1391 pointers and references. */
1392 static struct type *
1399 while (type != NULL && TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
1400 type = TYPE_TARGET_TYPE (type);
1405 /* This returns the type of the variable, dereferencing pointers, too. */
1406 static struct type *
1407 get_type_deref (var)
1412 type = get_type (var);
1414 if (type != NULL && (TYPE_CODE (type) == TYPE_CODE_PTR
1415 || TYPE_CODE (type) == TYPE_CODE_REF))
1416 type = get_target_type (type);
1421 /* This returns the target type (or NULL) of TYPE, also skipping
1422 past typedefs, just like get_type (). */
1423 static struct type *
1424 get_target_type (type)
1429 type = TYPE_TARGET_TYPE (type);
1430 while (type != NULL && TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
1431 type = TYPE_TARGET_TYPE (type);
1437 /* What is the default display for this variable? We assume that
1438 everything is "natural". Any exceptions? */
1439 static enum varobj_display_formats
1440 variable_default_display (var)
1443 return FORMAT_NATURAL;
1446 /* This function is similar to gdb's value_equal, except that this
1447 one is "safe" -- it NEVER longjmps. It determines if the VAR's
1448 value is the same as VAL2. */
1450 my_value_equal (val1, val2, error2)
1458 /* Special case: NULL values. If both are null, say
1460 if (val1 == NULL && val2 == NULL)
1462 else if (val1 == NULL || val2 == NULL)
1465 /* This is bogus, but unfortunately necessary. We must know
1466 exactly what caused an error -- reading val1 or val2 -- so
1467 that we can really determine if we think that something has changed. */
1470 /* We do need to catch errors here because the whole purpose
1471 is to test if value_equal() has errored */
1472 if (!gdb_value_equal (val1, val1, &r))
1475 if (!gdb_value_equal (val2, val2, &r))
1481 if (!gdb_value_equal (val1, val2, &r))
1483 /* An error occurred, this could have happened if
1484 either val1 or val2 errored. ERR1 and ERR2 tell
1485 us which of these it is. If both errored, then
1486 we assume nothing has changed. If one of them is
1487 valid, though, then something has changed. */
1490 /* both the old and new values caused errors, so
1491 we say the value did not change */
1492 /* This is indeterminate, though. Perhaps we should
1493 be safe and say, yes, it changed anyway?? */
1505 /* FIXME: The following should be generic for any pointer */
1508 struct vstack **pstack;
1513 s = (struct vstack *) xmalloc (sizeof (struct vstack));
1519 /* FIXME: The following should be generic for any pointer */
1520 static struct varobj *
1522 struct vstack **pstack;
1527 if ((*pstack)->var == NULL && (*pstack)->next == NULL)
1532 *pstack = (*pstack)->next;
1538 /* FIXME: The following should be generic for any pointer */
1540 cppush (pstack, name)
1541 struct cpstack **pstack;
1546 s = (struct cpstack *) xmalloc (sizeof (struct cpstack));
1552 /* FIXME: The following should be generic for any pointer */
1555 struct cpstack **pstack;
1560 if ((*pstack)->name == NULL && (*pstack)->next == NULL)
1565 *pstack = (*pstack)->next;
1572 * Language-dependencies
1575 /* Common entry points */
1577 /* Get the language of variable VAR. */
1578 static enum varobj_languages
1579 variable_language (var)
1582 enum varobj_languages lang;
1584 switch (var->root->exp->language_defn->la_language)
1590 case language_cplus:
1601 /* Return the number of children for a given variable.
1602 The result of this function is defined by the language
1603 implementation. The number of children returned by this function
1604 is the number of children that the user will see in the variable
1607 number_of_children (var)
1610 return (*var->root->lang->number_of_children) (var);;
1613 /* What is the expression for the root varobj VAR? Returns a malloc'd string. */
1615 name_of_variable (var)
1618 return (*var->root->lang->name_of_variable) (var);
1621 /* What is the name of the INDEX'th child of VAR? Returns a malloc'd string. */
1623 name_of_child (var, index)
1627 return (*var->root->lang->name_of_child) (var, index);
1630 /* What is the value_ptr of the root variable VAR?
1631 TYPE_CHANGED controls what to do if the type of a
1632 use_selected_frame = 1 variable changes. On input,
1633 TYPE_CHANGED = 1 means discard the old varobj, and replace
1634 it with this one. TYPE_CHANGED = 0 means leave it around.
1635 NB: In both cases, var_handle will point to the new varobj,
1636 so if you use TYPE_CHANGED = 0, you will have to stash the
1637 old varobj pointer away somewhere before calling this.
1638 On return, TYPE_CHANGED will be 1 if the type has changed, and
1641 value_of_root (var_handle, type_changed)
1642 struct varobj ** var_handle;
1647 if (var_handle == NULL)
1652 /* This should really be an exception, since this should
1653 only get called with a root variable. */
1655 if (var->root->rootvar != var)
1658 if (var->root->use_selected_frame)
1660 struct varobj *tmp_var;
1661 char *old_type, *new_type;
1662 old_type = varobj_get_type (var);
1663 tmp_var = varobj_create (NULL, var->name, (CORE_ADDR) 0,
1664 USE_SELECTED_FRAME);
1665 if (tmp_var == NULL)
1669 new_type = varobj_get_type (tmp_var);
1670 if (strcmp(old_type, new_type) == 0)
1672 varobj_delete (tmp_var, NULL, 0);
1680 savestring (var->obj_name, strlen (var->obj_name));
1681 uninstall_variable (var);
1685 tmp_var->obj_name = varobj_gen_name ();
1687 install_variable (tmp_var);
1688 *var_handle = tmp_var;
1697 return (*var->root->lang->value_of_root) (var_handle);
1700 /* What is the value_ptr for the INDEX'th child of PARENT? */
1702 value_of_child (parent, index)
1703 struct varobj *parent;
1708 value = (*parent->root->lang->value_of_child) (parent, index);
1710 /* If we're being lazy, fetch the real value of the variable. */
1711 if (value != NULL && VALUE_LAZY (value))
1712 gdb_value_fetch_lazy (value);
1717 /* What is the type of VAR? */
1718 static struct type *
1723 /* If the child had no evaluation errors, var->value
1724 will be non-NULL and contain a valid type. */
1725 if (var->value != NULL)
1726 return VALUE_TYPE (var->value);
1728 /* Otherwise, we must compute the type. */
1729 return (*var->root->lang->type_of_child) (var->parent, var->index);
1732 /* Is this variable editable? Use the variable's type to make
1733 this determination. */
1735 variable_editable (var)
1738 return (*var->root->lang->variable_editable) (var);
1741 /* GDB already has a command called "value_of_variable". Sigh. */
1743 my_value_of_variable (var)
1746 return (*var->root->lang->value_of_variable) (var);
1749 /* Is VAR something that can change? Depending on language,
1750 some variable's values never change. For example,
1751 struct and unions never change values. */
1753 type_changeable (var)
1759 if (CPLUS_FAKE_CHILD (var))
1762 type = get_type (var);
1764 switch (TYPE_CODE (type))
1766 case TYPE_CODE_STRUCT:
1767 case TYPE_CODE_UNION:
1780 c_number_of_children (var)
1784 struct type *target;
1787 type = get_type (var);
1788 target = get_target_type (type);
1791 switch (TYPE_CODE (type))
1793 case TYPE_CODE_ARRAY:
1794 if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (target) > 0
1795 && TYPE_ARRAY_UPPER_BOUND_TYPE (type) != BOUND_CANNOT_BE_DETERMINED)
1796 children = TYPE_LENGTH (type) / TYPE_LENGTH (target);
1801 case TYPE_CODE_STRUCT:
1802 case TYPE_CODE_UNION:
1803 children = TYPE_NFIELDS (type);
1807 /* This is where things get compilcated. All pointers have one child.
1808 Except, of course, for struct and union ptr, which we automagically
1809 dereference for the user and function ptrs, which have no children. */
1810 switch (TYPE_CODE (target))
1812 case TYPE_CODE_STRUCT:
1813 case TYPE_CODE_UNION:
1814 children = TYPE_NFIELDS (target);
1817 case TYPE_CODE_FUNC:
1822 /* Don't dereference char* or void*. */
1823 if (TYPE_NAME (target) != NULL
1824 && (STREQ (TYPE_NAME (target), "char")
1825 || STREQ (TYPE_NAME (target), "void")))
1833 /* Other types have no children */
1841 c_name_of_variable (parent)
1842 struct varobj *parent;
1844 return savestring (parent->name, strlen (parent->name));
1848 c_name_of_child (parent, index)
1849 struct varobj *parent;
1853 struct type *target;
1857 type = get_type (parent);
1858 target = get_target_type (type);
1860 switch (TYPE_CODE (type))
1862 case TYPE_CODE_ARRAY:
1864 /* We never get here unless parent->num_children is greater than 0... */
1866 while ((int) pow ((double) 10, (double) len) < index)
1868 name = (char *) xmalloc (1 + len * sizeof (char));
1869 sprintf (name, "%d", index);
1873 case TYPE_CODE_STRUCT:
1874 case TYPE_CODE_UNION:
1875 string = TYPE_FIELD_NAME (type, index);
1876 name = savestring (string, strlen (string));
1880 switch (TYPE_CODE (target))
1882 case TYPE_CODE_STRUCT:
1883 case TYPE_CODE_UNION:
1884 string = TYPE_FIELD_NAME (target, index);
1885 name = savestring (string, strlen (string));
1889 name = (char *) xmalloc ((strlen (parent->name) + 2) * sizeof (char));
1890 sprintf (name, "*%s", parent->name);
1896 /* This should not happen */
1897 name = xstrdup ("???");
1904 c_value_of_root (var_handle)
1905 struct varobj **var_handle;
1908 struct varobj *var = *var_handle;
1909 struct frame_info *fi;
1912 /* Only root variables can be updated... */
1913 if (var->root->rootvar != var)
1914 /* Not a root var */
1918 /* Determine whether the variable is still around. */
1919 if (var->root->valid_block == NULL)
1923 reinit_frame_cache ();
1926 fi = find_frame_addr_in_frame_chain (var->root->frame);
1928 within_scope = fi != NULL;
1929 /* FIXME: select_frame could fail */
1931 select_frame (fi, -1);
1936 /* We need to catch errors here, because if evaluate
1937 expression fails we just want to make val->error = 1 and
1939 if (gdb_evaluate_expression (var->root->exp, &new_val))
1941 if (VALUE_LAZY (new_val))
1943 /* We need to catch errors because if
1944 value_fetch_lazy fails we still want to continue
1945 (after making val->error = 1) */
1946 /* FIXME: Shouldn't be using VALUE_CONTENTS? The
1947 comment on value_fetch_lazy() says it is only
1948 called from the macro... */
1949 if (!gdb_value_fetch_lazy (new_val))
1958 release_value (new_val);
1966 c_value_of_child (parent, index)
1967 struct varobj *parent;
1970 value_ptr value, temp, indval;
1971 struct type *type, *target;
1974 type = get_type (parent);
1975 target = get_target_type (type);
1976 name = name_of_child (parent, index);
1977 temp = parent->value;
1982 switch (TYPE_CODE (type))
1984 case TYPE_CODE_ARRAY:
1986 /* This breaks if the array lives in a (vector) register. */
1987 value = value_slice (temp, index, 1);
1988 temp = value_coerce_array (value);
1989 gdb_value_ind (temp, &value);
1991 indval = value_from_longest (builtin_type_int, (LONGEST) index);
1992 gdb_value_subscript (temp, indval, &value);
1996 case TYPE_CODE_STRUCT:
1997 case TYPE_CODE_UNION:
1998 value = value_struct_elt (&temp, NULL, name, NULL, "vstructure");
2002 switch (TYPE_CODE (target))
2004 case TYPE_CODE_STRUCT:
2005 case TYPE_CODE_UNION:
2006 value = value_struct_elt (&temp, NULL, name, NULL, "vstructure");
2010 gdb_value_ind (temp, &value);
2021 release_value (value);
2026 static struct type *
2027 c_type_of_child (parent, index)
2028 struct varobj *parent;
2032 char *name = name_of_child (parent, index);
2034 switch (TYPE_CODE (parent->type))
2036 case TYPE_CODE_ARRAY:
2037 type = TYPE_TARGET_TYPE (parent->type);
2040 case TYPE_CODE_STRUCT:
2041 case TYPE_CODE_UNION:
2042 type = lookup_struct_elt_type (parent->type, name, 0);
2046 switch (TYPE_CODE (TYPE_TARGET_TYPE (parent->type)))
2048 case TYPE_CODE_STRUCT:
2049 case TYPE_CODE_UNION:
2050 type = lookup_struct_elt_type (parent->type, name, 0);
2054 type = TYPE_TARGET_TYPE (parent->type);
2060 /* This should not happen as only the above types have children */
2061 warning ("Child of parent whose type does not allow children");
2062 /* FIXME: Can we still go on? */
2071 c_variable_editable (var)
2074 switch (TYPE_CODE (get_type (var)))
2076 case TYPE_CODE_STRUCT:
2077 case TYPE_CODE_UNION:
2078 case TYPE_CODE_ARRAY:
2079 case TYPE_CODE_FUNC:
2080 case TYPE_CODE_MEMBER:
2081 case TYPE_CODE_METHOD:
2092 c_value_of_variable (var)
2098 if (var->value != NULL)
2102 /* This can happen if we attempt to get the value of a struct
2103 member when the parent is an invalid pointer. */
2104 return xstrdup ("???");
2107 /* BOGUS: if val_print sees a struct/class, it will print out its
2108 children instead of "{...}" */
2109 type = get_type (var);
2110 switch (TYPE_CODE (type))
2112 case TYPE_CODE_STRUCT:
2113 case TYPE_CODE_UNION:
2114 return xstrdup ("{...}");
2117 case TYPE_CODE_ARRAY:
2120 sprintf (number, "[%d]", var->num_children);
2121 return xstrdup (number);
2128 struct ui_file *stb = mem_fileopen ();
2129 struct cleanup *old_chain = make_cleanup_ui_file_delete (stb);
2132 if (VALUE_LAZY (val))
2133 gdb_value_fetch_lazy (val);
2134 val_print (VALUE_TYPE (val), VALUE_CONTENTS_RAW (val), 0,
2135 VALUE_ADDRESS (val),
2136 stb, format_code[(int) var->format], 1, 0, 0);
2137 thevalue = ui_file_xstrdup (stb, &dummy);
2138 do_cleanups (old_chain);
2149 cplus_number_of_children (var)
2153 int children, dont_know;
2158 if (!CPLUS_FAKE_CHILD (var))
2160 type = get_type_deref (var);
2162 if (((TYPE_CODE (type)) == TYPE_CODE_STRUCT) ||
2163 ((TYPE_CODE (type)) == TYPE_CODE_UNION))
2167 cplus_class_num_children (type, kids);
2168 if (kids[v_public] != 0)
2170 if (kids[v_private] != 0)
2172 if (kids[v_protected] != 0)
2175 /* Add any baseclasses */
2176 children += TYPE_N_BASECLASSES (type);
2179 /* FIXME: save children in var */
2186 type = get_type_deref (var->parent);
2188 cplus_class_num_children (type, kids);
2189 if (STREQ (var->name, "public"))
2190 children = kids[v_public];
2191 else if (STREQ (var->name, "private"))
2192 children = kids[v_private];
2194 children = kids[v_protected];
2199 children = c_number_of_children (var);
2204 /* Compute # of public, private, and protected variables in this class.
2205 That means we need to descend into all baseclasses and find out
2206 how many are there, too. */
2208 cplus_class_num_children (type, children)
2214 children[v_public] = 0;
2215 children[v_private] = 0;
2216 children[v_protected] = 0;
2218 for (i = TYPE_N_BASECLASSES (type); i < TYPE_NFIELDS (type); i++)
2220 /* If we have a virtual table pointer, omit it. */
2221 if (TYPE_VPTR_BASETYPE (type) == type
2222 && TYPE_VPTR_FIELDNO (type) == i)
2225 if (TYPE_FIELD_PROTECTED (type, i))
2226 children[v_protected]++;
2227 else if (TYPE_FIELD_PRIVATE (type, i))
2228 children[v_private]++;
2230 children[v_public]++;
2235 cplus_name_of_variable (parent)
2236 struct varobj *parent;
2238 return c_name_of_variable (parent);
2242 cplus_name_of_child (parent, index)
2243 struct varobj *parent;
2250 if (CPLUS_FAKE_CHILD (parent))
2252 /* Looking for children of public, private, or protected. */
2253 type = get_type_deref (parent->parent);
2256 type = get_type_deref (parent);
2259 switch (TYPE_CODE (type))
2261 case TYPE_CODE_STRUCT:
2262 case TYPE_CODE_UNION:
2263 cplus_class_num_children (type, children);
2265 if (CPLUS_FAKE_CHILD (parent))
2267 /* FIXME: This assumes that type orders
2268 inherited, public, private, protected */
2269 int i = index + TYPE_N_BASECLASSES (type);
2270 if (STREQ (parent->name, "private") || STREQ (parent->name, "protected"))
2271 i += children[v_public];
2272 if (STREQ (parent->name, "protected"))
2273 i += children[v_private];
2275 name = TYPE_FIELD_NAME (type, i);
2277 else if (index < TYPE_N_BASECLASSES (type))
2278 name = TYPE_FIELD_NAME (type, index);
2281 /* Everything beyond the baseclasses can
2282 only be "public", "private", or "protected" */
2283 index -= TYPE_N_BASECLASSES (type);
2287 if (children[v_public] != 0)
2293 if (children[v_private] != 0)
2299 if (children[v_protected] != 0)
2316 return c_name_of_child (parent, index);
2320 name = savestring (name, strlen (name));
2327 cplus_value_of_root (var_handle)
2328 struct varobj **var_handle;
2330 return c_value_of_root (var_handle);
2334 cplus_value_of_child (parent, index)
2335 struct varobj *parent;
2342 if (CPLUS_FAKE_CHILD (parent))
2343 type = get_type_deref (parent->parent);
2345 type = get_type_deref (parent);
2348 name = name_of_child (parent, index);
2350 if (((TYPE_CODE (type)) == TYPE_CODE_STRUCT) ||
2351 ((TYPE_CODE (type)) == TYPE_CODE_UNION))
2353 if (CPLUS_FAKE_CHILD (parent))
2355 value_ptr temp = parent->parent->value;
2356 value = value_struct_elt (&temp, NULL, name,
2357 NULL, "cplus_structure");
2358 release_value (value);
2360 else if (index >= TYPE_N_BASECLASSES (type))
2362 /* public, private, or protected */
2368 if (parent->value != NULL)
2372 if (TYPE_CODE (VALUE_TYPE (parent->value)) == TYPE_CODE_PTR
2373 || TYPE_CODE (VALUE_TYPE (parent->value)) == TYPE_CODE_REF)
2374 gdb_value_ind (parent->value, &temp);
2376 temp = parent->value;
2378 value = value_cast (TYPE_FIELD_TYPE (type, index), temp);
2379 release_value (value);
2385 return c_value_of_child (parent, index);
2390 static struct type *
2391 cplus_type_of_child (parent, index)
2392 struct varobj *parent;
2395 struct type *type, *t;
2397 t = get_type_deref (parent);
2399 switch (TYPE_CODE (t))
2401 case TYPE_CODE_STRUCT:
2402 case TYPE_CODE_UNION:
2403 if (index >= TYPE_N_BASECLASSES (t))
2411 type = TYPE_FIELD_TYPE (t, index);
2420 return c_type_of_child (parent, index);
2426 cplus_variable_editable (var)
2429 if (CPLUS_FAKE_CHILD (var))
2432 return c_variable_editable (var);
2436 cplus_value_of_variable (var)
2440 /* If we have one of our special types, don't print out
2442 if (CPLUS_FAKE_CHILD (var))
2443 return xstrdup ("");
2445 return c_value_of_variable (var);
2451 java_number_of_children (var)
2454 return cplus_number_of_children (var);
2458 java_name_of_variable (parent)
2459 struct varobj *parent;
2463 name = cplus_name_of_variable (parent);
2464 /* If the name has "-" in it, it is because we
2465 needed to escape periods in the name... */
2468 while (*p != '\000')
2479 java_name_of_child (parent, index)
2480 struct varobj *parent;
2485 name = cplus_name_of_child (parent, index);
2486 /* Escape any periods in the name... */
2489 while (*p != '\000')
2500 java_value_of_root (var_handle)
2501 struct varobj **var_handle;
2503 return cplus_value_of_root (var_handle);
2507 java_value_of_child (parent, index)
2508 struct varobj *parent;
2511 return cplus_value_of_child (parent, index);
2514 static struct type *
2515 java_type_of_child (parent, index)
2516 struct varobj *parent;
2519 return cplus_type_of_child (parent, index);
2523 java_variable_editable (var)
2526 return cplus_variable_editable (var);
2530 java_value_of_variable (var)
2533 return cplus_value_of_variable (var);
2536 extern void _initialize_varobj (void);
2538 _initialize_varobj (void)
2540 int sizeof_table = sizeof (struct vlist *) * VAROBJ_TABLE_SIZE;
2542 varobj_table = xmalloc (sizeof_table);
2543 memset (varobj_table, 0, sizeof_table);
2546 add_set_cmd ("debugvarobj", class_maintenance, var_zinteger,
2547 (char *) &varobjdebug,
2548 "Set varobj debugging.\n\
2549 When non-zero, varobj debugging is enabled.", &setlist),