Re: [PATCH] -var-update

Nick Roberts
2006-05-19T05:11:53Z

> I do not quite understand why coerce_array is used; I suspect the
> contents of an array are checked via the children instead of the
> parent. coerce_array happens to also call coerce_ref.

Maybe it's historical, as varobj_update used value_equal previously and this
uses coerce_array.

Anyway here's a patch that actually seems to work. I've taken code from
c_val_print. Maybe there should be more checks and I've not tested
varobj_set_value (-var-assign) yet, but I thought I'd sound out the genaral
approcah first.

--
Nick http://www.inet.net.nz/~nickrob

*** varobj.c 19 May 2006 11:37:28 +1200 1.60
--- varobj.c 19 May 2006 16:27:29 +1200
*************** varobj_create (char *objname,
*** 517,522 ****
--- 517,532 ----

var->type = value_type (var->value);

+ if (TYPE_CODE (var->type) == TYPE_CODE_REF)
+ {
+ var->value = value_at (TYPE_TARGET_TYPE (var->type),
+ unpack_pointer
+ (lookup_pointer_type (builtin_type_void),
+ value_contents_all (var->value)
+ + value_embedded_offset (var->value)));
+ release_value (var->value);
+ }
+
/* Set language info */
lang = variable_language (var);
var->root->lang = languages[lang];
*************** varobj_set_value (struct varobj *var, ch
*** 825,830 ****
--- 835,847 ----
return 0;
}

+ if (TYPE_CODE (var->type) == TYPE_CODE_REF)
+ value = value_at (TYPE_TARGET_TYPE (var->type),
+ unpack_pointer
+ (lookup_pointer_type (builtin_type_void),
+ value_contents_all (value)
+ + value_embedded_offset (value)));
+
if (!my_value_equal (var->value, value, &error))
var->updated = 1;
if (!gdb_value_assign (var->value, value, &val))
*************** c_value_of_root (struct varobj **var_han
*** 1915,1920 ****
--- 1932,1944 ----
else
var->error = 1;

+ if (TYPE_CODE (var->type) == TYPE_CODE_REF)
+ new_val = value_at (TYPE_TARGET_TYPE (var->type),
+ unpack_pointer
+ (lookup_pointer_type (builtin_type_void),
+ value_contents_all (new_val)
+ + value_embedded_offset (new_val)));
+
release_value (new_val);
return new_val;
}