From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6769 invoked by alias); 29 Nov 2006 12:56:09 -0000 Received: (qmail 6755 invoked by uid 22791); 29 Nov 2006 12:56:03 -0000 X-Spam-Check-By: sourceware.org Received: from zigzag.lvk.cs.msu.su (HELO zigzag.lvk.cs.msu.su) (158.250.17.23) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 29 Nov 2006 12:55:54 +0000 Received: from Debian-exim by zigzag.lvk.cs.msu.su with spam-scanned (Exim 4.50) id 1GpOyW-0004R2-Ta for gdb-patches@sources.redhat.com; Wed, 29 Nov 2006 15:55:50 +0300 Received: from localhost ([127.0.0.1] helo=ip6-localhost) by zigzag.lvk.cs.msu.su with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.50) id 1GpOyW-0004Qz-LX for gdb-patches@sources.redhat.com; Wed, 29 Nov 2006 15:55:44 +0300 From: Vladimir Prus To: gdb-patches@sources.redhat.com Subject: MI: fix base members in references Date: Wed, 29 Nov 2006 12:56:00 -0000 User-Agent: KMail/1.9.1 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_ONYbFif612OSO/L" Message-Id: <200611291555.42209.ghost@cs.msu.su> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-11/txt/msg00379.txt.bz2 --Boundary-00=_ONYbFif612OSO/L Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 1232 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 --Boundary-00=_ONYbFif612OSO/L Content-Type: text/x-diff; charset="us-ascii"; name="01REFERENCES_AND_BASES.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="01REFERENCES_AND_BASES.diff" Content-length: 679 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; --Boundary-00=_ONYbFif612OSO/L--