From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id 3545F382EA0F; Fri, 16 Sep 2022 14:41:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3545F382EA0F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663339260; bh=rK/dJVsLizkEqLT2+SoZRuS+cpUq2Fq3aXYJSLURkt4=; h=From:To:Subject:Date:From; b=h35bZFMJf9AKgdTDGS8VpJ3JpyShAu0mqPp9c9KHeUQh/xRD2xZPJ82nUebsYdtSu jNecok/VV5HBEdOpxt+kfC5KnLnfQr2lsg6Zc3Xgw6MnE5QTcUBDRPa6mCKysYpijD pg616rBStqUWonNFYkA3n++mFvUyDtMYPR1jRL3M= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/tdep] Fix PowerPC IEEE 128-bit format arg passing X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 77e6e213e0c8e77c53d123244ac75d6a825bda86 X-Git-Newrev: ff84aaf3e338702f982274ffb79e93562d05070c Message-Id: <20220916144100.3545F382EA0F@sourceware.org> Date: Fri, 16 Sep 2022 14:41:00 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dff84aaf3e338= 702f982274ffb79e93562d05070c commit ff84aaf3e338702f982274ffb79e93562d05070c Author: Tom de Vries Date: Fri Sep 16 16:40:56 2022 +0200 [gdb/tdep] Fix PowerPC IEEE 128-bit format arg passing =20 On a powerpc system with gcc 12 built to default to 128-bit IEEE long d= ouble, I run into: ... (gdb) print find_max_long_double_real(4, ldc1, ldc2, ldc3, ldc4)^M $8 =3D 0 + 0i^M (gdb) FAIL: gdb.base/varargs.exp: print \ find_max_long_double_real(4, ldc1, ldc2, ldc3, ldc4) ... =20 This is due to incorrect handling of the argument in ppc64_sysv_abi_pus= h_param. =20 Fix this and similar cases, and expand the test-case to test handling of homogeneous aggregates. =20 Tested on ppc64le-linux, power 10. =20 Co-Authored-By: Ulrich Weigand Tested-by: Carl Love Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29543 Diff: --- gdb/ppc-sysv-tdep.c | 25 +++++++++++++++++++------ gdb/testsuite/gdb.base/varargs.c | 28 ++++++++++++++++++++++++++++ gdb/testsuite/gdb.base/varargs.exp | 2 ++ 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c index 1fe81b95f6c..78bb40e49e4 100644 --- a/gdb/ppc-sysv-tdep.c +++ b/gdb/ppc-sysv-tdep.c @@ -1444,7 +1444,7 @@ ppc64_sysv_abi_push_param (struct gdbarch *gdbarch, =3D=3D floatformats_ieee_quad)) { /* IEEE FLOAT128, args in vector registers. */ - ppc64_sysv_abi_push_val (gdbarch, val, TYPE_LENGTH (type), 0, argpos= ); + ppc64_sysv_abi_push_val (gdbarch, val, TYPE_LENGTH (type), 16, argpo= s); ppc64_sysv_abi_push_vreg (gdbarch, val, argpos); } else if (type->code () =3D=3D TYPE_CODE_FLT @@ -1514,7 +1514,10 @@ ppc64_sysv_abi_push_param (struct gdbarch *gdbarch, } else { - ppc64_sysv_abi_push_val (gdbarch, val, TYPE_LENGTH (type), 0, argpos= ); + /* Align =3D=3D 0 is correct for ppc64_sysv_abi_push_freg, + Align =3D=3D 16 is correct for ppc64_sysv_abi_push_vreg. + Default to 0. */ + int align =3D 0; =20 /* The ABI (version 1.9) specifies that structs containing a single floating-point value, at any level of nesting of @@ -1532,7 +1535,10 @@ ppc64_sysv_abi_push_param (struct gdbarch *gdbarch, if (TYPE_LENGTH (type) =3D=3D 16 && (gdbarch_long_double_format (gdbarch) =3D=3D floatformats_ieee_quad)) - ppc64_sysv_abi_push_vreg (gdbarch, val, argpos); + { + ppc64_sysv_abi_push_vreg (gdbarch, val, argpos); + align =3D 16; + } else ppc64_sysv_abi_push_freg (gdbarch, type, val, argpos); } @@ -1556,8 +1562,10 @@ ppc64_sysv_abi_push_param (struct gdbarch *gdbarch, && (gdbarch_long_double_format (gdbarch) =3D=3D floatformats_ieee_quad)) /* IEEE FLOAT128, args in vector registers. */ - ppc64_sysv_abi_push_vreg (gdbarch, elval, argpos); - + { + ppc64_sysv_abi_push_vreg (gdbarch, elval, argpos); + align =3D 16; + } else if (eltype->code () =3D=3D TYPE_CODE_FLT || eltype->code () =3D=3D TYPE_CODE_DECFLOAT) /* IBM long double and all other floats and decfloats, args @@ -1567,9 +1575,14 @@ ppc64_sysv_abi_push_param (struct gdbarch *gdbarch, && eltype->is_vector () && tdep->vector_abi =3D=3D POWERPC_VEC_ALTIVEC && TYPE_LENGTH (eltype) =3D=3D 16) - ppc64_sysv_abi_push_vreg (gdbarch, elval, argpos); + { + ppc64_sysv_abi_push_vreg (gdbarch, elval, argpos); + align =3D 16; + } } } + + ppc64_sysv_abi_push_val (gdbarch, val, TYPE_LENGTH (type), align, ar= gpos); } } =20 diff --git a/gdb/testsuite/gdb.base/varargs.c b/gdb/testsuite/gdb.base/vara= rgs.c index cacb29d89e7..fcadcee6fb3 100644 --- a/gdb/testsuite/gdb.base/varargs.c +++ b/gdb/testsuite/gdb.base/varargs.c @@ -45,6 +45,16 @@ long double _Complex ldc2 =3D 2.0L + 2.0Li; long double _Complex ldc3 =3D 3.0L + 3.0Li; long double _Complex ldc4 =3D 4.0L + 4.0Li; =20 +struct sldc +{ + long double _Complex ldc; +}; + +struct sldc sldc1 =3D { 1.0L + 1.0Li }; +struct sldc sldc2 =3D { 2.0L + 2.0Li }; +struct sldc sldc3 =3D { 3.0L + 3.0Li }; +struct sldc sldc4 =3D { 4.0L + 4.0Li }; + #endif =20 int @@ -201,4 +211,22 @@ find_max_long_double_real (int num_vals, ...) } =20 =20 +long double _Complex +find_max_struct_long_double_real (int num_vals, ...) +{ + long double _Complex max =3D 0.0L + 0.0iL; + struct sldc x; + va_list argp; + int i; + + va_start(argp, num_vals); + for (i =3D 0; i < num_vals; i++) + { + x =3D va_arg (argp, struct sldc); + if (creall (max) < creal (x.ldc)) max =3D x.ldc; + } + + return max; +} + #endif /* TEST_COMPLEX */ diff --git a/gdb/testsuite/gdb.base/varargs.exp b/gdb/testsuite/gdb.base/va= rargs.exp index 7bd2cb08207..7fa464f09ad 100644 --- a/gdb/testsuite/gdb.base/varargs.exp +++ b/gdb/testsuite/gdb.base/varargs.exp @@ -103,4 +103,6 @@ if [support_complex_tests] { set test "print find_max_long_double_real(4, ldc1, ldc2, ldc3, ldc4)" gdb_test $test ".*=3D 4 \\+ 4i" =20 + set test "print find_max_struct_long_double_real(4, sldc1, sldc2, sldc= 3, sldc4)" + gdb_test $test ".*=3D 4 \\+ 4i" }