This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [Patch] -var-evaluate-expression NAME [FORMAT]
- From: "Marc Khouzam" <marc dot khouzam at ericsson dot com>
- To: "Nick Roberts" <nickrob at snap dot net dot nz>
- Cc: "Daniel Jacobowitz" <drow at false dot org>, <gdb-patches at sourceware dot org>
- Date: Tue, 5 Feb 2008 15:54:38 -0500
- Subject: RE: [Patch] -var-evaluate-expression NAME [FORMAT]
You don't like my new patch? :-)
I feels less risky (and it's cleaner than
my orginal one.)
My hesitation with your suggestion is that it
seems more risky to forget a case, and that it
is not as future-proof because it duplicates
some logic in mi-var-cmd and varobj.
Marc
-----Original Message-----
From: Nick Roberts [mailto:nickrob@snap.net.nz]
Sent: Tuesday, February 05, 2008 3:43 PM
To: Marc Khouzam
Cc: Daniel Jacobowitz; gdb-patches@sourceware.org
Subject: 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