Re: [PATCH 4/4] gdb.base/callfuncs.exp: Exercise "long double"
Andrew Burgess <[email protected]>
| Newsgroups | gmane.comp.gdb.patches |
|---|---|
| Message-ID | <[email protected]> |
Pedro Alves <[email protected]> writes: > 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. > > On x86_64-pc-windows-msvc, without the fix that teaches GDB about the > correct size of "long double", we get: > > $ grep FAIL gdb.sum > FAIL: gdb.base/callfuncs.exp: noproto: p ((int (*) ()) t_long_double_values)(45.654L,-67.66L) > FAIL: gdb.base/callfuncs.exp: p ((int (*) (long double, long double)) t_long_double_values)(45.654,-67.66) > > 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. > > 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. LGTM. Approved-By: Andrew Burgess <[email protected]> Thanks, Andrew > > Change-Id: Ibcc3590753d08ece4fbf03c5d890872197047fff > --- > 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/callfuncs.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 = 10.25; > double double_val14 = 11.25; > double double_val15 = 12.25; > > +/* "long double" cannot be pasted into a "long_double_val1" > + identifier, so the long double globals use an "ldouble" prefix. */ > +long double ldouble_val1 = 45.654; > +long double ldouble_val2 = -67.66; > +long double ldouble_val3 = 0.25; > +long double ldouble_val4 = 1.25; > +long double ldouble_val5 = 2.25; > +long double ldouble_val6 = 3.25; > +long double ldouble_val7 = 4.25; > +long double ldouble_val8 = 5.25; > +long double ldouble_val9 = 6.25; > +long double ldouble_val10 = 7.25; > +long double ldouble_val11 = 8.25; > +long double ldouble_val12 = 9.25; > +long double ldouble_val13 = 10.25; > +long double ldouble_val14 = 11.25; > +long double ldouble_val15 = 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 > > /* 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. */ > > -#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); \ > } > > -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) > > /* 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. */ > > -#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 = (f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 \ > + f12 + f13 + f14 + f15); \ > - sum_values = (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 = (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); \ > } > > -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) > > /* Various functions for _Complex types. */ > > diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/callfuncs.exp > index f020100ce8b..ebc389c6b03 100644 > --- a/gdb/testsuite/gdb.base/callfuncs.exp > +++ b/gdb/testsuite/gdb.base/callfuncs.exp > @@ -136,6 +136,32 @@ proc do_function_calls {prototypes} { > > gdb_test "p t_double_many_args (double_val1, double_val2, double_val3, double_val4, double_val5, double_val6, double_val7, double_val8, double_val9, double_val10, double_val11, double_val12, double_val13, double_val14, double_val15)" " = 1" "call function with many double arguments." > > + gdb_test "p t_long_double_values(0.0,0.0)" " = 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_values)(0.0,0.0)" " = 0" > + } else { > + gdb_test "p ((int (*) ()) t_long_double_values)(0.0L,0.0L)" " = 0" > + } > + > + gdb_test "p t_long_double_values(45.654,-67.66)" " = 1" > + if {$prototypes} { > + gdb_test "p ((int (*) (long double, long double)) t_long_double_values)(45.654,-67.66)" " = 1" > + } else { > + gdb_test "p ((int (*) ()) t_long_double_values)(45.654L,-67.66L)" " = 1" > + } > + > + gdb_test "p t_long_double_values(ldouble_val1,ldouble_val2)" " = 1" > + gdb_test "p t_long_double_values(45.654,ldouble_val2)" " = 1" > + gdb_test "p t_long_double_values(ldouble_val1,-67.66)" " = 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)" \ > + " = 1" \ > + "call function with many long double arguments" > + > gdb_test "p t_double_int(99.0, 1)" " = 0" > gdb_test "p t_double_int(99.0, 99)" " = 1" > gdb_test "p t_int_double(99, 1.0)" " = 0" > -- > 2.54.0