]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/varargs.exp
Fix for PR gdb/1543.
[thirdparty/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 # This file was written by Elena Zannoni (ezannoni@cygnus.com)
17
18
19 # this file tests command line calls with functions having variable
20 # args list
21 # corresponding source file: varargs.c
22
23 #print find_max1(5,1,2,3,4,5)
24 #print find_max1(1,3)
25 #call find_max1(10,1,2,3,4,5,6,7,8,29,0)
26 #print find_max2(3,1,2,3)
27 #print find_max_double(5,1.0,17.0,2.0,3.0,4.0)
28 #quit
29
30
31 if $tracelevel then {
32 strace $tracelevel
33 }
34
35 set prms_id 0
36 set bug_id 0
37
38 set prototypes 0
39 set testfile "varargs"
40 set srcfile ${testfile}.c
41 set binfile ${objdir}/${subdir}/${testfile}
42
43 if [get_compiler_info ${binfile}] {
44 return -1
45 }
46
47 set additional_flags {debug}
48
49 if {$hp_cc_compiler} {
50 lappend additional_flags "additional_flags=-Ae"
51 }
52
53 # build the first test case
54 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
55 executable ${additional_flags}] != "" } {
56 untested varargs.exp
57 return -1
58 }
59
60 # Start with a fresh gdb.
61
62 gdb_exit
63 gdb_start
64 gdb_reinitialize_dir $srcdir/$subdir
65 gdb_load ${binfile}
66 send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $"
67 send_gdb "set print address off\n" ; gdb_expect -re "$gdb_prompt $"
68 send_gdb "set width 0\n" ; gdb_expect -re "$gdb_prompt $"
69
70 if [gdb_skip_stdio_test "varargs.exp"] {
71 # Nothing in this module is testable without printf.
72 return;
73 }
74
75 if ![runto_main] then {
76 perror "couldn't run to breakpoint"
77 continue
78 }
79
80 if { $hp_aCC_compiler } {
81 # When compiled w/ aCC we need to disable overload resolution
82 # for command line calls.
83 # We need it for vararg calls since the aCC compiler gives us no
84 # information about the undeclared arguments, or even that there
85 # _are_ undeclared arguments. As far as gdb is concerned it only
86 # knows about the declared arguments. So we need to force the call
87 # even though the overload resolution mechanism says that the types
88 # don't match.
89 # - guo
90 gdb_test "set overload-resolution 0" ""
91 }
92
93 send_gdb "print find_max1(5,1,2,3,4,5)\n"
94 gdb_expect {
95 -re ".*find_max\\(5, 1, 2, 3, 4, 5\\) returns 5\[ \r\n\]+.\[0-9\]+ = 5.*$gdb_prompt $" {
96 pass "print find_max1(5,1,2,3,4,5)"
97 }
98 -re ".*$gdb_prompt $" { fail "print find_max1(5,1,2,3,4,5)" }
99 timeout { fail "(timeout) print find_max1(5,1,2,3,4,5)" }
100 }
101
102
103
104
105 send_gdb "print find_max1(1,3)\n"
106 gdb_expect {
107 -re ".*find_max\\(1, 3\\) returns 3\[ \r\n\]+.\[0-9\]+ = 3.*$gdb_prompt $" {
108 pass "print find_max1(1,3)"
109 }
110 -re ".*$gdb_prompt $" { fail "print find_max1(1,3)" }
111 timeout { fail "(timeout) print find_max1(1,3)" }
112 }
113
114
115 send_gdb "print find_max1(10,1,2,3,4,5,6,7,8,29,0)\n"
116 gdb_expect {
117 -re ".*find_max\\(10, 1, 2, 3, 4, 5, 6, 7, 8, 29, 0\\) returns 29\[ \r\n\]+.\[0-9\]+ = 29.*$gdb_prompt $" {
118 pass "print find_max1(10,1,2,3,4,5,6,7,8,29,0)"
119 }
120 -re ".*$gdb_prompt $" { fail "print find_max1(10,1,2,3,4,5,6,7,8,29,0)" }
121 timeout { fail "(timeout) print find_max1(10,1,2,3,4,5,6,7,8,29,0)" }
122 }
123
124
125
126 send_gdb "print find_max2(3,1,2,3)\n"
127 gdb_expect {
128 -re ".*find_max\\(3, 1, 2, 3\\) returns 3\[ \r\n\]+.\[0-9\]+ = 3.*$gdb_prompt $" {
129 pass "print find_max2(3,1,2,3)"
130 }
131 -re ".*$gdb_prompt $" { fail "print find_max2(3,1,2,3)" }
132 timeout { fail "(timeout) print find_max2(3,1,2,3)" }
133 }
134
135
136 if {![target_info exists gdb,skip_float_tests]} {
137 send_gdb "print find_max_double(5,1.0,17.0,2.0,3.0,4.0)\n"
138 gdb_expect {
139 -re ".*find_max\\(.*\\) returns 17\\.000000\[ \r\n\]+.\[0-9\]+ = 17.*$gdb_prompt $" {
140 pass "print find_max_double(5,1.0,17.0,2.0,3.0,4.0)"
141 }
142 -re ".*$gdb_prompt $" { fail "print find_max_double(5,1.0,17.0,2.0,3.0,4.0)" }
143 timeout { fail "(timeout) print find_max_double(5,1.0,17.0,2.0,3.0,4.0)" }
144 }
145 }
146