Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch, testsuite] Tests to _Complex type
@ 2011-05-06 14:13 Yao Qi
  2011-05-06 14:33 ` Joseph S. Myers
  0 siblings, 1 reply; 40+ messages in thread
From: Yao Qi @ 2011-05-06 14:13 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1425 bytes --]

When I am fixing GDB's inf-call in one port, I find tests to _Complex
type is quite limited, especially on argument passing, there is none.
This patch is to add more tests to _Complex type on argument passing and
vararg support.

Of course, these changes can be split, and moved to callfuncs.exp and
varargs.exp respectively.  I don't know to what extent _Complex is
supported on all GDB ports, so I put all _Complex related stuff into
complex.exp.

I run this case on these three systems I have, and some problems are
exposed:

i686-pc-linux-gnu: two SIGSEGV
FAIL: gdb.base/complex.exp: print find_max_double_real(4, dc1, dc2, dc3,
dc4)
FAIL: gdb.base/complex.exp: print complex_double_on_stackprint

armv7l-unknown-linux-gnueabi: four SIGSEGV
FAIL: gdb.base/complex.exp: print find_max_float_real(4, fc1, fc2, f3, f4)
FAIL: gdb.base/complex.exp: print find_max_double_real(4, dc1, dc2, dc3,
dc4)
FAIL: gdb.base/complex.exp: print complex_float_on_stackprint
FAIL: gdb.base/complex.exp: print complex_double_on_stackprint

x86_64-unknown-linux-gnu:
FAIL: gdb.base/complex.exp: print find_max_float_real(4, fc1, fc2, f3, f4)
FAIL: gdb.base/complex.exp: print find_max_double_real(4, dc1, dc2, dc3,
dc4)
FAIL: gdb.base/complex.exp: print complex_float_on_stackprint
FAIL: gdb.base/complex.exp: print complex_double_on_stackprint

This case causes new fails, so shall I kfail it?  Comments are welcome.

-- 
Yao (齐尧)

[-- Attachment #2: 0003-complex-test-case.patch --]
[-- Type: text/x-patch, Size: 3885 bytes --]

gdb/testsuite/
2011-05-06  Yao Qi  <yao@codesourcery.com>

	* gdb.base/complex.c (find_max_float_real): New.
	(find_max_double_real, complex_double_on_stack): New.
	(complex_float_on_stack): New.
	* gdb.base/complex.exp: Call these new functions in complex.c.

---
 gdb/testsuite/gdb.base/complex.c   |   78 ++++++++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.base/complex.exp |   19 +++++++++
 2 files changed, 97 insertions(+), 0 deletions(-)

diff --git a/gdb/testsuite/gdb.base/complex.c b/gdb/testsuite/gdb.base/complex.c
index 9b890c9..7623b6d 100644
--- a/gdb/testsuite/gdb.base/complex.c
+++ b/gdb/testsuite/gdb.base/complex.c
@@ -20,6 +20,7 @@ Free Software Foundation, Inc.
    a complex number.  */
 
 #include <stdlib.h>
+#include <stdarg.h>
 
 typedef __complex__ float cf;
 struct x { char c; cf f; } __attribute__ ((__packed__));
@@ -28,11 +29,14 @@ extern void f4 (struct unpacked_x*);
 extern void f3 (void);
 extern void f2 (struct x*);
 extern void f1 (void);
+extern void marker (void);
 int
 main (void)
 {
   f1 ();
   f3 ();
+  marker ();
+
   exit (0);
 }
 
@@ -67,3 +71,77 @@ f4 (struct unpacked_x *y)
   if (y->f != 1 || y->c != 42)
     abort ();
 }
+
+
+extern float crealf (float _Complex);
+
+float _Complex fc1 = 1.0F + 1.0iF;
+float _Complex fc2 = 2.0F + 2.0iF;
+float _Complex fc3 = 3.0F + 3.0iF;
+float _Complex fc4 = 4.0F + 4.0iF;
+
+float _Complex
+find_max_float_real (int num_vals, ...)
+{
+  float _Complex max = 0.0F + 0.0iF;
+  float _Complex x;
+  va_list argp;
+  int i;
+
+  va_start(argp, num_vals);
+  for (i = 0; i < num_vals; i++)
+    {
+      x = va_arg (argp, float _Complex);
+      if (crealf (max) < crealf (x)) max = x;
+    }
+
+  return max;
+}
+
+extern double creal (double _Complex);
+double _Complex dc1 = 1.0 + 1.0i;
+double _Complex dc2 = 2.0 + 2.0i;
+double _Complex dc3 = 3.0 + 3.0i;
+double _Complex dc4 = 4.0 + 4.0i;
+
+double _Complex
+find_max_double_real (int num_vals, ...)
+{
+  double _Complex max = 0.0F + 0.0iF;
+  double _Complex x;
+  va_list argp;
+  int i;
+
+  va_start(argp, num_vals);
+  for (i = 0; i < num_vals; i++)
+    {
+      x = va_arg (argp, double _Complex);
+      if (creal (max) < creal (x)) max = x;
+    }
+
+  return max;
+}
+
+/* Force DC is passed on stack.  */
+_Complex double
+complex_double_on_stack (double f1, double f2, double f3, double f4, double f5,
+			 double f6, double f7, double f8, double f9, double f10,
+			 double f11, double f12, double f13, double f14,
+			 double f15, _Complex double dc)
+{
+  return dc;
+};
+
+/* Force FC is passed on stack.  */
+_Complex float
+complex_float_on_stack (double f1, double f2, double f3, double f4, double f5,
+			 double f6, double f7, double f8, double f9, double f10,
+			 double f11, double f12, double f13, double f14,
+			 double f15, _Complex float fc)
+{
+  return fc;
+};
+
+void marker ()
+{
+}
diff --git a/gdb/testsuite/gdb.base/complex.exp b/gdb/testsuite/gdb.base/complex.exp
index 27af703..cb16fa5 100644
--- a/gdb/testsuite/gdb.base/complex.exp
+++ b/gdb/testsuite/gdb.base/complex.exp
@@ -55,4 +55,23 @@ if [runto f4] then {
 	    "print complex value in C"
 }
 
+if [runto marker] then {
+    gdb_test "print find_max_float_real(4, fc1, fc2, fc3, fc4)" \
+	".*= 4 \\+ 4 \\* I" \
+	"print find_max_float_real(4, fc1, fc2, f3, f4)"
+
+    gdb_test "print find_max_double_real(4, dc1, dc2, dc3, dc4)" \
+	".*= 4 \\+ 4 \\* I" \
+	"print find_max_double_real(4, dc1, dc2, dc3, dc4)"
+
+    gdb_test "print complex_float_on_stack (1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, fc1)" \
+	".*= 1 \\+ 1 \\* I" \
+	"print complex_float_on_stackprint"
+
+    gdb_test "print complex_double_on_stack (1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, dc1)" \
+	".*= 1 \\+ 1 \\* I" \
+	"print complex_double_on_stackprint"
+
+}
+
 return 0
-- 
1.7.0.4


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch, testsuite] Tests to _Complex type
  2011-05-06 14:13 [patch, testsuite] Tests to _Complex type Yao Qi
@ 2011-05-06 14:33 ` Joseph S. Myers
  2011-05-09  2:24   ` Yao Qi
  0 siblings, 1 reply; 40+ messages in thread
From: Joseph S. Myers @ 2011-05-06 14:33 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

On Fri, 6 May 2011, Yao Qi wrote:

> When I am fixing GDB's inf-call in one port, I find tests to _Complex
> type is quite limited, especially on argument passing, there is none.
> This patch is to add more tests to _Complex type on argument passing and
> vararg support.

It would be good to include a much wider range of tests.  structs and 
unions containing complex values (and arrays of complex values, and 
complex values mixed with real ones, etc.), complex values in many 
different argument positions, and after integer arguments as well as 
floating-point ones, all three types _Complex float, _Complex double, 
_Complex long double properly covered in these ways.  For structs and 
unions and arrays therein, the sort of case you want to cover includes the 
ARM (VFP ABI) and IA64 rules on homogeneous aggregates.

(The reason I don't suggest covering complex integer types is that they 
are a GNU extension with no documented GNU DWARF extension to represent 
them.  In principle target-specific types such as __float80 and __float128 
(on x86 and IA64) and their complex versions *should* be covered, but at 
present GCC doesn't support using _Complex with those type names so 
accessing the complex versions requires using mode attributes.)

-- 
Joseph S. Myers
joseph@codesourcery.com


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch, testsuite] Tests to _Complex type
  2011-05-06 14:33 ` Joseph S. Myers
@ 2011-05-09  2:24   ` Yao Qi
  2011-05-09 15:06     ` Tom Tromey
  0 siblings, 1 reply; 40+ messages in thread
From: Yao Qi @ 2011-05-09  2:24 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: gdb-patches

On 05/06/2011 10:33 PM, Joseph S. Myers wrote:
> It would be good to include a much wider range of tests.  structs and 
> unions containing complex values (and arrays of complex values, and 
> complex values mixed with real ones, etc.), complex values in many 
> different argument positions, and after integer arguments as well as 
> floating-point ones, all three types _Complex float, _Complex double, 
> _Complex long double properly covered in these ways.  For structs and 
> unions and arrays therein, the sort of case you want to cover includes the 
> ARM (VFP ABI) and IA64 rules on homogeneous aggregates.

Yes, I agree.  After go through gdb testsuite, we may do several tests
for _Complex in these following areas,
1. pass and return _Complex type and _Complex type in aggregate type in
function call, like funcargs.exp and callfuncs.exp.
2. vararg for _Complex type and _Complex type in aggregate type, like
varargs.exp
3. _Complex type in struct, like struct.exp.

GDB maintainers,
Shall we propagate _Complex related tests to each *.exp file, such as
funcargs.exp/callfuncs.exp/varargs.exp/struct.arg? or keep all _Complex
tests in a single exp file complex.exp?  I prefer the former one, but I
am afraid this will break some platforms which don't support _Complex.
Thoughts?

-- 
Yao (齐尧)


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch, testsuite] Tests to _Complex type
  2011-05-09  2:24   ` Yao Qi
@ 2011-05-09 15:06     ` Tom Tromey
  2011-05-19  4:26       ` [_Complex test 1/4] support_complex_tests in gdb.exp and pass _Complex args to func Yao Qi
                         ` (3 more replies)
  0 siblings, 4 replies; 40+ messages in thread
From: Tom Tromey @ 2011-05-09 15:06 UTC (permalink / raw)
  To: Yao Qi; +Cc: Joseph S. Myers, gdb-patches

>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:

Yao> Shall we propagate _Complex related tests to each *.exp file, such as
Yao> funcargs.exp/callfuncs.exp/varargs.exp/struct.arg? or keep all _Complex
Yao> tests in a single exp file complex.exp?  I prefer the former one, but I
Yao> am afraid this will break some platforms which don't support _Complex.
Yao> Thoughts?

As long as the change is done cleanly, and there is some mechanism for
avoiding the troublesome code on platforms not supporting _Complex (and
in particular making the rest of the tests in these files continue to
execute on such a platform), then it doesn't matter to me where the
tests end up.

Tom


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [_Complex test 1/4]  support_complex_tests in gdb.exp and pass _Complex args to func
  2011-05-09 15:06     ` Tom Tromey
@ 2011-05-19  4:26       ` Yao Qi
  2011-05-19  8:16         ` Mark Kettenis
  2011-05-19 10:12         ` Joseph S. Myers
  2011-05-19  4:34       ` [_Complex test 2/4] _Complex type in varargs.exp Yao Qi
                         ` (2 subsequent siblings)
  3 siblings, 2 replies; 40+ messages in thread
From: Yao Qi @ 2011-05-19  4:26 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1534 bytes --]

On 05/09/2011 11:06 PM, Tom Tromey wrote:
> As long as the change is done cleanly, and there is some mechanism for
> avoiding the troublesome code on platforms not supporting _Complex (and
> in particular making the rest of the tests in these files continue to
> execute on such a platform), then it doesn't matter to me where the
> tests end up.
> 

As suggested by Tom, the whole test cases to _Complex type should be run
on the platforms that support _Complex.  As a result,
support_complex_tests is added in lib/gdb.exp, which determines whether
to run tests to _Complex according to proper target triplets.  As I
comment in support_complex_tests, the list of target triplet is still
very conservative, because I don't want break existing tests on some
`complex-type-unsupported' platforms that I am not aware of.  People who
familiar with a certain platform can enrich this list later.

All the _Complex stuff in *.c are isolated by checking macro
TEST_COMPLEX.  If support_complex_tests returns 1, TEST_COMPLEX is
defined in compilation commandline.  For the platforms doesn't support
_Complex, the rest of test case will run as usual.

The other part I am not sure is about PROTOTYPES.  If I understand it
correctly, these stuff are used to be compatible with old C standard,
while _Complex types are introduced in C99.  We may don't need prototype
stuffs for functions of _Complex args/return type.  In my patch, I still
follow the existing manner.

Run funargs.exp on i686-pc-linux-gnu, no new fails.

-- 
Yao (齐尧)

[-- Attachment #2: 0001-funcargs.patch --]
[-- Type: text/x-patch, Size: 9844 bytes --]

2011-05-19  Yao Qi  <yao@codesourcery.com>
gdb/testsuite/

	* gdb.base/funcargs.c (callca, callcb, callcc): New.
	(callcd, callce, callcf, callc1a, callc1b): New.
	(callc2a, callc2b): New.
	* gdb.base/funcargs.exp (complex_args): New.
	(complex_integral_args, complex_float_integral_args): New.
	* lib/gdb.exp (support_complex_tests): New.  Determine
	whether to run test cases on _Complex types.

From 287afaa594c39214d72f10027ca195e7d2f61111 Mon Sep 17 00:00:00 2001
From: Yao Qi <yao@codesourcery.com>
Date: Sat, 14 May 2011 11:12:32 +0800
Subject: [PATCH 1/4] funcargs

---
 gdb/testsuite/gdb.base/funcargs.c   |  134 +++++++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.base/funcargs.exp |   94 ++++++++++++++++++++++++-
 gdb/testsuite/lib/gdb.exp           |   15 ++++
 3 files changed, 242 insertions(+), 1 deletions(-)

diff --git a/gdb/testsuite/gdb.base/funcargs.c b/gdb/testsuite/gdb.base/funcargs.c
index f7dfc64..6d16b62 100644
--- a/gdb/testsuite/gdb.base/funcargs.c
+++ b/gdb/testsuite/gdb.base/funcargs.c
@@ -53,6 +53,12 @@ float *fp = &f;
 double d = 5.0;
 double *dp = &d;
 
+#ifdef TEST_COMPLEX
+float _Complex fc = 1.0F + 2.0iF;
+double _Complex dc = 3.0 + 4.0i;
+long double _Complex ldc = 5.0L + 6.0iL;
+#endif /* TEST_COMPLEX */
+
 struct stag {
     int s1;
     int s2;
@@ -311,6 +317,117 @@ float *fp; double *dp;
 }
 
 
+
+#ifdef TEST_COMPLEX
+
+/* Test various _Complex type args.  */
+
+#ifdef PROTOTYPES
+void callca (float _Complex f1, float _Complex f2, float _Complex f3)
+#else
+callca (f1, f2, f3)
+float _Complex f1; float _Complex f2; float _Complex f3;
+#endif
+{
+
+}
+
+#ifdef PROTOTYPES
+void callcb (double _Complex d1, double _Complex d2, double _Complex d3)
+#else
+callcb (d1, d2, d3)
+double _Complex d1; double _Complex d2; double _Complex d3;
+#endif
+{
+
+}
+
+#ifdef PROTOTYPES
+void callcc (long double _Complex ld1, long double _Complex ld2, long double _Complex ld3)
+#else
+callcc (ld1, ld2, ld3)
+long double _Complex ld1; long double _Complex ld2; long double _Complex ld3;
+#endif
+{
+
+}
+
+#ifdef PROTOTYPES
+void callcd (float _Complex fc1, double _Complex dc1, long double _Complex ldc1)
+#else
+callcd (fc1, dc1, ldc1)
+float _Complex fc1; double _Complex dc1; long double _Complex ldc1;
+#endif
+{
+}
+
+#ifdef PROTOTYPES
+void callce (double _Complex dc1, long double _Complex ldc1, float _Complex fc1)
+#else
+callce (dc1, ldc1, fc1)
+double _Complex dc1; long double _Complex ldc1; float _Complex fc1;
+#endif
+{
+}
+
+#ifdef PROTOTYPES
+void callcf (long double _Complex ldc1, float _Complex fc1, double _Complex dc1)
+#else
+callcf (ldc1, fc1, dc1)
+long double _Complex ldc1; float _Complex fc1; double _Complex dc1;
+#endif
+{
+}
+
+
+/* Test passing _Complex type and integral.  */
+#ifdef PROTOTYPES
+void callc1a (char c, short s, int i, unsigned int ui, long l,
+	      float _Complex fc1, double _Complex dc1,
+	      long double _Complex ldc1)
+#else
+callc1a (c, s, i, ui, l, fc1, dc1, ldc1)
+char c; short s; int i; unsigned int ui; long l; float _Complex fc1; double _Complex dc1; long double _Complex ldc1;
+#endif
+{}
+
+#ifdef PROTOTYPES
+void callc1b (long double _Complex ldc1, char c, short s, int i,
+	      float _Complex fc1, unsigned int ui, long l,  double _Complex dc1)
+#else
+callc1b (ldc1, c, s, i, fc1, ui, l, dc1)
+char c; short s; int i; unsigned int ui; long l; float _Complex fc1; double _Complex dc1; long double _Complex ldc1;
+#endif
+{}
+
+
+#ifdef PROTOTYPES
+void callc2a (char c, short s, int i, unsigned int ui, long l, float f,
+	      double d, float _Complex fc1, double _Complex dc1,
+	      long double _Complex ldc1)
+#else
+callc2a (c, s, i, ui, l, f, d, fc1, dc1, ldc1)
+     char c; short s; int i; unsigned int ui; long l; float f; double d;
+     float _Complex fc1; double _Complex dc1;
+     long double _Complex ldc1;
+#endif
+{}
+
+#ifdef PROTOTYPES
+void callc2b (float _Complex fc1, char c, short s, int i, unsigned int ui,
+	      long double _Complex ldc1, long l, float f, double d,
+	      double _Complex dc1)
+#else
+callc2b (fc1, c, s, i, ui, ldc1, l, f, d, dc1)
+     char c; short s; int i; unsigned int ui; long l; float f; double d;
+     float _Complex fc1; double _Complex dc1;
+     long double _Complex ldc1;
+#endif
+{}
+
+
+#endif /* TEST_COMPLEX */
+
 /* Test passing structures and unions by reference. */
 
 
@@ -749,6 +866,23 @@ int main ()
   call2h (d, c, f, s, d, i, f, l);
   call2i (c, f, c, c, d, c, c, c, f, s, c, d);
 
+#ifdef TEST_COMPLEX
+  /* Test calling with _Complex types.  */
+  callca (fc, fc, fc);
+  callcb (dc, dc, dc);
+  callcc (ldc, ldc, ldc);
+  callcd (fc, dc, ldc);
+  callce (dc, ldc, fc);
+  callcf (ldc, fc, dc);
+
+
+  callc1a (c, s, i, ui, l, fc, dc, ldc);
+  callc1b (ldc, c, s, i, fc, ui, l, dc);
+
+  callc2a (c, s, i, ui, l, f, d, fc, dc, ldc);
+  callc2b (fc, c, s, i, ui, ldc, l, f, d, dc);
+#endif /* TEST_COMPLEX */
+
   /* Test dereferencing pointers to various integral and floating types */
 
   call3a (cp, sp, ip, lp);
diff --git a/gdb/testsuite/gdb.base/funcargs.exp b/gdb/testsuite/gdb.base/funcargs.exp
index 0b80082..14161c1 100644
--- a/gdb/testsuite/gdb.base/funcargs.exp
+++ b/gdb/testsuite/gdb.base/funcargs.exp
@@ -24,7 +24,13 @@ if $tracelevel {
 set testfile "funcargs"
 set srcfile ${testfile}.c
 set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+
+set compile_flags {debug nowarnings quiet}
+if [support_complex_tests] {
+    set compile_flags "$compile_flags additional_flags=-DTEST_COMPLEX"
+}
+
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $compile_flags] != "" } {
      untested funcargs.exp
      return -1
 }
@@ -239,6 +245,77 @@ proc float_and_integral_args {} {
     gdb_stop_suppressing_tests;
 }
 
+
+#
+# Locate actual args; _Complex types.
+#
+
+proc complex_args {} {
+    global gdb_prompt
+
+    delete_breakpoints
+
+    gdb_breakpoint callca;
+    gdb_breakpoint callcb;
+    gdb_breakpoint callcc;
+    gdb_breakpoint callcd;
+    gdb_breakpoint callce;
+    gdb_breakpoint callcf;
+
+    # Run; should stop at call1a and print actual arguments.
+    gdb_run_cmd
+    gdb_expect {
+	-re ".* callca \\(f1=1 \\+ 2 \\* I, f2=1 \\+ 2 \\* I, f3=1 \\+ 2 \\* I\\) .*$gdb_prompt $" { pass "run to call2a" }
+	timeout { fail "(timeout) run to callca" ; gdb_suppress_tests; }
+    }
+    gdb_test "cont" ".* callcb \\(d1=3 \\+ 4 \\* I, d2=3 \\+ 4 \\* I, d3=3 \\+ 4 \\* I\\) .*" "continue to callcb"
+    gdb_test "cont" ".* callcc \\(ld1=5 \\+ 6 \\* I, ld2=5 \\+ 6 \\* I, ld3=5 \\+ 6 \\* I\\) .*" "continue to callcb"
+    gdb_test "cont" ".* callcd \\(fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I\\) .*" "continue to callcd"
+    gdb_test "cont" ".* callce \\(dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I, fc1=1 \\+ 2 \\* I\\) .*" "continue to callce"
+    gdb_test "cont" ".* callcf \\(ldc1=5 \\+ 6 \\* I, fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I\\) .*" "continue to callcf"
+}
+
+
+#
+# Locate actual args; _Complex types and integral.
+#
+proc  complex_integral_args {} {
+    global gdb_prompt
+
+    delete_breakpoints
+
+    gdb_breakpoint callc1a;
+    gdb_breakpoint callc1b;
+
+    # Run; should stop at call1a and print actual arguments.
+    gdb_run_cmd
+    gdb_expect {
+	-re ".* callc1a \\(c=97 'a', s=1, i=2, ui=7, l=3, fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I\\) .*$gdb_prompt $" { pass "run to callc1a" }
+	timeout { fail "(timeout) run to callc1a" ; gdb_suppress_tests; }
+    }
+    gdb_test "cont" ".* callc1b \\(ldc1=5 \\+ 6 \\* I\\, c=97 'a', s=1, i=2, fc1=1 \\+ 2 \\* I, ui=7, l=3, dc1=3 \\+ 4 \\* I\\) .*" "continue to callc1b"
+}
+
+#
+# Locate acual args; _Complex types and integral/float.
+#
+proc complex_float_integral_args {} {
+    global gdb_prompt
+
+    delete_breakpoints
+
+    gdb_breakpoint callc2a;
+    gdb_breakpoint callc2b;
+
+    # Run; should stop at call1a and print actual arguments.
+    gdb_run_cmd
+    gdb_expect {
+	-re ".* callc2a \\(c=97 'a', s=1, i=2, ui=7, l=3, f=4, d=5, fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I\\) .*$gdb_prompt $" { pass "run to callc2a" }
+	timeout { fail "(timeout) run to callc1a" ; gdb_suppress_tests; }
+    }
+    gdb_test "cont" ".* callc2b \\(fc1=1 \\+ 2 \\* I, c=97 'a', s=1, i=2, ui=7, ldc1=5 \\+ 6 \\* I\\, l=3, f=4, d=5, dc1=3 \\+ 4 \\* I\\) .*" "continue to callc2b"
+}
+
 #
 # Locate actual args; dereference pointers to ints and floats.
 #
@@ -1167,6 +1244,21 @@ funcargs_reload
 if {![target_info exists gdb,skip_float_tests]} {
   float_and_integral_args
 }
+
+# Test _Complex type here if supported.
+if [support_complex_tests] {
+    funcargs_reload
+    complex_args
+
+    funcargs_reload
+    complex_integral_args
+
+    if {![target_info exists gdb,skip_float_tests]} {
+	funcargs_reload
+	complex_float_integral_args
+    }
+}
+
 funcargs_reload
 pointer_args
 funcargs_reload
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 531120c..8be8396 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1486,6 +1486,21 @@ proc skip_shlib_tests {} {
     return 1
 }
 
+# Return a 1 if we should run tests to _Complex types, otherwise, skip it.
+
+proc support_complex_tests {} {
+    # In order to avoid breaking test on platforms not supporting _Complex,
+    # the list of target triplet supporting tests to _Complex type is still
+    # conservative.  More target triplet can be added here if we are sure
+    # _Complex type is supported.
+    if {[istarget *-*-linux*]
+        || [istarget *-*-elf*]} {
+	return 1;
+    }
+
+    return 0;
+}
+
 # Return 1 if target is ILP32.
 # This cannot be decided simply from looking at the target string,
 # as it might depend on externally passed compiler options like -m64.
-- 
1.7.0.4


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [_Complex test 2/4] _Complex type in varargs.exp
  2011-05-09 15:06     ` Tom Tromey
  2011-05-19  4:26       ` [_Complex test 1/4] support_complex_tests in gdb.exp and pass _Complex args to func Yao Qi
@ 2011-05-19  4:34       ` Yao Qi
  2011-05-19 10:13         ` Joseph S. Myers
  2011-05-19 17:12         ` Tom Tromey
  2011-05-19  4:46       ` [_Complex test 3/4] Isolate each test's effect in callfuncs.exp Yao Qi
  2011-05-19  5:09       ` [_Complex test 4/4] _Complex tests " Yao Qi
  3 siblings, 2 replies; 40+ messages in thread
