* breakpoint.c (remove_sal): New.
[deliverable/binutils-gdb.git] / gdb / varobj.c
index 1d8c8e8af54b14a9f7d3aa5e529053d79313fdf9..5ea81fa3ef66bb7830a0ad6428864de5198cdfea 100644 (file)
@@ -5,7 +5,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -14,9 +14,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
 #include "exceptions.h"
@@ -101,6 +99,10 @@ struct varobj
   /* NOTE: This is the "expression" */
   char *name;
 
+  /* Alloc'd expression for this child.  Can be used to create a
+     root variable corresponding to this child.  */
+  char *path_expr;
+
   /* The alloc'd name for this variable's object. This is here for
      convenience when constructing this object's children. */
   char *obj_name;
@@ -108,7 +110,9 @@ struct varobj
   /* Index of this variable in its parent or -1 */
   int index;
 
-  /* The type of this variable. This may NEVER be NULL. */
+  /* The type of this variable.  This can be NULL
+     for artifial variable objects -- currently, the "accessibility" 
+     variable objects in C++.  */
   struct type *type;
 
   /* The value of this expression or subexpression.  A NULL value
@@ -137,6 +141,16 @@ struct varobj
 
   /* Last print value.  */
   char *print_value;
+
+  /* Is this variable frozen.  Frozen variables are never implicitly
+     updated by -var-update * 
+     or -var-update <direct-or-indirect-parent>.  */
+  int frozen;
+
+  /* Is the value of this variable intentionally not fetched?  It is
+     not fetched if either the variable is frozen, or any parents is
+     frozen.  */
+  int not_fetched;
 };
 
 struct cpstack
@@ -226,6 +240,8 @@ static char *c_name_of_variable (struct varobj *parent);
 
 static char *c_name_of_child (struct varobj *parent, int index);
 
+static char *c_path_expr_of_child (struct varobj *child);
+
 static struct value *c_value_of_root (struct varobj **var_handle);
 
 static struct value *c_value_of_child (struct varobj *parent, int index);
@@ -246,6 +262,8 @@ static char *cplus_name_of_variable (struct varobj *parent);
 
 static char *cplus_name_of_child (struct varobj *parent, int index);
 
+static char *cplus_path_expr_of_child (struct varobj *child);
+
 static struct value *cplus_value_of_root (struct varobj **var_handle);
 
 static struct value *cplus_value_of_child (struct varobj *parent, int index);
@@ -264,6 +282,8 @@ static char *java_name_of_variable (struct varobj *parent);
 
 static char *java_name_of_child (struct varobj *parent, int index);
 
+static char *java_path_expr_of_child (struct varobj *child);
+
 static struct value *java_value_of_root (struct varobj **var_handle);
 
 static struct value *java_value_of_child (struct varobj *parent, int index);
@@ -291,6 +311,10 @@ struct language_specific
   /* The name of the INDEX'th child of PARENT. */
   char *(*name_of_child) (struct varobj * parent, int index);
 
+  /* Returns the rooted expression of CHILD, which is a variable
+     obtain that has some parent.  */
+  char *(*path_expr_of_child) (struct varobj * child);
+
   /* The ``struct value *'' of the root variable ROOT. */
   struct value *(*value_of_root) (struct varobj ** root_handle);
 
