Commit | Line | Data |
---|---|---|
0fb0cc75 JB |
1 | # Copyright 1997, 1998, 1999, 2000, 2007, 2008, 2009 |
2 | # Free Software Foundation, Inc. | |
c906108c SS |
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 | |
e22f8b7c | 6 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 7 | # (at your option) any later version. |
e22f8b7c | 8 | # |
c906108c SS |
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. | |
e22f8b7c | 13 | # |
c906108c | 14 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
c906108c | 16 | |
c906108c SS |
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 | set prms_id 0 | |
37 | set bug_id 0 | |
38 | ||
39 | set prototypes 0 | |
40 | set testfile "varargs" | |
41 | set srcfile ${testfile}.c | |
42 | set binfile ${objdir}/${subdir}/${testfile} | |
43 | ||
44 | if [get_compiler_info ${binfile}] { | |
45 | return -1 | |
46 | } | |
47 | ||
5ac01682 DJ |
48 | set additional_flags {debug} |
49 | ||
085dd6e6 | 50 | if {$hp_cc_compiler} { |
5ac01682 | 51 | lappend additional_flags "additional_flags=-Ae" |
c906108c SS |
52 | } |
53 | ||
54 | # build the first test case | |
5ac01682 DJ |
55 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ |
56 | executable ${additional_flags}] != "" } { | |
b60f0898 JB |
57 | untested varargs.exp |
58 | return -1 | |
c906108c SS |
59 | } |
60 | ||
61 | # Start with a fresh gdb. | |
62 | ||
63 | gdb_exit | |
64 | gdb_start | |
65 | gdb_reinitialize_dir $srcdir/$subdir | |
66 | gdb_load ${binfile} | |
67 | send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $" | |
68 | send_gdb "set print address off\n" ; gdb_expect -re "$gdb_prompt $" | |
69 | send_gdb "set width 0\n" ; gdb_expect -re "$gdb_prompt $" | |
70 | ||
13a5e3b8 MS |
71 | if [gdb_skip_stdio_test "varargs.exp"] { |
72 | # Nothing in this module is testable without printf. | |
73 | return; | |
74 | } | |
c906108c SS |
75 | |
76 | if ![runto_main] then { | |
77 | perror "couldn't run to breakpoint" | |
78 | continue | |
79 | } | |
80 | ||
085dd6e6 JM |
81 | if { $hp_aCC_compiler } { |
82 | # When compiled w/ aCC we need to disable overload resolution | |
83 | # for command line calls. | |
84 | # We need it for vararg calls since the aCC compiler gives us no | |
85 | # information about the undeclared arguments, or even that there | |
86 | # _are_ undeclared arguments. As far as gdb is concerned it only | |
87 | # knows about the declared arguments. So we need to force the call | |
88 | # even though the overload resolution mechanism says that the types | |
89 | # don't match. | |
90 | # - guo | |
91 | gdb_test "set overload-resolution 0" "" | |
92 | } | |
c906108c SS |
93 | |
94 | send_gdb "print find_max1(5,1,2,3,4,5)\n" | |
95 | gdb_expect { | |
96 | -re ".*find_max\\(5, 1, 2, 3, 4, 5\\) returns 5\[ \r\n\]+.\[0-9\]+ = 5.*$gdb_prompt $" { | |
97 | pass "print find_max1(5,1,2,3,4,5)" | |
98 | } | |
99 | -re ".*$gdb_prompt $" { fail "print find_max1(5,1,2,3,4,5)" } | |
100 | timeout { fail "(timeout) print find_max1(5,1,2,3,4,5)" } | |
101 | } | |
102 | ||
103 | ||
104 | ||
105 | ||
106 | send_gdb "print find_max1(1,3)\n" | |
107 | gdb_expect { | |
108 | -re ".*find_max\\(1, 3\\) returns 3\[ \r\n\]+.\[0-9\]+ = 3.*$gdb_prompt $" { | |
109 | pass "print find_max1(1,3)" | |
110 | } | |
111 | -re ".*$gdb_prompt $" { fail "print find_max1(1,3)" } | |
112 | timeout { fail "(timeout) print find_max1(1,3)" } | |
113 | } | |
114 | ||
115 | ||
116 | send_gdb "print find_max1(10,1,2,3,4,5,6,7,8,29,0)\n" | |
117 | gdb_expect { | |
118 | -re ".*find_max\\(10, 1, 2, 3, 4, 5, 6, 7, 8, 29, 0\\) returns 29\[ \r\n\]+.\[0-9\]+ = 29.*$gdb_prompt $" { | |
119 | pass "print find_max1(10,1,2,3,4,5,6,7,8,29,0)" | |
120 | } | |
121 | -re ".*$gdb_prompt $" { fail "print find_max1(10,1,2,3,4,5,6,7,8,29,0)" } | |
122 | timeout { fail "(timeout) print find_max1(10,1,2,3,4,5,6,7,8,29,0)" } | |
123 | } | |
124 | ||
125 | ||
126 | ||
127 | send_gdb "print find_max2(3,1,2,3)\n" | |
128 | gdb_expect { | |
129 | -re ".*find_max\\(3, 1, 2, 3\\) returns 3\[ \r\n\]+.\[0-9\]+ = 3.*$gdb_prompt $" { | |
130 | pass "print find_max2(3,1,2,3)" | |
131 | } | |
132 | -re ".*$gdb_prompt $" { fail "print find_max2(3,1,2,3)" } | |
133 | timeout { fail "(timeout) print find_max2(3,1,2,3)" } | |
134 | } | |
135 | ||
136 | ||
9e086581 JM |
137 | if {![target_info exists gdb,skip_float_tests]} { |
138 | send_gdb "print find_max_double(5,1.0,17.0,2.0,3.0,4.0)\n" | |
139 | gdb_expect { | |
c906108c | 140 | -re ".*find_max\\(.*\\) returns 17\\.000000\[ \r\n\]+.\[0-9\]+ = 17.*$gdb_prompt $" { |
9e086581 JM |
141 | pass "print find_max_double(5,1.0,17.0,2.0,3.0,4.0)" |
142 | } | |
c906108c SS |
143 | -re ".*$gdb_prompt $" { fail "print find_max_double(5,1.0,17.0,2.0,3.0,4.0)" } |
144 | timeout { fail "(timeout) print find_max_double(5,1.0,17.0,2.0,3.0,4.0)" } | |
145 | } | |
9e086581 | 146 | } |
c906108c | 147 |