From: Yao Qi @ 2011-05-19  4:34 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 490 bytes --]

This patch is to add _Complex type in vararg testing.

Run varargs.exp on i686-pc-linux-gnu, get new two KFAIL.  Note that PR
12776 is opened to track this problem.

KFAIL: gdb.base/varargs.exp: print find_max_double_real(4, dc1, dc2,
dc3, dc4) (PRMS: gdb/12776)
KFAIL: gdb.base/varargs.exp: print find_max_double_real(4, dc1, dc2,
dc3, dc4) (PRMS: gdb/12776)

                === gdb Summary ===

# of expected passes            9
# of known failures             2

-- 
Yao (齐尧)

[-- Attachment #2: 0002-vararg-of-type-_Complex.patch --]
[-- Type: text/x-patch, Size: 4561 bytes --]

gdb/testsuite/

	Test inf-call of varargs of type _Complex.
	* gdb.base/varargs.c (find_max_float_real): New.
	(find_max_double_real, find_max_long_double_real): New.
	* gdb.base/varargs.exp: Call these new added functions.

From c2ebad1f79857052030c535ba0c647ddf798f2c1 Mon Sep 17 00:00:00 2001
From: Yao Qi <yao@codesourcery.com>
Date: Wed, 18 May 2011 15:35:31 +0800
Subject: [PATCH 2/4] vararg of type _Complex

---
 gdb/testsuite/gdb.base/varargs.c   |   80 ++++++++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.base/varargs.exp |   38 +++++++++++++++++
 2 files changed, 118 insertions(+), 0 deletions(-)

diff --git a/gdb/testsuite/gdb.base/varargs.c b/gdb/testsuite/gdb.base/varargs.c
index 1122767..1ad2ffc 100644
--- a/gdb/testsuite/gdb.base/varargs.c
+++ b/gdb/testsuite/gdb.base/varargs.c
@@ -23,6 +23,28 @@ float fa,fb,fc,fd;
 double da,db,dc,dd;
 double dmax_val;
 
+#ifdef TEST_COMPLEX
+extern float crealf (float _Complex);
+extern double creal (double _Complex);
+extern long double creall (long double _Complex);
+
+float _Complex fc1 = 1.0F + 1.0iF;
+float _Complex fc2 = 2.0F + 2.0iF;
+float _Complex fc3 = 3.0F + 3.0iF;
+float _Complex fc4 = 4.0F + 4.0iF;
+
+double _Complex dc1 = 1.0 + 1.0i;
+double _Complex dc2 = 2.0 + 2.0i;
+double _Complex dc3 = 3.0 + 3.0i;
+double _Complex dc4 = 4.0 + 4.0i;
+
+long double _Complex ldc1 = 1.0L + 1.0Li;
+long double _Complex ldc2 = 2.0L + 2.0Li;
+long double _Complex ldc3 = 3.0L + 3.0Li;
+long double _Complex ldc4 = 4.0L + 4.0Li;
+
+#endif
+
 int main() {
   c = -1;
   uc = 1;
@@ -109,3 +131,61 @@ double find_max_double(int num_vals, double first_val, ...) {
   return max_val;
 }
 
+
+#ifdef TEST_COMPLEX
+float _Complex
+find_max_float_real (int num_vals, ...)
+{
+  float _Complex max = 0.0F + 0.0iF;
+  float _Complex x;
+  va_list argp;
+  int i;
+
+  va_start(argp, num_vals);
+  for (i = 0; i < num_vals; i++)
+    {
+      x = va_arg (argp, float _Complex);
+      if (crealf (max) < crealf (x)) max = x;
+    }
+
+  return max;
+}
+
+double _Complex
+find_max_double_real (int num_vals, ...)
+{
+  double _Complex max = 0.0 + 0.0i;
+  double _Complex x;
+  va_list argp;
+  int i;
+
+  va_start(argp, num_vals);
+  for (i = 0; i < num_vals; i++)
+    {
+      x = va_arg (argp, double _Complex);
+      if (creal (max) < creal (x)) max = x;
+    }
+
+  return max;
+}
+
+long double _Complex
+find_max_long_double_real (int num_vals, ...)
+{
+  long double _Complex max = 0.0L + 0.0iL;
+  long double _Complex x;
+  va_list argp;
+  int i;
+
+  va_start(argp, num_vals);
+  for (i = 0; i < num_vals; i++)
+    {
+      x = va_arg (argp, long double _Complex);
+      if (creall (max) < creal (x)) max = x;
+    }
+
+  return max;
+}
+
+
+#endif /* TEST_COMPLEX */
diff --git a/gdb/testsuite/gdb.base/varargs.exp b/gdb/testsuite/gdb.base/varargs.exp
index 4627862..2a6c53b 100644
--- a/gdb/testsuite/gdb.base/varargs.exp
+++ b/gdb/testsuite/gdb.base/varargs.exp
@@ -44,6 +44,9 @@ if [get_compiler_info ${binfile}] {
 }
 
 set additional_flags {debug}
+if [support_complex_tests] {
+    set additional_flags "$additional_flags additional_flags=-DTEST_COMPLEX"
+}
 
 if {$hp_cc_compiler} {
     lappend additional_flags "additional_flags=-Ae"
@@ -112,3 +115,38 @@ if {![target_info exists gdb,skip_float_tests]} {
 	"print find_max_double(5,1.0,17.0,2.0,3.0,4.0)"
 }
 
+
+# Test _Complex type here if supported.
+if [support_complex_tests] {
+    global gdb_prompt
+
+    gdb_test_multiple "print find_max_float_real(4, fc1, fc2, fc3, fc4)" \
+	"print find_max_float_real(4, fc1, fc2, fc3, fc4)" {
+	-re ".*= 4 \\+ 4 \\* I.*$gdb_prompt $" {
+	    pass "print find_max_float_real(4, fc1, fc2, fc3, fc4)"
+	}
+	-re ".*$gdb_prompt $" {
+	    kfail gdb/12776 "print find_max_float_real(4, fc1, fc2, fc3, fc4)"
+	}
+    }
+
+    gdb_test_multiple "print find_max_double_real(4, dc1, dc2, dc3, dc4)" \
+	"print find_max_double_real(4, dc1, dc2, dc3, dc4)" {
+	-re ".*= 4 \\+ 4 \\* I.*${gdb_prompt} $" {
+	    pass "print find_max_float_real(4, fc1, fc2, fc3, fc4)"
+	}
+	-re ".*$gdb_prompt $" {
+	    kfail gdb/12776 "print find_max_double_real(4, dc1, dc2, dc3, dc4)"
+	}
+    }
+    gdb_test_multiple "print find_max_long_double_real(4, ldc1, ldc2, ldc3, ldc4)" \
+	"print find_max_long_double_real(4, ldc1, ldc2, ldc3, ldc4)" {
+	 -re ".*= 4 \\+ 4 \\* I.*${gdb_prompt} $" {
+	     pass "print find_max_long_double_real(4, ldc1, ldc2, ldc3, ldc4)"
+	 }
+	 -re ".*$gdb_prompt $" {
+	    kfail gdb/12776 "print find_max_long_double_real(4, ldc1, ldc2, ldc3, ldc4)"
+	}
+    }
+
+}
-- 
1.7.0.4


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [_Complex test 3/4] Isolate each test's effect in callfuncs.exp
  2011-05-09 15:06     ` Tom Tromey
  2011-05-19  4:26       ` [_Complex test 1/4] support_complex_tests in gdb.exp and pass _Complex args to func Yao Qi
  2011-05-19  4:34       ` [_Complex test 2/4] _Complex type in varargs.exp Yao Qi
@ 2011-05-19  4:46       ` Yao Qi
  2011-05-19 18:46         ` Tom Tromey
  2011-05-19  5:09       ` [_Complex test 4/4] _Complex tests " Yao Qi
  3 siblings, 1 reply; 40+ messages in thread
From: Yao Qi @ 2011-05-19  4:46 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 473 bytes --]

When I was writing patch 4/4 in callfuncs.exp, a fatal fail will make
the rest of tests failed as well.

In this patch, some code is moved to proc rerun_and_prepare, which is
called some times at the beginning of each tests.  Also, fetch registers
before each test starts, and then, compare with the register state after
test is done.

This patch is not about _Complex type testing.  With this patch, test
result of patch 4/4 looks more reasonable.

-- 
Yao (齐尧)

[-- Attachment #2: 0003-prepare-for-test.patch --]
[-- Type: text/x-patch, Size: 4622 bytes --]

gdb/testsuite/

	* gdb.base/callfuncs.exp (rerun_and_prepare): New.
	Call rerun_and_prepare for each test to isolate effects.

From 461e0c6aac5ed689bae57f3995e073769288d235 Mon Sep 17 00:00:00 2001
From: Yao Qi <yao@codesourcery.com>
Date: Wed, 18 May 2011 23:12:18 +0800
Subject: [PATCH 3/4] prepare for test

---
 gdb/testsuite/gdb.base/callfuncs.exp |   82 ++++++++++++++++++++++------------
 1 files changed, 54 insertions(+), 28 deletions(-)

diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/callfuncs.exp
index 27ebd1e..ff86eb8 100644
--- a/gdb/testsuite/gdb.base/callfuncs.exp
+++ b/gdb/testsuite/gdb.base/callfuncs.exp
@@ -273,6 +273,39 @@ proc fetch_all_registers {test} {
     return $all_registers_lines
 }
 
+proc rerun_and_prepare {} {
+    global hp_aCC_compiler
+
+    if { $hp_aCC_compiler } {
+	# Do not set language explicitly to 'C'.  This will cause aCC
+	# tests to fail because promotion rules are different.  Just let
+	# the language be set to the default.
+
+	if { ![runto_main] } {
+	    gdb_suppress_tests;
+	}
+
+	# However, turn off overload-resolution for aCC.  Having it on causes
+	# a lot of failures.
+
+	gdb_test_no_output "set overload-resolution 0"
+    } else {
+	gdb_test_no_output "set language c"
+	if { ![runto_main] } {
+	    gdb_suppress_tests;
+	}
+    }
+
+    get_debug_format
+
+    # Make sure that malloc gets called and that the floating point unit
+    # is initialized via a call to t_double_values.
+    gdb_test "next" "t_double_values\\(double_val1, double_val2\\);.*" \
+	"next to t_double_values"
+    gdb_test "next" "t_structs_c\\(struct_val1\\);.*" \
+	"next to t_structs_c"
+}
+
 
 # Start with a fresh gdb.
 
@@ -285,34 +318,7 @@ gdb_test_no_output "set print sevenbit-strings"
 gdb_test_no_output "set print address off"
 gdb_test_no_output "set width 0"
 
-if { $hp_aCC_compiler } {
-    # Do not set language explicitly to 'C'.  This will cause aCC
-    # tests to fail because promotion rules are different.  Just let
-    # the language be set to the default.
-
-    if { ![runto_main] } {
-	gdb_suppress_tests;
-    }
-
-    # However, turn off overload-resolution for aCC.  Having it on causes
-    # a lot of failures.
-
-    gdb_test_no_output "set overload-resolution 0"
-} else {
-    gdb_test_no_output "set language c"
-    if { ![runto_main] } {
-	gdb_suppress_tests;
-    }
-}
-
-get_debug_format
-
-# Make sure that malloc gets called and that the floating point unit
-# is initialized via a call to t_double_values.
-gdb_test "next" "t_double_values\\(double_val1, double_val2\\);.*" \
-  "next to t_double_values"
-gdb_test "next" "t_structs_c\\(struct_val1\\);.*" \
-  "next to t_structs_c"
+rerun_and_prepare
 
 # Save all register contents.
 set old_reg_content [fetch_all_registers "retrieve original register contents"]
@@ -330,6 +336,10 @@ if {$old_reg_content == $new_reg_content} then {
     fail "gdb function calls preserve register contents"
 }
 
+rerun_and_prepare
+# Save all register contents.
+set old_reg_content [fetch_all_registers "retrieve original register contents"]
+
 # Set breakpoint at a function we will call from gdb.
 gdb_breakpoint add
 
@@ -351,6 +361,12 @@ if ![gdb_test "bt 2" \
     }
 }
 
+rerun_and_prepare
+# Set breakpoint at a function we will call from gdb.
+gdb_breakpoint add
+# Save all register contents.
+set old_reg_content [fetch_all_registers "retrieve original register contents"]
+
 # Call function (causing a breakpoint hit in the call dummy) and do a finish,
 # make sure we are back at main and still have the same register contents.
 gdb_test "print add(4,5)" "The program being debugged stopped while.*" \
@@ -370,6 +386,12 @@ if ![gdb_test "bt 2" \
     }
 }
 
+rerun_and_prepare
+# Set breakpoint at a function we will call from gdb.
+gdb_breakpoint add
+# Save all register contents.
+set old_reg_content [fetch_all_registers "retrieve original register contents"]
+
 # Call function (causing a breakpoint hit in the call dummy) and do a return
 # with a value, make sure we are back at main with the same register contents.
 gdb_test "print add(4,5)" "The program being debugged stopped while.*" \
@@ -388,6 +410,10 @@ if ![gdb_test "return 7" \
     }
 }
 
+rerun_and_prepare
+# Set breakpoint at a function we will call from gdb.
+gdb_breakpoint add
+set old_reg_content [fetch_all_registers "retrieve original register contents"]
+
 # Call function (causing a breakpoint hit in the call dummy), and
 # call another function from the call dummy frame (thereby setting up
 # several nested call dummy frames).  Test that backtrace and finish
-- 
1.7.0.4


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [_Complex test 4/4] _Complex tests in callfuncs.exp
  2011-05-09 15:06     ` Tom Tromey
                         ` (2 preceding siblings ...)
  2011-05-19  4:46       ` [_Complex test 3/4] Isolate each test's effect in callfuncs.exp Yao Qi
@ 2011-05-19  5:09       ` Yao Qi
  2011-05-20  8:17         ` Yao Qi
  2011-05-26 17:07         ` [_Complex test 4/4] " Tom Tromey
  3 siblings, 2 replies; 40+ messages in thread
From: Yao Qi @ 2011-05-19  5:09 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1028 bytes --]

These tests in this patch is about passing _Complex type args and return
_Complex type.

Rerun callfuncs.exp on i686-pc-linux-gnu, and get two new KFAIL and one
FAIL.  This extra FAIL is caused by these two KFAILs.  PR 12783 is opened.

KFAIL: gdb.base/callfuncs.exp: call inferior func with struct - returns
double _Complex (PRMS: gdb/12783)
KFAIL: gdb.base/callfuncs.exp: call inferior func with struct - returns
long double _Complex (PRMS: gdb/12783)

FAIL: gdb.base/callfuncs.exp: gdb function calls preserve register contents

                === gdb Summary ===

# of expected passes            153
# of unexpected failures        1
# of known failures             2

Note that there is no tests about _Complex in aggregate types in this
patch set, because gdb.base/structs.exp can not be extended to cover
_Complex types easily.  I find there is an interesting test on
struct/union in gcc (gcc.dg/compat/struct-layout-1.exp), and still need
some time to see if we can make use of it in gdb tests.

-- 
Yao (齐尧)

[-- Attachment #2: 0004-pass-args-of-type-complex-to-func.patch --]
[-- Type: text/x-patch, Size: 10606 bytes --]

gdb/testsuite/

	* gdb.base/callfuncs.c (t_structs_fc): New.
	(t_structs_dc, t_structs_ldc): New.
	(t_double_many_args):
	(DEF_FUNC_MANY_ARGS_1, DEF_FUNC_MANY_ARGS_2): Define.
	(DEF_FUNC_MANY_ARGS_3, DEF_FUNC_VALUES_1): Define.
	(DEF_FUNC_VALUES_2, DEF_FUNC_VALUES_3): Define.
	* gdb.base/callfuncs.exp: Call new functions.

From 12b36674dc96051b3b5b9f1eb6b14e1cce022bcc Mon Sep 17 00:00:00 2001
From: Yao Qi <yao@codesourcery.com>
Date: Wed, 18 May 2011 21:43:57 +0800
Subject: [PATCH 4/4] pass args of type complex to func

---
 gdb/testsuite/gdb.base/callfuncs.c   |  151 +++++++++++++++++++++++++++++++++-
 gdb/testsuite/gdb.base/callfuncs.exp |   55 ++++++++++++-
 2 files changed, 204 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.base/callfuncs.c b/gdb/testsuite/gdb.base/callfuncs.c
index 406d22a..80815f9 100644
--- a/gdb/testsuite/gdb.base/callfuncs.c
+++ b/gdb/testsuite/gdb.base/callfuncs.c
@@ -73,6 +73,30 @@ double double_val13 = 10.25;
 double double_val14 = 11.25;
 double double_val15 = 12.25;
 
+#ifdef TEST_COMPLEX
+extern float crealf (float _Complex);
+extern float cimagf (float _Complex);
+extern double creal (double _Complex);
+extern double cimag (double _Complex);
+extern long double creall (long double _Complex);
+extern long double cimagl (long double _Complex);
+
+float _Complex fc1 = 1.0F + 1.0iF;
+float _Complex fc2 = 2.0F + 2.0iF;
+float _Complex fc3 = 3.0F + 3.0iF;
+float _Complex fc4 = 4.0F + 4.0iF;
+
+double _Complex dc1 = 1.0 + 1.0i;
+double _Complex dc2 = 2.0 + 2.0i;
+double _Complex dc3 = 3.0 + 3.0i;
+double _Complex dc4 = 4.0 + 4.0i;
+
+long double _Complex ldc1 = 1.0L + 1.0Li;
+long double _Complex ldc2 = 2.0L + 2.0Li;
+long double _Complex ldc3 = 3.0L + 3.0Li;
+long double _Complex ldc4 = 4.0L + 4.0Li;
+#endif /* TEST_COMPLEX */
+
 #define DELTA (0.001)
 
 char *string_val1 = (char *)"string 1";
@@ -89,8 +113,15 @@ struct struct1 {
   float f;
   double d;
   char a[4];
+#ifdef TEST_COMPLEX
+  float _Complex fc;
+  double _Complex dc;
+  long double _Complex ldc;
+} struct_val1 ={ 'x', 87, 76, 51, 2.1234, 9.876, "foo", 3.0F + 3.0Fi,
+		 4.0L + 4.0Li, 5.0L + 5.0Li};
+#else
 } struct_val1 = { 'x', 87, 76, 51, 2.1234, 9.876, "foo" };
