This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[_Complex test 1/4] support_complex_tests in gdb.exp and pass _Complex args to func
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 (éå)
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