Re: [PATCH 1/4] gdb.base/nodebug.exp: Add long double testing

Andrew Burgess <[email protected]>
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
Pedro Alves <[email protected]> writes:

> gdb.base/nodebug.exp is missing testing calling long double functions.
> This commit adds such tests.
>
> With a GDB that doesn't know that "long double" is 64-bit on
> x86_64-pc-windows-msvc, we get:
>
>  FAIL: gdb.base/nodebug.exp: p (long double) mult_long_double(2.0L, 3.0L)
>  FAIL: gdb.base/nodebug.exp: p ((long double (*) (long double, long double)) mult_long_double)(2.0L, 3.0L)
>  FAIL: gdb.base/nodebug.exp: p ((long double (*) (long double, long double)) mult_long_double)(2, 3)
>  FAIL: gdb.base/nodebug.exp: p ((long double (*) ()) mult_long_double_noproto)(2.0L, 3.0L)
>
> Passes cleanly on:
>
>  - x86_64-pc-linux-gnu
>  - x86_64-w64-mingw32
>  - x86_64-pc-windows-msvc, with the "long double" fix
>
> Change-Id: If9ee749187e1d30fedcba17ae12634f3bd90de2f
> ---
>  gdb/testsuite/gdb.base/nodebug.c   | 13 +++++++++++++
>  gdb/testsuite/gdb.base/nodebug.exp |  6 ++++++
>  2 files changed, 19 insertions(+)
>
> diff --git a/gdb/testsuite/gdb.base/nodebug.c b/gdb/testsuite/gdb.base/nodebug.c
> index c7bc93991b8..275a9d6ff60 100644
> --- a/gdb/testsuite/gdb.base/nodebug.c
> +++ b/gdb/testsuite/gdb.base/nodebug.c
> @@ -72,6 +72,12 @@ mult (double v1, double v2)
>    return v1 * v2;
>  }
>  
> +long double
> +mult_long_double (long double v1, long double v2)
> +{
> +  return v1 * v2;
> +}
> +
>  double
>  mult_noproto (v1, v2)
>    double v1, v2;
> @@ -79,6 +85,13 @@ mult_noproto (v1, v2)
>    return v1 * v2;
>  }
>  
> +long double
> +mult_long_double_noproto (v1, v2)
> +  long double v1, v2;
> +{
> +  return v1 * v2;
> +}

Not that it really matters, but the ordering seems a bit weird, the
existing functions are all:

X
X_noproto
Y
Y_noproto
etc...

but you broke this pattern.  I only mention it because I have some
actual worthwhile points to raise below...

> +
>  uint8_t
>  add8 (uint8_t v1, uint8_t v2)
>  {
> diff --git a/gdb/testsuite/gdb.base/nodebug.exp b/gdb/testsuite/gdb.base/nodebug.exp
> index e4138a801da..1a16e86ed2c 100644
> --- a/gdb/testsuite/gdb.base/nodebug.exp
> +++ b/gdb/testsuite/gdb.base/nodebug.exp
> @@ -78,6 +78,12 @@ proc test_call_promotion {} {
>      gdb_test "p ((double (*) ()) mult_noproto)(2.0f, 3.0f)" " = 6"
>      gdb_test "p ((double (*) ()) mult_noproto)(2.0, 3.0)" " = 6"
>  
> +    # Same, but for long double.
> +    gdb_test "p (long double) mult_long_double(2.0L, 3.0L)" " = 6"
> +    gdb_test "p ((long double (*) (long double, long double)) mult_long_double)(2.0L, 3.0L)" " = 6"
> +    gdb_test "p ((long double (*) (long double, long double)) mult_long_double)(2, 3)" " = 6"
> +    gdb_test "p ((long double (*) ()) mult_long_double_noproto)(2.0L, 3.0L)" " = 6"

I noticed that the double test also includes a case which tests float to
double promotion, but that case is skipped here.  Wouldn't it be a good
idea to include both float to long double and double to long double
tests here too?

Thanks,
Andrew


> +
>      # Check that GDB promotes char->int correctly.
>      gdb_test "p /d (uint8) add8((uint8) 2, (uint8) 3)" " = 5"
>      gdb_test "p /d ((uint8 (*) (uint8, uint8)) add8)((uint8) 2, (uint8) 3)" " = 5"
> -- 
> 2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.