This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]