-
+#endif /* TEST_COMPLEX */
 /* Some functions that can be passed as arguments to other test
    functions, or called directly. */
 #ifdef PROTOTYPES
@@ -183,6 +214,11 @@ char  *t_structs_a (struct struct1 tstruct)
   strcpy (buf, tstruct.a);
   return buf;
 }
+#ifdef TEST_COMPLEX
+float _Complex t_structs_fc (struct struct1 tstruct) { return tstruct.fc;}
+double _Complex t_structs_dc (struct struct1 tstruct) { return tstruct.dc;}
+long double _Complex t_structs_fc (struct struct1 tstruct) { return tstruct.ldc;}
+#endif
 #else
 char   t_structs_c (tstruct) struct struct1 tstruct; { return (tstruct.c); }
 short  t_structs_s (tstruct) struct struct1 tstruct; { return (tstruct.s); }
@@ -196,6 +232,11 @@ char  *t_structs_a (tstruct) struct struct1 tstruct;
   strcpy (buf, tstruct.a);
   return buf;
 }
+#ifdef TEST_COMPLEX
+float _Complex t_structs_fc (tstruct) struct struct1 tstruct; { return tstruct.fc;}
+double _Complex t_structs_dc (tstruct) struct struct1 tstruct; { return tstruct.dc;}
+long double _Complex t_structs_ldc (tstruct) struct struct1 tstruct; { return tstruct.ldc;}
+#endif
 #endif
 
 /* Test that calling functions works if there are a lot of arguments.  */
@@ -400,6 +441,114 @@ t_double_many_args (double f1, double f2, double f3, double f4, double f5,
 	  && (sum_args - sum_values) > -DELTA);
 }
 
+/* Various functions for _Complex types.  */
+
+#ifdef TEST_COMPLEX
+
+#define COMPARE_WITHIN_RANGE(ARG1, ARG2, DEL, FUNC) \
+  ((FUNC(ARG1) - FUNC(ARG2)) < DEL) && ((FUNC(ARG1) - FUNC(ARG2) > -DEL))
+
+#define DEF_FUNC_MANY_ARGS_1(TYPE, NAME)			\
+t_##NAME##_complex_many_args (f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, \
+			      f12, f13, f14, f15, f16)			\
+     TYPE _Complex f1, TYPE _Complex f2, TYPE _Complex f3, \
+     TYPE _Complex f4, TYPE _Complex f5, TYPE _Complex f6, \
+     TYPE _Complex f7, TYPE _Complex f8, TYPE _Complex f9, \
+     TYPE _Complex f10, TYPE _Complex f11, TYPE _Complex f12, \
+     TYPE _Complex f13, TYPE _Complex f14, TYPE _Complex f15, \
+     TYPE _Complex f16;
+
+#define DEF_FUNC_MANY_ARGS_2(TYPE, NAME)		  \
+t_##NAME##_complex_many_args (TYPE _Complex f1, TYPE _Complex f2, \
+			      TYPE _Complex f3, TYPE _Complex f4, \
+			      TYPE _Complex f5, TYPE _Complex f6, \
+			      TYPE _Complex f7, TYPE _Complex f8, \
+			      TYPE _Complex f9, TYPE _Complex f10,	\
+			      TYPE _Complex f11, TYPE _Complex f12,	\
+			      TYPE _Complex f13, TYPE _Complex f14,	\
+			      TYPE _Complex f15, TYPE _Complex f16)
+
+#define DEF_FUNC_MANY_ARGS_3(TYPE, CREAL, CIMAG) \
+{ \
+   TYPE _Complex expected = fc1 + fc2 + fc3 + fc4 + fc1 + fc2 + fc3 + fc4 \
+    + fc1 + fc2 + fc3 + fc4 + fc1 + fc2 + fc3 + fc4; \
+  TYPE _Complex actual = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 \
+    + f11 + f12 + f13 + f14 + f15 + f16; \
+  return (COMPARE_WITHIN_RANGE(expected, actual, DELTA, creal) \
+	  && COMPARE_WITHIN_RANGE(expected, actual, DELTA, creal) \
+	  && COMPARE_WITHIN_RANGE(expected, actual, DELTA, cimag)   \
+	  && COMPARE_WITHIN_RANGE(expected, actual, DELTA, cimag)); \
+}
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_MANY_ARGS_1(float, float)
+#else
+DEF_FUNC_MANY_ARGS_2(float, float)
+#endif
+DEF_FUNC_MANY_ARGS_3(float, crealf, cimagf)
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_MANY_ARGS_1(double, double)
+#else
+DEF_FUNC_MANY_ARGS_2(double, double)
+#endif
+DEF_FUNC_MANY_ARGS_3(double, creal, cimag)
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_MANY_ARGS_1(long double, long_double)
+#else
+DEF_FUNC_MANY_ARGS_2(long double, long_double)
+#endif
+DEF_FUNC_MANY_ARGS_3(long double, creall, cimagl)
+
+
+
+
+#define DEF_FUNC_VALUES_1(TYPE, NAME)			\
+  t_##NAME##_complex_values (f1, f2) TYPE _Complex f1, TYPE _Complex f2;
+
+#define DEF_FUNC_VALUES_2(TYPE, NAME) \
+  t_##NAME##_complex_values (TYPE _Complex f1, TYPE _Complex f2)
+
+#define DEF_FUNC_VALUES_3(FORMAL_PARM, TYPE, CREAL, CIMAG)	\
+{ \
+ return (COMPARE_WITHIN_RANGE(f1, FORMAL_PARM##1, DELTA, CREAL) \
+	  && COMPARE_WITHIN_RANGE(f2, FORMAL_PARM##2, DELTA, CREAL) \
+	  && COMPARE_WITHIN_RANGE(f1,  FORMAL_PARM##1, DELTA, CIMAG) \
+	  && COMPARE_WITHIN_RANGE(f2,  FORMAL_PARM##2, DELTA, CIMAG)); \
+}
+
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_VALUES_1(float, float)
+#else
+DEF_FUNC_VALUES_2(float, float)
+#endif
+DEF_FUNC_VALUES_3(fc, float, crealf, cimagf)
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_VALUES_1(double, double)
+#else
+DEF_FUNC_VALUES_2(double, double)
+#endif
+DEF_FUNC_VALUES_3(fc, double, creal, cimag)
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_VALUES_1(long double, long_double)
+#else
+DEF_FUNC_VALUES_2(long double, long_double)
+#endif
+DEF_FUNC_VALUES_3(fc, long double, creall, cimagl)
+
+#endif /* TEST_COMPLEX */
+
+
 #ifdef PROTOTYPES
 int t_string_values (char *string_arg1, char *string_arg2)
 #else
diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/callfuncs.exp
index ff86eb8..7bff47c 100644
--- a/gdb/testsuite/gdb.base/callfuncs.exp
+++ b/gdb/testsuite/gdb.base/callfuncs.exp
@@ -25,7 +25,12 @@ set testfile "callfuncs"
 set srcfile ${testfile}.c
 set binfile ${objdir}/${subdir}/${testfile}
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+set compile_flags {debug}
+if [support_complex_tests] {
+    set compile_flags "$compile_flags additional_flags=-DTEST_COMPLEX"
+}
+
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $compile_flags] != "" } {
      untested callfuncs.exp
      return -1
 }
@@ -144,6 +149,23 @@ proc do_function_calls {} {
 	gdb_test "p t_int_double(99, 99.0)" " = 1"
     }
 
+    if [support_complex_tests] {
+	gdb_test "p t_float_complex_values(fc1, fc2)" " = 1"
+	gdb_test "p t_float_complex_values(fc3, fc4)" " = 0"
+	gdb_test "p t_float_complex_many_args(fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4)" " = 1"
+	gdb_test "p t_float_complex_many_args(fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1)" " = 0"
+
+	gdb_test "p t_double_complex_values(dc1, dc2)" " = 1"
+	gdb_test "p t_double_complex_values(dc3, dc4)" " = 0"
+	gdb_test "p t_double_complex_many_args(dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4)" " = 1"
+	gdb_test "p t_double_complex_many_args(dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1)" " = 0"
+
+	gdb_test "p t_long_double_complex_values(ldc1, ldc2)" " = 1"
+	gdb_test "p t_long_double_complex_values(ldc3, ldc4)" " = 0"
+	gdb_test "p t_long_double_complex_many_args(ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4)" " = 1"
+	gdb_test "p t_long_double_complex_many_args(ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1,ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1)" " = 0"
+    }
+
     gdb_test "p t_string_values(string_val2,string_val1)" " = 0"
     gdb_test "p t_string_values(string_val1,string_val2)" " = 1"
     gdb_test "p t_string_values(\"string 1\",\"string 2\")" " = 1"
@@ -217,6 +239,37 @@ proc do_function_calls {} {
 	    "call inferior func with struct - returns double"
     }
 
+    if [support_complex_tests] {
+
+	gdb_test_multiple "p t_structs_fc(struct_val1)" \
+	    "call inferior func with struct - returns float _Complex" {
+		-re ".*= 3 \\+ 3 \\* I.*$gdb_prompt $" {
+		    pass "call inferior func with struct - returns float _Complex"
+		}
+		-r ".*$gdb_prompt $" {
+		    kfail gdb/12783 "call inferior func with struct - returns float _Complex"
+		}
+	    }
+	gdb_test_multiple "p t_structs_dc(struct_val1)" \
+	    "call inferior func with struct - returns double _Complex" {
+		-re  ".*= 4 \\+ 4 \\* I.*$gdb_prompt $" {
+		    pass "call inferior func with struct - returns double _Complex"
+		}
+		-re ".*$gdb_prompt $" {
+		    kfail gdb/12783 "call inferior func with struct - returns double _Complex"
+		}
+	    }
+	gdb_test_multiple "p t_structs_ldc(struct_val1)" \
+	    "call inferior func with struct - returns long double _Complex" {
+		-re  "= 5 \\+ 5 \\* I.*$gdb_prompt $" {
+		    pass "call inferior func with struct - returns long double _Complex"
+		}
+		-re ".*$gdb_prompt $" {
+		    kfail gdb/12783 "call inferior func with struct - returns long double _Complex"
+		}
+	    }
+    }
+
     gdb_test "p t_structs_a(struct_val1)" "= (.unsigned char .. )?\"foo\"" \
     	"call inferior func with struct - returns char *"
 }
-- 
1.7.0.4


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 1/4]  support_complex_tests in gdb.exp and pass _Complex args to func
  2011-05-19  4:26       ` [_Complex test 1/4] support_complex_tests in gdb.exp and pass _Complex args to func Yao Qi
@ 2011-05-19  8:16         ` Mark Kettenis
  2011-05-19 10:16           ` Joseph S. Myers
  2011-05-19 13:01           ` Yao Qi
  2011-05-19 10:12         ` Joseph S. Myers
  1 sibling, 2 replies; 40+ messages in thread
From: Mark Kettenis @ 2011-05-19  8:16 UTC (permalink / raw)
  To: yao; +Cc: gdb-patches

> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 531120c..8be8396 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -1486,6 +1486,21 @@ proc skip_shlib_tests {} {
>      return 1
>  }
>  
> +# Return a 1 if we should run tests to _Complex types, otherwise, skip it.
> +
> +proc support_complex_tests {} {
> +    # In order to avoid breaking test on platforms not supporting _Complex,
> +    # the list of target triplet supporting tests to _Complex type is still
> +    # conservative.  More target triplet can be added here if we are sure
> +    # _Complex type is supported.
> +    if {[istarget *-*-linux*]
> +        || [istarget *-*-elf*]} {
> +	return 1;

Sorry, but this is wrong on many levels.  For one thing, _Complex
support has very little to do with with the OS you're running.  It's
primarily a compiler issue.  So you should probably use a test based
on test_compiler_info here.  The GCC C99 status page suggests that the
first release to properly support complex is GCC 4.5.  Earlier
versions are marked as "broken" but may actually have enough support
for these simple tests.

The other thing is that the testsuite should not be "conservative".
We should run as many tests as possible on as many platforms as
possible.  Tests that are known to fail should be KFAILed (if there is
a known bug/issue with GDB itself) or XFAILed (if there is an issue
with the platform).  Only if running the tests causes serious problems
(crashing the OS, causing excessive timeouts) we should consider
skipping them.


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 1/4]  support_complex_tests in gdb.exp and pass _Complex args to func
  2011-05-19  4:26       ` [_Complex test 1/4] support_complex_tests in gdb.exp and pass _Complex args to func Yao Qi
  2011-05-19  8:16         ` Mark Kettenis
@ 2011-05-19 10:12         ` Joseph S. Myers
  1 sibling, 0 replies; 40+ messages in thread
From: Joseph S. Myers @ 2011-05-19 10:12 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

On Thu, 19 May 2011, Yao Qi wrote:

> The other part I am not sure is about PROTOTYPES.  If I understand it
> correctly, these stuff are used to be compatible with old C standard,
> while _Complex types are introduced in C99.  We may don't need prototype
> stuffs for functions of _Complex args/return type.  In my patch, I still
> follow the existing manner.

I don't know how PROTOTYPES is used in the GDB testsuite.  I don't see any 
need to support compilers with complex support but without prototypes 
support.  However, it does make sense to test that passing _Complex float 
to an unprototyped function works correctly.  (Whereas float is promoted 
to double when passed to an unprototyped function, _Complex float is *not* 
promoted to _Complex double.  Hopefully GDB already knows that, but it 
seems a good thing to have a test of.)

-- 
Joseph S. Myers
joseph@codesourcery.com


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 2/4] _Complex type in varargs.exp
  2011-05-19  4:34       ` [_Complex test 2/4] _Complex type in varargs.exp Yao Qi
@ 2011-05-19 10:13         ` Joseph S. Myers
  2011-05-19 13:42           ` Yao Qi
  2011-05-19 17:12         ` Tom Tromey
  1 sibling, 1 reply; 40+ messages in thread
From: Joseph S. Myers @ 2011-05-19 10:13 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

On Thu, 19 May 2011, Yao Qi wrote:

> This patch is to add _Complex type in vararg testing.
> 
> Run varargs.exp on i686-pc-linux-gnu, get new two KFAIL.  Note that PR
> 12776 is opened to track this problem.

I think such KFAILs need to be target specific, so only for 32-bit x86 in 
this case, since for each target architecture where such a test fails it's 
going to be a separate bug in that target's ABI implementation in GDB and 
should have a separate PR.

-- 
Joseph S. Myers
joseph@codesourcery.com


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 1/4]  support_complex_tests in gdb.exp and pass _Complex args to func
  2011-05-19  8:16         ` Mark Kettenis
@ 2011-05-19 10:16           ` Joseph S. Myers
  2011-05-19 13:26             ` Yao Qi
  2011-05-19 13:01           ` Yao Qi
  1 sibling, 1 reply; 40+ messages in thread
From: Joseph S. Myers @ 2011-05-19 10:16 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: yao, gdb-patches

On Thu, 19 May 2011, Mark Kettenis wrote:

> Sorry, but this is wrong on many levels.  For one thing, _Complex
> support has very little to do with with the OS you're running.  It's
> primarily a compiler issue.  So you should probably use a test based
> on test_compiler_info here.  The GCC C99 status page suggests that the
> first release to properly support complex is GCC 4.5.  Earlier
> versions are marked as "broken" but may actually have enough support
> for these simple tests.

I don't believe the breakage (issues such as mixed real/complex arithmetic 
wrongly converting the real operand to complex type, with implications for 
NaNs and signed zeros) is of any relevance to the GDB tests.

I'd think the right approach is simply to see if the compiler accepts a 
trivial source file of the form

_Complex float cf;
_Complex double cd;
_Complex long double cld;

and if it does, then presume complex support is present.

-- 
Joseph S. Myers
joseph@codesourcery.com


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 1/4]  support_complex_tests in gdb.exp and pass _Complex args to func
  2011-05-19  8:16         ` Mark Kettenis
  2011-05-19 10:16           ` Joseph S. Myers
@ 2011-05-19 13:01           ` Yao Qi
  2011-05-19 13:24             ` Mark Kettenis
  1 sibling, 1 reply; 40+ messages in thread
From: Yao Qi @ 2011-05-19 13:01 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

On 05/19/2011 04:14 PM, Mark Kettenis wrote:
> The other thing is that the testsuite should not be "conservative".
> We should run as many tests as possible on as many platforms as
> possible.  Tests that are known to fail should be KFAILed (if there is
> a known bug/issue with GDB itself) or XFAILed (if there is an issue
> with the platform).  Only if running the tests causes serious problems
> (crashing the OS, causing excessive timeouts) we should consider
> skipping them.

No.  I don't want to break running non-complex-type tests in
funcargs.exp or varargs.exp on platforms that don't support _Complex
after this patch.

-- 
Yao (齐尧)


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 1/4]  support_complex_tests in gdb.exp and pass _Complex args to func
  2011-05-19 13:01           ` Yao Qi
@ 2011-05-19 13:24             ` Mark Kettenis
  2011-05-19 13:38               ` Mark Kettenis
  0 siblings, 1 reply; 40+ messages in thread
From: Mark Kettenis @ 2011-05-19 13:24 UTC (permalink / raw)
  To: yao; +Cc: gdb-patches

> Date: Thu, 19 May 2011 21:01:26 +0800
> From: Yao Qi <yao@codesourcery.com>
> 
> On 05/19/2011 04:14 PM, Mark Kettenis wrote:
> > The other thing is that the testsuite should not be "conservative".
> > We should run as many tests as possible on as many platforms as
> > possible.  Tests that are known to fail should be KFAILed (if there is
> > a known bug/issue with GDB itself) or XFAILed (if there is an issue
> > with the platform).  Only if running the tests causes serious problems
> > (crashing the OS, causing excessive timeouts) we should consider
> > skipping them.
> 
> No.  I don't want to break running non-complex-type tests in
> funcargs.exp or varargs.exp on platforms that don't support _Complex
> after this patch.

Ok, I see what you're trying to avoid now.  In that case you should
first build the test binary without defining TEST_COMPLEX, run the
existing tests, rebuild the binary with TEST_COMPLEX and then run the
new _Complex tests.  Or simply seperate the _Complex tests into files
of their own.


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 1/4]  support_complex_tests in gdb.exp and pass _Complex args to func
  2011-05-19 10:16           ` Joseph S. Myers
@ 2011-05-19 13:26             ` Yao Qi
  2011-05-19 17:10               ` Tom Tromey
  0 siblings, 1 reply; 40+ messages in thread
From: Yao Qi @ 2011-05-19 13:26 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: Mark Kettenis, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 371 bytes --]

On 05/19/2011 06:16 PM, Joseph S. Myers wrote:
> I'd think the right approach is simply to see if the compiler accepts a 
> trivial source file of the form
> 
> _Complex float cf;
> _Complex double cd;
> _Complex long double cld;
> 
> and if it does, then presume complex support is present.

Joseph,
This is a good idea.  Done this in new patch.

-- 
Yao (齐尧)

