From patchwork Fri Sep 25 01:44:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandra Loosemore X-Patchwork-Id: 8848 Received: (qmail 46884 invoked by alias); 25 Sep 2015 01:45:03 -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 46813 invoked by uid 89); 25 Sep 2015 01:45:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 25 Sep 2015 01:44:59 +0000 Received: from svr-orw-fem-04.mgc.mentorg.com ([147.34.97.41]) by relay1.mentorg.com with esmtp id 1ZfI4G-0005m5-Lr from Sandra_Loosemore@mentor.com for gdb-patches@sourceware.org; Thu, 24 Sep 2015 18:44:56 -0700 Received: from [IPv6:::1] (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.3.224.2; Thu, 24 Sep 2015 18:44:55 -0700 Message-ID: <5604A6E3.5020005@codesourcery.com> Date: Thu, 24 Sep 2015 19:44:03 -0600 From: Sandra Loosemore User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: gdb-patches Subject: [patch, testsuite] replace bogus pointer-to-member test in gdb.cp/classes.exp While I was working on this patch https://sourceware.org/ml/gdb-patches/2015-09/msg00566.html to fix a regexp bug in gdb.cp/classes.exp, I also took a look at the long-standing failure involving the pmi comparison. In addition to the uninitialized-variable problem noted in the comments (dating back to 2004!), casting a pointer-to-member to an int and expecting it to have (or not have) any particular value seems highly dubious to me in terms of correctness and portability. I also don't think it's representative of actual use cases involving pointer-to-member variables in the debugger. This patch addresses the uninitialized variable and potential optimizing-away problems by moving the definition to file scope, and changes the test to just printing its value. OK to commit? -Sandra diff --git a/gdb/testsuite/gdb.cp/classes.cc b/gdb/testsuite/gdb.cp/classes.cc index 648452c..9fb687e 100644 --- a/gdb/testsuite/gdb.cp/classes.cc +++ b/gdb/testsuite/gdb.cp/classes.cc @@ -433,6 +433,7 @@ Foo::operator int() { return x; } ByAnyOtherName foo(10, 11); Bar bar(20, 21, 22); +int Foo::* pmi = &Foo::y; /* Use a typedef for the baseclass to exercise gnu-v3-abi.c:gnuv3_dynamic_class recursion. It's important that the class itself have no name to make sure @@ -599,11 +600,6 @@ main() enums1 (); register_class (); - /* FIXME: pmi gets optimized out. Need to do some more computation with - it or something. (No one notices, because the test is xfail'd anyway, - but that probably won't always be true...). */ - int Foo::* pmi = &Foo::y; - /* Make sure the AIX linker doesn't remove the variable. */ v_tagless.one = 5; diff --git a/gdb/testsuite/gdb.cp/classes.exp b/gdb/testsuite/gdb.cp/classes.exp index 00f16fc..9dab864 100644 --- a/gdb/testsuite/gdb.cp/classes.exp +++ b/gdb/testsuite/gdb.cp/classes.exp @@ -509,12 +509,7 @@ proc test_pointers_to_class_members {} { gdb_test "ptype Bar::z" "type = int" gdb_test "ptype &Bar::z" "type = int Bar::\\*" - # TODO: this is a bogus test. It's looking at a variable that - # has not even been declared yet, so it's accessing random junk - # on the stack and comparing that it's NOT equal to a specific - # value. It's been like this since gdb 4.10 in 1993! - # -- chastain 2004-01-01 - gdb_test "print (int)pmi == sizeof(int)" ".* = false" + gdb_test "print pmi" "\\$\[0-9\]+ = &Foo::y" } # Test static members.