From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28649 invoked by alias); 20 May 2011 08:10:22 -0000 Received: (qmail 28635 invoked by uid 22791); 20 May 2011 08:10:19 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL,BAYES_00,SARE_OBFU_PART_CIA,SARE_RMML_Stock9,TW_LC,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 20 May 2011 08:10:02 +0000 Received: (qmail 6440 invoked from network); 20 May 2011 08:09:59 -0000 Received: from unknown (HELO ?192.168.0.102?) (yao@127.0.0.2) by mail.codesourcery.com with ESMTPA; 20 May 2011 08:09:59 -0000 Message-ID: <4DD621CE.2050509@codesourcery.com> Date: Fri, 20 May 2011 08:10:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8 MIME-Version: 1.0 To: Tom Tromey CC: "Joseph S. Myers" , Mark Kettenis , gdb-patches@sourceware.org Subject: Re: [_Complex test 1/4] support_complex_tests in gdb.exp and pass _Complex args to func References: <4DC401D0.1050500@codesourcery.com> <4DC75036.4040806@codesourcery.com> <4DD49BE7.80206@codesourcery.com> <201105190814.p4J8EMYF020774@glazunov.sibelius.xs4all.nl> <4DD51A55.9000209@codesourcery.com> In-Reply-To: Content-Type: multipart/mixed; boundary="------------080709060902070507000206" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-05/txt/msg00471.txt.bz2 This is a multi-part message in MIME format. --------------080709060902070507000206 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-length: 1587 On 05/20/2011 01:09 AM, Tom Tromey wrote: >>>>>> "Yao" == Yao Qi 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 (齐尧) --------------080709060902070507000206 Content-Type: text/x-patch; name="0001-funcargs.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-funcargs.patch" Content-length: 10458 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 --------------080709060902070507000206--