This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [Patch] -var-evaluate-expression NAME [FORMAT]
> > What happens if you just use value_get_print_value (var->value,
> > var->format) directly in mi_cmd_var_evaluate_expression instead of
> > varobj_get_value (var)?
>
> This won't work, because it bypassed all the logic done between the call to
> varobj_get_value() and the one to value_get_print_value(); such things as
> returning "{...}" for structs and unions, returning "[numChildren]" for
> arrays; it would also bypass the checks for var->value == NULL, and
> value_lazy(), etc.
I didn't mean use value_get_print_value in all cases but something like:
if (formatFound && varobj_value_is_changeable_p (var))
ui_out_field_string (uiout, "value",
value_get_print_value (varobj_get_struct_value (var),
format));
else
ui_out_field_string (uiout, "value", varobj_get_value (var));
where varobj_get_struct_value is defined in varobj.c as:
struct value *
varobj_get_struct_value (struct varobj *var)
{
return var->value;
}
I've not checked all the details and it might need tweaking. If
var->value == NULL, I think you just get a null string:
-var-evaluate-expression var1
^done,value=""
If varobj_value_is_changeable_p is t and the value not NULL, I don't think the
value can be lazy etc.
--
Nick http://www.inet.net.nz/~nickrob