Variable objects: references formatting

Vladimir Prus
2006-05-03T09:22:13Z

[-- Attachment #1: Type: text/plain, Size: 504 bytes --]

Hi!
At the moment, when using variable objects to display a struct or a class,
the result of -data-evaluate-expression is "...". However, when displaying
a reference to a class, the result of -data-evaluate-expression is
{}-enclosed list of members and their values.

This disparity does not seem to be reasonable, the attached patch fixes it:

Changelog:

2006-05-03 Vladimir Prus <ghost@cs.msu.su>
varobj.c (c_value_of_variable): Ignore top-level references.

Patch attached.

Thanks,
Volodya

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: varobj_references_to_classes.diff --]
[-- Type: text/x-diff; name="varobj_references_to_classes.diff", Size: 609 bytes --]

Index: varobj.c
===================================================================
RCS file: /cvs/src/src/gdb/varobj.c,v
retrieving revision 1.58
diff -u -r1.58 varobj.c
@@ -2055,8 +2219,14 @@
{
/* BOGUS: if val_print sees a struct/class, it will print out its
children instead of "{...}" */
+ struct type* type = get_type (var);
+ /* Strip top-level references. */
+ while (TYPE_CODE (type) == TYPE_CODE_REF)
+ {
+ type = TYPE_TARGET_TYPE (type);
+ }

- switch (TYPE_CODE (get_type (var)))
+ switch (TYPE_CODE (type))
{