From: Yao Qi <yao@codesourcery.com>
To: Tom Tromey <tromey@redhat.com>
Cc: "Joseph S. Myers" <joseph@codesourcery.com>,
Mark Kettenis <mark.kettenis@xs4all.nl>,
gdb-patches@sourceware.org
Subject: Re: [_Complex test 1/4] support_complex_tests in gdb.exp and pass _Complex args to func
Date: Fri, 20 May 2011 08:10:00 -0000 [thread overview]
Message-ID: <4DD621CE.2050509@codesourcery.com> (raw)
In-Reply-To: <m3mxiiboro.fsf@fleche.redhat.com>
[-- 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
next prev parent reply other threads:[~2011-05-20 8:10 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 ` [_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 [this message]
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=4DD621CE.2050509@codesourcery.com \
--to=yao@codesourcery.com \
--cc=gdb-patches@sourceware.org \
--cc=joseph@codesourcery.com \
--cc=mark.kettenis@xs4all.nl \
--cc=tromey@redhat.com \
/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