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