[-- Attachment #2: 0001-funcargs.patch --]
[-- Type: text/x-patch, Size: 10484 bytes --]

gdb/testsuite/

        * gdb.base/funcargs.c (callca, callcb, callcc): New.
        (callcd, callce, callcf, callc1a, callc1b): New.
        (callc2a, callc2b): New.
        * gdb.base/funcargs.exp (complex_args): New.
        (complex_integral_args, complex_float_integral_args): New.
        * lib/gdb.exp (support_complex_tests): New.  Determine
        whether to run test cases on _Complex types.
---
 gdb/testsuite/gdb.base/funcargs.c   |  134 +++++++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.base/funcargs.exp |   94 ++++++++++++++++++++++++-
 gdb/testsuite/lib/gdb.exp           |   41 +++++++++++
 3 files changed, 268 insertions(+), 1 deletions(-)

diff --git a/gdb/testsuite/gdb.base/funcargs.c b/gdb/testsuite/gdb.base/funcargs.c
index f7dfc64..6d16b62 100644
--- a/gdb/testsuite/gdb.base/funcargs.c
+++ b/gdb/testsuite/gdb.base/funcargs.c
@@ -53,6 +53,12 @@ float *fp = &f;
 double d = 5.0;
 double *dp = &d;
 
+#ifdef TEST_COMPLEX
+float _Complex fc = 1.0F + 2.0iF;
+double _Complex dc = 3.0 + 4.0i;
+long double _Complex ldc = 5.0L + 6.0iL;
+#endif /* TEST_COMPLEX */
+
 struct stag {
     int s1;
     int s2;
@@ -311,6 +317,117 @@ float *fp; double *dp;
 }
 
 
+
+#ifdef TEST_COMPLEX
+
+/* Test various _Complex type args.  */
+
+#ifdef PROTOTYPES
+void callca (float _Complex f1, float _Complex f2, float _Complex f3)
+#else
+callca (f1, f2, f3)
+float _Complex f1; float _Complex f2; float _Complex f3;
+#endif
+{
+
+}
+
+#ifdef PROTOTYPES
+void callcb (double _Complex d1, double _Complex d2, double _Complex d3)
+#else
+callcb (d1, d2, d3)
+double _Complex d1; double _Complex d2; double _Complex d3;
+#endif
+{
+
+}
+
+#ifdef PROTOTYPES
+void callcc (long double _Complex ld1, long double _Complex ld2, long double _Complex ld3)
+#else
+callcc (ld1, ld2, ld3)
+long double _Complex ld1; long double _Complex ld2; long double _Complex ld3;
+#endif
+{
+
+}
+
+#ifdef PROTOTYPES
+void callcd (float _Complex fc1, double _Complex dc1, long double _Complex ldc1)
+#else
+callcd (fc1, dc1, ldc1)
+float _Complex fc1; double _Complex dc1; long double _Complex ldc1;
+#endif
+{
+}
+
+#ifdef PROTOTYPES
+void callce (double _Complex dc1, long double _Complex ldc1, float _Complex fc1)
+#else
+callce (dc1, ldc1, fc1)
+double _Complex dc1; long double _Complex ldc1; float _Complex fc1;
+#endif
+{
+}
+
+#ifdef PROTOTYPES
+void callcf (long double _Complex ldc1, float _Complex fc1, double _Complex dc1)
+#else
+callcf (ldc1, fc1, dc1)
+long double _Complex ldc1; float _Complex fc1; double _Complex dc1;
+#endif
+{
+}
+
+
+/* Test passing _Complex type and integral.  */
+#ifdef PROTOTYPES
+void callc1a (char c, short s, int i, unsigned int ui, long l,
+	      float _Complex fc1, double _Complex dc1,
+	      long double _Complex ldc1)
+#else
+callc1a (c, s, i, ui, l, fc1, dc1, ldc1)
+char c; short s; int i; unsigned int ui; long l; float _Complex fc1; double _Complex dc1; long double _Complex ldc1;
+#endif
+{}
+
+#ifdef PROTOTYPES
+void callc1b (long double _Complex ldc1, char c, short s, int i,
+	      float _Complex fc1, unsigned int ui, long l,  double _Complex dc1)
+#else
+callc1b (ldc1, c, s, i, fc1, ui, l, dc1)
+char c; short s; int i; unsigned int ui; long l; float _Complex fc1; double _Complex dc1; long double _Complex ldc1;
+#endif
+{}
+
+
+#ifdef PROTOTYPES
+void callc2a (char c, short s, int i, unsigned int ui, long l, float f,
+	      double d, float _Complex fc1, double _Complex dc1,
+	      long double _Complex ldc1)
+#else
+callc2a (c, s, i, ui, l, f, d, fc1, dc1, ldc1)
+     char c; short s; int i; unsigned int ui; long l; float f; double d;
+     float _Complex fc1; double _Complex dc1;
+     long double _Complex ldc1;
+#endif
+{}
+
+#ifdef PROTOTYPES
+void callc2b (float _Complex fc1, char c, short s, int i, unsigned int ui,
+	      long double _Complex ldc1, long l, float f, double d,
+	      double _Complex dc1)
+#else
+callc2b (fc1, c, s, i, ui, ldc1, l, f, d, dc1)
+     char c; short s; int i; unsigned int ui; long l; float f; double d;
+     float _Complex fc1; double _Complex dc1;
+     long double _Complex ldc1;
+#endif
+{}
+
+
+#endif /* TEST_COMPLEX */
+
 /* Test passing structures and unions by reference. */
 
 
@@ -749,6 +866,23 @@ int main ()
   call2h (d, c, f, s, d, i, f, l);
   call2i (c, f, c, c, d, c, c, c, f, s, c, d);
 
+#ifdef TEST_COMPLEX
+  /* Test calling with _Complex types.  */
+  callca (fc, fc, fc);
+  callcb (dc, dc, dc);
+  callcc (ldc, ldc, ldc);
+  callcd (fc, dc, ldc);
+  callce (dc, ldc, fc);
+  callcf (ldc, fc, dc);
+
+
+  callc1a (c, s, i, ui, l, fc, dc, ldc);
+  callc1b (ldc, c, s, i, fc, ui, l, dc);
+
+  callc2a (c, s, i, ui, l, f, d, fc, dc, ldc);
+  callc2b (fc, c, s, i, ui, ldc, l, f, d, dc);
+#endif /* TEST_COMPLEX */
+
   /* Test dereferencing pointers to various integral and floating types */
 
   call3a (cp, sp, ip, lp);
diff --git a/gdb/testsuite/gdb.base/funcargs.exp b/gdb/testsuite/gdb.base/funcargs.exp
index 0b80082..14161c1 100644
--- a/gdb/testsuite/gdb.base/funcargs.exp
+++ b/gdb/testsuite/gdb.base/funcargs.exp
@@ -24,7 +24,13 @@ if $tracelevel {
 set testfile "funcargs"
 set srcfile ${testfile}.c
 set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+
+set compile_flags {debug nowarnings quiet}
+if [support_complex_tests] {
+    set compile_flags "$compile_flags additional_flags=-DTEST_COMPLEX"
+}
+
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $compile_flags] != "" } {
      untested funcargs.exp
      return -1
 }
@@ -239,6 +245,77 @@ proc float_and_integral_args {} {
     gdb_stop_suppressing_tests;
 }
 
+
+#
+# Locate actual args; _Complex types.
+#
+
+proc complex_args {} {
+    global gdb_prompt
+
+    delete_breakpoints
+
+    gdb_breakpoint callca;
+    gdb_breakpoint callcb;
+    gdb_breakpoint callcc;
+    gdb_breakpoint callcd;
+    gdb_breakpoint callce;
+    gdb_breakpoint callcf;
+
+    # Run; should stop at call1a and print actual arguments.
+    gdb_run_cmd
+    gdb_expect {
+	-re ".* callca \\(f1=1 \\+ 2 \\* I, f2=1 \\+ 2 \\* I, f3=1 \\+ 2 \\* I\\) .*$gdb_prompt $" { pass "run to call2a" }
+	timeout { fail "(timeout) run to callca" ; gdb_suppress_tests; }
+    }
+    gdb_test "cont" ".* callcb \\(d1=3 \\+ 4 \\* I, d2=3 \\+ 4 \\* I, d3=3 \\+ 4 \\* I\\) .*" "continue to callcb"
+    gdb_test "cont" ".* callcc \\(ld1=5 \\+ 6 \\* I, ld2=5 \\+ 6 \\* I, ld3=5 \\+ 6 \\* I\\) .*" "continue to callcb"
+    gdb_test "cont" ".* callcd \\(fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I\\) .*" "continue to callcd"
+    gdb_test "cont" ".* callce \\(dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I, fc1=1 \\+ 2 \\* I\\) .*" "continue to callce"
+    gdb_test "cont" ".* callcf \\(ldc1=5 \\+ 6 \\* I, fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I\\) .*" "continue to callcf"
+}
+
+
+#
+# Locate actual args; _Complex types and integral.
+#
+proc  complex_integral_args {} {
+    global gdb_prompt
+
+    delete_breakpoints
+
+    gdb_breakpoint callc1a;
+    gdb_breakpoint callc1b;
+
+    # Run; should stop at call1a and print actual arguments.
+    gdb_run_cmd
+    gdb_expect {
+	-re ".* callc1a \\(c=97 'a', s=1, i=2, ui=7, l=3, fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I\\) .*$gdb_prompt $" { pass "run to callc1a" }
+	timeout { fail "(timeout) run to callc1a" ; gdb_suppress_tests; }
+    }
+    gdb_test "cont" ".* callc1b \\(ldc1=5 \\+ 6 \\* I\\, c=97 'a', s=1, i=2, fc1=1 \\+ 2 \\* I, ui=7, l=3, dc1=3 \\+ 4 \\* I\\) .*" "continue to callc1b"
+}
+
+#
+# Locate acual args; _Complex types and integral/float.
+#
+proc complex_float_integral_args {} {
+    global gdb_prompt
+
+    delete_breakpoints
+
+    gdb_breakpoint callc2a;
+    gdb_breakpoint callc2b;
+
+    # Run; should stop at call1a and print actual arguments.
+    gdb_run_cmd
+    gdb_expect {
+	-re ".* callc2a \\(c=97 'a', s=1, i=2, ui=7, l=3, f=4, d=5, fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I\\) .*$gdb_prompt $" { pass "run to callc2a" }
+	timeout { fail "(timeout) run to callc1a" ; gdb_suppress_tests; }
+    }
+    gdb_test "cont" ".* callc2b \\(fc1=1 \\+ 2 \\* I, c=97 'a', s=1, i=2, ui=7, ldc1=5 \\+ 6 \\* I\\, l=3, f=4, d=5, dc1=3 \\+ 4 \\* I\\) .*" "continue to callc2b"
+}
+
 #
 # Locate actual args; dereference pointers to ints and floats.
 #
@@ -1167,6 +1244,21 @@ funcargs_reload
 if {![target_info exists gdb,skip_float_tests]} {
   float_and_integral_args
 }
+
+# Test _Complex type here if supported.
+if [support_complex_tests] {
+    funcargs_reload
+    complex_args
+
+    funcargs_reload
+    complex_integral_args
+
+    if {![target_info exists gdb,skip_float_tests]} {
+	funcargs_reload
+	complex_float_integral_args
+    }
+}
+
 funcargs_reload
 pointer_args
 funcargs_reload
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 531120c..0923f91 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1486,6 +1486,47 @@ proc skip_shlib_tests {} {
     return 1
 }
 
+# Return a 1 if we should run tests to _Complex types, otherwise, skip it.
+
+proc support_complex_tests {} {
+    global support_complex_tests_saved
+
+    # Use the cached value, if it exists.
+    if [info exists support_complex_tests_saved] {
+        verbose "returning saved $support_complex_tests_saved" 2
+        return $support_complex_tests_saved
+    }
+
+    # Set up, compile, and execute a test program containing _Complex types.
+    # Include the current process ID in the file names to prevent conflicts
+    # with invocations for multiple testsuites.
+    set src complex[pid].c
+    set exe complex[pid].x
+
+    set f [open $src "w"]
+    puts $f "int main() {"
+    puts $f "_Complex float cf;"
+    puts $f "_Complex double cd;"
+    puts $f "_Complex long double cld;"
+    puts $f "  return 0; }"
+    close $f
+
+    verbose "compiling testfile $src" 2
+    set compile_flags {debug nowarnings}
+    set lines [gdb_compile $src $exe executable $compile_flags]
+    file delete $src
+    file delete $exe
+
+    if ![string match "" $lines] then {
+        verbose "testfile compilation failed, returning 0" 2
+        set support_complex_tests_saved 0
+    } else {
+	set support_complex_tests_saved 1
+    }
+
+    return $support_complex_tests_saved;
+}
+
 # Return 1 if target is ILP32.
 # This cannot be decided simply from looking at the target string,
 # as it might depend on externally passed compiler options like -m64.
-- 
1.7.0.4


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 1/4]  support_complex_tests in gdb.exp and pass _Complex args to func
  2011-05-19 13:24             ` Mark Kettenis
@ 2011-05-19 13:38               ` Mark Kettenis
  0 siblings, 0 replies; 40+ messages in thread
From: Mark Kettenis @ 2011-05-19 13:38 UTC (permalink / raw)
  To: yao; +Cc: gdb-patches

> Date: Thu, 19 May 2011 15:22:32 +0200 (CEST)
> From: Mark Kettenis <mark.kettenis@xs4all.nl>
> 
> > Date: Thu, 19 May 2011 21:01:26 +0800
> > From: Yao Qi <yao@codesourcery.com>
> > 
> > On 05/19/2011 04:14 PM, Mark Kettenis wrote:
> > > The other thing is that the testsuite should not be "conservative".
> > > We should run as many tests as possible on as many platforms as
> > > possible.  Tests that are known to fail should be KFAILed (if there is
> > > a known bug/issue with GDB itself) or XFAILed (if there is an issue
> > > with the platform).  Only if running the tests causes serious problems
> > > (crashing the OS, causing excessive timeouts) we should consider
> > > skipping them.
> > 
> > No.  I don't want to break running non-complex-type tests in
> > funcargs.exp or varargs.exp on platforms that don't support _Complex
> > after this patch.
> 
> Ok, I see what you're trying to avoid now.  In that case you should
> first build the test binary without defining TEST_COMPLEX, run the
> existing tests, rebuild the binary with TEST_COMPLEX and then run the
> new _Complex tests.  Or simply seperate the _Complex tests into files
> of their own.

Of course the feature-based test that Joseph suggested is fine as well.


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 2/4] _Complex type in varargs.exp
  2011-05-19 10:13         ` Joseph S. Myers
@ 2011-05-19 13:42           ` Yao Qi
  2011-05-19 15:27             ` Joseph S. Myers
  0 siblings, 1 reply; 40+ messages in thread
From: Yao Qi @ 2011-05-19 13:42 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: gdb-patches

On 05/19/2011 06:13 PM, Joseph S. Myers wrote:
> On Thu, 19 May 2011, Yao Qi wrote:
> 
>> This patch is to add _Complex type in vararg testing.
>>
>> Run varargs.exp on i686-pc-linux-gnu, get new two KFAIL.  Note that PR
>> 12776 is opened to track this problem.
> 
> I think such KFAILs need to be target specific, so only for 32-bit x86 in 
> this case, since for each target architecture where such a test fails it's 
> going to be a separate bug in that target's ABI implementation in GDB and 
> should have a separate PR.

Tests in this case also fail on armv7l-unknown-linux-gnueabi and
x86_64-unknown-linux-gnu.  Shall I have to file yet another two PRs for
armv7l-unknown-linux-gnueabi and x86_64-unknown-linux-gnu respectively,
and KFAIL them to different PR separately?  At least, I didn't see such
usage elsewhere in gdb testsuite.

IMO, KFAIL with target triplet works for the situation that one test
passes on all ports except one or two.  However, our test fails on most
ports, different from KFAIL's typical usage.

-- 
Yao (齐尧)


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 2/4] _Complex type in varargs.exp
  2011-05-19 13:42           ` Yao Qi
@ 2011-05-19 15:27             ` Joseph S. Myers
  2011-05-20  9:09               ` Pedro Alves
  2011-05-20 15:22               ` Yao Qi
  0 siblings, 2 replies; 40+ messages in thread
From: Joseph S. Myers @ 2011-05-19 15:27 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

On Thu, 19 May 2011, Yao Qi wrote:

> Tests in this case also fail on armv7l-unknown-linux-gnueabi and
> x86_64-unknown-linux-gnu.  Shall I have to file yet another two PRs for
> armv7l-unknown-linux-gnueabi and x86_64-unknown-linux-gnu respectively,
> and KFAIL them to different PR separately?  At least, I didn't see such
> usage elsewhere in gdb testsuite.

I think the correct division is one PR per target architecture for all 
complex types ABI issues, rather than one PR per test failure.  That's the 
only way a target maintainer can sensibly fix their target's problems, 
test that they are fixed, and close the relevant PR; otherwise you have a 
catch-all bug that's open for ever without meaningfully reflecting what 
actually needs to be done to fix the problem.

> IMO, KFAIL with target triplet works for the situation that one test
> passes on all ports except one or two.  However, our test fails on most
> ports, different from KFAIL's typical usage.

The aim is that soon the bug *is* fixed for all the most commonly used 
targets - but will likely remain open much longer for many more rarely 
used targets.

-- 
Joseph S. Myers
joseph@codesourcery.com


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 1/4]  support_complex_tests in gdb.exp and pass _Complex args to func
  2011-05-19 13:26             ` Yao Qi
@ 2011-05-19 17:10               ` Tom Tromey
  2011-05-20  8:10                 ` Yao Qi
  0 siblings, 1 reply; 40+ messages in thread
From: Tom Tromey @ 2011-05-19 17:10 UTC (permalink / raw)
  To: Yao Qi; +Cc: Joseph S. Myers, Mark Kettenis, gdb-patches

>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:

Yao> This is a good idea.  Done this in new patch.

Thanks for doing this.

Yao> +#ifdef PROTOTYPES
Yao> +void callca (float _Complex f1, float _Complex f2, float _Complex f3)
Yao> +#else
Yao> +callca (f1, f2, f3)
Yao> +float _Complex f1; float _Complex f2; float _Complex f3;
Yao> +#endif

I would not worry about the no PROTOTYPES case.  You can leave this in
if you want though.

Yao> +set compile_flags {debug nowarnings quiet}
Yao> +if [support_complex_tests] {
Yao> +    set compile_flags "$compile_flags additional_flags=-DTEST_COMPLEX"

I think it is better to use lappend here.

Yao> +    gdb_breakpoint callca;
Yao> +    gdb_breakpoint callcb;
Yao> +    gdb_breakpoint callcc;
Yao> +    gdb_breakpoint callcd;
Yao> +    gdb_breakpoint callce;
Yao> +    gdb_breakpoint callcf;

These ";"s are not needed.  There are a few instances of this.

Yao> +# Return a 1 if we should run tests to _Complex types, otherwise, skip it.

Just "Return 1 if...", and then ", otherwise 0.".

I am curious if you tested this in some situation where the complex
tests are skipped.

Tom


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 2/4] _Complex type in varargs.exp
  2011-05-19  4:34       ` [_Complex test 2/4] _Complex type in varargs.exp Yao Qi
  2011-05-19 10:13         ` Joseph S. Myers
@ 2011-05-19 17:12         ` Tom Tromey
  2011-05-20  8:11           ` Yao Qi
  1 sibling, 1 reply; 40+ messages in thread
From: Tom Tromey @ 2011-05-19 17:12 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:

Yao> 	Test inf-call of varargs of type _Complex.
Yao> 	* gdb.base/varargs.c (find_max_float_real): New.
Yao> 	(find_max_double_real, find_max_long_double_real): New.
Yao> 	* gdb.base/varargs.exp: Call these new added functions.

Yao> +if [support_complex_tests] {
Yao> +    set additional_flags "$additional_flags additional_flags=-DTEST_COMPLEX"

lappend

Tom


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 3/4] Isolate each test's effect in callfuncs.exp
  2011-05-19  4:46       ` [_Complex test 3/4] Isolate each test's effect in callfuncs.exp Yao Qi
@ 2011-05-19 18:46         ` Tom Tromey
  2011-05-30  2:56           ` [committed] " Yao Qi
  0 siblings, 1 reply; 40+ messages in thread
From: Tom Tromey @ 2011-05-19 18:46 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:

Yao> 	* gdb.base/callfuncs.exp (rerun_and_prepare): New.
Yao> 	Call rerun_and_prepare for each test to isolate effects.

It took me a surprisingly long time to see where rerun_and_prepare was
actually re-running :)

This is ok.

Tom


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 1/4]  support_complex_tests in gdb.exp and pass _Complex args to func
  2011-05-19 17:10               ` Tom Tromey
@ 2011-05-20  8:10                 ` Yao Qi
  2011-05-26 17:07                   ` Tom Tromey
  0 siblings, 1 reply; 40+ messages in thread
From: Yao Qi @ 2011-05-20  8:10 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Joseph S. Myers, Mark Kettenis, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1593 bytes --]

On 05/20/2011 01:09 AM, Tom Tromey wrote:
>>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:
> 
> Yao> +#ifdef PROTOTYPES
> Yao> +void callca (float _Complex f1, float _Complex f2, float _Complex f3)
> Yao> +#else
> Yao> +callca (f1, f2, f3)
> Yao> +float _Complex f1; float _Complex f2; float _Complex f3;
> Yao> +#endif
> 
> I would not worry about the no PROTOTYPES case.  You can leave this in
> if you want though.
> 

OK, I'll leave them there.

