2011-05-30 Yao Qi <yao@codesourcery.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / varargs.exp
1 # Copyright 1997, 1998, 1999, 2000, 2007, 2008, 2009, 2010, 2011
2 # Free Software Foundation, Inc.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17 # This file was written by Elena Zannoni (ezannoni@cygnus.com)
18
19
20 # this file tests command line calls with functions having variable
21 # args list
22 # corresponding source file: varargs.c
23
24 #print find_max1(5,1,2,3,4,5)
25 #print find_max1(1,3)
26 #call find_max1(10,1,2,3,4,5,6,7,8,29,0)
27 #print find_max2(3,1,2,3)
28 #print find_max_double(5,1.0,17.0,2.0,3.0,4.0)
29 #quit
30
31
32 if $tracelevel then {
33 strace $tracelevel
34 }
35
36
37 set prototypes 0
38 set testfile "varargs"
39 set srcfile ${testfile}.c
40 set binfile ${objdir}/${subdir}/${testfile}
41
42 if [get_compiler_info ${binfile}] {
43 return -1
44 }
45
46 set additional_flags {debug}
47 if [support_complex_tests] {
48 lappend additional_flags "additional_flags=-DTEST_COMPLEX"
49 }
50
51 if {$hp_cc_compiler} {
52 lappend additional_flags "additional_flags=-Ae"
53 }
54
55 # build the first test case
56 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
57 executable ${additional_flags}] != "" } {
58 untested varargs.exp
59 return -1
60 }
61
62 # Start with a fresh gdb.
63
64 gdb_exit
65 gdb_start
66 gdb_reinitialize_dir $srcdir/$subdir
67 gdb_load ${binfile}
68 gdb_test_no_output "set print sevenbit-strings"
69 gdb_test_no_output "set print address off"
70 gdb_test_no_output "set width 0"
71
72
73 if [gdb_skip_stdio_test "varargs.exp"] {
74 # Nothing in this module is testable without printf.
75 return;
76 }
77
78 if ![runto_main] then {
79 perror "couldn't run to breakpoint"
80 continue
81 }
82
83 if { $hp_aCC_compiler } {
84 # When compiled w/ aCC we need to disable overload resolution
85 # for command line calls.
86 # We need it for vararg calls since the aCC compiler gives us no
87 # information about the undeclared arguments, or even that there
88 # _are_ undeclared arguments. As far as gdb is concerned it only
89 # knows about the declared arguments. So we need to force the call
90 # even though the overload resolution mechanism says that the types
91 # don't match.
92 # - guo
93 gdb_test_no_output "set overload-resolution 0"
94 }
95
96 gdb_test "print find_max1(5,1,2,3,4,5)" \
97 "find_max\\(5, 1, 2, 3, 4, 5\\) returns 5\[ \r\n\]+.\[0-9\]+ = 5" \
98 "print find_max1(5,1,2,3,4,5)"
99
100 gdb_test "print find_max1(1,3)" \
101 ".*find_max\\(1, 3\\) returns 3\[ \r\n\]+.\[0-9\]+ = 3" \
102 "print find_max1(1,3)"
103
104 gdb_test "print find_max1(10,1,2,3,4,5,6,7,8,29,0)" \
105 ".*find_max\\(10, 1, 2, 3, 4, 5, 6, 7, 8, 29, 0\\) returns 29\[ \r\n\]+.\[0-9\]+ = 29" \
106 "print find_max1(10,1,2,3,4,5,6,7,8,29,0)"
107
108 gdb_test "print find_max2(3,1,2,3)" \
109 ".*find_max\\(3, 1, 2, 3\\) returns 3\[ \r\n\]+.\[0-9\]+ = 3" \
110 "print find_max2(3,1,2,3)"
111
112 if {![target_info exists gdb,skip_float_tests]} {
113 gdb_test "print find_max_double(5,1.0,17.0,2.0,3.0,4.0)" \
114 ".*find_max\\(.*\\) returns 17\\.000000\[ \r\n\]+.\[0-9\]+ = 17" \
115 "print find_max_double(5,1.0,17.0,2.0,3.0,4.0)"
116 }
117
118
119 # Test _Complex type here if supported.
120 if [support_complex_tests] {
121 global gdb_prompt
122
123 set test "print find_max_float_real(4, fc1, fc2, fc3, fc4)"
124 setup_kfail_for_target gdb/12790 "x86_64-*-*"
125 setup_kfail_for_target gdb/12791 "arm*-*-*"
126 gdb_test $test ".*= 4 \\+ 4 \\* I" $test
127
128 set test "print find_max_double_real(4, dc1, dc2, dc3, dc4)"
129 setup_kfail_for_target gdb/12776 "i?86-*-*"
130 setup_kfail_for_target gdb/12790 "x86_64-*-*"
131 setup_kfail_for_target gdb/12791 "arm*-*-*"
132 gdb_test $test ".*= 4 \\+ 4 \\* I" $test
133
134 set test "print find_max_long_double_real(4, ldc1, ldc2, ldc3, ldc4)"
135 setup_kfail_for_target gdb/12776 "i?86-*-*"
136 setup_kfail_for_target gdb/12790 "x86_64-*-*"
137 setup_kfail_for_target gdb/12791 "arm*-*-*"
138 gdb_test $test ".*= 4 \\+ 4 \\* I" $test
139
140 }
This page took 0.032899 seconds and 5 git commands to generate.