Re: MI: fix base members in references

Jim Blandy
2006-12-05T21:32:37Z

Vladimir Prus <ghost@cs.msu.su> writes:
> *PING*? This is one-liner, and causes no regressions, so should be
> non-controversial.

(By the way --- it's handy to include a link to the post with the
patch, or ideally the patch itself.)

Here's the original patch:

Index: varobj.c
===================================================================
RCS file: /cvs/src/src/gdb/varobj.c,v
retrieving revision 1.62
diff -u -p -r1.62 varobj.c
--- varobj.c 29 Nov 2006 06:41:13 -0000 1.62
+++ varobj.c 29 Nov 2006 12:51:53 -0000
@@ -2428,8 +2428,9 @@ cplus_value_of_child (struct varobj *par
{
struct value *temp = NULL;

+ /* No special processing for references is needed --
+ value_cast below handles references. */
if (TYPE_CODE (value_type (parent->value)) == TYPE_CODE_PTR
- || TYPE_CODE (value_type (parent->value)) == TYPE_CODE_REF)
{
if (!gdb_value_ind (parent->value, &temp))
return NULL;

How should this behave if parent->value is a reference to a pointer?
Shouldn't it follow the ref, and then behave the same as when it's a
pointer? If so, then the fix would be something like this instead
(not that I understand this code):

*** varobj.c 29 Nov 2006 15:47:40 -0800 1.62
--- varobj.c 05 Dec 2006 13:31:51 -0800
***************
*** 2426,2441 ****
/* Baseclass */
if (parent->value != NULL)
{
! struct value *temp = NULL;

! if (TYPE_CODE (value_type (parent->value)) == TYPE_CODE_PTR
! || TYPE_CODE (value_type (parent->value)) == TYPE_CODE_REF)
{
! if (!gdb_value_ind (parent->value, &temp))
return NULL;
}
- else
- temp = parent->value;

if (temp != NULL)
{
--- 2426,2439 ----
/* Baseclass */
if (parent->value != NULL)
{
! struct value *temp = coerce_ref (parent->value);

! if (TYPE_CODE (value_type (temp)) == TYPE_CODE_PTR
! || TYPE_CODE (value_type (temp)) == TYPE_CODE_REF)
{
! if (!gdb_value_ind (temp, &temp))
return NULL;
}

if (temp != NULL)
{