From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 93PZLqrF9mCaVgAAWB0awg (envelope-from ) for ; Tue, 20 Jul 2021 08:46:34 -0400 Received: by simark.ca (Postfix, from userid 112) id B64591E79C; Tue, 20 Jul 2021 08:46:34 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id B5DDF1E79C for ; Tue, 20 Jul 2021 08:46:33 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C516E3839438 for ; Tue, 20 Jul 2021 12:46:32 +0000 (GMT) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id A152E3839400 for ; Tue, 20 Jul 2021 12:46:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A152E3839400 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C70C222425 for ; Tue, 20 Jul 2021 12:46:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1626785179; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=qU3edySOE6j2RVCwGJ4lTqwy4jO64KPFxvC3LgKA7mE=; b=uPqkwc8ESN/AlHFhorMMUKk8b6tJP3W8h28jr8nmJBqajwPOxTt/M3CIcSVaY6OXKxa19r eA6WHeHzJoFH4fEkhwQWjhQsylGQ5TiNmJuDadkxhPUbzgcIdHrDxayna0eIAv/fejdBX8 upPzTKfuUw4giPW2dnX24pYD6VdVoxk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1626785179; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=qU3edySOE6j2RVCwGJ4lTqwy4jO64KPFxvC3LgKA7mE=; b=uiULkVKFJpdmTxRnRGDtL5SXcroKMj8UE2EMI+dSaHslIvnnCe6RBicg4VymsCUizYD+o0 vnY1RXDsyDQZEyBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B3BF113D68 for ; Tue, 20 Jul 2021 12:46:19 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id B2XHKpvF9mARbAAAMHmgww (envelope-from ) for ; Tue, 20 Jul 2021 12:46:19 +0000 Date: Tue, 20 Jul 2021 14:46:18 +0200 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH][gdb/testsuite] Fix FAILs due to PR gcc/101452 Message-ID: <20210720124616.GA4600@delia.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi, When running test-case gdb.base/ptype-offsets.exp with gcc-11 (with -gdwarf-5 default) or gcc-10 with target board unix/gdb:debug_flags=-gdwarf-5 we run into this regression: ... (gdb) ptype/o static_member^M /* offset | size */ type = struct static_member {^M - static static_member Empty;^M /* 0 | 4 */ int abc;^M ^M /* total size (bytes): 4 */^M }^M -(gdb) PASS: gdb.base/ptype-offsets.exp: ptype/o static_member +(gdb) FAIL: gdb.base/ptype-offsets.exp: ptype/o static_member ... This is caused by missing debug info, which I filed as gcc PR101452 - "[debug, dwarf-5] undefined static member removed by -feliminate-unused-debug-symbols". It's not clear yet whether this is a bug or a feature, but work around this in the test-cases by: - defining the static member - adding additional_flags=-fno-eliminate-unused-debug-types. Tested on x86_64-linux. Any comments? Thanks, - Tom [gdb/testsuite] Fix FAILs due to PR gcc/101452 gdb/testsuite/ChangeLog: 2021-07-20 Tom de Vries * lib/gdb.exp (gcc_major_version): New proc. * gdb.base/ptype-offsets.cc: Define static member static_member::Empty. * gdb.cp/templates.exp: Define static member using -DGCC_BUG. * gdb.cp/m-static.exp: Add additional_flags=-fno-eliminate-unused-debug-types. * gdb.cp/pr-574.exp: Same. * gdb.cp/pr9167.exp: Same. --- gdb/testsuite/gdb.base/ptype-offsets.cc | 3 +++ gdb/testsuite/gdb.cp/m-static.exp | 8 +++++++- gdb/testsuite/gdb.cp/pr-574.exp | 8 +++++++- gdb/testsuite/gdb.cp/pr9167.exp | 8 +++++++- gdb/testsuite/gdb.cp/templates.exp | 8 +++++++- gdb/testsuite/lib/gdb.exp | 21 +++++++++++++++++++++ 6 files changed, 52 insertions(+), 4 deletions(-) diff --git a/gdb/testsuite/gdb.base/ptype-offsets.cc b/gdb/testsuite/gdb.base/ptype-offsets.cc index dc21e34752f..7678fc6a666 100644 --- a/gdb/testsuite/gdb.base/ptype-offsets.cc +++ b/gdb/testsuite/gdb.base/ptype-offsets.cc @@ -185,6 +185,9 @@ struct static_member int abc; }; +/* Work around PR gcc/101452. */ +static_member static_member::Empty; + struct empty_member { struct { } empty; diff --git a/gdb/testsuite/gdb.cp/m-static.exp b/gdb/testsuite/gdb.cp/m-static.exp index 8260ca377f5..15932038487 100644 --- a/gdb/testsuite/gdb.cp/m-static.exp +++ b/gdb/testsuite/gdb.cp/m-static.exp @@ -31,8 +31,14 @@ if [get_compiler_info] { return -1 } +set flags [list debug c++] +if { [test_compiler_info gcc-*] && [gcc_major_version] >= 10 } { + # Work around PR gcc/101452. + lappend flags additional_flags=-fno-eliminate-unused-debug-types +} + if {[prepare_for_testing "failed to prepare" $testfile \ - [list $srcfile $srcfile2] {debug c++}]} { + [list $srcfile $srcfile2] $flags]} { return -1 } diff --git a/gdb/testsuite/gdb.cp/pr-574.exp b/gdb/testsuite/gdb.cp/pr-574.exp index dab52fd428c..da596f120f6 100644 --- a/gdb/testsuite/gdb.cp/pr-574.exp +++ b/gdb/testsuite/gdb.cp/pr-574.exp @@ -32,7 +32,13 @@ if [get_compiler_info "c++"] { return -1 } -if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} { +set flags [list debug c++] +if { [test_compiler_info gcc-*] && [gcc_major_version] >= 10 } { + # Work around PR gcc/101452. + lappend flags additional_flags=-fno-eliminate-unused-debug-types +} + +if {[prepare_for_testing "failed to prepare" $testfile $srcfile $flags]} { return -1 } diff --git a/gdb/testsuite/gdb.cp/pr9167.exp b/gdb/testsuite/gdb.cp/pr9167.exp index 34508f70e6c..d88c75d8a12 100644 --- a/gdb/testsuite/gdb.cp/pr9167.exp +++ b/gdb/testsuite/gdb.cp/pr9167.exp @@ -15,7 +15,13 @@ standard_testfile .cc -if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} { +set flags [list debug c++] +if { [test_compiler_info gcc-*] && [gcc_major_version] >= 10 } { + # Work around PR gcc/101452. + lappend flags additional_flags=-fno-eliminate-unused-debug-types +} + +if {[prepare_for_testing "failed to prepare" $testfile $srcfile $flags]} { return -1 } diff --git a/gdb/testsuite/gdb.cp/templates.exp b/gdb/testsuite/gdb.cp/templates.exp index 4d589426c28..8b905e4254f 100644 --- a/gdb/testsuite/gdb.cp/templates.exp +++ b/gdb/testsuite/gdb.cp/templates.exp @@ -27,7 +27,13 @@ if [get_compiler_info "c++"] { return -1 } -if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} { +set flags [list debug c++] +if { [test_compiler_info gcc-*] && [gcc_major_version] >= 10 } { + # Work around PR gcc/101452. + lappend flags additional_flags=-DGCC_BUG +} + +if {[prepare_for_testing "failed to prepare" $testfile $srcfile $flags]} { return -1 } diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index e79e0622f9d..16c46647101 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -3998,6 +3998,27 @@ proc test_compiler_info { {compiler ""} } { return [string match $compiler $compiler_info] } +# Return the gcc major version, or -1. +# For gcc 4.8.5, the major version is 4.8. +# For gcc 7.5.0, the major version 7. + +proc gcc_major_version { } { + global compiler_info + global decimal + if { ![test_compiler_info "gcc-*"] } { + return -1 + } + set res [regexp gcc-($decimal)-($decimal)- $compiler_info \ + dummy_var major minor] + if { $res != 1 } { + return -1 + } + if { $major >= 5} { + return $major + } + return $major.$minor +} + proc current_target_name { } { global target_info if [info exists target_info(target,name)] {