import gdb-1999-06-28 snapshot
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / varargs.exp
CommitLineData
c906108c
SS
1# Copyright (C) 1997, 1998 Free Software Foundation, Inc.
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
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
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.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20# This file was written by Elena Zannoni (ezannoni@cygnus.com)
21
22
23# this file tests command line calls with functions having variable
24# args list
25# corresponding source file: varargs.c
26
27#print find_max1(5,1,2,3,4,5)
28#print find_max1(1,3)
29#call find_max1(10,1,2,3,4,5,6,7,8,29,0)
30#print find_max2(3,1,2,3)
31#print find_max_double(5,1.0,17.0,2.0,3.0,4.0)
32#quit
33
34
35if $tracelevel then {
36 strace $tracelevel
37}
38
39set prms_id 0
40set bug_id 0
41
42set prototypes 0
43set testfile "varargs"
44set srcfile ${testfile}.c
45set binfile ${objdir}/${subdir}/${testfile}
46
47if [get_compiler_info ${binfile}] {
48 return -1
49}
50
085dd6e6
JM
51if {$hp_cc_compiler} {
52 set additional_flags "additional_flags=-Ae"
c906108c
SS
53} else {
54 set additional_flags ""
55}
56
57# build the first test case
085dd6e6 58if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug ${additional_flags}}] != "" } {
c906108c
SS
59 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
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
72
73if ![runto_main] then {
74 perror "couldn't run to breakpoint"
75 continue
76}
77
085dd6e6
JM
78if { $hp_aCC_compiler } {
79 # When compiled w/ aCC we need to disable overload resolution
80 # for command line calls.
81 # We need it for vararg calls since the aCC compiler gives us no
82 # information about the undeclared arguments, or even that there
83 # _are_ undeclared arguments. As far as gdb is concerned it only
84 # knows about the declared arguments. So we need to force the call
85 # even though the overload resolution mechanism says that the types
86 # don't match.
87 # - guo
88 gdb_test "set overload-resolution 0" ""
89}
c906108c
SS
90
91send_gdb "print find_max1(5,1,2,3,4,5)\n"
92gdb_expect {
93 -re ".*find_max\\(5, 1, 2, 3, 4, 5\\) returns 5\[ \r\n\]+.\[0-9\]+ = 5.*$gdb_prompt $" {
94 pass "print find_max1(5,1,2,3,4,5)"
95 }
96 -re ".*$gdb_prompt $" { fail "print find_max1(5,1,2,3,4,5)" }
97 timeout { fail "(timeout) print find_max1(5,1,2,3,4,5)" }
98 }
99
100
101
102
103send_gdb "print find_max1(1,3)\n"
104gdb_expect {
105 -re ".*find_max\\(1, 3\\) returns 3\[ \r\n\]+.\[0-9\]+ = 3.*$gdb_prompt $" {
106 pass "print find_max1(1,3)"
107 }
108 -re ".*$gdb_prompt $" { fail "print find_max1(1,3)" }
109 timeout { fail "(timeout) print find_max1(1,3)" }
110 }
111
112
113send_gdb "print find_max1(10,1,2,3,4,5,6,7,8,29,0)\n"
114gdb_expect {
115 -re ".*find_max\\(10, 1, 2, 3, 4, 5, 6, 7, 8, 29, 0\\) returns 29\[ \r\n\]+.\[0-9\]+ = 29.*$gdb_prompt $" {
116 pass "print find_max1(10,1,2,3,4,5,6,7,8,29,0)"
117 }
118 -re ".*$gdb_prompt $" { fail "print find_max1(10,1,2,3,4,5,6,7,8,29,0)" }
119 timeout { fail "(timeout) print find_max1(10,1,2,3,4,5,6,7,8,29,0)" }
120 }
121
122
123
124send_gdb "print find_max2(3,1,2,3)\n"
125gdb_expect {
126 -re ".*find_max\\(3, 1, 2, 3\\) returns 3\[ \r\n\]+.\[0-9\]+ = 3.*$gdb_prompt $" {
127 pass "print find_max2(3,1,2,3)"
128 }
129 -re ".*$gdb_prompt $" { fail "print find_max2(3,1,2,3)" }
130 timeout { fail "(timeout) print find_max2(3,1,2,3)" }
131 }
132
133
9e086581
JM
134if {![target_info exists gdb,skip_float_tests]} {
135 send_gdb "print find_max_double(5,1.0,17.0,2.0,3.0,4.0)\n"
136 gdb_expect {
c906108c 137 -re ".*find_max\\(.*\\) returns 17\\.000000\[ \r\n\]+.\[0-9\]+ = 17.*$gdb_prompt $" {
9e086581
JM
138 pass "print find_max_double(5,1.0,17.0,2.0,3.0,4.0)"
139 }
c906108c
SS
140 -re ".*$gdb_prompt $" { fail "print find_max_double(5,1.0,17.0,2.0,3.0,4.0)" }
141 timeout { fail "(timeout) print find_max_double(5,1.0,17.0,2.0,3.0,4.0)" }
142 }
9e086581 143}
c906108c 144
This page took 0.032835 seconds and 4 git commands to generate.