From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32188 invoked by alias); 20 May 2011 08:17:44 -0000 Received: (qmail 32169 invoked by uid 22791); 20 May 2011 08:17:41 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL,BAYES_00,SARE_OBFU_PART_CIA,TW_CP,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:17:26 +0000 Received: (qmail 8840 invoked from network); 20 May 2011 08:17:24 -0000 Received: from unknown (HELO ?192.168.0.102?) (yao@127.0.0.2) by mail.codesourcery.com with ESMTPA; 20 May 2011 08:17:24 -0000 Message-ID: <4DD6238D.40501@codesourcery.com> Date: Fri, 20 May 2011 08:17: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: gdb-patches@sourceware.org Subject: Re: [_Complex test 4/4] _Complex tests in callfuncs.exp References: <4DC401D0.1050500@codesourcery.com> <4DC75036.4040806@codesourcery.com> <4DD4A5DC.9060004@codesourcery.com> In-Reply-To: <4DD4A5DC.9060004@codesourcery.com> Content-Type: multipart/mixed; boundary="------------070705050403090908090709" 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/msg00473.txt.bz2 This is a multi-part message in MIME format. --------------070705050403090908090709 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-length: 223 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 (齐尧) --------------070705050403090908090709 Content-Type: text/x-patch; name="0004-pass-args-of-type-complex-to-func.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0004-pass-args-of-type-complex-to-func.patch" Content-length: 10666 >From 1c0d4f9c00ccdcd94d797ef8767ebce6e508a556 Mon Sep 17 00:00:00 2001 From: Yao Qi 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 --------------070705050403090908090709--