[binutils-gdb] gdb.base/callfuncs.exp: Exercise "long double"
Pedro Alves via Gdb-cvs <[email protected]> Wed, 22 Jul 2026 13:01:12 +0000 (GMT)
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D293f50b84a96= 64213fde309e2dc51a49d719029c commit 293f50b84a9664213fde309e2dc51a49d719029c Author: Pedro Alves <[email protected]> Date: Tue Jul 14 20:46:28 2026 +0100 gdb.base/callfuncs.exp: Exercise "long double" =20 gdb.base/callfuncs.exp tests calling functions that take and return floating point arguments, but only for float and double. Add long double too, so that GDB's handling of the type in inferior function calls is exercised. =20 On x86_64-pc-windows-msvc, without the fix that teaches GDB about the correct size of "long double", we get: =20 $ grep FAIL gdb.sum FAIL: gdb.base/callfuncs.exp: noproto: p ((int (*) ()) t_long_double_v= alues)(45.654L,-67.66L) FAIL: gdb.base/callfuncs.exp: p ((int (*) (long double, long double)) = t_long_double_values)(45.654,-67.66) =20 These two tests go through GDB's expression parser for the long double type. Without the long double fix, GDB is passing 128-bit (amd64 default) but on the MSVC ABI, it should be passing 64-bit. =20 The other tests pass even without the fix, as those are direct calls that get the parameter type from DWARF, which has the correct long double size. =20 Approved-By: Andrew Burgess <[email protected]> Change-Id: Ibcc3590753d08ece4fbf03c5d890872197047fff Diff: --- gdb/testsuite/gdb.base/callfuncs.c | 58 +++++++++++++++++++++++++-------= ---- gdb/testsuite/gdb.base/callfuncs.exp | 26 ++++++++++++++++ 2 files changed, 67 insertions(+), 17 deletions(-) diff --git a/gdb/testsuite/gdb.base/callfuncs.c b/gdb/testsuite/gdb.base/ca= llfuncs.c index 0e6d9dcdd71..918e8d6f97d 100644 --- a/gdb/testsuite/gdb.base/callfuncs.c +++ b/gdb/testsuite/gdb.base/callfuncs.c @@ -72,6 +72,24 @@ double double_val13 =3D 10.25; double double_val14 =3D 11.25; double double_val15 =3D 12.25; =20 +/* "long double" cannot be pasted into a "long_double_val1" + identifier, so the long double globals use an "ldouble" prefix. */ +long double ldouble_val1 =3D 45.654; +long double ldouble_val2 =3D -67.66; +long double ldouble_val3 =3D 0.25; +long double ldouble_val4 =3D 1.25; +long double ldouble_val5 =3D 2.25; +long double ldouble_val6 =3D 3.25; +long double ldouble_val7 =3D 4.25; +long double ldouble_val8 =3D 5.25; +long double ldouble_val9 =3D 6.25; +long double ldouble_val10 =3D 7.25; +long double ldouble_val11 =3D 8.25; +long double ldouble_val12 =3D 9.25; +long double ldouble_val13 =3D 10.25; +long double ldouble_val14 =3D 11.25; +long double ldouble_val15 =3D 12.25; + #ifdef TEST_COMPLEX extern float crealf (float _Complex); extern float cimagf (float _Complex); @@ -359,20 +377,23 @@ float float_arg1, float_arg2; #endif =20 /* Define a function NAME comparing its two TYPE arguments against the - TYPE_val1 and TYPE_val2 globals. */ + TYPE_val1 and TYPE_val2 globals. PREFIX is passed separately + because "long double" cannot be pasted into a "long_double_val1" + identifier. */ =20 -#define DEFINE_T_FLOAT_VALUES(TYPE, NAME) \ +#define DEFINE_T_FLOAT_VALUES(TYPE, NAME, PREFIX) \ int \ NAME T_VALUES_PARAMS (TYPE) \ { \ - return ((arg1 - TYPE##_val1) < DELTA \ - && (arg1 - TYPE##_val1) > -DELTA \ - && (arg2 - TYPE##_val2) < DELTA \ - && (arg2 - TYPE##_val2) > -DELTA); \ + return ((arg1 - PREFIX##_val1) < DELTA \ + && (arg1 - PREFIX##_val1) > -DELTA \ + && (arg2 - PREFIX##_val2) < DELTA \ + && (arg2 - PREFIX##_val2) > -DELTA); \ } =20 -DEFINE_T_FLOAT_VALUES (float, t_float_values2) -DEFINE_T_FLOAT_VALUES (double, t_double_values) +DEFINE_T_FLOAT_VALUES (float, t_float_values2, float) +DEFINE_T_FLOAT_VALUES (double, t_double_values, double) +DEFINE_T_FLOAT_VALUES (long double, t_long_double_values, ldouble) =20 /* The parameter list of a t_TYPE_many_args function. Split out into prototyped vs non-prototyped variants because a macro body cannot @@ -394,9 +415,11 @@ DEFINE_T_FLOAT_VALUES (double, t_double_values) test that GDB can construct the parameter save area correctly. Note that Linux/ppc32 has 8 float registers to use for float parameter passing and Linux/ppc64 has 13, so the number of - arguments has to be at least 14 to contemplate these platforms. */ + arguments has to be at least 14 to contemplate these platforms. + PREFIX is passed separately because "long double" cannot be pasted + into a "long_double_val1" identifier. */ =20 -#define DEFINE_T_MANY_ARGS(TYPE, NAME) \ +#define DEFINE_T_MANY_ARGS(TYPE, NAME, PREFIX) \ TYPE \ NAME T_MANY_ARGS_PARAMS (TYPE) \ { \ @@ -405,18 +428,19 @@ NAME T_MANY_ARGS_PARAMS (TYPE) \ \ sum_args =3D (f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 \ + f12 + f13 + f14 + f15); \ - sum_values =3D (TYPE##_val1 + TYPE##_val2 + TYPE##_val3 \ - + TYPE##_val4 + TYPE##_val5 + TYPE##_val6 \ - + TYPE##_val7 + TYPE##_val8 + TYPE##_val9 \ - + TYPE##_val10 + TYPE##_val11 + TYPE##_val12 \ - + TYPE##_val13 + TYPE##_val14 + TYPE##_val15); \ + sum_values =3D (PREFIX##_val1 + PREFIX##_val2 + PREFIX##_val3 \ + + PREFIX##_val4 + PREFIX##_val5 + PREFIX##_val6 \ + + PREFIX##_val7 + PREFIX##_val8 + PREFIX##_val9 \ + + PREFIX##_val10 + PREFIX##_val11 + PREFIX##_val12 \ + + PREFIX##_val13 + PREFIX##_val14 + PREFIX##_val15); \ \ return ((sum_args - sum_values) < DELTA \ && (sum_args - sum_values) > -DELTA); \ } =20 -DEFINE_T_MANY_ARGS (float, t_float_many_args) -DEFINE_T_MANY_ARGS (double, t_double_many_args) +DEFINE_T_MANY_ARGS (float, t_float_many_args, float) +DEFINE_T_MANY_ARGS (double, t_double_many_args, double) +DEFINE_T_MANY_ARGS (long double, t_long_double_many_args, ldouble) =20 /* Various functions for _Complex types. */ =20 diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/= callfuncs.exp index 0ac1c603351..4637f41e4eb 100644 --- a/gdb/testsuite/gdb.base/callfuncs.exp +++ b/gdb/testsuite/gdb.base/callfuncs.exp @@ -136,6 +136,32 @@ proc do_function_calls {prototypes} { =20 gdb_test "p t_double_many_args (double_val1, double_val2, double_val3, do= uble_val4, double_val5, double_val6, double_val7, double_val8, double_val9,= double_val10, double_val11, double_val12, double_val13, double_val14, doub= le_val15)" " =3D 1" "call function with many double arguments." =20 + gdb_test "p t_long_double_values(0.0,0.0)" " =3D 0" + # Same, via function pointer. When the pointer type is + # unprototyped, GDB has no parameter type to coerce the + # arguments to, so the literals must carry the "L" suffix to + # be passed as long double rather than double. + if {$prototypes} { + gdb_test "p ((int (*) (long double, long double)) t_long_double_value= s)(0.0,0.0)" " =3D 0" + } else { + gdb_test "p ((int (*) ()) t_long_double_values)(0.0L,0.0L)" " =3D 0" + } + + gdb_test "p t_long_double_values(45.654,-67.66)" " =3D 1" + if {$prototypes} { + gdb_test "p ((int (*) (long double, long double)) t_long_double_value= s)(45.654,-67.66)" " =3D 1" + } else { + gdb_test "p ((int (*) ()) t_long_double_values)(45.654L,-67.66L)" " = =3D 1" + } + + gdb_test "p t_long_double_values(ldouble_val1,ldouble_val2)" " =3D 1" + gdb_test "p t_long_double_values(45.654,ldouble_val2)" " =3D 1" + gdb_test "p t_long_double_values(ldouble_val1,-67.66)" " =3D 1" + + gdb_test "p t_long_double_many_args (ldouble_val1, ldouble_val2, ldouble_= val3, ldouble_val4, ldouble_val5, ldouble_val6, ldouble_val7, ldouble_val8,= ldouble_val9, ldouble_val10, ldouble_val11, ldouble_val12, ldouble_val13, = ldouble_val14, ldouble_val15)" \ + " =3D 1" \ + "call function with many long double arguments" + gdb_test "p t_double_int(99.0, 1)" " =3D 0" gdb_test "p t_double_int(99.0, 99)" " =3D 1" gdb_test "p t_int_double(99, 1.0)" " =3D 0"