* gdb.base/call-signal-resume.exp, gdb.base/unwindonsignal.exp: Skip
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / varargs.exp
CommitLineData
4c38e0a4 1# Copyright 1997, 1998, 1999, 2000, 2007, 2008, 2009, 2010
0fb0cc75 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
32if $tracelevel then {
33 strace $tracelevel
34}
35
36set prms_id 0
37set bug_id 0
38
39set prototypes 0
40set testfile "varargs"
41set srcfile ${testfile}.c
42set binfile ${objdir}/${subdir}/${testfile}
43
44if [get_compiler_info ${binfile}] {
45 return -1
46}
47
5ac01682
DJ
48set additional_flags {debug}
49
085dd6e6 50if {$hp_cc_compiler} {
5ac01682 51 lappend additional_flags "additional_flags=-Ae"
c906108c
SS
52}
53
54# build the first test case
5ac01682
DJ
55if { [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
63gdb_exit
64gdb_start
65gdb_reinitialize_dir $srcdir/$subdir
66gdb_load ${binfile}
67send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $"
68send_gdb "set print address off\n" ; gdb_expect -re "$gdb_prompt $"
69send_gdb "set width 0\n" ; gdb_expect -re "$gdb_prompt $"
70
13a5e3b8
MS
71if [gdb_skip_stdio_test "varargs.exp"] {
72 # Nothing in this module is testable without printf.
73 return;
74}
c906108c
SS
75
76if ![runto_main] then {
77 perror "couldn't run to breakpoint"
78 continue
79}
80
085dd6e6
JM
81if { $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
94send_gdb "print find_max1(5,1,2,3,4,5)\n"
95gdb_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
106send_gdb "print find_max1(1,3)\n"
107gdb_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
116send_gdb "print find_max1(10,1,2,3,4,5,6,7,8,29,0)\n"
117gdb_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
127send_gdb "print find_max2(3,1,2,3)\n"
128gdb_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
137if {![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
This page took 1.051404 seconds and 4 git commands to generate.