@@ -315,6 +339,7 @@ static struct language_specific languages[vlang_end] = {
    c_number_of_children,
    c_name_of_variable,
    c_name_of_child,
+   c_path_expr_of_child,
    c_value_of_root,
    c_value_of_child,
    c_type_of_child,
@@ -327,6 +352,7 @@ static struct language_specific languages[vlang_end] = {
    c_number_of_children,
    c_name_of_variable,
    c_name_of_child,
+   c_path_expr_of_child,
    c_value_of_root,
    c_value_of_child,
    c_type_of_child,
@@ -339,6 +365,7 @@ static struct language_specific languages[vlang_end] = {
    cplus_number_of_children,
    cplus_name_of_variable,
    cplus_name_of_child,
+   cplus_path_expr_of_child,
    cplus_value_of_root,
    cplus_value_of_child,
    cplus_type_of_child,
@@ -351,6 +378,7 @@ static struct language_specific languages[vlang_end] = {
    java_number_of_children,
    java_name_of_variable,
    java_name_of_child,
+   java_path_expr_of_child,
    java_value_of_root,
    java_value_of_child,
    java_type_of_child,
@@ -434,6 +462,7 @@ varobj_create (char *objname,
       char *p;
       enum varobj_languages lang;
       struct value *value = NULL;
+      int expr_len;
 
       /* Parse and evaluate the expression, filling in as much
          of the variable's data as possible */
@@ -478,7 +507,10 @@ varobj_create (char *objname,
 
       var->format = variable_default_display (var);
       var->root->valid_block = innermost_block;
-      var->name = savestring (expression, strlen (expression));
+      expr_len = strlen (expression);
+      var->name = savestring (expression, expr_len);
+      /* For a root var, the name and the expr are the same.  */
+      var->path_expr = savestring (expression, expr_len);
 
       /* When the frame is different from the current frame, 
          we must select the appropriate frame before parsing
@@ -669,6 +701,26 @@ varobj_get_display_format (struct varobj *var)
   return var->format;
 }
 
+void
+varobj_set_frozen (struct varobj *var, int frozen)
+{
+  /* When a variable is unfrozen, we don't fetch its value.
+     The 'not_fetched' flag remains set, so next -var-update
+     won't complain.
+
+     We don't fetch the value, because for structures the client
+     should do -var-update anyway.  It would be bad to have different
+     client-size logic for structure and other types.  */
+  var->frozen = frozen;
+}
+
+int
+varobj_get_frozen (struct varobj *var)
+{
+  return var->frozen;
+}
+
+
 int
 varobj_get_num_children (struct varobj *var)
 {
@@ -776,6 +828,23 @@ varobj_get_gdb_type (struct varobj *var)
   return var->type;
 }
 
+/* Return a pointer to the full rooted expression of varobj VAR.
+   If it has not been computed yet, compute it.  */
+char *
+varobj_get_path_expr (struct varobj *var)
+{
+  if (var->path_expr != NULL)
+    return var->path_expr;
+  else 
+    {
+      /* For root varobjs, we initialize path_expr
+        when creating varobj, so here it should be
+        child varobj.  */
+      gdb_assert (!is_root_p (var));
+      return (*var->root->lang->path_expr_of_child) (var);
+    }
+}
+
 enum varobj_languages
 varobj_get_language (struct varobj *var)
 {
@@ -915,6 +984,7 @@ install_new_value (struct varobj *var, struct value *value, int initial)
   int changeable;
   int need_to_fetch;
   int changed = 0;
+  int intentionally_not_fetched = 0;
 
   /* We need to know the varobj's type to decide if the value should
      be fetched or not.  C++ fake children (public/protected/private) don't have
@@ -950,7 +1020,20 @@ install_new_value (struct varobj *var, struct value *value, int initial)
      will be lazy, which means we've lost that old value.  */
   if (need_to_fetch && value && value_lazy (value))
     {
-      if (!gdb_value_fetch_lazy (value))
+      struct varobj *parent = var->parent;
+      int frozen = var->frozen;
+      for (; !frozen && parent; parent = parent->parent)
+       frozen |= parent->frozen;
+
+      if (frozen && initial)
+       {
+         /* For variables that are frozen, or are children of frozen
+            variables, we don't do fetch on initial assignment.
+            For non-initial assignemnt we do the fetch, since it means we're
+            explicitly asked to compare the new value with the old one.  */
+         intentionally_not_fetched = 1;
+       }
+      else if (!gdb_value_fetch_lazy (value))
        {
          /* Set the value to NULL, so that for the next -var-update,
             we don't try to compare the new value with this value,
@@ -980,9 +1063,16 @@ install_new_value (struct varobj *var, struct value *value, int initial)
        {
          /* Try to compare the values.  That requires that both
             values are non-lazy.  */
-         
-         /* Quick comparison of NULL values.  */
-         if (var->value == NULL && value == NULL)
+         if (var->not_fetched && value_lazy (var->value))
+           {
+             /* This is a frozen varobj and the value was never read.
+                Presumably, UI shows some "never read" indicator.
+                Now that we've fetched the real value, we need to report
+                this varobj as changed so that UI can show the real
+                value.  */
+             changed = 1;
+           }
+          else  if (var->value == NULL && value == NULL)
            /* Equal. */
            ;
          else if (var->value == NULL || value == NULL)
@@ -1012,9 +1102,13 @@ install_new_value (struct varobj *var, struct value *value, int initial)
     }
 
   /* We must always keep the new value, since children depend on it.  */
-  if (var->value != NULL)
+  if (var->value != NULL && var->value != value)
     value_free (var->value);
   var->value = value;
+  if (value && value_lazy (value) && intentionally_not_fetched)
+    var->not_fetched = 1;
+  else
+    var->not_fetched = 0;
   var->updated = 0;
 
   gdb_assert (!var->value || value_type (var->value));
@@ -1031,17 +1125,21 @@ install_new_value (struct varobj *var, struct value *value, int initial)
     < 0 for error values, see varobj.h.
     Otherwise it is the number of children + parent changed.
 
-   Only root variables can be updated... 
+   The EXPLICIT parameter specifies if this call is result
+   of MI request to update this specific variable, or 
+   result of implicit -var-update *. For implicit request, we don't
+   update frozen variables.
 
    NOTE: This function may delete the caller's varobj. If it
    returns TYPE_CHANGED, then it has done this and VARP will be modified
    to point to the new varobj.  */
 
 int
-varobj_update (struct varobj **varp, struct varobj ***changelist)
+varobj_update (struct varobj **varp, struct varobj ***changelist,
+              int explicit)
 {
   int changed = 0;
-  int type_changed;
+  int type_changed = 0;
   int i;
   int vleft;
   struct varobj *v;
@@ -1056,48 +1154,56 @@ varobj_update (struct varobj **varp, struct varobj ***changelist)
   /* sanity check: have we been passed a pointer?  */
   gdb_assert (changelist);
 
-  if (!is_root_p (*varp))
-    error (_("Only root variables can be updated"));
+  /* Frozen means frozen -- we don't check for any change in
+     this varobj, including its going out of scope, or
+     changing type.  One use case for frozen varobjs is
+     retaining previously evaluated expressions, and we don't
+     want them to be reevaluated at all.  */
+  if (!explicit && (*varp)->frozen)
+    return 0;
 
   if (!(*varp)->root->is_valid)
     return INVALID;
 
-  /* Save the selected stack frame, since we will need to change it
-     in order to evaluate expressions.  */
-  old_fid = get_frame_id (deprecated_safe_get_selected_frame ());
-
-  /* Update the root variable. value_of_root can return NULL
-     if the variable is no longer around, i.e. we stepped out of
-     the frame in which a local existed. We are letting the 
-     value_of_root variable dispose of the varobj if the type
-     has changed.  */
-  type_changed = 1;
-  new = value_of_root (varp, &type_changed);
-
-  /* Restore selected frame.  */
-  fi = frame_find_by_id (old_fid);
-  if (fi)
-    select_frame (fi);
-
-  /* If this is a "use_selected_frame" varobj, and its type has changed,
-     them note that it's changed.  */
-  if (type_changed)
-    VEC_safe_push (varobj_p, result, *varp);
-
-  if (install_new_value ((*varp), new, type_changed))
+  if ((*varp)->root->rootvar == *varp)
     {
-      /* If type_changed is 1, install_new_value will never return
-        non-zero, so we'll never report the same variable twice.  */
-      gdb_assert (!type_changed);
-      VEC_safe_push (varobj_p, result, *varp);
-    }
+      /* Save the selected stack frame, since we will need to change it
+        in order to evaluate expressions.  */
+      old_fid = get_frame_id (deprecated_safe_get_selected_frame ());
+      
+      /* Update the root variable. value_of_root can return NULL
+        if the variable is no longer around, i.e. we stepped out of
+        the frame in which a local existed. We are letting the 
+        value_of_root variable dispose of the varobj if the type
+        has changed.  */
+      type_changed = 1;
+      new = value_of_root (varp, &type_changed);
+
+      /* Restore selected frame.  */
+      fi = frame_find_by_id (old_fid);
+      if (fi)
+       select_frame (fi);
+      
+      /* If this is a "use_selected_frame" varobj, and its type has changed,
+        them note that it's changed.  */
+      if (type_changed)
+       VEC_safe_push (varobj_p, result, *varp);
+      
+        if (install_new_value ((*varp), new, type_changed))
+         {
+           /* If type_changed is 1, install_new_value will never return
+              non-zero, so we'll never report the same variable twice.  */
+           gdb_assert (!type_changed);
+           VEC_safe_push (varobj_p, result, *varp);
+         }
 
-  if (new == NULL)
-    {
-      /* This means the varobj itself is out of scope.
-        Report it.  */
-      VEC_free (varobj_p, result);
-      return NOT_IN_SCOPE;
+      if (new == NULL)
+       {
+         /* This means the varobj itself is out of scope.
+            Report it.  */
+         VEC_free (varobj_p, result);
+         return NOT_IN_SCOPE;
+       }
     }
 
   VEC_safe_push (varobj_p, stack, *varp);
@@ -1115,13 +1221,13 @@ varobj_update (struct varobj **varp, struct varobj ***changelist)
        {
          varobj_p c = VEC_index (varobj_p, v->children, i);
          /* Child may be NULL if explicitly deleted by -var-delete.  */
-         if (c != NULL)
+         if (c != NULL && !c->frozen)
            VEC_safe_push (varobj_p, stack, c);
        }
 
       /* Update this variable, unless it's a root, which is already
         updated.  */
-      if (v != *varp)
+      if (v->root->rootvar != v)
        {         
          new = value_of_child (v->parent, v->index);
          if (install_new_value (v, new, 0 /* type not changed */))
@@ -1392,6 +1498,7 @@ new_variable (void)
 
   var = (struct varobj *) xmalloc (sizeof (struct varobj));
   var->name = NULL;
+  var->path_expr = NULL;
   var->obj_name = NULL;
   var->index = -1;
   var->type = NULL;
@@ -1403,6 +1510,8 @@ new_variable (void)
   var->root = NULL;
   var->updated = 0;
   var->print_value = NULL;
+  var->frozen = 0;
+  var->not_fetched = 0;
 
   return var;
 }
@@ -1438,6 +1547,7 @@ free_variable (struct varobj *var)
   xfree (var->name);
   xfree (var->obj_name);
   xfree (var->print_value);
+  xfree (var->path_expr);
   xfree (var);
 }
 
@@ -1641,13 +1751,14 @@ value_of_root (struct varobj **var_handle, int *type_changed)
     {
       struct varobj *tmp_var;
       char *old_type, *new_type;
-      old_type = varobj_get_type (var);
+
       tmp_var = varobj_create (NULL, var->name, (CORE_ADDR) 0,
                               USE_SELECTED_FRAME);
       if (tmp_var == NULL)
        {
          return NULL;
        }
+      old_type = varobj_get_type (var);
       new_type = varobj_get_type (tmp_var);
       if (strcmp (old_type, new_type) == 0)
        {
@@ -1671,6 +1782,8 @@ value_of_root (struct varobj **var_handle, int *type_changed)
          var = *var_handle;
          *type_changed = 1;
        }
+      xfree (old_type);
+      xfree (new_type);
     }
   else
     {
@@ -1775,13 +1888,21 @@ varobj_value_is_changeable_p (struct varobj *var)
    Both TYPE and *TYPE should be non-null. VALUE
    can be null if we want to only translate type.
    *VALUE can be null as well -- if the parent
-   value is not known.  */
+   value is not known.  
+
+   If WAS_PTR is not NULL, set *WAS_PTR to 0 or 1
+   depending on whether pointer was deferenced
+   in this function.  */
 static void
 adjust_value_for_child_access (struct value **value,
-                                 struct type **type)
+                                 struct type **type,
+                                 int *was_ptr)
 {
   gdb_assert (type && *type);
 
+  if (was_ptr)
+    *was_ptr = 0;
+
   *type = check_typedef (*type);
   
   /* The type of value stored in varobj, that is passed
@@ -1802,6 +1923,8 @@ adjust_value_for_child_access (struct value **value,
          if (value && *value)
            gdb_value_ind (*value, value);        
          *type = target_type;
+         if (was_ptr)
+           *was_ptr = 1;
        }
     }
 
@@ -1818,7 +1941,7 @@ c_number_of_children (struct varobj *var)
   int children = 0;
   struct type *target;
 
-  adjust_value_for_child_access (NULL, &type);
+  adjust_value_for_child_access (NULL, &type, NULL);
   target = get_target_type (type);
 
   switch (TYPE_CODE (type))
@@ -1914,10 +2037,13 @@ value_struct_element_index (struct value *value, int type_index)
    to NULL.  */
 static void 
 c_describe_child (struct varobj *parent, int index,
-                 char **cname, struct value **cvalue, struct type **ctype)
+                 char **cname, struct value **cvalue, struct type **ctype,
+                 char **cfull_expression)
 {
   struct value *value = parent->value;
   struct type *type = get_value_type (parent);
+  char *parent_expression = NULL;
+  int was_ptr;
 
   if (cname)
     *cname = NULL;
@@ -1925,8 +2051,12 @@ c_describe_child (struct varobj *parent, int index,
     *cvalue = NULL;
   if (ctype)
     *ctype = NULL;
-
-  adjust_value_for_child_access (&value, &type);
+  if (cfull_expression)
+    {
+      *cfull_expression = NULL;
+      parent_expression = varobj_get_path_expr (parent);
+    }
+  adjust_value_for_child_access (&value, &type, &was_ptr);
       
   switch (TYPE_CODE (type))
     {
@@ -1946,6 +2076,12 @@ c_describe_child (struct varobj *parent, int index,
       if (ctype)
        *ctype = get_target_type (type);
 
+      if (cfull_expression)
+       *cfull_expression = xstrprintf ("(%s)[%d]", parent_expression, 
+                                       index
+                                       + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)));
+
+
       break;
 
     case TYPE_CODE_STRUCT:
@@ -1965,6 +2101,13 @@ c_describe_child (struct varobj *parent, int index,
       if (ctype)
        *ctype = TYPE_FIELD_TYPE (type, index);
 
+      if (cfull_expression)
+       {
+         char *join = was_ptr ? "->" : ".";
+         *cfull_expression = xstrprintf ("(%s)%s%s", parent_expression, join,
+                                         TYPE_FIELD_NAME (type, index));
+       }
+
       break;
 
     case TYPE_CODE_PTR:
@@ -1979,6 +2122,9 @@ c_describe_child (struct varobj *parent, int index,
         declared type of the variable.  */
       if (ctype)
        *ctype = TYPE_TARGET_TYPE (type);
+
+      if (cfull_expression)
+       *cfull_expression = xstrprintf ("*(%s)", parent_expression);
       
       break;
 
@@ -1986,6 +2132,8 @@ c_describe_child (struct varobj *parent, int index,
       /* This should not happen */
       if (cname)
        *cname = xstrdup ("???");
+      if (cfull_expression)
+       *cfull_expression = xstrdup ("???");
       /* Don't set value and type, we don't know then. */
     }
 }
@@ -1994,10 +2142,18 @@ static char *
 c_name_of_child (struct varobj *parent, int index)
 {
   char *name;
-  c_describe_child (parent, index, &name, NULL, NULL);
+  c_describe_child (parent, index, &name, NULL, NULL, NULL);
   return name;
 }
 
+static char *
+c_path_expr_of_child (struct varobj *child)
+{
+  c_describe_child (child->parent, child->index, NULL, NULL, NULL, 
+                   &child->path_expr);
+  return child->path_expr;
+}
+
 static struct value *
 c_value_of_root (struct varobj **var_handle)
 {
@@ -2046,7 +2202,7 @@ static struct value *
 c_value_of_child (struct varobj *parent, int index)
 {
   struct value *value = NULL;
-  c_describe_child (parent, index, NULL, &value, NULL);
+  c_describe_child (parent, index, NULL, &value, NULL, NULL);
 
   return value;
 }
@@ -2055,7 +2211,7 @@ static struct type *
 c_type_of_child (struct varobj *parent, int index)
 {
   struct type *type = NULL;
-  c_describe_child (parent, index, NULL, NULL, &type);
+  c_describe_child (parent, index, NULL, NULL, &type, NULL);
   return type;
 }
 
@@ -2116,6 +2272,12 @@ c_value_of_variable (struct varobj *var)
          }
        else
          {
+           if (var->not_fetched && value_lazy (var->value))
+             /* Frozen variable and no value yet.  We don't
+                implicitly fetch the value.  MI response will
+                use empty string for the value, which is OK.  */
+             return NULL;
+
            gdb_assert (varobj_value_is_changeable_p (var));
            gdb_assert (!value_lazy (var->value));
            return value_get_print_value (var->value, var->format);
@@ -2139,7 +2301,7 @@ cplus_number_of_children (struct varobj *var)
   if (!CPLUS_FAKE_CHILD (var))
     {
       type = get_value_type (var);
-      adjust_value_for_child_access (NULL, &type);
+      adjust_value_for_child_access (NULL, &type, NULL);
 
       if (((TYPE_CODE (type)) == TYPE_CODE_STRUCT) ||
          ((TYPE_CODE (type)) == TYPE_CODE_UNION))
@@ -2166,7 +2328,7 @@ cplus_number_of_children (struct varobj *var)
       int kids[3];
 
       type = get_value_type (var->parent);
-      adjust_value_for_child_access (NULL, &type);
+      adjust_value_for_child_access (NULL, &type, NULL);
 
       cplus_class_num_children (type, kids);
       if (strcmp (var->name, "public") == 0)
@@ -2237,11 +2399,14 @@ match_accessibility (struct type *type, int index, enum accessibility acc)
 
 static void
 cplus_describe_child (struct varobj *parent, int index,
-                     char **cname, struct value **cvalue, struct type **ctype)
+                     char **cname, struct value **cvalue, struct type **ctype,
+                     char **cfull_expression)
 {
-  char *name = 0;
+  char *name = NULL;
   struct value *value;
   struct type *type;
+  int was_ptr;
+  char *parent_expression = NULL;
 
   if (cname)
     *cname = NULL;
@@ -2249,24 +2414,30 @@ cplus_describe_child (struct varobj *parent, int index,
     *cvalue = NULL;
   if (ctype)
     *ctype = NULL;
-
+  if (cfull_expression)
+    *cfull_expression = NULL;
 
   if (CPLUS_FAKE_CHILD (parent))
     {
       value = parent->parent->value;
       type = get_value_type (parent->parent);
+      if (cfull_expression)
+       parent_expression = varobj_get_path_expr (parent->parent);
     }
   else
     {
       value = parent->value;
       type = get_value_type (parent);
+      if (cfull_expression)
+       parent_expression = varobj_get_path_expr (parent);
     }
 
-  adjust_value_for_child_access (&value, &type);
+  adjust_value_for_child_access (&value, &type, &was_ptr);
 
   if (TYPE_CODE (type) == TYPE_CODE_STRUCT
       || TYPE_CODE (type) == TYPE_CODE_STRUCT)
     {
+      char *join = was_ptr ? "->" : ".";
       if (CPLUS_FAKE_CHILD (parent))
        {
          /* The fields of the class type are ordered as they
@@ -2301,6 +2472,11 @@ cplus_describe_child (struct varobj *parent, int index,
 
          if (ctype)
            *ctype = TYPE_FIELD_TYPE (type, type_index);
+
+         if (cfull_expression)
+           *cfull_expression = xstrprintf ("((%s)%s%s)", parent_expression,
+                                           join, 
+                                           TYPE_FIELD_NAME (type, type_index));
        }
       else if (index < TYPE_N_BASECLASSES (type))
        {
@@ -2311,16 +2487,34 @@ cplus_describe_child (struct varobj *parent, int index,
          if (cvalue && value)
            {
              *cvalue = value_cast (TYPE_FIELD_TYPE (type, index), value);
+             release_value (*cvalue);
            }
 
          if (ctype)
            {
              *ctype = TYPE_FIELD_TYPE (type, index);
            }
+
+         if (cfull_expression)
+           {
+             char *ptr = was_ptr ? "*" : "";
+             /* Cast the parent to the base' type. Note that in gdb,
+                expression like 
+                        (Base1)d
+                will create an lvalue, for all appearences, so we don't
+                need to use more fancy:
+                        *(Base1*)(&d)
+                construct.  */
+             *cfull_expression = xstrprintf ("(%s(%s%s) %s)", 
+                                             ptr, 
+                                             TYPE_FIELD_NAME (type, index),
+                                             ptr,
+                                             parent_expression);
+           }
        }
       else
        {
-         char *access = 0;
+         char *access = NULL;
          int children[3];
          cplus_class_num_children (type, children);
 
@@ -2359,16 +2553,17 @@ cplus_describe_child (struct varobj *parent, int index,
              /* error! */
              break;
            }
-         
+
+         gdb_assert (access);
          if (cname)
            *cname = xstrdup (access);
 
-         /* Value and type are null here.  */
+         /* Value and type and full expression are null here.  */
        }
     }
   else
     {
-      c_describe_child (parent, index, cname, cvalue, ctype);
+      c_describe_child (parent, index, cname, cvalue, ctype, cfull_expression);
     }  
 }
 
@@ -2376,10 +2571,18 @@ static char *
 cplus_name_of_child (struct varobj *parent, int index)
 {
   char *name = NULL;
-  cplus_describe_child (parent, index, &name, NULL, NULL);
+  cplus_describe_child (parent, index, &name, NULL, NULL, NULL);
   return name;
 }
 
+static char *
+cplus_path_expr_of_child (struct varobj *child)
+{
+  cplus_describe_child (child->parent, child->index, NULL, NULL, NULL, 
+                       &child->path_expr);
+  return child->path_expr;
+}
+
 static struct value *
 cplus_value_of_root (struct varobj **var_handle)
 {
@@ -2390,7 +2593,7 @@ static struct value *
 cplus_value_of_child (struct varobj *parent, int index)
 {
   struct value *value = NULL;
-  cplus_describe_child (parent, index, NULL, &value, NULL);
+  cplus_describe_child (parent, index, NULL, &value, NULL, NULL);
   return value;
 }
 
@@ -2398,7 +2601,7 @@ static struct type *
 cplus_type_of_child (struct varobj *parent, int index)
 {
   struct type *type = NULL;
-  cplus_describe_child (parent, index, NULL, NULL, &type);
+  cplus_describe_child (parent, index, NULL, NULL, &type, NULL);
   return type;
 }
 
@@ -2470,6 +2673,12 @@ java_name_of_child (struct varobj *parent, int index)
   return name;
 }
 
+static char *
+java_path_expr_of_child (struct varobj *child)
+{
+  return NULL;
+}
+
 static struct value *
 java_value_of_root (struct varobj **var_handle)
 {
This page took 0.033546 seconds and 4 git commands to generate.