Commit | Line | Data |
---|---|---|
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 | ||
32 | if $tracelevel then { | |
33 | strace $tracelevel | |
34 | } | |
35 | ||
c906108c SS |
36 | |
37 | set prototypes 0 | |
38 | set testfile "varargs" | |
39 | set srcfile ${testfile}.c | |
40 | set binfile ${objdir}/${subdir}/${testfile} | |
41 | ||
42 | if [get_compiler_info ${binfile}] { | |
43 | return -1 | |
44 | } | |
45 | ||
5ac01682 DJ |
46 | set additional_flags {debug} |
47 | ||
085dd6e6 | 48 | if {$hp_cc_compiler} { |
5ac01682 | 49 | lappend additional_flags "additional_flags=-Ae" |
c906108c SS |
50 | } |
51 | ||
52 | # build the first test case | |
5ac01682 DJ |
53 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ |
54 | executable ${additional_flags}] != "" } { | |
b60f0898 JB |
55 | untested varargs.exp |
56 | return -1 | |
c906108c SS |
57 | } |
58 | ||
59 | # Start with a fresh gdb. | |
60 | ||
61 | gdb_exit | |
62 | gdb_start | |
63 | gdb_reinitialize_dir $srcdir/$subdir | |
64 | gdb_load ${binfile} | |
02746bbc MS |
65 | gdb_test_no_output "set print sevenbit-strings" |
66 | gdb_test_no_output "set print address off" | |
67 | gdb_test_no_output "set width 0" | |
68 | ||
c906108c | 69 | |
13a5e3b8 MS |
70 | if [gdb_skip_stdio_test "varargs.exp"] { |
71 | # Nothing in this module is testable without printf. | |
72 | return; | |
73 | } | |
c906108c SS |
74 | |
75 | if ![runto_main] then { | |
76 | perror "couldn't run to breakpoint" | |
77 | continue | |
78 | } | |
79 | ||
085dd6e6 JM |
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 | |
27d3a1a2 | 90 | gdb_test_no_output "set overload-resolution 0" |
085dd6e6 | 91 | } |
c906108c | 92 | |
02746bbc MS |
93 | gdb_test "print find_max1(5,1,2,3,4,5)" \ |
94 | "find_max\\(5, 1, 2, 3, 4, 5\\) returns 5\[ \r\n\]+.\[0-9\]+ = 5" \ | |
95 | "print find_max1(5,1,2,3,4,5)" | |
c906108c | 96 | |
02746bbc MS |
97 | gdb_test "print find_max1(1,3)" \ |
98 | ".*find_max\\(1, 3\\) returns 3\[ \r\n\]+.\[0-9\]+ = 3" \ | |
99 | "print find_max1(1,3)" | |
c906108c | 100 | |
02746bbc MS |
101 | gdb_test "print find_max1(10,1,2,3,4,5,6,7,8,29,0)" \ |
102 | ".*find_max\\(10, 1, 2, 3, 4, 5, 6, 7, 8, 29, 0\\) returns 29\[ \r\n\]+.\[0-9\]+ = 29" \ | |
103 | "print find_max1(10,1,2,3,4,5,6,7,8,29,0)" | |
c906108c | 104 | |
02746bbc MS |
105 | gdb_test "print find_max2(3,1,2,3)" \ |
106 | ".*find_max\\(3, 1, 2, 3\\) returns 3\[ \r\n\]+.\[0-9\]+ = 3" \ | |
107 | "print find_max2(3,1,2,3)" | |
c906108c | 108 | |
9e086581 | 109 | if {![target_info exists gdb,skip_float_tests]} { |
02746bbc MS |
110 | gdb_test "print find_max_double(5,1.0,17.0,2.0,3.0,4.0)" \ |
111 | ".*find_max\\(.*\\) returns 17\\.000000\[ \r\n\]+.\[0-9\]+ = 17" \ | |
112 | "print find_max_double(5,1.0,17.0,2.0,3.0,4.0)" | |
9e086581 | 113 | } |
c906108c | 114 |