Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Re: MI: fix base members in references
@ 2006-12-09 21:27 Nick Roberts
  2006-12-09 21:38 ` Vladimir Prus
  0 siblings, 1 reply; 33+ messages in thread
From: Nick Roberts @ 2006-12-09 21:27 UTC (permalink / raw)
  To: Vladimir Prus; +Cc: gdb-patches


> > The patch below seems to fix it for me.  Its a diff on 1.63 _with_ your
> > yet to be committed changes.

> I would have preferred if instead of adding if, the code was modified to
> look at

>         value_type (var->value)

> as opposed to

>         var->type

I'm not sure that I follow your point.  The patch just gets the target type,
after dereferencing, in the case of a pointer.

> The latter is the type of the varobj expression as it is in source program.
> The former is the value we're actually showing. It makes sense to use
> value_type (var->value) for all presentation purposes.

The former appears to be a type also (not a value).

> > Since we have been the only two people directly contributing to for a
> > while now MI, and as it would stop the patches piling up, perhaps Vladimir
> > (if
> > interested) 

> I don't very well understand maintainership structure in gdb, but I would
> surely appreciate a permission to commit MI patches directly. 

Well it also carries the responsibility of reviewing other peoples patches :-)


-- 
Nick                                           http://www.inet.net.nz/~nickrob


^ permalink raw reply	[flat|nested] 33+ messages in thread
* MI: fix base members in references
@ 2006-11-29 12:56 Vladimir Prus
  2006-12-05 13:23 ` Vladimir Prus
  2006-12-05 20:45 ` Daniel Jacobowitz
  0 siblings, 2 replies; 33+ messages in thread
From: Vladimir Prus @ 2006-11-29 12:56 UTC (permalink / raw)
  To: gdb-patches

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


A KDevelop user reported the following bug. If you have C++ reference variable 
that refers to a class type, and that class has bases, gdb is not able to 
show the values of any fields of bases. The trimmed down example is this:

	struct S { int i; int j; };
	struct S2 : S {};
	
	int foo(S2& s)
	{
		return s.i;
	}
	
	int main()
	{
		S2 s;
		s.i = 1;
		s.j = 2;
		return foo(s);
	}

If you are in 'foo' and try to create MI variable objects for s, and navigate 
it, the varobjs for 'i' and 'j' members of the base class will have no value.

The problem happens when creating varobj for the base object. MI sees that 
it's reference and tries to pass it via value_ind. The latter immediately 
removes top-level reference and rightly refuses to deference a structure.

MI should just do nothing about references -- the value_cast function used to
obtain base handles references just fine.

The attached patch fixed the problem, no regression. I'll write a testcase for 
it as soon as my previous references patch is reviewed -- I don't want to 
pile too many testcases in as-yet-uncommitted file.

OK?

If this patch is fine, can I also commit it to 6.6 branch? The bug in question 
is quite problematic for C++ code.

- Volodya




[-- Attachment #2: 01REFERENCES_AND_BASES.diff --]
[-- Type: text/x-diff, Size: 679 bytes --]

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;

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2006-12-11  8:03 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-09 21:27 MI: fix base members in references Nick Roberts
2006-12-09 21:38 ` Vladimir Prus
2006-12-09 21:50   ` Nick Roberts
2006-12-09 22:15     ` Vladimir Prus
2006-12-10  4:19       ` Nick Roberts
2006-12-10 11:24         ` Vladimir Prus
2006-12-10 20:09           ` Nick Roberts
2006-12-10 20:42         ` Daniel Jacobowitz
2006-12-10 21:20           ` Nick Roberts
2006-12-11  2:35             ` Daniel Jacobowitz
2006-12-11  5:58               ` Nick Roberts
2006-12-11  7:22                 ` Vladimir Prus
2006-12-11  8:03                   ` Nick Roberts
  -- strict thread matches above, loose matches on Subject: below --
2006-11-29 12:56 Vladimir Prus
2006-12-05 13:23 ` Vladimir Prus
2006-12-05 21:32   ` Jim Blandy
2006-12-05 20:59     ` Nick Roberts
2006-12-05 21:12       ` Daniel Jacobowitz
2006-12-05 21:25         ` Nick Roberts
2006-12-05 21:47           ` Daniel Jacobowitz
2006-12-05 22:27             ` Jim Blandy
2006-12-06  8:44             ` Vladimir Prus
2006-12-07  2:22             ` Nick Roberts
2006-12-07  5:24               ` Nick Roberts
2006-12-07  6:22                 ` Vladimir Prus
2006-12-07  6:53                   ` Vladimir Prus
2006-12-07 10:36                   ` Nick Roberts
2006-12-08 12:53                     ` Vladimir Prus
2006-12-09 22:10                     ` Vladimir Prus
2006-12-05 20:45 ` Daniel Jacobowitz
2006-12-06  9:04   ` Vladimir Prus
2006-12-06 20:29     ` Joel Brobecker
2006-12-06 20:33       ` Vladimir Prus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox