* gdb.base/completion.exp: Handle lack of other symbols beginning
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / varargs.exp
1 # Copyright 1997, 1998, 1999, 2000, 2007, 2008 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 3 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, see <http://www.gnu.org/licenses/>. */
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
34 if $tracelevel then {
35 strace $tracelevel
36 }
37
38 set prms_id 0
39 set bug_id 0
40
41 set prototypes 0
42 set testfile "varargs"
43 set srcfile ${testfile}.c
44 set binfile ${objdir}/${subdir}/${testfile}
45
46 if [get_compiler_info ${binfile}] {
47 return -1
48 }
49
50 set additional_flags {debug}
51
52 if {$hp_cc_compiler} {
53 lappend additional_flags "additional_flags=-Ae"
54 }
55
56 # build the first test case
57 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
58 executable ${additional_flags}] != "" } {
59 untested varargs.exp
60 return -1
61 }
62
63 # Start with a fresh gdb.
64
65 gdb_exit
66 gdb_start
67 gdb_reinitialize_dir $srcdir/$subdir
68 gdb_load ${binfile}
69 send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $"
70 send_gdb "set print address off\n" ; gdb_expect -re "$gdb_prompt $"
71 send_gdb "set width 0\n" ; gdb_expect -re "$gdb_prompt $"
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 "set overload-resolution 0" ""
94 }
95
96 send_gdb "print find_max1(5,1,2,3,4,5)\n"
97 gdb_expect {
98 -re ".*find_max\\(5, 1, 2, 3, 4, 5\\) returns 5\[ \r\n\]+.\[0-9\]+ = 5.*$gdb_prompt $" {
99 pass "print find_max1(5,1,2,3,4,5)"
100 }
101 -re ".*$gdb_prompt $" { fail "print find_max1(5,1,2,3,4,5)" }
102 timeout { fail "(timeout) print find_max1(5,1,2,3,4,5)" }
103 }
104
105
106
107
108 send_gdb "print find_max1(1,3)\n"
109 gdb_expect {
110 -re ".*find_max\\(1, 3\\) returns 3\[ \r\n\]+.\[0-9\]+ = 3.*$gdb_prompt $" {
111 pass "print find_max1(1,3)"
112 }
113 -re ".*$gdb_prompt $" { fail "print find_max1(1,3)" }
114 timeout { fail "(timeout) print find_max1(1,3)" }
115 }
116
117
118 send_gdb "print find_max1(10,1,2,3,4,5,6,7,8,29,0)\n"
119 gdb_expect {
120 -re ".*find_max\\(10, 1, 2, 3, 4, 5, 6, 7, 8, 29, 0\\) returns 29\[ \r\n\]+.\[0-9\]+ = 29.*$gdb_prompt $" {
121 pass "print find_max1(10,1,2,3,4,5,6,7,8,29,0)"
122 }
123 -re ".*$gdb_prompt $" { fail "print find_max1(10,1,2,3,4,5,6,7,8,29,0)" }
124 timeout { fail "(timeout) print find_max1(10,1,2,3,4,5,6,7,8,29,0)" }
125 }
126
127
128
129 send_gdb "print find_max2(3,1,2,3)\n"
130 gdb_expect {
131 -re ".*find_max\\(3, 1, 2, 3\\) returns 3\[ \r\n\]+.\[0-9\]+ = 3.*$gdb_prompt $" {
132 pass "print find_max2(3,1,2,3)"
133 }
134 -re ".*$gdb_prompt $" { fail "print find_max2(3,1,2,3)" }
135 timeout { fail "(timeout) print find_max2(3,1,2,3)" }
136 }
137
138
139 if {![target_info exists gdb,skip_float_tests]} {
140 send_gdb "print find_max_double(5,1.0,17.0,2.0,3.0,4.0)\n"
141 gdb_expect {
142 -re ".*find_max\\(.*\\) returns 17\\.000000\[ \r\n\]+.\[0-9\]+ = 17.*$gdb_prompt $" {
143 pass "print find_max_double(5,1.0,17.0,2.0,3.0,4.0)"
144 }
145 -re ".*$gdb_prompt $" { fail "print find_max_double(5,1.0,17.0,2.0,3.0,4.0)" }
146 timeout { fail "(timeout) print find_max_double(5,1.0,17.0,2.0,3.0,4.0)" }
147 }
148 }
149
This page took 0.041322 seconds and 5 git commands to generate.