From: Yao Qi <yao@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: [_Complex test 1/4] support_complex_tests in gdb.exp and pass _Complex args to func
Date: Thu, 19 May 2011 04:26:00 -0000 [thread overview]
Message-ID: <4DD49BE7.80206@codesourcery.com> (raw)
In-Reply-To: <m3oc3bud5j.fsf@fleche.redhat.com>
[-- 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
next prev parent reply other threads:[~2011-05-19 4:26 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Yao Qi [this message]
2011-05-19 8:16 ` [_Complex test 1/4] support_complex_tests in gdb.exp and pass _Complex args to func 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DD49BE7.80206@codesourcery.com \
--to=yao@codesourcery.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox