From patchwork Fri Sep 7 22:04:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 29235 Received: (qmail 67783 invoked by alias); 7 Sep 2018 22:04:37 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 67668 invoked by uid 89); 7 Sep 2018 22:04:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.2 spammy=H*Ad:D*oracle.com X-HELO: sesbmg23.ericsson.net Received: from sesbmg23.ericsson.net (HELO sesbmg23.ericsson.net) (193.180.251.37) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Sep 2018 22:04:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1536357871; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=GtY0CMsC+reL6OxpKUpZp5jHrueN4nIXbKaXQl5AdgI=; b=POWezJE/iNux97Xu0c3OWuu5dKeipTzfJpb0POty0HdbUzUjvsxYjFUWoZs2qG67 RgBOb9BjSlQqa7mf0ucs7WscRNCeKVL61f6OC3Ll8rNepyyLjCOnz7sEiW4zCkjG st66g8xbFEQ70udOhj8Ns/QtogMJGkaznniQtn3BbcE=; Received: from ESESBMB502.ericsson.se (Unknown_Domain [153.88.183.115]) by sesbmg23.ericsson.net (Symantec Mail Security) with SMTP id D2.1D.05037.FE5F29B5; Sat, 8 Sep 2018 00:04:31 +0200 (CEST) Received: from ESESBMB502.ericsson.se (153.88.183.169) by ESESBMB502.ericsson.se (153.88.183.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Sat, 8 Sep 2018 00:04:29 +0200 Received: from NAM05-DM3-obe.outbound.protection.outlook.com (153.88.183.157) by ESESBMB502.ericsson.se (153.88.183.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3 via Frontend Transport; Sat, 8 Sep 2018 00:04:29 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=J4EASDFDUQ8bR5dKosLrM1GRLpznXp3x315PMFsoBnc=; b=bt4gfrms+gMLlL7gdYS9B1C3/ujcIlprY+SOlapwh2tyQv4P1lqAjBYRiTbQyLhFXaFLJJ6YQ2feDQ3UVAXHWGE5LttZsvwbwxki4OBzTw7VXUe30qIEvhkVMB0OrVeARpPrGwvp4RcP+PdcSjsdJrowE9SzMDEb2Az1uYn0HZ0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; Received: from [100.94.56.16] (192.176.1.80) by SN6PR15MB2399.namprd15.prod.outlook.com (2603:10b6:805:24::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1101.17; Fri, 7 Sep 2018 22:04:26 +0000 Subject: Re: [PATCH v2 PR gdb/16841] virtual inheritance via typedef cannot find base From: Simon Marchi To: Weimin Pan , References: <1535067835-60808-1-git-send-email-weimin.pan@oracle.com> <4958cf6a-a9ab-9448-0017-a4317d5a09ad@ericsson.com> Message-ID: <19388904-5ebe-7240-1352-35a348087825@ericsson.com> Date: Fri, 7 Sep 2018 23:04:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <4958cf6a-a9ab-9448-0017-a4317d5a09ad@ericsson.com> Return-Path: simon.marchi@ericsson.com Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-IsSubscribed: yes Here's a suggestion of modifications for the test, implementing what I mentioned. Feel free to change it as you wish. From 70cc479b7465b119c2aacd092167ebb5c60dd70b Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 7 Sep 2018 23:00:28 +0100 Subject: [PATCH] Modifications to the test --- gdb/testsuite/gdb.cp/virtbase2.cc | 7 +++- gdb/testsuite/gdb.cp/virtbase2.exp | 68 +++++++++++++++++++++++++++----------- 2 files changed, 54 insertions(+), 21 deletions(-) diff --git a/gdb/testsuite/gdb.cp/virtbase2.cc b/gdb/testsuite/gdb.cp/virtbase2.cc index 4f7631e..4620ef5 100644 --- a/gdb/testsuite/gdb.cp/virtbase2.cc +++ b/gdb/testsuite/gdb.cp/virtbase2.cc @@ -1,4 +1,9 @@ -struct base { +struct superbase { + int x; + superbase () : x(22) {} +}; + +struct base : superbase { int i; double d; base() : i(55), d(6.6) {} }; diff --git a/gdb/testsuite/gdb.cp/virtbase2.exp b/gdb/testsuite/gdb.cp/virtbase2.exp index c29ff1c..854f81e 100644 --- a/gdb/testsuite/gdb.cp/virtbase2.exp +++ b/gdb/testsuite/gdb.cp/virtbase2.exp @@ -28,23 +28,51 @@ if {![runto_main]} then { continue } -gdb_breakpoint "derived::func_d" -gdb_continue_to_breakpoint "continue to derived::func_d" -gdb_test "print i" " = 55" "i in base class" -gdb_test "print derived::i" " = 55" "i in base class" -gdb_test "print derived::base::i" " = 55" "i in base class" -gdb_test "print base::i" " = 55" "i in base class" -gdb_test "print d" " = 6.5999999999999996" "d in base class" -gdb_test "print derived::d" " = 6.5999999999999996" "d in base class" -gdb_test "print derived::base::d" " = 6.5999999999999996" "d in base class" -gdb_test "print base::d" " = 6.5999999999999996" "d in base class" -gdb_breakpoint "foo::func_f" -gdb_continue_to_breakpoint "continue to foo::func_f" -gdb_test "print i" " = 55" "i in base class" -gdb_test "print derived::i" " = 55" "i in base class" -gdb_test "print derived::base::i" " = 55" "i in base class" -gdb_test "print base::i" " = 55" "i in base class" -gdb_test "print d" " = 6.5999999999999996" "d in base class" -gdb_test "print derived::d" " = 6.5999999999999996" "d in base class" -gdb_test "print derived::base::d" " = 6.5999999999999996" "d in base class" -gdb_test "print base::d" " = 6.5999999999999996" "d in base class" +proc make_scope_list { scopes } { + if { [llength $scopes] == 1 } { + return [list "" "${scopes}::"] + } + + # Pop the first element, save the first scope. + set this_scope [lindex $scopes 0] + set scopes [lreplace $scopes 0 0] + + set child_result [make_scope_list $scopes] + + # Add a copy of the child's result without this scope... + set result $child_result + + # ... and a copy of the child's result with this scope. + foreach r $child_result { + lappend result "${this_scope}::$r" + } + + return $result +} + +proc test_variables_in_base { scopes } { + foreach scope [make_scope_list $scopes] { + gdb_test "print ${scope}i" " = 55" + gdb_test "print ${scope}d" " = 6.5999999999999996" + } +} + +proc test_variables_in_superbase { scopes } { + foreach scope [make_scope_list $scopes] { + gdb_test "print ${scope}x" " = 22" + } +} + +with_test_prefix "derived::func_d" { + gdb_breakpoint "derived::func_d" + gdb_continue_to_breakpoint "continue to derived::func_d" + test_variables_in_base {derived base} + test_variables_in_superbase {derived base superbase} +} + +with_test_prefix "foo::func_f" { + gdb_breakpoint "foo::func_f" + gdb_continue_to_breakpoint "continue to foo::func_f" + test_variables_in_base {foo derived base} + test_variables_in_superbase {foo derived base superbase} +}