> Yao> +set compile_flags {debug nowarnings quiet}
> Yao> +if [support_complex_tests] {
> Yao> +    set compile_flags "$compile_flags additional_flags=-DTEST_COMPLEX"
> 
> I think it is better to use lappend here.
> 

Done.

> Yao> +    gdb_breakpoint callca;
> Yao> +    gdb_breakpoint callcb;
> Yao> +    gdb_breakpoint callcc;
> Yao> +    gdb_breakpoint callcd;
> Yao> +    gdb_breakpoint callce;
> Yao> +    gdb_breakpoint callcf;
> 
> These ";"s are not needed.  There are a few instances of this.
> 

Fixed.

> Yao> +# Return a 1 if we should run tests to _Complex types, otherwise, skip it.
> 
> Just "Return 1 if...", and then ", otherwise 0.".
> 

Fixed.

> I am curious if you tested this in some situation where the complex
> tests are skipped.

I simulate the `complex-unsupported platform' by removing "o" in keyword
"double" in support_complex_tests, "_Complex double cd;" -> "_Complex
duble cd;", and run gdb.base/varargs.exp again.  As you can see,
_Complex related tests are skipped.

Running ../../../git/gdb/gdb/testsuite/gdb.base/varargs.exp ...

		=== gdb Summary ===

# of expected passes		8

-- 
Yao (齐尧)

[-- Attachment #2: 0001-funcargs.patch --]
[-- Type: text/x-patch, Size: 10458 bytes --]

gdb/testsuite/

        * gdb.base/funcargs.c (callca, callcb, callcc): New.
        (callcd, callce, callcf, callc1a, callc1b): New.
        (callc2a, callc2b): New.
        * gdb.base/funcargs.exp (complex_args): New.
        (complex_integral_args, complex_float_integral_args): New.
        * lib/gdb.exp (support_complex_tests): New.  Determine
        whether to run test cases on _Complex types.
---
 gdb/testsuite/gdb.base/funcargs.c   |  134 +++++++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.base/funcargs.exp |   94 ++++++++++++++++++++++++-
 gdb/testsuite/lib/gdb.exp           |   41 +++++++++++
 3 files changed, 268 insertions(+), 1 deletions(-)

diff --git a/gdb/testsuite/gdb.base/funcargs.c b/gdb/testsuite/gdb.base/funcargs.c
index f7dfc64..6d16b62 100644
--- a/gdb/testsuite/gdb.base/funcargs.c
+++ b/gdb/testsuite/gdb.base/funcargs.c
@@ -53,6 +53,12 @@ float *fp = &f;
 double d = 5.0;
 double *dp = &d;
 
+#ifdef TEST_COMPLEX
+float _Complex fc = 1.0F + 2.0iF;
+double _Complex dc = 3.0 + 4.0i;
+long double _Complex ldc = 5.0L + 6.0iL;
+#endif /* TEST_COMPLEX */
+
 struct stag {
     int s1;
     int s2;
@@ -311,6 +317,117 @@ float *fp; double *dp;
 }
 
 
+
+#ifdef TEST_COMPLEX
+
+/* Test various _Complex type args.  */
+
+#ifdef PROTOTYPES
+void callca (float _Complex f1, float _Complex f2, float _Complex f3)
+#else
+callca (f1, f2, f3)
+float _Complex f1; float _Complex f2; float _Complex f3;
+#endif
+{
+
+}
+
+#ifdef PROTOTYPES
+void callcb (double _Complex d1, double _Complex d2, double _Complex d3)
+#else
+callcb (d1, d2, d3)
+double _Complex d1; double _Complex d2; double _Complex d3;
+#endif
+{
+
+}
+
+#ifdef PROTOTYPES
+void callcc (long double _Complex ld1, long double _Complex ld2, long double _Complex ld3)
+#else
+callcc (ld1, ld2, ld3)
+long double _Complex ld1; long double _Complex ld2; long double _Complex ld3;
+#endif
+{
+
+}
+
+#ifdef PROTOTYPES
+void callcd (float _Complex fc1, double _Complex dc1, long double _Complex ldc1)
+#else
+callcd (fc1, dc1, ldc1)
+float _Complex fc1; double _Complex dc1; long double _Complex ldc1;
+#endif
+{
+}
+
+#ifdef PROTOTYPES
+void callce (double _Complex dc1, long double _Complex ldc1, float _Complex fc1)
+#else
+callce (dc1, ldc1, fc1)
+double _Complex dc1; long double _Complex ldc1; float _Complex fc1;
+#endif
+{
+}
+
+#ifdef PROTOTYPES
+void callcf (long double _Complex ldc1, float _Complex fc1, double _Complex dc1)
+#else
+callcf (ldc1, fc1, dc1)
+long double _Complex ldc1; float _Complex fc1; double _Complex dc1;
+#endif
+{
+}
+
+
+/* Test passing _Complex type and integral.  */
+#ifdef PROTOTYPES
+void callc1a (char c, short s, int i, unsigned int ui, long l,
+	      float _Complex fc1, double _Complex dc1,
+	      long double _Complex ldc1)
+#else
+callc1a (c, s, i, ui, l, fc1, dc1, ldc1)
+char c; short s; int i; unsigned int ui; long l; float _Complex fc1; double _Complex dc1; long double _Complex ldc1;
+#endif
+{}
+
+#ifdef PROTOTYPES
+void callc1b (long double _Complex ldc1, char c, short s, int i,
+	      float _Complex fc1, unsigned int ui, long l,  double _Complex dc1)
+#else
+callc1b (ldc1, c, s, i, fc1, ui, l, dc1)
+char c; short s; int i; unsigned int ui; long l; float _Complex fc1; double _Complex dc1; long double _Complex ldc1;
+#endif
+{}
+
+
+#ifdef PROTOTYPES
+void callc2a (char c, short s, int i, unsigned int ui, long l, float f,
+	      double d, float _Complex fc1, double _Complex dc1,
+	      long double _Complex ldc1)
+#else
+callc2a (c, s, i, ui, l, f, d, fc1, dc1, ldc1)
+     char c; short s; int i; unsigned int ui; long l; float f; double d;
+     float _Complex fc1; double _Complex dc1;
+     long double _Complex ldc1;
+#endif
+{}
+
+#ifdef PROTOTYPES
+void callc2b (float _Complex fc1, char c, short s, int i, unsigned int ui,
+	      long double _Complex ldc1, long l, float f, double d,
+	      double _Complex dc1)
+#else
+callc2b (fc1, c, s, i, ui, ldc1, l, f, d, dc1)
+     char c; short s; int i; unsigned int ui; long l; float f; double d;
+     float _Complex fc1; double _Complex dc1;
+     long double _Complex ldc1;
+#endif
+{}
+
+
+#endif /* TEST_COMPLEX */
+
 /* Test passing structures and unions by reference. */
 
 
@@ -749,6 +866,23 @@ int main ()
   call2h (d, c, f, s, d, i, f, l);
   call2i (c, f, c, c, d, c, c, c, f, s, c, d);
 
+#ifdef TEST_COMPLEX
+  /* Test calling with _Complex types.  */
+  callca (fc, fc, fc);
+  callcb (dc, dc, dc);
+  callcc (ldc, ldc, ldc);
+  callcd (fc, dc, ldc);
+  callce (dc, ldc, fc);
+  callcf (ldc, fc, dc);
+
+
+  callc1a (c, s, i, ui, l, fc, dc, ldc);
+  callc1b (ldc, c, s, i, fc, ui, l, dc);
+
+  callc2a (c, s, i, ui, l, f, d, fc, dc, ldc);
+  callc2b (fc, c, s, i, ui, ldc, l, f, d, dc);
+#endif /* TEST_COMPLEX */
+
   /* Test dereferencing pointers to various integral and floating types */
 
   call3a (cp, sp, ip, lp);
diff --git a/gdb/testsuite/gdb.base/funcargs.exp b/gdb/testsuite/gdb.base/funcargs.exp
index 0b80082..3e29313 100644
--- a/gdb/testsuite/gdb.base/funcargs.exp
+++ b/gdb/testsuite/gdb.base/funcargs.exp
@@ -24,7 +24,13 @@ if $tracelevel {
 set testfile "funcargs"
 set srcfile ${testfile}.c
 set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+
+set compile_flags {debug nowarnings quiet}
+if [support_complex_tests] {
+    lappend compile_flags "additional_flags=-DTEST_COMPLEX"
+}
+
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $compile_flags] != "" } {
      untested funcargs.exp
      return -1
 }
@@ -239,6 +245,77 @@ proc float_and_integral_args {} {
     gdb_stop_suppressing_tests;
 }
 
+
+#
+# Locate actual args; _Complex types.
+#
+
+proc complex_args {} {
+    global gdb_prompt
+
+    delete_breakpoints
+
+    gdb_breakpoint callca
+    gdb_breakpoint callcb
+    gdb_breakpoint callcc
+    gdb_breakpoint callcd
+    gdb_breakpoint callce
+    gdb_breakpoint callcf
+
+    # Run; should stop at call1a and print actual arguments.
+    gdb_run_cmd
+    gdb_expect {
+	-re ".* callca \\(f1=1 \\+ 2 \\* I, f2=1 \\+ 2 \\* I, f3=1 \\+ 2 \\* I\\) .*$gdb_prompt $" { pass "run to call2a" }
+	timeout { fail "(timeout) run to callca" ; gdb_suppress_tests; }
+    }
+    gdb_test "cont" ".* callcb \\(d1=3 \\+ 4 \\* I, d2=3 \\+ 4 \\* I, d3=3 \\+ 4 \\* I\\) .*" "continue to callcb"
+    gdb_test "cont" ".* callcc \\(ld1=5 \\+ 6 \\* I, ld2=5 \\+ 6 \\* I, ld3=5 \\+ 6 \\* I\\) .*" "continue to callcb"
+    gdb_test "cont" ".* callcd \\(fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I\\) .*" "continue to callcd"
+    gdb_test "cont" ".* callce \\(dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I, fc1=1 \\+ 2 \\* I\\) .*" "continue to callce"
+    gdb_test "cont" ".* callcf \\(ldc1=5 \\+ 6 \\* I, fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I\\) .*" "continue to callcf"
+}
+
+
+#
+# Locate actual args; _Complex types and integral.
+#
+proc  complex_integral_args {} {
+    global gdb_prompt
+
+    delete_breakpoints
+
+    gdb_breakpoint callc1a
+    gdb_breakpoint callc1b
+
+    # Run; should stop at call1a and print actual arguments.
+    gdb_run_cmd
+    gdb_expect {
+	-re ".* callc1a \\(c=97 'a', s=1, i=2, ui=7, l=3, fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I\\) .*$gdb_prompt $" { pass "run to callc1a" }
+	timeout { fail "(timeout) run to callc1a" ; gdb_suppress_tests; }
+    }
+    gdb_test "cont" ".* callc1b \\(ldc1=5 \\+ 6 \\* I\\, c=97 'a', s=1, i=2, fc1=1 \\+ 2 \\* I, ui=7, l=3, dc1=3 \\+ 4 \\* I\\) .*" "continue to callc1b"
+}
+
+#
+# Locate acual args; _Complex types and integral/float.
+#
+proc complex_float_integral_args {} {
+    global gdb_prompt
+
+    delete_breakpoints
+
+    gdb_breakpoint callc2a
+    gdb_breakpoint callc2b
+
+    # Run; should stop at call1a and print actual arguments.
+    gdb_run_cmd
+    gdb_expect {
+	-re ".* callc2a \\(c=97 'a', s=1, i=2, ui=7, l=3, f=4, d=5, fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I\\) .*$gdb_prompt $" { pass "run to callc2a" }
+	timeout { fail "(timeout) run to callc1a" ; gdb_suppress_tests; }
+    }
+    gdb_test "cont" ".* callc2b \\(fc1=1 \\+ 2 \\* I, c=97 'a', s=1, i=2, ui=7, ldc1=5 \\+ 6 \\* I\\, l=3, f=4, d=5, dc1=3 \\+ 4 \\* I\\) .*" "continue to callc2b"
+}
+
 #
 # Locate actual args; dereference pointers to ints and floats.
 #
@@ -1167,6 +1244,21 @@ funcargs_reload
 if {![target_info exists gdb,skip_float_tests]} {
   float_and_integral_args
 }
+
+# Test _Complex type here if supported.
+if [support_complex_tests] {
+    funcargs_reload
+    complex_args
+
+    funcargs_reload
+    complex_integral_args
+
+    if {![target_info exists gdb,skip_float_tests]} {
+	funcargs_reload
+	complex_float_integral_args
+    }
+}
+
 funcargs_reload
 pointer_args
 funcargs_reload
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 531120c..b9d5752 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1486,6 +1486,47 @@ proc skip_shlib_tests {} {
     return 1
 }
 
+# Return 1 if _Complex types are supported, otherwise, return 0.
+
+proc support_complex_tests {} {
+    global support_complex_tests_saved
+
+    # Use the cached value, if it exists.
+    if [info exists support_complex_tests_saved] {
+        verbose "returning saved $support_complex_tests_saved" 2
+        return $support_complex_tests_saved
+    }
+
+    # Set up, compile, and execute a test program containing _Complex types.
+    # Include the current process ID in the file names to prevent conflicts
+    # with invocations for multiple testsuites.
+    set src complex[pid].c
+    set exe complex[pid].x
+
+    set f [open $src "w"]
+    puts $f "int main() {"
+    puts $f "_Complex float cf;"
+    puts $f "_Complex double cd;"
+    puts $f "_Complex long double cld;"
+    puts $f "  return 0; }"
+    close $f
+
+    verbose "compiling testfile $src" 2
+    set compile_flags {debug nowarnings quiet}
+    set lines [gdb_compile $src $exe executable $compile_flags]
+    file delete $src
+    file delete $exe
+
+    if ![string match "" $lines] then {
+        verbose "testfile compilation failed, returning 0" 2
+        set support_complex_tests_saved 0
+    } else {
+	set support_complex_tests_saved 1
+    }
+
+    return $support_complex_tests_saved
+}
+
 # Return 1 if target is ILP32.
 # This cannot be decided simply from looking at the target string,
 # as it might depend on externally passed compiler options like -m64.
-- 
1.7.0.4


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 2/4] _Complex type in varargs.exp
  2011-05-19 17:12         ` Tom Tromey
@ 2011-05-20  8:11           ` Yao Qi
  0 siblings, 0 replies; 40+ messages in thread
From: Yao Qi @ 2011-05-20  8:11 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 268 bytes --]

On 05/20/2011 01:12 AM, Tom Tromey wrote:
>>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:

> 
> Yao> +if [support_complex_tests] {
> Yao> +    set additional_flags "$additional_flags additional_flags=-DTEST_COMPLEX"
> 
> lappend


Fixed.

-- 
Yao (齐尧)

[-- Attachment #2: 0002-vararg-of-type-_Complex.patch --]
[-- Type: text/x-patch, Size: 4565 bytes --]

From f0b13b14eb28833608fecb5fd7531870b9747c80 Mon Sep 17 00:00:00 2001
From: Yao Qi <yao@codesourcery.com>
Date: Wed, 18 May 2011 15:35:31 +0800
Subject: [PATCH 2/4] vararg of type _Complex

gdb/testsuite/

        Test inf-call of varargs of type _Complex.
        * gdb.base/varargs.c (find_max_float_real): New.
        (find_max_double_real, find_max_long_double_real): New.
        * gdb.base/varargs.exp: Call these new added functions.
---
 gdb/testsuite/gdb.base/varargs.c   |   80 ++++++++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.base/varargs.exp |   38 +++++++++++++++++
 2 files changed, 118 insertions(+), 0 deletions(-)

diff --git a/gdb/testsuite/gdb.base/varargs.c b/gdb/testsuite/gdb.base/varargs.c
index 1122767..1ad2ffc 100644
--- a/gdb/testsuite/gdb.base/varargs.c
+++ b/gdb/testsuite/gdb.base/varargs.c
@@ -23,6 +23,28 @@ float fa,fb,fc,fd;
 double da,db,dc,dd;
 double dmax_val;
 
+#ifdef TEST_COMPLEX
+extern float crealf (float _Complex);
+extern double creal (double _Complex);
+extern long double creall (long double _Complex);
+
+float _Complex fc1 = 1.0F + 1.0iF;
+float _Complex fc2 = 2.0F + 2.0iF;
+float _Complex fc3 = 3.0F + 3.0iF;
+float _Complex fc4 = 4.0F + 4.0iF;
+
+double _Complex dc1 = 1.0 + 1.0i;
+double _Complex dc2 = 2.0 + 2.0i;
+double _Complex dc3 = 3.0 + 3.0i;
+double _Complex dc4 = 4.0 + 4.0i;
+
+long double _Complex ldc1 = 1.0L + 1.0Li;
+long double _Complex ldc2 = 2.0L + 2.0Li;
+long double _Complex ldc3 = 3.0L + 3.0Li;
+long double _Complex ldc4 = 4.0L + 4.0Li;
+
+#endif
+
 int main() {
   c = -1;
   uc = 1;
@@ -109,3 +131,61 @@ double find_max_double(int num_vals, double first_val, ...) {
   return max_val;
 }
 
+
+#ifdef TEST_COMPLEX
+float _Complex
+find_max_float_real (int num_vals, ...)
+{
+  float _Complex max = 0.0F + 0.0iF;
+  float _Complex x;
+  va_list argp;
+  int i;
+
+  va_start(argp, num_vals);
+  for (i = 0; i < num_vals; i++)
+    {
+      x = va_arg (argp, float _Complex);
+      if (crealf (max) < crealf (x)) max = x;
+    }
+
+  return max;
+}
+
+double _Complex
+find_max_double_real (int num_vals, ...)
+{
+  double _Complex max = 0.0 + 0.0i;
+  double _Complex x;
+  va_list argp;
+  int i;
+
+  va_start(argp, num_vals);
+  for (i = 0; i < num_vals; i++)
+    {
+      x = va_arg (argp, double _Complex);
+      if (creal (max) < creal (x)) max = x;
+    }
+
+  return max;
+}
+
+long double _Complex
+find_max_long_double_real (int num_vals, ...)
+{
+  long double _Complex max = 0.0L + 0.0iL;
+  long double _Complex x;
+  va_list argp;
+  int i;
+
+  va_start(argp, num_vals);
+  for (i = 0; i < num_vals; i++)
+    {
+      x = va_arg (argp, long double _Complex);
+      if (creall (max) < creal (x)) max = x;
+    }
+
+  return max;
+}
+
+
+#endif /* TEST_COMPLEX */
diff --git a/gdb/testsuite/gdb.base/varargs.exp b/gdb/testsuite/gdb.base/varargs.exp
index 4627862..3dda4fb 100644
--- a/gdb/testsuite/gdb.base/varargs.exp
+++ b/gdb/testsuite/gdb.base/varargs.exp
@@ -44,6 +44,9 @@ if [get_compiler_info ${binfile}] {
 }
 
 set additional_flags {debug}
+if [support_complex_tests] {
+    lappend additional_flags "additional_flags=-DTEST_COMPLEX"
+}
 
 if {$hp_cc_compiler} {
     lappend additional_flags "additional_flags=-Ae"
@@ -112,3 +115,38 @@ if {![target_info exists gdb,skip_float_tests]} {
 	"print find_max_double(5,1.0,17.0,2.0,3.0,4.0)"
 }
 
+
+# Test _Complex type here if supported.
+if [support_complex_tests] {
+    global gdb_prompt
+
+    gdb_test_multiple "print find_max_float_real(4, fc1, fc2, fc3, fc4)" \
+	"print find_max_float_real(4, fc1, fc2, fc3, fc4)" {
+	-re ".*= 4 \\+ 4 \\* I.*$gdb_prompt $" {
+	    pass "print find_max_float_real(4, fc1, fc2, fc3, fc4)"
+	}
+	-re ".*$gdb_prompt $" {
+	    kfail gdb/12776 "print find_max_float_real(4, fc1, fc2, fc3, fc4)"
+	}
+    }
+
+    gdb_test_multiple "print find_max_double_real(4, dc1, dc2, dc3, dc4)" \
+	"print find_max_double_real(4, dc1, dc2, dc3, dc4)" {
+	-re ".*= 4 \\+ 4 \\* I.*${gdb_prompt} $" {
+	    pass "print find_max_float_real(4, fc1, fc2, fc3, fc4)"
+	}
+	-re ".*$gdb_prompt $" {
+	    kfail gdb/12776 "print find_max_double_real(4, dc1, dc2, dc3, dc4)"
+	}
+    }
+    gdb_test_multiple "print find_max_long_double_real(4, ldc1, ldc2, ldc3, ldc4)" \
+	"print find_max_long_double_real(4, ldc1, ldc2, ldc3, ldc4)" {
+	 -re ".*= 4 \\+ 4 \\* I.*${gdb_prompt} $" {
+	     pass "print find_max_long_double_real(4, ldc1, ldc2, ldc3, ldc4)"
+	 }
+	 -re ".*$gdb_prompt $" {
+	    kfail gdb/12776 "print find_max_double_real(4, dc1, dc2, dc3, dc4)"
+	}
+    }
+
+}
-- 
1.7.0.4


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 4/4] _Complex tests in callfuncs.exp
  2011-05-19  5:09       ` [_Complex test 4/4] _Complex tests " Yao Qi
@ 2011-05-20  8:17         ` Yao Qi
  2011-05-24  1:46           ` [_Complex test 4/4 V3] " Yao Qi
  2011-05-26 17:07         ` [_Complex test 4/4] " Tom Tromey
  1 sibling, 1 reply; 40+ messages in thread
From: Yao Qi @ 2011-05-20  8:17 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 229 bytes --]

On 05/19/2011 01:08 PM, Yao Qi wrote:
> +set compile_flags {debug}
> +if [support_complex_tests] {
> +    set compile_flags "$compile_flags additional_flags=-DTEST_COMPLEX"
> +}

Use lappend in new patch.

-- 
Yao (齐尧)

[-- Attachment #2: 0004-pass-args-of-type-complex-to-func.patch --]
[-- Type: text/x-patch, Size: 10665 bytes --]

From 1c0d4f9c00ccdcd94d797ef8767ebce6e508a556 Mon Sep 17 00:00:00 2001
From: Yao Qi <yao@codesourcery.com>
Date: Wed, 18 May 2011 21:43:57 +0800
Subject: [PATCH 4/4] pass args of type complex to func

gdb/testsuite/

        * gdb.base/funcargs.c (callca, callcb, callcc): New.
        (callcd, callce, callcf, callc1a, callc1b): New.
        (callc2a, callc2b): New.
        * gdb.base/funcargs.exp (complex_args): New.
        (complex_integral_args, complex_float_integral_args): New.
        * lib/gdb.exp (support_complex_tests): New.  Determine
        whether to run test cases on _Complex types.
---
 gdb/testsuite/gdb.base/callfuncs.c   |  147 +++++++++++++++++++++++++++++++++-
 gdb/testsuite/gdb.base/callfuncs.exp |   55 ++++++++++++-
 2 files changed, 200 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.base/callfuncs.c b/gdb/testsuite/gdb.base/callfuncs.c
index 406d22a..946ebde 100644
--- a/gdb/testsuite/gdb.base/callfuncs.c
+++ b/gdb/testsuite/gdb.base/callfuncs.c
@@ -73,6 +73,30 @@ double double_val13 = 10.25;
 double double_val14 = 11.25;
 double double_val15 = 12.25;
 
+#ifdef TEST_COMPLEX
+extern float crealf (float _Complex);
+extern float cimagf (float _Complex);
+extern double creal (double _Complex);
+extern double cimag (double _Complex);
+extern long double creall (long double _Complex);
+extern long double cimagl (long double _Complex);
+
+float _Complex fc1 = 1.0F + 1.0iF;
+float _Complex fc2 = 2.0F + 2.0iF;
+float _Complex fc3 = 3.0F + 3.0iF;
+float _Complex fc4 = 4.0F + 4.0iF;
+
+double _Complex dc1 = 1.0 + 1.0i;
+double _Complex dc2 = 2.0 + 2.0i;
+double _Complex dc3 = 3.0 + 3.0i;
+double _Complex dc4 = 4.0 + 4.0i;
+
+long double _Complex ldc1 = 1.0L + 1.0Li;
+long double _Complex ldc2 = 2.0L + 2.0Li;
+long double _Complex ldc3 = 3.0L + 3.0Li;
+long double _Complex ldc4 = 4.0L + 4.0Li;
+#endif /* TEST_COMPLEX */
+
 #define DELTA (0.001)
 
 char *string_val1 = (char *)"string 1";
@@ -89,8 +113,15 @@ struct struct1 {
   float f;
   double d;
   char a[4];
+#ifdef TEST_COMPLEX
+  float _Complex fc;
+  double _Complex dc;
+  long double _Complex ldc;
+} struct_val1 ={ 'x', 87, 76, 51, 2.1234, 9.876, "foo", 3.0F + 3.0Fi,
+		 4.0L + 4.0Li, 5.0L + 5.0Li};
+#else
 } struct_val1 = { 'x', 87, 76, 51, 2.1234, 9.876, "foo" };
-
+#endif /* TEST_COMPLEX */
 /* Some functions that can be passed as arguments to other test
    functions, or called directly. */
 #ifdef PROTOTYPES
@@ -183,6 +214,11 @@ char  *t_structs_a (struct struct1 tstruct)
   strcpy (buf, tstruct.a);
   return buf;
 }
+#ifdef TEST_COMPLEX
+float _Complex t_structs_fc (struct struct1 tstruct) { return tstruct.fc;}
+double _Complex t_structs_dc (struct struct1 tstruct) { return tstruct.dc;}
+long double _Complex t_structs_fc (struct struct1 tstruct) { return tstruct.ldc;}
+#endif
 #else
 char   t_structs_c (tstruct) struct struct1 tstruct; { return (tstruct.c); }
 short  t_structs_s (tstruct) struct struct1 tstruct; { return (tstruct.s); }
@@ -196,6 +232,11 @@ char  *t_structs_a (tstruct) struct struct1 tstruct;
   strcpy (buf, tstruct.a);
   return buf;
 }
+#ifdef TEST_COMPLEX
+float _Complex t_structs_fc (tstruct) struct struct1 tstruct; { return tstruct.fc;}
+double _Complex t_structs_dc (tstruct) struct struct1 tstruct; { return tstruct.dc;}
+long double _Complex t_structs_ldc (tstruct) struct struct1 tstruct; { return tstruct.ldc;}
+#endif
 #endif
 
 /* Test that calling functions works if there are a lot of arguments.  */
@@ -400,6 +441,110 @@ t_double_many_args (double f1, double f2, double f3, double f4, double f5,
 	  && (sum_args - sum_values) > -DELTA);
 }
 
+/* Various functions for _Complex types.  */
+
+#ifdef TEST_COMPLEX
+
+#define COMPARE_WITHIN_RANGE(ARG1, ARG2, DEL, FUNC) \
+  ((FUNC(ARG1) - FUNC(ARG2)) < DEL) && ((FUNC(ARG1) - FUNC(ARG2) > -DEL))
+
+#define DEF_FUNC_MANY_ARGS_1(TYPE, NAME)			\
+t_##NAME##_complex_many_args (f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, \
+			      f12, f13, f14, f15, f16)			\
+     TYPE _Complex f1, TYPE _Complex f2, TYPE _Complex f3, \
+     TYPE _Complex f4, TYPE _Complex f5, TYPE _Complex f6, \
+     TYPE _Complex f7, TYPE _Complex f8, TYPE _Complex f9, \
+     TYPE _Complex f10, TYPE _Complex f11, TYPE _Complex f12, \
+     TYPE _Complex f13, TYPE _Complex f14, TYPE _Complex f15, \
+     TYPE _Complex f16;
+
+#define DEF_FUNC_MANY_ARGS_2(TYPE, NAME)		  \
+t_##NAME##_complex_many_args (TYPE _Complex f1, TYPE _Complex f2, \
+			      TYPE _Complex f3, TYPE _Complex f4, \
+			      TYPE _Complex f5, TYPE _Complex f6, \
+			      TYPE _Complex f7, TYPE _Complex f8, \
+			      TYPE _Complex f9, TYPE _Complex f10,	\
+			      TYPE _Complex f11, TYPE _Complex f12,	\
+			      TYPE _Complex f13, TYPE _Complex f14,	\
+			      TYPE _Complex f15, TYPE _Complex f16)
+
+#define DEF_FUNC_MANY_ARGS_3(TYPE, CREAL, CIMAG) \
+{ \
+   TYPE _Complex expected = fc1 + fc2 + fc3 + fc4 + fc1 + fc2 + fc3 + fc4 \
+    + fc1 + fc2 + fc3 + fc4 + fc1 + fc2 + fc3 + fc4; \
+  TYPE _Complex actual = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 \
+    + f11 + f12 + f13 + f14 + f15 + f16; \
+  return (COMPARE_WITHIN_RANGE(expected, actual, DELTA, creal) \
+	  && COMPARE_WITHIN_RANGE(expected, actual, DELTA, creal) \
+	  && COMPARE_WITHIN_RANGE(expected, actual, DELTA, cimag)   \
+	  && COMPARE_WITHIN_RANGE(expected, actual, DELTA, cimag)); \
+}
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_MANY_ARGS_1(float, float)
+#else
+DEF_FUNC_MANY_ARGS_2(float, float)
+#endif
+DEF_FUNC_MANY_ARGS_3(float, crealf, cimagf)
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_MANY_ARGS_1(double, double)
+#else
+DEF_FUNC_MANY_ARGS_2(double, double)
+#endif
+DEF_FUNC_MANY_ARGS_3(double, creal, cimag)
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_MANY_ARGS_1(long double, long_double)
+#else
+DEF_FUNC_MANY_ARGS_2(long double, long_double)
+#endif
+DEF_FUNC_MANY_ARGS_3(long double, creall, cimagl)
+
+#define DEF_FUNC_VALUES_1(TYPE, NAME)			\
+  t_##NAME##_complex_values (f1, f2) TYPE _Complex f1, TYPE _Complex f2;
+
+#define DEF_FUNC_VALUES_2(TYPE, NAME) \
+  t_##NAME##_complex_values (TYPE _Complex f1, TYPE _Complex f2)
+
+#define DEF_FUNC_VALUES_3(FORMAL_PARM, TYPE, CREAL, CIMAG)	\
+{ \
+ return (COMPARE_WITHIN_RANGE(f1, FORMAL_PARM##1, DELTA, CREAL) \
+	  && COMPARE_WITHIN_RANGE(f2, FORMAL_PARM##2, DELTA, CREAL) \
+	  && COMPARE_WITHIN_RANGE(f1,  FORMAL_PARM##1, DELTA, CIMAG) \
+	  && COMPARE_WITHIN_RANGE(f2,  FORMAL_PARM##2, DELTA, CIMAG)); \
+}
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_VALUES_1(float, float)
+#else
+DEF_FUNC_VALUES_2(float, float)
+#endif
+DEF_FUNC_VALUES_3(fc, float, crealf, cimagf)
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_VALUES_1(double, double)
+#else
+DEF_FUNC_VALUES_2(double, double)
+#endif
+DEF_FUNC_VALUES_3(fc, double, creal, cimag)
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_VALUES_1(long double, long_double)
+#else
+DEF_FUNC_VALUES_2(long double, long_double)
+#endif
+DEF_FUNC_VALUES_3(fc, long double, creall, cimagl)
+
+#endif /* TEST_COMPLEX */
+
+
 #ifdef PROTOTYPES
 int t_string_values (char *string_arg1, char *string_arg2)
 #else
diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/callfuncs.exp
index ff86eb8..0e0dc45 100644
--- a/gdb/testsuite/gdb.base/callfuncs.exp
+++ b/gdb/testsuite/gdb.base/callfuncs.exp
@@ -25,7 +25,12 @@ set testfile "callfuncs"
 set srcfile ${testfile}.c
 set binfile ${objdir}/${subdir}/${testfile}
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+set compile_flags {debug}
+if [support_complex_tests] {
+    lappend compile_flags "additional_flags=-DTEST_COMPLEX"
+}
+
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $compile_flags] != "" } {
      untested callfuncs.exp
      return -1
 }
@@ -144,6 +149,23 @@ proc do_function_calls {} {
 	gdb_test "p t_int_double(99, 99.0)" " = 1"
     }
 
+    if [support_complex_tests] {
+	gdb_test "p t_float_complex_values(fc1, fc2)" " = 1"
+	gdb_test "p t_float_complex_values(fc3, fc4)" " = 0"
+	gdb_test "p t_float_complex_many_args(fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4)" " = 1"
+	gdb_test "p t_float_complex_many_args(fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1)" " = 0"
+
+	gdb_test "p t_double_complex_values(dc1, dc2)" " = 1"
+	gdb_test "p t_double_complex_values(dc3, dc4)" " = 0"
+	gdb_test "p t_double_complex_many_args(dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4)" " = 1"
+	gdb_test "p t_double_complex_many_args(dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1)" " = 0"
+
+	gdb_test "p t_long_double_complex_values(ldc1, ldc2)" " = 1"
+	gdb_test "p t_long_double_complex_values(ldc3, ldc4)" " = 0"
+	gdb_test "p t_long_double_complex_many_args(ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4)" " = 1"
+	gdb_test "p t_long_double_complex_many_args(ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1,ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1)" " = 0"
+    }
+
     gdb_test "p t_string_values(string_val2,string_val1)" " = 0"
     gdb_test "p t_string_values(string_val1,string_val2)" " = 1"
     gdb_test "p t_string_values(\"string 1\",\"string 2\")" " = 1"
@@ -217,6 +239,37 @@ proc do_function_calls {} {
 	    "call inferior func with struct - returns double"
     }
 
+    if [support_complex_tests] {
+
+	gdb_test_multiple "p t_structs_fc(struct_val1)" \
+	    "call inferior func with struct - returns float _Complex" {
+		-re ".*= 3 \\+ 3 \\* I.*$gdb_prompt $" {
+		    pass "call inferior func with struct - returns float _Complex"
+		}
+		-r ".*$gdb_prompt $" {
+		    kfail gdb/12783 "call inferior func with struct - returns float _Complex"
+		}
+	    }
+	gdb_test_multiple "p t_structs_dc(struct_val1)" \
+	    "call inferior func with struct - returns double _Complex" {
+		-re  ".*= 4 \\+ 4 \\* I.*$gdb_prompt $" {
+		    pass "call inferior func with struct - returns double _Complex"
+		}
+		-re ".*$gdb_prompt $" {
+		    kfail gdb/12783 "call inferior func with struct - returns double _Complex"
+		}
+	    }
+	gdb_test_multiple "p t_structs_ldc(struct_val1)" \
+	    "call inferior func with struct - returns long double _Complex" {
+		-re  "= 5 \\+ 5 \\* I.*$gdb_prompt $" {
+		    pass "call inferior func with struct - returns long double _Complex"
+		}
+		-re ".*$gdb_prompt $" {
+		    kfail gdb/12783 "call inferior func with struct - returns long double _Complex"
+		}
+	    }
+    }
+
     gdb_test "p t_structs_a(struct_val1)" "= (.unsigned char .. )?\"foo\"" \
     	"call inferior func with struct - returns char *"
 }
-- 
1.7.0.4


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 2/4] _Complex type in varargs.exp
  2011-05-19 15:27             ` Joseph S. Myers
@ 2011-05-20  9:09               ` Pedro Alves
  2011-05-20 15:22               ` Yao Qi
  1 sibling, 0 replies; 40+ messages in thread
From: Pedro Alves @ 2011-05-20  9:09 UTC (permalink / raw)
  To: gdb-patches; +Cc: Joseph S. Myers, Yao Qi

I completely agree.

On Thursday 19 May 2011 16:27:39, Joseph S. Myers wrote:
> On Thu, 19 May 2011, Yao Qi wrote:
> 
> > Tests in this case also fail on armv7l-unknown-linux-gnueabi and
> > x86_64-unknown-linux-gnu.  Shall I have to file yet another two PRs for
> > armv7l-unknown-linux-gnueabi and x86_64-unknown-linux-gnu respectively,
> > and KFAIL them to different PR separately?  At least, I didn't see such
> > usage elsewhere in gdb testsuite.
> 
> I think the correct division is one PR per target architecture for all 
> complex types ABI issues, rather than one PR per test failure.  That's the 
> only way a target maintainer can sensibly fix their target's problems, 
> test that they are fixed, and close the relevant PR; otherwise you have a 
> catch-all bug that's open for ever without meaningfully reflecting what 
> actually needs to be done to fix the problem.
> 
> > IMO, KFAIL with target triplet works for the situation that one test
> > passes on all ports except one or two.  However, our test fails on most
> > ports, different from KFAIL's typical usage.
> 
> The aim is that soon the bug *is* fixed for all the most commonly used 
> targets - but will likely remain open much longer for many more rarely 
> used targets.

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 2/4] _Complex type in varargs.exp
  2011-05-19 15:27             ` Joseph S. Myers
  2011-05-20  9:09               ` Pedro Alves
