From patchwork Mon Oct 21 13:09:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 35195 Received: (qmail 127198 invoked by alias); 21 Oct 2019 13:09:13 -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 127189 invoked by uid 89); 21 Oct 2019 13:09:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT autolearn=ham version=3.3.1 spammy=ba, ad, thereby, ac X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 21 Oct 2019 13:09:11 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id E9CBB204CC; Mon, 21 Oct 2019 09:09:09 -0400 (EDT) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [8.43.85.239]) by mx1.osci.io (Postfix) with ESMTP id 73C832022D; Mon, 21 Oct 2019 09:09:04 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 34F7821926; Mon, 21 Oct 2019 09:09:04 -0400 (EDT) X-Gerrit-PatchSet: 2 Date: Mon, 21 Oct 2019 09:09:03 -0400 From: "Sourceware to Gerrit sync (Code Review)" To: Tom de Vries , Andrew Burgess , gdb-patches@sourceware.org Auto-Submitted: auto-generated X-Gerrit-MessageType: newpatchset Subject: [pushed] [gdb/testsuite] Compile infcall-nested-structs.exp with -O2 X-Gerrit-Change-Id: Ic027e1c957fecd6686345639db99f5eaee3cdf05 X-Gerrit-Change-Number: 143 X-Gerrit-ChangeURL: X-Gerrit-Commit: 94cb3754118669d46c8ad87c986d8d9c59fac65a In-Reply-To: References: Reply-To: noreply@gnutoolchain-gerrit.osci.io, tdevries@suse.de, andrew.burgess@embecosm.com, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3 Message-Id: <20191021130904.34F7821926@gnutoolchain-gerrit.osci.io> The original change was created by Tom de Vries. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/143 ...................................................................... [gdb/testsuite] Compile infcall-nested-structs.exp with -O2 As mentioned in commit 745ff14e6e1 "[gdb/tdep] Fix 'Unexpected register class' assert in amd64_push_arguments", of the 12 KFAILs added there, 3 are KPASSing with g++ 4.8.5. The KPASSes are due to: - gdb incorrectly expecting the second half of the result of function rtn_str_struct_02_01 in register %rdx. - rtn_str_struct_02_01 using %rdx as a temporary, thereby accidentally setting it to the expected value. Reduce the chance of hiding errors due accidental register settings by compiling the test-case with -O2. This fixes the KPASSes when applied on top of commit 745ff14e6e1. Tested on x86_64-linux. Tested with g++ 4.8.5, 7.4.1, 8.3.1, 9.2.1. gdb/testsuite/ChangeLog: 2019-10-21 Tom de Vries * gdb.base/infcall-nested-structs.c: Add __attribute__((noinline,noclone)) to all functions. (call_all): Add missing variable initialization. Simplify return value. (breakpt): Increment volatile variable, to prevent call from being optimized out. * gdb.base/infcall-nested-structs.exp: Compile with -O2. Change-Id: Ic027e1c957fecd6686345639db99f5eaee3cdf05 --- M gdb/testsuite/ChangeLog M gdb/testsuite/gdb.base/infcall-nested-structs.c M gdb/testsuite/gdb.base/infcall-nested-structs.exp 3 files changed, 63 insertions(+), 35 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 1075a1d..9f826a6 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2019-10-21 Tom de Vries + + * gdb.base/infcall-nested-structs.c: Add + __attribute__((noinline,noclone)) to all functions. + (call_all): Add missing variable initialization. Simplify return value. + (breakpt): Increment volatile variable, to prevent call from being + optimized out. + * gdb.base/infcall-nested-structs.exp: Compile with -O2. + 2019-10-17 Tom de Vries * gdb.fortran/module.exp: Allow info variables to print info for files diff --git a/gdb/testsuite/gdb.base/infcall-nested-structs.c b/gdb/testsuite/gdb.base/infcall-nested-structs.c index 795ab4a..f2a4294 100644 --- a/gdb/testsuite/gdb.base/infcall-nested-structs.c +++ b/gdb/testsuite/gdb.base/infcall-nested-structs.c @@ -51,13 +51,13 @@ #endif /* TEST_COMPLEX */ #define MAKE_CHECK_FUNCS(TYPE) \ - int \ + int __attribute__((noinline,noclone)) \ check_arg_ ## TYPE (struct TYPE arg) \ { \ return cmp_ ## TYPE (arg, ref_val_ ## TYPE); \ } \ \ - struct TYPE \ + struct TYPE __attribute__((noinline,noclone)) \ rtn_str_ ## TYPE (void) \ { \ return (ref_val_ ## TYPE); \ @@ -128,125 +128,141 @@ #endif -int cmp_struct_01_01 (struct struct_01_01 a, struct struct_01_01 b) +int __attribute__((noinline,noclone)) +cmp_struct_01_01 (struct struct_01_01 a, struct struct_01_01 b) { return a.s2.s1.a == b.s2.s1.a; } -int cmp_struct_01_02 (struct struct_01_02 a, struct struct_01_02 b) +int __attribute__((noinline,noclone)) +cmp_struct_01_02 (struct struct_01_02 a, struct struct_01_02 b) { return a.a == b.a; } -int cmp_struct_01_03 (struct struct_01_03 a, struct struct_01_03 b) +int __attribute__((noinline,noclone)) +cmp_struct_01_03 (struct struct_01_03 a, struct struct_01_03 b) { return a.s4.s3.a == b.s4.s3.a; } -int cmp_struct_01_04 (struct struct_01_04 a, struct struct_01_04 b) +int __attribute__((noinline,noclone)) +cmp_struct_01_04 (struct struct_01_04 a, struct struct_01_04 b) { return a.a == b.a; } -int cmp_struct_02_01 (struct struct_02_01 a, struct struct_02_01 b) +int __attribute__((noinline,noclone)) +cmp_struct_02_01 (struct struct_02_01 a, struct struct_02_01 b) { return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b; } -int cmp_struct_02_02 (struct struct_02_02 a, struct struct_02_02 b) +int __attribute__((noinline,noclone)) +cmp_struct_02_02 (struct struct_02_02 a, struct struct_02_02 b) { return a.a == b.a && a.b == b.b; } -int cmp_struct_02_03 (struct struct_02_03 a, struct struct_02_03 b) +int __attribute__((noinline,noclone)) +cmp_struct_02_03 (struct struct_02_03 a, struct struct_02_03 b) { return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b; } -int cmp_struct_02_04 (struct struct_02_04 a, struct struct_02_04 b) +int __attribute__((noinline,noclone)) +cmp_struct_02_04 (struct struct_02_04 a, struct struct_02_04 b) { return a.a == b.a && a.b == b.b; } -int cmp_struct_04_01 (struct struct_04_01 a, struct struct_04_01 b) +int __attribute__((noinline,noclone)) +cmp_struct_04_01 (struct struct_04_01 a, struct struct_04_01 b) { return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b && a.s2.s1.c == b.s2.s1.c && a.s2.s1.d == b.s2.s1.d; } -int cmp_struct_04_02 (struct struct_04_02 a, struct struct_04_02 b) +int __attribute__((noinline,noclone)) +cmp_struct_04_02 (struct struct_04_02 a, struct struct_04_02 b) { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d; } -int cmp_struct_04_03 (struct struct_04_03 a, struct struct_04_03 b) +int __attribute__((noinline,noclone)) +cmp_struct_04_03 (struct struct_04_03 a, struct struct_04_03 b) { return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b && a.s8.s7.c == b.s8.s7.c && a.s10.s9.d == b.s10.s9.d; } -int cmp_struct_04_04 (struct struct_04_04 a, struct struct_04_04 b) +int __attribute__((noinline,noclone)) +cmp_struct_04_04 (struct struct_04_04 a, struct struct_04_04 b) { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d; } -int cmp_struct_05_01 (struct struct_05_01 a, struct struct_05_01 b) +int __attribute__((noinline,noclone)) +cmp_struct_05_01 (struct struct_05_01 a, struct struct_05_01 b) { return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b && a.s2.s1.c == b.s2.s1.c && a.s2.s1.d == b.s2.s1.d && a.s2.s1.e == b.s2.s1.e; } -int cmp_struct_05_02 (struct struct_05_02 a, struct struct_05_02 b) +int __attribute__((noinline,noclone)) +cmp_struct_05_02 (struct struct_05_02 a, struct struct_05_02 b) { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d && a.e == b.e; } -int cmp_struct_05_03 (struct struct_05_03 a, struct struct_05_03 b) +int __attribute__((noinline,noclone)) +cmp_struct_05_03 (struct struct_05_03 a, struct struct_05_03 b) { return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b && a.s8.s7.c == b.s8.s7.c && a.s10.s9.d == b.s10.s9.d && a.s12.s11.e == b.s12.s11.e; } -int cmp_struct_05_04 (struct struct_05_04 a, struct struct_05_04 b) +int __attribute__((noinline,noclone)) +cmp_struct_05_04 (struct struct_05_04 a, struct struct_05_04 b) { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d && a.e == b.e; } #ifdef __cplusplus -int +int __attribute__((noinline,noclone)) cmp_struct_static_02_01 (struct struct_static_02_01 a, struct struct_static_02_01 b) { return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b; } -int +int __attribute__((noinline,noclone)) cmp_struct_static_02_02 (struct struct_static_02_02 a, struct struct_static_02_02 b) { return a.a == b.a && a.b == b.b; } -int +int __attribute__((noinline,noclone)) cmp_struct_static_02_03 (struct struct_static_02_03 a, struct struct_static_02_03 b) { return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b; } -int +int __attribute__((noinline,noclone)) cmp_struct_static_02_04 (struct struct_static_02_04 a, struct struct_static_02_04 b) { return a.a == b.a && a.b == b.b; } -int +int __attribute__((noinline,noclone)) cmp_struct_static_04_01 (struct struct_static_04_01 a, struct struct_static_04_01 b) { return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b && a.s2.s1.c == b.s2.s1.c && a.s2.s1.d == b.s2.s1.d; } -int +int __attribute__((noinline,noclone)) cmp_struct_static_04_02 (struct struct_static_04_02 a, struct struct_static_04_02 b) { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d; } -int +int __attribute__((noinline,noclone)) cmp_struct_static_04_03 (struct struct_static_04_03 a, struct struct_static_04_03 b) { return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b && a.s8.s7.c == b.s8.s7.c && a.s10.s9.d == b.s10.s9.d; } -int +int __attribute__((noinline,noclone)) cmp_struct_static_04_04 (struct struct_static_04_04 a, struct struct_static_04_04 b) { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d; } -int +int __attribute__((noinline,noclone)) cmp_struct_static_06_01 (struct struct_static_06_01 a, struct struct_static_06_01 b) { return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b && a.s2.s1.c == b.s2.s1.c && a.s2.s1.d == b.s2.s1.d && a.s2.s1.e == b.s2.s1.e && a.f == b.f; } -int +int __attribute__((noinline,noclone)) cmp_struct_static_06_02 (struct struct_static_06_02 a, struct struct_static_06_02 b) { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d && a.e == b.e && a.f == b.f; } -int +int __attribute__((noinline,noclone)) cmp_struct_static_06_03 (struct struct_static_06_03 a, struct struct_static_06_03 b) { return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b && a.s8.s7.c == b.s8.s7.c && a.s10.s9.d == b.s10.s9.d && a.s12.s11.e == b.s12.s11.e && a.s12.s11.f == b.s12.s11.f; } -int +int __attribute__((noinline,noclone)) cmp_struct_static_06_04 (struct struct_static_06_04 a, struct struct_static_06_04 b) { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d && a.e == b.e @@ -350,10 +366,10 @@ #define CALL_LINE(NAME) val += check_arg_ ## NAME (rtn_str_ ## NAME ()) -int +int __attribute__((noinline,noclone)) call_all () { - int val; + int val = 0; CALL_LINE(struct_01_01); CALL_LINE(struct_01_02); @@ -386,13 +402,15 @@ CALL_LINE(struct_static_06_04); #endif - return (val != 4); + return val; } -void +int volatile v = 1; + +void __attribute__((noinline, noclone)) breakpt (void) { - /* Nothing. */ + v++; } int diff --git a/gdb/testsuite/gdb.base/infcall-nested-structs.exp b/gdb/testsuite/gdb.base/infcall-nested-structs.exp index 982149f..e3045d9 100644 --- a/gdb/testsuite/gdb.base/infcall-nested-structs.exp +++ b/gdb/testsuite/gdb.base/infcall-nested-structs.exp @@ -73,6 +73,7 @@ # Create the additional flags set flags $compile_flags lappend flags $lang + lappend flags "additional_flags=-O2" for {set n 0} {$n<[llength ${types}]} {incr n} { set m [I2A ${n}]