From patchwork Fri Nov 5 12:28:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 47102 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6E8543858411 for ; Fri, 5 Nov 2021 12:29:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6E8543858411 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636115383; bh=O0fs6zU1BQOdtIEyh9dTHJdI26ff1e1NQbcy7XDZ07A=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=AHEVjv5PgpnJaJL/53nJMI3WvaN98UXpw/Avr+pML027njZDL9qT1nGEqMhgSbA8W xu9lihsMr30e+ohn5qmh/YRPsiuynHah6nxm+OnXu1ulouS+yYBf5c9yOEUC8EWaER HCtx3wPQ9pMrlGmBF1uSck9MaEMgB5wdtffPs6Qs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id E7A043858030 for ; Fri, 5 Nov 2021 12:28:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E7A043858030 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-84--ZAL4FTAMuyWRdGQUNXlNg-1; Fri, 05 Nov 2021 08:28:17 -0400 X-MC-Unique: -ZAL4FTAMuyWRdGQUNXlNg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A501E1E1B; Fri, 5 Nov 2021 12:28:16 +0000 (UTC) Received: from localhost (unknown [10.33.36.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C5BA1B472; Fri, 5 Nov 2021 12:28:15 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Add xfail to pretty printer tests that fail in C++20 Date: Fri, 5 Nov 2021 12:28:15 +0000 Message-Id: <20211105122815.2220789-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Tested x86-linux, in C++17 and C++20 modes, with GDB 10 and GDB 12. Pushed to trunk. For some reason the type printer for std::string doesn't work in C++20 mode, so std::basic_string, allocator is printed out in full rather than being shown as std::string. It's probably related to the fact that the extern template declarations are disabled for C++20, but I don't know why that affects GDB. For now I'm just marking the relevant tests as XFAIL. That requires adding support for target selectors to individual GDB directives such as note-test and whatis-regexp-test. libstdc++-v3/ChangeLog: * testsuite/lib/gdb-test.exp: Add target selector support to the dg-final directives. * testsuite/libstdc++-prettyprinters/80276.cc: Add xfail for C++20. * testsuite/libstdc++-prettyprinters/libfundts.cc: Likewise. * testsuite/libstdc++-prettyprinters/prettyprinters.exp: Tweak comment. --- libstdc++-v3/testsuite/lib/gdb-test.exp | 63 ++++++++++++------- .../libstdc++-prettyprinters/80276.cc | 2 +- .../libstdc++-prettyprinters/libfundts.cc | 4 +- .../prettyprinters.exp | 2 +- 4 files changed, 45 insertions(+), 26 deletions(-) diff --git a/libstdc++-v3/testsuite/lib/gdb-test.exp b/libstdc++-v3/testsuite/lib/gdb-test.exp index f993355c2b4..db0fc2f0280 100644 --- a/libstdc++-v3/testsuite/lib/gdb-test.exp +++ b/libstdc++-v3/testsuite/lib/gdb-test.exp @@ -50,40 +50,48 @@ proc get_line_number {filename marker} { return $gdb_markers($filename,$marker) } -# Make note of a gdb test. A test consists of a variable name and an -# expected result. -proc note-test {var result} { +proc register_gdb_test {var result kind rexp selector} { global gdb_tests - lappend gdb_tests $var $result print 0 + set xfail 0 + if {[string length $selector] > 0} { + switch [dg-process-target $selector] { + "N" { return } + "S" { } + "P" { } + "F" { set xfail 1 } + } + } + + lappend gdb_tests $var $result $kind $rexp $xfail +} + +# Make note of a gdb test. A test consists of a variable name and an +# expected result, and an optional target selector. +proc note-test {var result {selector {}}} { + register_gdb_test $var $result print 0 $selector } # A test that uses a regular expression. This is like note-test, but # the result is a regular expression that is matched against the # output. -proc regexp-test {var result} { - global gdb_tests - - lappend gdb_tests $var $result print 1 +proc regexp-test {var result {selector {}}} { + register_gdb_test $var $result print 1 $selector } # A test of 'whatis'. This tests a type rather than a variable. -proc whatis-test {var result} { - global gdb_tests - - lappend gdb_tests $var $result whatis 0 +proc whatis-test {var result {selector {}}} { + register_gdb_test $var $result whatis 0 $selector } # A test of 'whatis' that uses a regular expression. This tests a type rather # than a variable. -proc whatis-regexp-test {var result} { - global gdb_tests - - lappend gdb_tests $var $result whatis 1 +proc whatis-regexp-test {var result {selector {}}} { + register_gdb_test $var $result whatis 1 $selector } # Utility for testing variable values using gdb, invoked via dg-final. -# Tests all tests indicated by note-test and regexp-test. +# Tests all tests indicated by note-test, whatis-test, and the regexp versions. # # Argument 0 is the marker on which to put a breakpoint # Argument 2 handles expected failures and the like @@ -144,7 +152,7 @@ proc gdb-test { marker {selector {}} {load_xmethods 0} } { puts $fd "info share" set count 0 - foreach {var result kind rexp} $gdb_tests { + foreach {var result kind rexp xfail} $gdb_tests { incr count set gdb_var($count) $var set gdb_expected($count) $result @@ -152,6 +160,7 @@ proc gdb-test { marker {selector {}} {load_xmethods 0} } { if {$do_whatis_tests} { set gdb_is_type($count) 1 set gdb_is_regexp($count) $rexp + set gdb_is_xfail($count) $xfail set gdb_command($count) "whatis $var" } else { unsupported "$testname" @@ -161,6 +170,7 @@ proc gdb-test { marker {selector {}} {load_xmethods 0} } { } else { set gdb_is_type($count) 0 set gdb_is_regexp($count) $rexp + set gdb_is_xfail($count) $xfail set gdb_command($count) "print $var" } puts $fd $gdb_command($count) @@ -198,11 +208,20 @@ proc gdb-test { marker {selector {}} {load_xmethods 0} } { } if {$match} { - pass "$testname $gdb_command($test_counter)" + if {$gdb_is_xfail($test_counter)} { + xpass "$testname $gdb_command($test_counter)" + verbose " matched =>$first<=" + } else { + pass "$testname $gdb_command($test_counter)" + } } else { - fail "$testname $gdb_command($test_counter)" - verbose " got =>$first<=" - verbose "expected =>$gdb_expected($test_counter)<=" + if {$gdb_is_xfail($test_counter)} { + xfail "$testname $gdb_command($test_counter)" + } else { + fail "$testname $gdb_command($test_counter)" + verbose " got =>$first<=" + verbose "expected =>$gdb_expected($test_counter)<=" + } } if {$test_counter == $count} { diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/80276.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/80276.cc index 1443f2a5495..00255c9ebca 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/80276.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/80276.cc @@ -46,7 +46,7 @@ main() // { dg-final { whatis-regexp-test p1 "std::unique_ptr\\*>>>" } } // { dg-final { whatis-regexp-test p2 "std::unique_ptr\\*>>\\\[\\\]>" } } // { dg-final { whatis-regexp-test p3 "std::unique_ptr\\*>>\\\[10\\\]>" } } - // { dg-final { whatis-regexp-test p4 "std::unique_ptr\\\[\\\]>>\\\[99\\\]>" } } + // { dg-final { whatis-regexp-test p4 "std::unique_ptr\\\[\\\]>>\\\[99\\\]>" { xfail c++20 } } } placeholder(&p1); // Mark SPOT placeholder(&p2); diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc index 67d177bf76b..af948e02365 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc @@ -50,7 +50,7 @@ main() om = std::map{ {1, 2.}, {3, 4.}, {5, 6.} }; // { dg-final { regexp-test om {std::experimental::optional> containing std::(__debug::)?map with 3 elements = {\[1\] = 2, \[3\] = 4, \[5\] = 6}} } } optional os{ "stringy" }; -// { dg-final { note-test os {std::experimental::optional = {[contained value] = "stringy"}} } } +// { dg-final { note-test os {std::experimental::optional = {[contained value] = "stringy"}} { xfail c++20 } } } any a; // { dg-final { note-test a {std::experimental::any [no contained value]} } } @@ -61,7 +61,7 @@ main() any ap = (void*)nullptr; // { dg-final { note-test ap {std::experimental::any containing void * = {[contained value] = 0x0}} } } any as = *os; -// { dg-final { note-test as {std::experimental::any containing std::string = {[contained value] = "stringy"}} } } +// { dg-final { note-test as {std::experimental::any containing std::string = {[contained value] = "stringy"}} { xfail c++20 } } } any as2("stringiest"); // { dg-final { regexp-test as2 {std::experimental::any containing const char \* = {\[contained value\] = 0x[[:xdigit:]]+ "stringiest"}} } } any am = *om; diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/prettyprinters.exp b/libstdc++-v3/testsuite/libstdc++-prettyprinters/prettyprinters.exp index 9cd3a26d6ae..96686b268bc 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/prettyprinters.exp +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/prettyprinters.exp @@ -49,7 +49,7 @@ gdb-dg-runtest [lsort [glob $srcdir/$subdir/*.cc]] \ if { [check_effective_target_lto] } { append cxxflags " -flto" - # work around sourceware.org 20882 + # Work around linker bug https://sourceware.org/PR20882 regsub {^(.*)-Wl,--gc-sections(.*)$} $cxxldflags {\1\2} cxxldflags gdb-dg-runtest [lsort [glob $srcdir/$subdir/*.cc]] \ "" "$DEFAULT_CXXFLAGS -flto $PCH_CXXFLAGS"