From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27009 invoked by alias); 18 Jun 2018 16:12:18 -0000 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 Received: (qmail 26999 invoked by uid 89); 18 Jun 2018 16:12:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_SHORT,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:8.14.4, H*r:Gateway, AFAIK, afaik X-HELO: userp2130.oracle.com Received: from userp2130.oracle.com (HELO userp2130.oracle.com) (156.151.31.86) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 18 Jun 2018 16:12:14 +0000 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5IG9SAX031803; Mon, 18 Jun 2018 16:12:11 GMT Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2jmt01ctb5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Jun 2018 16:12:11 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w5IGCAnF005690 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Jun 2018 16:12:10 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w5IGC9Tk021267; Mon, 18 Jun 2018 16:12:09 GMT Received: from [172.27.35.125] (/108.88.88.153) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 18 Jun 2018 09:12:09 -0700 Subject: Re: [PATCH PR gdb/16841] virtual inheritance via typedef cannot find base To: Simon Marchi , gdb-patches@sourceware.org References: <1529106313-11806-1-git-send-email-weimin.pan@oracle.com> <97eae4ee-dc9b-2c02-83e2-d35974319ed2@simark.ca> From: Wei-min Pan Message-ID: <162ef4ff-42b9-7a91-01d2-660f1d2239da@oracle.com> Date: Mon, 18 Jun 2018 16:12:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <97eae4ee-dc9b-2c02-83e2-d35974319ed2@simark.ca> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8927 signatures=668702 X-SW-Source: 2018-06/txt/msg00462.txt.bz2 On 6/16/2018 6:06 PM, Simon Marchi wrote: > On 2018-06-15 07:45 PM, Weimin Pan wrote: >> Fix failure to find member of a typedef base class >> >> The test case below demonstrates the problem, as described in this PR's Comment 5: >> >> typedef struct { >> int x; >> } A; >> >> struct C : A { >> int y; >> }; >> >> int main() >> { >> C c; >> return 55; >> } >> >> $ gdb a.out >> (gdb) ptype C::x >> Internal error: non-aggregate type to value_struct_elt_for_reference >> >> In value_struct_elt_for_reference(), need to call check_typedef() on >> the aggregate type to handle the case of *curtype being ptr->typedef. > Thanks, that makes sense. I noted some nits, you can push the patch after > addressing them. > >> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog >> index b2938b1..78771d3 100644 >> --- a/gdb/testsuite/ChangeLog >> +++ b/gdb/testsuite/ChangeLog >> @@ -1,3 +1,9 @@ >> +2018-06-12 Weimin Pan >> + >> + PR gdb/16841 >> + * gdb/testsuite/gdb.cp/typedef-base-ptype.cc: New file. >> + * gdb/testsuite/gdb.cp/typedef-base-ptype.exp: New file. > Filenames should be relative to the ChangeLog file, so remove "gdb/testsuite/". > >> diff --git a/gdb/testsuite/gdb.cp/typedef-base-ptype.cc b/gdb/testsuite/gdb.cp/typedef-base-ptype.cc >> new file mode 100644 >> index 0000000..bfbcc4a >> --- /dev/null >> +++ b/gdb/testsuite/gdb.cp/typedef-base-ptype.cc >> @@ -0,0 +1,30 @@ >> +/* This testcase is part of GDB, the GNU debugger. >> + >> + Copyright 2018 Free Software Foundation, Inc. >> + >> + This program is free software; you can redistribute it and/or modify >> + it under the terms of the GNU General Public License as published by >> + the Free Software Foundation; either version 3 of the License, or >> + (at your option) any later version. >> + >> + This program is distributed in the hope that it will be useful, >> + but WITHOUT ANY WARRANTY; without even the implied warranty of >> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> + GNU General Public License for more details. >> + >> + You should have received a copy of the GNU General Public License >> + along with this program. If not, see . */ >> + >> +typedef struct { >> + int x; >> +} A; >> + >> +struct C : A { >> + int y; >> +}; >> + >> +int main() >> +{ >> + C c; >> + return 55; >> +} > We try to make the test code follow the GNU coding style (unless testing > a particular formatting is the purpose of the test). > >> diff --git a/gdb/testsuite/gdb.cp/typedef-base-ptype.exp b/gdb/testsuite/gdb.cp/typedef-base-ptype.exp > I would suggest naming this test "typedef-base.exp", because we may add other tests > than ptype in it. For example, David's original reproducer in PR 16841 still won't > work after this patch (AFAIK), and would be a good candidate to end up as a test in > this file. > >> new file mode 100644 >> index 0000000..e588fd3 >> --- /dev/null >> +++ b/gdb/testsuite/gdb.cp/typedef-base-ptype.exp >> @@ -0,0 +1,37 @@ >> +# Copyright 2018 Free Software Foundation, Inc. >> + >> +# This program is free software; you can redistribute it and/or modify >> +# it under the terms of the GNU General Public License as published by >> +# the Free Software Foundation; either version 3 of the License, or >> +# (at your option) any later version. >> +# >> +# This program is distributed in the hope that it will be useful, >> +# but WITHOUT ANY WARRANTY; without even the implied warranty of >> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> +# GNU General Public License for more details. >> +# >> +# You should have received a copy of the GNU General Public License >> +# along with this program. If not, see . > Can you add a one-liner comment that states the purpose of the test? Something > like > > # Make sure that inheritance through a typedef is well handled. > > Thanks, > > Simon > Hi Simon, Will incorporate your comments into the patch and push it. Thanks, Weimin