@ 2011-05-20 15:22               ` Yao Qi
  2011-05-20 15:37                 ` Pedro Alves
  1 sibling, 1 reply; 40+ messages in thread
From: Yao Qi @ 2011-05-20 15:22 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 2084 bytes --]

On 05/19/2011 11:27 PM, Joseph S. Myers wrote:
> On Thu, 19 May 2011, Yao Qi wrote:
> 
>> Tests in this case also fail on armv7l-unknown-linux-gnueabi and
>> x86_64-unknown-linux-gnu.  Shall I have to file yet another two PRs for
>> armv7l-unknown-linux-gnueabi and x86_64-unknown-linux-gnu respectively,
>> and KFAIL them to different PR separately?  At least, I didn't see such
>> usage elsewhere in gdb testsuite.
> 
> I think the correct division is one PR per target architecture for all 
> complex types ABI issues, rather than one PR per test failure.  That's the 
> only way a target maintainer can sensibly fix their target's problems, 
> test that they are fixed, and close the relevant PR; otherwise you have a 
> catch-all bug that's open for ever without meaningfully reflecting what 
> actually needs to be done to fix the problem.

OK, I opened another two PRs for armv7l-unknown-linux-gnueabi and
x86_64-unknown-linux-gnu.  KFAIL to different PRs according to the
target.  An internal error on x86_64-linux is not KFAIL'ed, because I
failed to KFAIL it after some experiments for some time.

x86_64-unknown-linux-gnu:
KFAIL: gdb.base/varargs.exp: print find_max_float_real(4, fc1, fc2, fc3,
fc4) (PRMS: gdb/12790)
KFAIL: gdb.base/varargs.exp: print find_max_double_real(4, dc1, dc2,
dc3, dc4) (PRMS: gdb/12790)
FAIL: gdb.base/varargs.exp: print find_max_long_double_real(4, ldc1,
ldc2, ldc3, ldc4) (GDB internal error)

armv7l-unknown-linux-gnueabi:
KFAIL: gdb.base/varargs.exp: print find_max_float_real(4, fc1, fc2, fc3,
fc4) (PRMS: gdb/12791)
KFAIL: gdb.base/varargs.exp: print find_max_double_real(4, dc1, dc2,
dc3, dc4) (PRMS: gdb/12791)
KFAIL: gdb.base/varargs.exp: print find_max_long_double_real(4, ldc1,
ldc2, ldc3, ldc4) (PRMS: gdb/12791)

i686-pc-linux-gnu:
KFAIL: gdb.base/varargs.exp: print find_max_double_real(4, dc1, dc2,
dc3, dc4) (PRMS: gdb/12776)
KFAIL: gdb.base/varargs.exp: print find_max_long_double_real(4, ldc1,
ldc2, ldc3, ldc4) (PRMS: gdb/12776)

If this patch is acceptable, I'll do the similar changes in patch 4/4.

-- 
Yao (齐尧)

[-- Attachment #2: 0002-vararg-of-type-_Complex.patch --]
[-- Type: text/x-patch, Size: 4741 bytes --]

From 66ec9759f8595d3f998ed612a1bf6e79be85fc6e Mon Sep 17 00:00:00 2001
From: Yao Qi <yao@codesourcery.com>
Date: Wed, 18 May 2011 15:35:31 +0800
Subject: [PATCH 2/4] vararg of type _Complex

gdb/testsuite/

        Test inf-call of varargs of type _Complex.
        * gdb.base/varargs.c (find_max_float_real): New.
        (find_max_double_real, find_max_long_double_real): New.
        * gdb.base/varargs.exp: Call these new added functions.
---
 gdb/testsuite/gdb.base/varargs.c   |   80 ++++++++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.base/varargs.exp |   62 ++++++++++++++++++++++++++++
 2 files changed, 142 insertions(+), 0 deletions(-)

diff --git a/gdb/testsuite/gdb.base/varargs.c b/gdb/testsuite/gdb.base/varargs.c
index 1122767..1ad2ffc 100644
--- a/gdb/testsuite/gdb.base/varargs.c
+++ b/gdb/testsuite/gdb.base/varargs.c
@@ -23,6 +23,28 @@ float fa,fb,fc,fd;
 double da,db,dc,dd;
 double dmax_val;
 
+#ifdef TEST_COMPLEX
+extern float crealf (float _Complex);
+extern double creal (double _Complex);
+extern long double creall (long double _Complex);
+
+float _Complex fc1 = 1.0F + 1.0iF;
+float _Complex fc2 = 2.0F + 2.0iF;
+float _Complex fc3 = 3.0F + 3.0iF;
+float _Complex fc4 = 4.0F + 4.0iF;
+
+double _Complex dc1 = 1.0 + 1.0i;
+double _Complex dc2 = 2.0 + 2.0i;
+double _Complex dc3 = 3.0 + 3.0i;
+double _Complex dc4 = 4.0 + 4.0i;
+
+long double _Complex ldc1 = 1.0L + 1.0Li;
+long double _Complex ldc2 = 2.0L + 2.0Li;
+long double _Complex ldc3 = 3.0L + 3.0Li;
+long double _Complex ldc4 = 4.0L + 4.0Li;
+
+#endif
+
 int main() {
   c = -1;
   uc = 1;
@@ -109,3 +131,61 @@ double find_max_double(int num_vals, double first_val, ...) {
   return max_val;
 }
 
+
+#ifdef TEST_COMPLEX
+float _Complex
+find_max_float_real (int num_vals, ...)
+{
+  float _Complex max = 0.0F + 0.0iF;
+  float _Complex x;
+  va_list argp;
+  int i;
+
+  va_start(argp, num_vals);
+  for (i = 0; i < num_vals; i++)
+    {
+      x = va_arg (argp, float _Complex);
+      if (crealf (max) < crealf (x)) max = x;
+    }
+
+  return max;
+}
+
+double _Complex
+find_max_double_real (int num_vals, ...)
+{
+  double _Complex max = 0.0 + 0.0i;
+  double _Complex x;
+  va_list argp;
+  int i;
+
+  va_start(argp, num_vals);
+  for (i = 0; i < num_vals; i++)
+    {
+      x = va_arg (argp, double _Complex);
+      if (creal (max) < creal (x)) max = x;
+    }
+
+  return max;
+}
+
+long double _Complex
+find_max_long_double_real (int num_vals, ...)
+{
+  long double _Complex max = 0.0L + 0.0iL;
+  long double _Complex x;
+  va_list argp;
+  int i;
+
+  va_start(argp, num_vals);
+  for (i = 0; i < num_vals; i++)
+    {
+      x = va_arg (argp, long double _Complex);
+      if (creall (max) < creal (x)) max = x;
+    }
+
+  return max;
+}
+
+
+#endif /* TEST_COMPLEX */
diff --git a/gdb/testsuite/gdb.base/varargs.exp b/gdb/testsuite/gdb.base/varargs.exp
index 4627862..c556bff 100644
--- a/gdb/testsuite/gdb.base/varargs.exp
+++ b/gdb/testsuite/gdb.base/varargs.exp
@@ -44,6 +44,9 @@ if [get_compiler_info ${binfile}] {
 }
 
 set additional_flags {debug}
+if [support_complex_tests] {
+    lappend additional_flags "additional_flags=-DTEST_COMPLEX"
+}
 
 if {$hp_cc_compiler} {
     lappend additional_flags "additional_flags=-Ae"
@@ -112,3 +115,62 @@ if {![target_info exists gdb,skip_float_tests]} {
 	"print find_max_double(5,1.0,17.0,2.0,3.0,4.0)"
 }
 
+
+# Test _Complex type here if supported.
+if [support_complex_tests] {
+    global gdb_prompt
+
+    set test "print find_max_float_real(4, fc1, fc2, fc3, fc4)"
+    gdb_test_multiple $test $test {
+	-re ".*= 4 \\+ 4 \\* I.*${gdb_prompt} $" {
+	    pass $test
+	}
+	-re ".*$gdb_prompt $" {
+	    if {[istarget "x86_64-*-*"]} {
+		kfail gdb/12790 $test
+	    } elseif {[istarget "arm*-*-*"]} {
+		kfail gdb/12791 $test
+	    } else {
+		fail $test
+	    }
+	}
+    }
+
+    set test "print find_max_double_real(4, dc1, dc2, dc3, dc4)"
+    gdb_test_multiple $test $test {
+	-re ".*= 4 \\+ 4 \\* I.*${gdb_prompt} $" {
+	    pass $test
+	}
+	-re ".*$gdb_prompt $" {
+	    if {[istarget "i?86-*-*"]} {
+		kfail gdb/12776 $test
+	    } elseif {[istarget "x86_64-*-*"]} {
+		kfail gdb/12790 $test
+	    } elseif {[istarget "arm*-*-*"]} {
+		kfail gdb/12791 $test
+	    } else {
+		fail $test
+	    }
+	}
+    }
+
+    set test "print find_max_long_double_real(4, ldc1, ldc2, ldc3, ldc4)"
+    gdb_test_multiple $test $test {
+	-re ".*= 4 \\+ 4 \\* I.*${gdb_prompt} $" {
+	    pass $test
+	}
+	-re ".*$gdb_prompt $" {
+	    if {[istarget "i?86-*-*"]} {
+		kfail gdb/12776 $test
+	    } elseif {[istarget "x86_64-*-*"]} {
+		kfail gdb/12790 $test
+	    } elseif {[istarget "arm*-*-*"]} {
+		kfail gdb/12791 $test
+	    } else {
+		fail $test
+	    }
+	}
+
+    }
+
+}
-- 
1.7.0.4


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 2/4] _Complex type in varargs.exp
  2011-05-20 15:22               ` Yao Qi
@ 2011-05-20 15:37                 ` Pedro Alves
  2011-05-23  4:09                   ` Yao Qi
  0 siblings, 1 reply; 40+ messages in thread
From: Pedro Alves @ 2011-05-20 15:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Yao Qi, Joseph S. Myers

On Friday 20 May 2011 16:22:15, Yao Qi wrote:
> OK, I opened another two PRs for armv7l-unknown-linux-gnueabi and
> x86_64-unknown-linux-gnu.  KFAIL to different PRs according to the
> target.  An internal error on x86_64-linux is not KFAIL'ed, because I
> failed to KFAIL it after some experiments for some time.

Did you try setup_kfail?  See below.  The way you have things
doesn't catch the internal error case because that is matched
within gdb_test_multiple itself.  You could also check the return
of gdb_test_multiple to see if an internal match happened, but
that's more complicated than setup_kfail.

> x86_64-unknown-linux-gnu:
> KFAIL: gdb.base/varargs.exp: print find_max_float_real(4, fc1, fc2, fc3,
> fc4) (PRMS: gdb/12790)
> KFAIL: gdb.base/varargs.exp: print find_max_double_real(4, dc1, dc2,
> dc3, dc4) (PRMS: gdb/12790)
> FAIL: gdb.base/varargs.exp: print find_max_long_double_real(4, ldc1,
> ldc2, ldc3, ldc4) (GDB internal error)
> 

    setup_kfail gdb/12776 "i?86-*-*"
    setup_kfail gdb/12790 "x86_64-*-*"
    setup_kfail gdb/12791 "arm*-*-*"
    set test "print find_max_long_double_real(4, ldc1, ldc2, ldc3, ldc4)"
    gdb_test_multiple $test $test {
	-re ".*= 4 \\+ 4 \\* I.*${gdb_prompt} $" {
	    pass $test
	}
    }

Maybe you can even convert the gdb_test_multiple's to gdb_test that way.
(You could also put the setup_kfails in a procedure to not need to 
repeat them everywhere).

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 2/4] _Complex type in varargs.exp
  2011-05-20 15:37                 ` Pedro Alves
@ 2011-05-23  4:09                   ` Yao Qi
  2011-05-23 10:27                     ` Pedro Alves
  0 siblings, 1 reply; 40+ messages in thread
From: Yao Qi @ 2011-05-23  4:09 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Joseph S. Myers

[-- Attachment #1: Type: text/plain, Size: 2553 bytes --]

On 05/20/2011 11:37 PM, Pedro Alves wrote:
> Did you try setup_kfail?  See below.  The way you have things
> doesn't catch the internal error case because that is matched
> within gdb_test_multiple itself.  You could also check the return
> of gdb_test_multiple to see if an internal match happened, but
> that's more complicated than setup_kfail.
> 

I see.  It has been mentioned in the comment to proc gdb_test_multiple

# Returns:
#    1 if the test failed, according to a built-in failure pattern
#    0 if only user-supplied patterns matched
#   -1 if there was an internal error.

Thanks.

>> > x86_64-unknown-linux-gnu:
>> > KFAIL: gdb.base/varargs.exp: print find_max_float_real(4, fc1, fc2, fc3,
>> > fc4) (PRMS: gdb/12790)
>> > KFAIL: gdb.base/varargs.exp: print find_max_double_real(4, dc1, dc2,
>> > dc3, dc4) (PRMS: gdb/12790)
>> > FAIL: gdb.base/varargs.exp: print find_max_long_double_real(4, ldc1,
>> > ldc2, ldc3, ldc4) (GDB internal error)
>> > 
>     setup_kfail gdb/12776 "i?86-*-*"
>     setup_kfail gdb/12790 "x86_64-*-*"
>     setup_kfail gdb/12791 "arm*-*-*"
>     set test "print find_max_long_double_real(4, ldc1, ldc2, ldc3, ldc4)"
>     gdb_test_multiple $test $test {
> 	-re ".*= 4 \\+ 4 \\* I.*${gdb_prompt} $" {
> 	    pass $test
> 	}
>     }

This is exactly what I did when I was writing this patch.  However, the
wrong PR number is got in KFAIL result, like this,

KFAIL: gdb.base/varargs.exp: print find_max_long_double_real(4, ldc1,
ldc2, ldc3, ldc4) (PRMS: gdb/12791)

I was running test case on i686-pc-linux-gnu, but the PR number
displayed was arm's PR.  Source code of proc setup_kfail shows that PR
number is saved in kfail_prms unconditionally.  Of course, only the PR
in last call of setup_kfail is saved.  This is a limitation of
setup_kfail, IMO.  I gave up on this direction then.

In order to overcome this limitation, a new proc setup_kfail_for_target
is added in lib/gdb.exp, which only call setup_kfail if istarget returns
true.

> Maybe you can even convert the gdb_test_multiple's to gdb_test that way.
> (You could also put the setup_kfails in a procedure to not need to 
> repeat them everywhere).

Since we are using setup_kfail, we can surely convert gdb_test_multiple
to gdb_test.  I don't put setup_kfails in a proc, because, KFAILs on x86
are different from KFAILs on arm/x86_64.

In my new patch, the internal-error on x86_64 is KFAIL'ed.

KFAIL: gdb.base/varargs.exp: print find_max_long_double_real(4, ldc1,
ldc2, ldc3, ldc4) (GDB internal error) (PRMS: gdb/12790)

-- 
Yao (齐尧)

[-- Attachment #2: 0002-vararg-of-type-_Complex.patch --]
[-- Type: text/x-patch, Size: 4821 bytes --]

From 9dec3cd80b6e3fa4c7544bcd1560a7abfe5a749f Mon Sep 17 00:00:00 2001
From: Yao Qi <yao@codesourcery.com>
Date: Wed, 18 May 2011 15:35:31 +0800
Subject: [PATCH 2/4] vararg of type _Complex

gdb/testsuite/

        Test inf-call of varargs of type _Complex.
        * gdb.base/varargs.c (find_max_float_real): New.
        (find_max_double_real, find_max_long_double_real): New.
        * gdb.base/varargs.exp: Call these new added functions.

	* lib/gdb.exp (setup_kfail_for_target): New.
---
 gdb/testsuite/gdb.base/varargs.c   |   80 ++++++++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.base/varargs.exp |   26 ++++++++++++
 gdb/testsuite/lib/gdb.exp          |    8 ++++
 3 files changed, 114 insertions(+), 0 deletions(-)

diff --git a/gdb/testsuite/gdb.base/varargs.c b/gdb/testsuite/gdb.base/varargs.c
index 1122767..1ad2ffc 100644
--- a/gdb/testsuite/gdb.base/varargs.c
+++ b/gdb/testsuite/gdb.base/varargs.c
@@ -23,6 +23,28 @@ float fa,fb,fc,fd;
 double da,db,dc,dd;
 double dmax_val;
 
+#ifdef TEST_COMPLEX
+extern float crealf (float _Complex);
+extern double creal (double _Complex);
+extern long double creall (long double _Complex);
+
+float _Complex fc1 = 1.0F + 1.0iF;
+float _Complex fc2 = 2.0F + 2.0iF;
+float _Complex fc3 = 3.0F + 3.0iF;
+float _Complex fc4 = 4.0F + 4.0iF;
+
+double _Complex dc1 = 1.0 + 1.0i;
+double _Complex dc2 = 2.0 + 2.0i;
+double _Complex dc3 = 3.0 + 3.0i;
+double _Complex dc4 = 4.0 + 4.0i;
+
+long double _Complex ldc1 = 1.0L + 1.0Li;
+long double _Complex ldc2 = 2.0L + 2.0Li;
+long double _Complex ldc3 = 3.0L + 3.0Li;
+long double _Complex ldc4 = 4.0L + 4.0Li;
+
+#endif
+
 int main() {
   c = -1;
   uc = 1;
@@ -109,3 +131,61 @@ double find_max_double(int num_vals, double first_val, ...) {
   return max_val;
 }
 
+
+#ifdef TEST_COMPLEX
+float _Complex
+find_max_float_real (int num_vals, ...)
+{
+  float _Complex max = 0.0F + 0.0iF;
+  float _Complex x;
+  va_list argp;
+  int i;
+
+  va_start(argp, num_vals);
+  for (i = 0; i < num_vals; i++)
+    {
+      x = va_arg (argp, float _Complex);
+      if (crealf (max) < crealf (x)) max = x;
+    }
+
+  return max;
+}
+
+double _Complex
+find_max_double_real (int num_vals, ...)
+{
+  double _Complex max = 0.0 + 0.0i;
+  double _Complex x;
+  va_list argp;
+  int i;
+
+  va_start(argp, num_vals);
+  for (i = 0; i < num_vals; i++)
+    {
+      x = va_arg (argp, double _Complex);
+      if (creal (max) < creal (x)) max = x;
+    }
+
+  return max;
+}
+
+long double _Complex
+find_max_long_double_real (int num_vals, ...)
+{
+  long double _Complex max = 0.0L + 0.0iL;
+  long double _Complex x;
+  va_list argp;
+  int i;
+
+  va_start(argp, num_vals);
+  for (i = 0; i < num_vals; i++)
+    {
+      x = va_arg (argp, long double _Complex);
+      if (creall (max) < creal (x)) max = x;
+    }
+
+  return max;
+}
+
+
+#endif /* TEST_COMPLEX */
diff --git a/gdb/testsuite/gdb.base/varargs.exp b/gdb/testsuite/gdb.base/varargs.exp
index 4627862..6ecfcbf 100644
--- a/gdb/testsuite/gdb.base/varargs.exp
+++ b/gdb/testsuite/gdb.base/varargs.exp
@@ -44,6 +44,9 @@ if [get_compiler_info ${binfile}] {
 }
 
 set additional_flags {debug}
+if [support_complex_tests] {
+    lappend additional_flags "additional_flags=-DTEST_COMPLEX"
+}
 
 if {$hp_cc_compiler} {
     lappend additional_flags "additional_flags=-Ae"
@@ -112,3 +115,26 @@ if {![target_info exists gdb,skip_float_tests]} {
 	"print find_max_double(5,1.0,17.0,2.0,3.0,4.0)"
 }
 
+
+# Test _Complex type here if supported.
+if [support_complex_tests] {
+    global gdb_prompt
+
+    set test "print find_max_float_real(4, fc1, fc2, fc3, fc4)"
+    setup_kfail_for_target gdb/12790 "x86_64-*-*"
+    setup_kfail_for_target gdb/12791 "arm*-*-*"
+    gdb_test $test ".*= 4 \\+ 4 \\* I" $test
+
+    set test "print find_max_double_real(4, dc1, dc2, dc3, dc4)"
+    setup_kfail_for_target gdb/12776 "i?86-*-*"
+    setup_kfail_for_target gdb/12790 "x86_64-*-*"
+    setup_kfail_for_target gdb/12791 "arm*-*-*"
+    gdb_test $test ".*= 4 \\+ 4 \\* I" $test
+
+    set test "print find_max_long_double_real(4, ldc1, ldc2, ldc3, ldc4)"
+    setup_kfail_for_target gdb/12776 "i?86-*-*"
+    setup_kfail_for_target gdb/12790 "x86_64-*-*"
+    setup_kfail_for_target gdb/12791 "arm*-*-*"
+    gdb_test $test ".*= 4 \\+ 4 \\* I" $test
+
+}
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index b9d5752..a63dd61 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2996,6 +2996,14 @@ proc setup_xfail_format { format } {
     return $ret;
 }
 
+# Like setup_kfail, but only call setup_kfail conditionally if
+# istarget[TARGET] returns true.
+proc setup_kfail_for_target { PR target } {
+    if { [istarget $target] } {
+	setup_kfail $PR $target
+    }
+}
+
 proc gdb_step_for_stub { } {
     global gdb_prompt;
 
-- 
1.7.0.4


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 2/4] _Complex type in varargs.exp
  2011-05-23  4:09                   ` Yao Qi
@ 2011-05-23 10:27                     ` Pedro Alves
  2011-05-30  2:55                       ` [committed] " Yao Qi
  0 siblings, 1 reply; 40+ messages in thread
From: Pedro Alves @ 2011-05-23 10:27 UTC (permalink / raw)
  To: gdb-patches; +Cc: Yao Qi, Joseph S. Myers

On Monday 23 May 2011 05:08:58, Yao Qi wrote:
> On 05/20/2011 11:37 PM, Pedro Alves wrote:
> > Did you try setup_kfail?  See below.  The way you have things
> > doesn't catch the internal error case because that is matched
> > within gdb_test_multiple itself.  You could also check the return
> > of gdb_test_multiple to see if an internal match happened, but
> > that's more complicated than setup_kfail.
> > 
> 
> I see.  It has been mentioned in the comment to proc gdb_test_multiple
> 
> # Returns:
> #    1 if the test failed, according to a built-in failure pattern
> #    0 if only user-supplied patterns matched
> #   -1 if there was an internal error.
> 
> Thanks.
> 
> >> > x86_64-unknown-linux-gnu:
> >> > KFAIL: gdb.base/varargs.exp: print find_max_float_real(4, fc1, fc2, fc3,
> >> > fc4) (PRMS: gdb/12790)
> >> > KFAIL: gdb.base/varargs.exp: print find_max_double_real(4, dc1, dc2,
> >> > dc3, dc4) (PRMS: gdb/12790)
> >> > FAIL: gdb.base/varargs.exp: print find_max_long_double_real(4, ldc1,
> >> > ldc2, ldc3, ldc4) (GDB internal error)
> >> > 
> >     setup_kfail gdb/12776 "i?86-*-*"
> >     setup_kfail gdb/12790 "x86_64-*-*"
> >     setup_kfail gdb/12791 "arm*-*-*"
> >     set test "print find_max_long_double_real(4, ldc1, ldc2, ldc3, ldc4)"
> >     gdb_test_multiple $test $test {
> > 	-re ".*= 4 \\+ 4 \\* I.*${gdb_prompt} $" {
> > 	    pass $test
> > 	}
> >     }
> 
> This is exactly what I did when I was writing this patch.  However, the
> wrong PR number is got in KFAIL result, like this,
> 
> KFAIL: gdb.base/varargs.exp: print find_max_long_double_real(4, ldc1,
> ldc2, ldc3, ldc4) (PRMS: gdb/12791)
> 
> I was running test case on i686-pc-linux-gnu, but the PR number
> displayed was arm's PR.  Source code of proc setup_kfail shows that PR
> number is saved in kfail_prms unconditionally.  Of course, only the PR
> in last call of setup_kfail is saved.  This is a limitation of
> setup_kfail, IMO.  

Huh, indeed.

> I gave up on this direction then.
> 
> In order to overcome this limitation, a new proc setup_kfail_for_target
> is added in lib/gdb.exp, which only call setup_kfail if istarget returns
> true.

Okay.

> 
> > Maybe you can even convert the gdb_test_multiple's to gdb_test that way.
> > (You could also put the setup_kfails in a procedure to not need to 
> > repeat them everywhere).
> 
> Since we are using setup_kfail, we can surely convert gdb_test_multiple
> to gdb_test.  I don't put setup_kfails in a proc, because, KFAILs on x86
> are different from KFAILs on arm/x86_64.
> 
> In my new patch, the internal-error on x86_64 is KFAIL'ed.
> 
> KFAIL: gdb.base/varargs.exp: print find_max_long_double_real(4, ldc1,
> ldc2, ldc3, ldc4) (GDB internal error) (PRMS: gdb/12790)

Looks good to me.

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [_Complex test 4/4 V3] _Complex tests in callfuncs.exp
  2011-05-20  8:17         ` Yao Qi
@ 2011-05-24  1:46           ` Yao Qi
  2011-05-24  9:00             ` Mark Kettenis
  0 siblings, 1 reply; 40+ messages in thread
From: Yao Qi @ 2011-05-24  1:46 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1987 bytes --]


This is the version 3 of patch 4/4.  In this version,
setup_kfail_for_target is used to KFAIL the same fail to different PRs
according to target triplet, same as what I did in patch 3/4.

Run callfuncs.exp with this patch applied on three different targets.
Note that there is one extra FAIL in i686-pc-linux-gnu and
armv7l-unknown-linux-gnueabi, caused by these KFAILs.

i686-pc-linux-gnu:
KFAIL: gdb.base/callfuncs.exp: call inferior func with struct - returns
double _Complex (PRMS: gdb/12783)
KFAIL: gdb.base/callfuncs.exp: call inferior func with struct - returns
long double _Complex (PRMS: gdb/12783)
FAIL: gdb.base/callfuncs.exp: gdb function calls preserve register contents

armv7l-unknown-linux-gnueabi:
KFAIL: gdb.base/callfuncs.exp: call inferior func with struct - returns
float _Complex (PRMS: gdb/12797)
KFAIL: gdb.base/callfuncs.exp: call inferior func with struct - returns
double _Complex (PRMS: gdb/12797)
KFAIL: gdb.base/callfuncs.exp: call inferior func with struct - returns
long double _Complex (PRMS: gdb/12797)
FAIL: gdb.base/callfuncs.exp: gdb function calls preserve register contents

x86_64-pc-linux-gnu:
KFAIL: gdb.base/callfuncs.exp: p t_float_complex_values(fc1, fc2) (PRMS:
gdb/12798)
KFAIL: gdb.base/callfuncs.exp: p t_float_complex_many_args(fc1, fc2,
fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4)
(PRMS: gdb/12800)
KFAIL: gdb.base/callfuncs.exp: p t_double_complex_values(dc1, dc2)
(PRMS: gdb/12798)
KFAIL: gdb.base/callfuncs.exp: p t_double_complex_many_args(dc1, dc2,
dc3, dc4, dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4)
(PRMS: gdb/12800)
KFAIL: gdb.base/callfuncs.exp: call inferior func with struct - returns
float _Complex (PRMS: gdb/12796)
KFAIL: gdb.base/callfuncs.exp: call inferior func with struct - returns
double _Complex (PRMS: gdb/12796)
KFAIL: gdb.base/callfuncs.exp: call inferior func with struct - returns
long double _Complex (GDB internal error) (PRMS: gdb/12796)

-- 
Yao (齐尧)

[-- Attachment #2: 0004-pass-args-of-type-complex-to-func.patch --]
[-- Type: text/x-patch, Size: 10423 bytes --]

From a6f9d0ddd17e71cec1c1d18d09a084c15771dc56 Mon Sep 17 00:00:00 2001
From: Yao Qi <yao@codesourcery.com>
Date: Wed, 18 May 2011 21:43:57 +0800
Subject: [PATCH 4/4] pass args of type complex to func

gdb/testsuite/

        * gdb.base/funcargs.c (callca, callcb, callcc): New.
        (callcd, callce, callcf, callc1a, callc1b): New.
        (callc2a, callc2b): New.
        * gdb.base/funcargs.exp (complex_args): New.
        (complex_integral_args, complex_float_integral_args): New.
---
 gdb/testsuite/gdb.base/callfuncs.c   |  147 +++++++++++++++++++++++++++++++++-
 gdb/testsuite/gdb.base/callfuncs.exp |   50 +++++++++++-
 2 files changed, 195 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.base/callfuncs.c b/gdb/testsuite/gdb.base/callfuncs.c
index 406d22a..f764b82 100644
--- a/gdb/testsuite/gdb.base/callfuncs.c
+++ b/gdb/testsuite/gdb.base/callfuncs.c
@@ -73,6 +73,30 @@ double double_val13 = 10.25;
 double double_val14 = 11.25;
 double double_val15 = 12.25;
 
+#ifdef TEST_COMPLEX
+extern float crealf (float _Complex);
+extern float cimagf (float _Complex);
+extern double creal (double _Complex);
+extern double cimag (double _Complex);
+extern long double creall (long double _Complex);
+extern long double cimagl (long double _Complex);
+
+float _Complex fc1 = 1.0F + 1.0iF;
+float _Complex fc2 = 2.0F + 2.0iF;
+float _Complex fc3 = 3.0F + 3.0iF;
+float _Complex fc4 = 4.0F + 4.0iF;
+
+double _Complex dc1 = 1.0 + 1.0i;
+double _Complex dc2 = 2.0 + 2.0i;
+double _Complex dc3 = 3.0 + 3.0i;
+double _Complex dc4 = 4.0 + 4.0i;
+
+long double _Complex ldc1 = 1.0L + 1.0Li;
+long double _Complex ldc2 = 2.0L + 2.0Li;
+long double _Complex ldc3 = 3.0L + 3.0Li;
+long double _Complex ldc4 = 4.0L + 4.0Li;
+#endif /* TEST_COMPLEX */
+
 #define DELTA (0.001)
 
 char *string_val1 = (char *)"string 1";
@@ -89,8 +113,15 @@ struct struct1 {
   float f;
   double d;
   char a[4];
+#ifdef TEST_COMPLEX
+  float _Complex fc;
+  double _Complex dc;
+  long double _Complex ldc;
+} struct_val1 ={ 'x', 87, 76, 51, 2.1234, 9.876, "foo", 3.0F + 3.0Fi,
+		 4.0L + 4.0Li, 5.0L + 5.0Li};
+#else
 } struct_val1 = { 'x', 87, 76, 51, 2.1234, 9.876, "foo" };
-
+#endif /* TEST_COMPLEX */
 /* Some functions that can be passed as arguments to other test
    functions, or called directly. */
 #ifdef PROTOTYPES
@@ -183,6 +214,11 @@ char  *t_structs_a (struct struct1 tstruct)
   strcpy (buf, tstruct.a);
   return buf;
 }
+#ifdef TEST_COMPLEX
+float _Complex t_structs_fc (struct struct1 tstruct) { return tstruct.fc;}
+double _Complex t_structs_dc (struct struct1 tstruct) { return tstruct.dc;}
+long double _Complex t_structs_fc (struct struct1 tstruct) { return tstruct.ldc;}
+#endif
 #else
 char   t_structs_c (tstruct) struct struct1 tstruct; { return (tstruct.c); }
 short  t_structs_s (tstruct) struct struct1 tstruct; { return (tstruct.s); }
@@ -196,6 +232,11 @@ char  *t_structs_a (tstruct) struct struct1 tstruct;
   strcpy (buf, tstruct.a);
   return buf;
 }
+#ifdef TEST_COMPLEX
+float _Complex t_structs_fc (tstruct) struct struct1 tstruct; { return tstruct.fc;}
+double _Complex t_structs_dc (tstruct) struct struct1 tstruct; { return tstruct.dc;}
+long double _Complex t_structs_ldc (tstruct) struct struct1 tstruct; { return tstruct.ldc;}
+#endif
 #endif
 
 /* Test that calling functions works if there are a lot of arguments.  */
@@ -400,6 +441,110 @@ t_double_many_args (double f1, double f2, double f3, double f4, double f5,
 	  && (sum_args - sum_values) > -DELTA);
 }
 
+/* Various functions for _Complex types.  */
+
+#ifdef TEST_COMPLEX
+
+#define COMPARE_WITHIN_RANGE(ARG1, ARG2, DEL, FUNC) \
+  ((FUNC(ARG1) - FUNC(ARG2)) < DEL) && ((FUNC(ARG1) - FUNC(ARG2) > -DEL))
+
+#define DEF_FUNC_MANY_ARGS_1(TYPE, NAME)			\
+t_##NAME##_complex_many_args (f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, \
+			      f12, f13, f14, f15, f16)			\
+     TYPE _Complex f1, TYPE _Complex f2, TYPE _Complex f3, \
+     TYPE _Complex f4, TYPE _Complex f5, TYPE _Complex f6, \
+     TYPE _Complex f7, TYPE _Complex f8, TYPE _Complex f9, \
+     TYPE _Complex f10, TYPE _Complex f11, TYPE _Complex f12, \
+     TYPE _Complex f13, TYPE _Complex f14, TYPE _Complex f15, \
+     TYPE _Complex f16;
+
+#define DEF_FUNC_MANY_ARGS_2(TYPE, NAME)		  \
+t_##NAME##_complex_many_args (TYPE _Complex f1, TYPE _Complex f2, \
+			      TYPE _Complex f3, TYPE _Complex f4, \
+			      TYPE _Complex f5, TYPE _Complex f6, \
+			      TYPE _Complex f7, TYPE _Complex f8, \
+			      TYPE _Complex f9, TYPE _Complex f10,	\
+			      TYPE _Complex f11, TYPE _Complex f12,	\
+			      TYPE _Complex f13, TYPE _Complex f14,	\
+			      TYPE _Complex f15, TYPE _Complex f16)
+
+#define DEF_FUNC_MANY_ARGS_3(TYPE, CREAL, CIMAG) \
+{ \
+   TYPE _Complex expected = fc1 + fc2 + fc3 + fc4 + fc1 + fc2 + fc3 + fc4 \
+    + fc1 + fc2 + fc3 + fc4 + fc1 + fc2 + fc3 + fc4; \
+  TYPE _Complex actual = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 \
+    + f11 + f12 + f13 + f14 + f15 + f16; \
+  return (COMPARE_WITHIN_RANGE(expected, actual, DELTA, creal) \
+	  && COMPARE_WITHIN_RANGE(expected, actual, DELTA, creal) \
+	  && COMPARE_WITHIN_RANGE(expected, actual, DELTA, cimag)   \
+	  && COMPARE_WITHIN_RANGE(expected, actual, DELTA, cimag)); \
+}
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_MANY_ARGS_1(float, float)
+#else
+DEF_FUNC_MANY_ARGS_2(float, float)
+#endif
+DEF_FUNC_MANY_ARGS_3(float, crealf, cimagf)
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_MANY_ARGS_1(double, double)
+#else
+DEF_FUNC_MANY_ARGS_2(double, double)
+#endif
+DEF_FUNC_MANY_ARGS_3(double, creal, cimag)
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_MANY_ARGS_1(long double, long_double)
+#else
+DEF_FUNC_MANY_ARGS_2(long double, long_double)
+#endif
+DEF_FUNC_MANY_ARGS_3(long double, creall, cimagl)
+
+#define DEF_FUNC_VALUES_1(TYPE, NAME)			\
+  t_##NAME##_complex_values (f1, f2) TYPE _Complex f1, TYPE _Complex f2;
+
+#define DEF_FUNC_VALUES_2(TYPE, NAME) \
+  t_##NAME##_complex_values (TYPE _Complex f1, TYPE _Complex f2)
+
+#define DEF_FUNC_VALUES_3(FORMAL_PARM, TYPE, CREAL, CIMAG)	\
+{ \
+  return (COMPARE_WITHIN_RANGE(f1, FORMAL_PARM##1, DELTA, CREAL)    \
+	  && COMPARE_WITHIN_RANGE(f2, FORMAL_PARM##2, DELTA, CREAL)    \
+	  && COMPARE_WITHIN_RANGE(f1,  FORMAL_PARM##1, DELTA, CIMAG)   \
+	  && COMPARE_WITHIN_RANGE(f2,  FORMAL_PARM##2, DELTA, CIMAG)); \
+}
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_VALUES_1(float, float)
+#else
+DEF_FUNC_VALUES_2(float, float)
+#endif
+DEF_FUNC_VALUES_3(fc, float, crealf, cimagf)
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_VALUES_1(double, double)
+#else
+DEF_FUNC_VALUES_2(double, double)
+#endif
+DEF_FUNC_VALUES_3(fc, double, creal, cimag)
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_VALUES_1(long double, long_double)
+#else
+DEF_FUNC_VALUES_2(long double, long_double)
+#endif
+DEF_FUNC_VALUES_3(fc, long double, creall, cimagl)
+
+#endif /* TEST_COMPLEX */
+
+
 #ifdef PROTOTYPES
 int t_string_values (char *string_arg1, char *string_arg2)
 #else
diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/callfuncs.exp
index 5294a2d..78e6dd2 100644
--- a/gdb/testsuite/gdb.base/callfuncs.exp
+++ b/gdb/testsuite/gdb.base/callfuncs.exp
@@ -25,7 +25,12 @@ set testfile "callfuncs"
 set srcfile ${testfile}.c
 set binfile ${objdir}/${subdir}/${testfile}
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+set compile_flags {debug}
+if [support_complex_tests] {
+    lappend compile_flags "additional_flags=-DTEST_COMPLEX"
+}
+
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $compile_flags] != "" } {
      untested callfuncs.exp
      return -1
 }
@@ -144,6 +149,29 @@ proc do_function_calls {} {
 	gdb_test "p t_int_double(99, 99.0)" " = 1"
     }
 
+    if [support_complex_tests] {
+	setup_kfail_for_target gdb/12798 "x86_64-*-*"
+	gdb_test "p t_float_complex_values(fc1, fc2)" " = 1"
+	gdb_test "p t_float_complex_values(fc3, fc4)" " = 0"
+
+	setup_kfail_for_target gdb/12800 "x86_64-*-*"
+	gdb_test "p t_float_complex_many_args(fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4)" " = 1"
+	gdb_test "p t_float_complex_many_args(fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1)" " = 0"
+
+	setup_kfail_for_target gdb/12798 "x86_64-*-*"
+	gdb_test "p t_double_complex_values(dc1, dc2)" " = 1"
+	gdb_test "p t_double_complex_values(dc3, dc4)" " = 0"
+
+	setup_kfail_for_target gdb/12800 "x86_64-*-*"
+	gdb_test "p t_double_complex_many_args(dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4)" " = 1"
+	gdb_test "p t_double_complex_many_args(dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1)" " = 0"
+
+	gdb_test "p t_long_double_complex_values(ldc1, ldc2)" " = 1"
+	gdb_test "p t_long_double_complex_values(ldc3, ldc4)" " = 0"
+	gdb_test "p t_long_double_complex_many_args(ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4)" " = 1"
+	gdb_test "p t_long_double_complex_many_args(ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1,ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1)" " = 0"
+    }
+
     gdb_test "p t_string_values(string_val2,string_val1)" " = 0"
     gdb_test "p t_string_values(string_val1,string_val2)" " = 1"
     gdb_test "p t_string_values(\"string 1\",\"string 2\")" " = 1"
@@ -217,6 +245,26 @@ proc do_function_calls {} {
 	    "call inferior func with struct - returns double"
     }
 
+    if [support_complex_tests] {
+
+	setup_kfail_for_target gdb/12796 "x86_64-*-*"
+	setup_kfail_for_target gdb/12797 "arm*-*-*"
+	gdb_test "p t_structs_fc(struct_val1)" ".*= 3 \\+ 3 \\* I" \
+	    "call inferior func with struct - returns float _Complex"
+
+	setup_kfail_for_target gdb/12783 "i?86-*-*"
+	setup_kfail_for_target gdb/12796 "x86_64-*-*"
+	setup_kfail_for_target gdb/12797 "arm*-*-*"
+	gdb_test "p t_structs_dc(struct_val1)" ".*= 4 \\+ 4 \\* I" \
+	    "call inferior func with struct - returns double _Complex"
+
+	setup_kfail_for_target gdb/12783 "i?86-*-*"
+	setup_kfail_for_target gdb/12796 "x86_64-*-*"
+	setup_kfail_for_target gdb/12797 "arm*-*-*"
+	gdb_test "p t_structs_ldc(struct_val1)" "= 5 \\+ 5 \\* I" \
+	    "call inferior func with struct - returns long double _Complex"
+    }
+
     gdb_test "p t_structs_a(struct_val1)" "= (.unsigned char .. )?\"foo\"" \
     	"call inferior func with struct - returns char *"
 }
-- 
1.7.0.4


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 4/4 V3] _Complex tests in callfuncs.exp
  2011-05-24  1:46           ` [_Complex test 4/4 V3] " Yao Qi
@ 2011-05-24  9:00             ` Mark Kettenis
  2011-05-24  9:34               ` Yao Qi
  0 siblings, 1 reply; 40+ messages in thread
From: Mark Kettenis @ 2011-05-24  9:00 UTC (permalink / raw)
  To: yao; +Cc: gdb-patches

> Date: Tue, 24 May 2011 09:45:42 +0800
> From: Yao Qi <yao@codesourcery.com>
> 
> This is the version 3 of patch 4/4.  In this version,
> setup_kfail_for_target is used to KFAIL the same fail to different PRs
> according to target triplet, same as what I did in patch 3/4.

Can't you fold this behaviour into the normal setup_kfail?


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 4/4 V3] _Complex tests in callfuncs.exp
  2011-05-24  9:00             ` Mark Kettenis
@ 2011-05-24  9:34               ` Yao Qi
  2011-05-24 10:00                 ` Mark Kettenis
  0 siblings, 1 reply; 40+ messages in thread
From: Yao Qi @ 2011-05-24  9:34 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

On 05/24/2011 04:59 PM, Mark Kettenis wrote:
>> > This is the version 3 of patch 4/4.  In this version,
>> > setup_kfail_for_target is used to KFAIL the same fail to different PRs
>> > according to target triplet, same as what I did in patch 3/4.
> Can't you fold this behaviour into the normal setup_kfail?

I don't want to propagate this changes to setup_kfail in DejaGnu,
because I don't know how setup_kfail is used elsewhere.  It is better to
keep setup_kfail_for_target local in GDB, IMO.

-- 
Yao (齐尧)


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 4/4 V3] _Complex tests in callfuncs.exp
  2011-05-24  9:34               ` Yao Qi
@ 2011-05-24 10:00                 ` Mark Kettenis
  2011-05-24 13:54                   ` Yao Qi
  0 siblings, 1 reply; 40+ messages in thread
From: Mark Kettenis @ 2011-05-24 10:00 UTC (permalink / raw)
  To: yao; +Cc: gdb-patches

> Date: Tue, 24 May 2011 17:34:15 +0800
> From: Yao Qi <yao@codesourcery.com>
> 
> On 05/24/2011 04:59 PM, Mark Kettenis wrote:
> >> > This is the version 3 of patch 4/4.  In this version,
> >> > setup_kfail_for_target is used to KFAIL the same fail to different PRs
> >> > according to target triplet, same as what I did in patch 3/4.
> > Can't you fold this behaviour into the normal setup_kfail?
> 
> I don't want to propagate this changes to setup_kfail in DejaGnu,
> because I don't know how setup_kfail is used elsewhere.  It is better to
> keep setup_kfail_for_target local in GDB, IMO.

Ah, I didn't realize that setup_kfail was part of dejagnu proper.
Still I think that setup_kfail_for_target is what the behaviour of
setup_kfail should be.  So dejagnu should be changed.

I'd say you should just go with your previous version that uses
setup_kfail, and submit the enhancement of setup_kfail to the dejagnu
maintainers.  I believe you can link together bugs in bugzilla, so in
the interim, you could use that feature to link together the various
bug reports such that people can find the right one even if the bug ID
that gets printed is the wrong one.

Anyway, getting these tests in is more important than getting the
linking to bug reports exactly right.  If other people think that
setup_kfail_for_target is the way to go, feel free to ignore me.


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 4/4 V3] _Complex tests in callfuncs.exp
  2011-05-24 10:00                 ` Mark Kettenis
@ 2011-05-24 13:54                   ` Yao Qi
  0 siblings, 0 replies; 40+ messages in thread
From: Yao Qi @ 2011-05-24 13:54 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

On 05/24/2011 05:58 PM, Mark Kettenis wrote:
> Ah, I didn't realize that setup_kfail was part of dejagnu proper.
> Still I think that setup_kfail_for_target is what the behaviour of
> setup_kfail should be.  So dejagnu should be changed.
> 

IMO, it is a separate issue to change setup_kfail to what
setup_kfail_for_target like.

> I'd say you should just go with your previous version that uses
> setup_kfail, and submit the enhancement of setup_kfail to the dejagnu
> maintainers.  I believe you can link together bugs in bugzilla, so in
> the interim, you could use that feature to link together the various
> bug reports such that people can find the right one even if the bug ID
> that gets printed is the wrong one.
> 

There are various tricks in bugzilla to link different PRs together, but
it should not be recommended.  We don't know how long these bugs can be
fixed, so it is important to keep an *correct* PR number in KFAIL
message.  That is reason why KFAIL was invented, I think.

Despite of changes going to GDB or DejaGnu, the patch is almost the
same.  Only difference is setup_kfail vs. setup_kfail_for_target.

> Anyway, getting these tests in is more important than getting the
> linking to bug reports exactly right.  If other people think that

Now, we have the approach from which we can get tests running and get
the the correct bug report number.  As I said above, moving
setup_kfail_for_target to setup_kfail is a separate issue, and is a
little bit out of scope of GDB.

> setup_kfail_for_target is the way to go, feel free to ignore me.

-- 
Yao (齐尧)


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 4/4] _Complex tests in callfuncs.exp
  2011-05-19  5:09       ` [_Complex test 4/4] _Complex tests " Yao Qi
  2011-05-20  8:17         ` Yao Qi
@ 2011-05-26 17:07         ` Tom Tromey
  2011-05-30  2:57           ` [committed] " Yao Qi
  1 sibling, 1 reply; 40+ messages in thread
From: Tom Tromey @ 2011-05-26 17:07 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:

Yao> 	* gdb.base/callfuncs.c (t_structs_fc): New.
Yao> 	(t_structs_dc, t_structs_ldc): New.
Yao> 	(t_double_many_args):
Yao> 	(DEF_FUNC_MANY_ARGS_1, DEF_FUNC_MANY_ARGS_2): Define.
Yao> 	(DEF_FUNC_MANY_ARGS_3, DEF_FUNC_VALUES_1): Define.
Yao> 	(DEF_FUNC_VALUES_2, DEF_FUNC_VALUES_3): Define.
Yao> 	* gdb.base/callfuncs.exp: Call new functions.

Ok.

Tom


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [_Complex test 1/4]  support_complex_tests in gdb.exp and pass _Complex args to func
  2011-05-20  8:10                 ` Yao Qi
@ 2011-05-26 17:07                   ` Tom Tromey
  2011-05-30  2:53                     ` [committed] " Yao Qi
  0 siblings, 1 reply; 40+ messages in thread
From: Tom Tromey @ 2011-05-26 17:07 UTC (permalink / raw)
  To: Yao Qi; +Cc: Joseph S. Myers, Mark Kettenis, gdb-patches

>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:

Tom> I am curious if you tested this in some situation where the complex
Tom> tests are skipped.

Yao> I simulate the `complex-unsupported platform' by removing "o" in keyword
Yao> "double" in support_complex_tests, "_Complex double cd;" -> "_Complex
Yao> duble cd;", and run gdb.base/varargs.exp again.  As you can see,
Yao> _Complex related tests are skipped.

Sounds good, thanks.

Just a couple trivial nits.

Yao> +proc  complex_integral_args {} {

Extra space.

Yao> +# Locate acual args; _Complex types and integral/float.

Typo: actual.

Ok with those fixed.

Tom


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [committed] [_Complex test 1/4]  support_complex_tests in gdb.exp and pass _Complex args to func
  2011-05-26 17:07                   ` Tom Tromey
@ 2011-05-30  2:53                     ` Yao Qi
  0 siblings, 0 replies; 40+ messages in thread
From: Yao Qi @ 2011-05-30  2:53 UTC (permalink / raw)
  To: gdb-patches

On 05/27/2011 12:33 AM, Tom Tromey wrote:
> Just a couple trivial nits.
> 
> Yao> +proc  complex_integral_args {} {
> 
> Extra space.
> 

Fixed.

> Yao> +# Locate acual args; _Complex types and integral/float.
> 
> Typo: actual.
> 

Fixed.

> Ok with those fixed.
> 

Commit with these two fixes.
http://sourceware.org/ml/gdb-cvs/2011-05/msg00239.html

-- 
Yao (齐尧)


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [committed] [_Complex test 2/4] _Complex type in varargs.exp
  2011-05-23 10:27                     ` Pedro Alves
@ 2011-05-30  2:55                       ` Yao Qi
  0 siblings, 0 replies; 40+ messages in thread
From: Yao Qi @ 2011-05-30  2:55 UTC (permalink / raw)
  To: gdb-patches

On 05/23/2011 06:27 PM, Pedro Alves wrote:
>> > In my new patch, the internal-error on x86_64 is KFAIL'ed.
>> > 
>> > KFAIL: gdb.base/varargs.exp: print find_max_long_double_real(4, ldc1,
>> > ldc2, ldc3, ldc4) (GDB internal error) (PRMS: gdb/12790)
> Looks good to me.

Committed to trunk.
http://sourceware.org/ml/gdb-cvs/2011-05/msg00240.html

-- 
Yao (齐尧)


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [committed] [_Complex test 3/4] Isolate each test's effect in callfuncs.exp
  2011-05-19 18:46         ` Tom Tromey
@ 2011-05-30  2:56           ` Yao Qi
  0 siblings, 0 replies; 40+ messages in thread
From: Yao Qi @ 2011-05-30  2:56 UTC (permalink / raw)
  To: gdb-patches

On 05/20/2011 02:45 AM, Tom Tromey wrote:
> Yao> 	* gdb.base/callfuncs.exp (rerun_and_prepare): New.
> Yao> 	Call rerun_and_prepare for each test to isolate effects.
> 
> It took me a surprisingly long time to see where rerun_and_prepare was
> actually re-running :)
> 
> This is ok.

Committed to trunk.
http://sourceware.org/ml/gdb-cvs/2011-05/msg00241.html

-- 
Yao (齐尧)


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [committed] [_Complex test 4/4] _Complex tests in callfuncs.exp
  2011-05-26 17:07         ` [_Complex test 4/4] " Tom Tromey
@ 2011-05-30  2:57           ` Yao Qi
  0 siblings, 0 replies; 40+ messages in thread
From: Yao Qi @ 2011-05-30  2:57 UTC (permalink / raw)
  To: gdb-patches

On 05/27/2011 12:41 AM, Tom Tromey wrote:
>>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:
> 
> Yao> 	* gdb.base/callfuncs.c (t_structs_fc): New.
> Yao> 	(t_structs_dc, t_structs_ldc): New.
> Yao> 	(t_double_many_args):
> Yao> 	(DEF_FUNC_MANY_ARGS_1, DEF_FUNC_MANY_ARGS_2): Define.
> Yao> 	(DEF_FUNC_MANY_ARGS_3, DEF_FUNC_VALUES_1): Define.
> Yao> 	(DEF_FUNC_VALUES_2, DEF_FUNC_VALUES_3): Define.
> Yao> 	* gdb.base/callfuncs.exp: Call new functions.
> 
> Ok.
> 

Committed.
http://sourceware.org/ml/gdb-cvs/2011-05/msg00242.html

-- 
Yao (齐尧)


^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2011-05-30  2:57 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-06 14:13 [patch, testsuite] Tests to _Complex type Yao Qi
2011-05-06 14:33 ` Joseph S. Myers
2011-05-09  2:24   ` Yao Qi
2011-05-09 15:06     ` Tom Tromey
2011-05-19  4:26       ` [_Complex test 1/4] support_complex_tests in gdb.exp and pass _Complex args to func Yao Qi
2011-05-19  8:16         ` Mark Kettenis
2011-05-19 10:16           ` Joseph S. Myers
2011-05-19 13:26             ` Yao Qi
2011-05-19 17:10               ` Tom Tromey
2011-05-20  8:10                 ` Yao Qi
2011-05-26 17:07                   ` Tom Tromey
2011-05-30  2:53                     ` [committed] " Yao Qi
2011-05-19 13:01           ` Yao Qi
2011-05-19 13:24             ` Mark Kettenis
2011-05-19 13:38               ` Mark Kettenis
2011-05-19 10:12         ` Joseph S. Myers
2011-05-19  4:34       ` [_Complex test 2/4] _Complex type in varargs.exp Yao Qi
2011-05-19 10:13         ` Joseph S. Myers
2011-05-19 13:42           ` Yao Qi
2011-05-19 15:27             ` Joseph S. Myers
2011-05-20  9:09               ` Pedro Alves
2011-05-20 15:22               ` Yao Qi
2011-05-20 15:37                 ` Pedro Alves
2011-05-23  4:09                   ` Yao Qi
2011-05-23 10:27                     ` Pedro Alves
2011-05-30  2:55                       ` [committed] " Yao Qi
2011-05-19 17:12         ` Tom Tromey
2011-05-20  8:11           ` Yao Qi
2011-05-19  4:46       ` [_Complex test 3/4] Isolate each test's effect in callfuncs.exp Yao Qi
2011-05-19 18:46         ` Tom Tromey
2011-05-30  2:56           ` [committed] " Yao Qi
2011-05-19  5:09       ` [_Complex test 4/4] _Complex tests " Yao Qi
2011-05-20  8:17         ` Yao Qi
2011-05-24  1:46           ` [_Complex test 4/4 V3] " Yao Qi
2011-05-24  9:00             ` Mark Kettenis
2011-05-24  9:34               ` Yao Qi
2011-05-24 10:00                 ` Mark Kettenis
2011-05-24 13:54                   ` Yao Qi
2011-05-26 17:07         ` [_Complex test 4/4] " Tom Tromey
2011-05-30  2:57           ` [committed] " Yao Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox