]>
Commit | Line | Data |
---|---|---|
c906108c SS |
1 | # Copyright (C) 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 | # [email protected] | |
19 | ||
20 | # This file was written by Elena Zannoni ([email protected]) | |
21 | ||
22 | # This test deals with calling functions which have strings as parameters. | |
23 | # it plays around with constant strings. | |
24 | # the corresponding source file is call-strs.c | |
25 | # | |
26 | ||
27 | #debug strarg | |
28 | ||
29 | if $tracelevel then { | |
30 | strace $tracelevel | |
31 | } | |
32 | ||
33 | set prms_id 0 | |
34 | set bug_id 0 | |
35 | ||
36 | set testfile "call-strs" | |
37 | set srcfile ${testfile}.c | |
38 | set binfile ${objdir}/${subdir}/${testfile} | |
39 | ||
40 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { | |
41 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
42 | } | |
43 | ||
44 | ||
45 | ||
46 | # The a29k can't call functions, so don't even bother with this test. | |
47 | if [target_info exists gdb,cannot_call_functions] { | |
48 | setup_xfail "*-*-*" 2416 | |
49 | fail "This target can not call functions" | |
50 | continue | |
51 | } | |
52 | ||
53 | # Set the current language to C. This counts as a test. If it | |
54 | # fails, then we skip the other tests. | |
55 | ||
56 | proc set_lang_c {} { | |
57 | global gdb_prompt | |
58 | ||
59 | send_gdb "set language c\n" | |
60 | gdb_expect { | |
61 | -re ".*$gdb_prompt $" {} | |
62 | timeout { fail "set language c (timeout)" ; return 0; } | |
63 | } | |
64 | ||
65 | send_gdb "show language\n" | |
66 | gdb_expect { | |
67 | -re ".* source language is \"c\".*$gdb_prompt $" { | |
68 | pass "set language to \"c\"" | |
69 | return 1 | |
70 | } | |
71 | -re ".*$gdb_prompt $" { | |
72 | fail "setting language to \"c\"" | |
73 | return 0 | |
74 | } | |
75 | timeout { | |
76 | fail "can't show language (timeout)" | |
77 | return 0 | |
78 | } | |
79 | } | |
80 | } | |
81 | ||
82 | ||
83 | ||
84 | # Start with a fresh gdb. | |
85 | ||
86 | gdb_exit | |
87 | gdb_start | |
88 | gdb_reinitialize_dir $srcdir/$subdir | |
89 | gdb_load ${binfile} | |
90 | send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $" | |
91 | send_gdb "set print address off\n" ; gdb_expect -re "$gdb_prompt $" | |
92 | send_gdb "set width 0\n" ; gdb_expect -re "$gdb_prompt $" | |
93 | ||
94 | ||
95 | if ![runto_main] then { | |
96 | perror "couldn't run to breakpoint" | |
97 | continue | |
98 | } | |
99 | ||
100 | #step | |
101 | send_gdb "step\n" | |
102 | gdb_expect { | |
103 | -re ".*strcpy\\(buf, \"test string\"\\);.*$gdb_prompt $" {pass "step after assignment to s"} | |
104 | -re ".*$gdb_prompt $" { fail "step after assignment to s" } | |
105 | timeout { fail "step after assignment to s (timeout)" } | |
106 | } | |
107 | ||
108 | ||
109 | #step | |
7a292a7a | 110 | send_gdb "next\n" |
c906108c | 111 | gdb_expect { |
7a292a7a SS |
112 | -re ".*str_func\\(\"abcd\", \"efgh\", \"ijkl\", \"mnop\", \"qrst\", \"uvwx\", \"yz12\"\\);.*$gdb_prompt $" {pass "next over strcpy"} |
113 | -re ".*$gdb_prompt $" { fail "next over strcpy" } | |
114 | timeout { fail "next over strcpy (timeout)" } | |
c906108c SS |
115 | } |
116 | ||
117 | #print buf | |
118 | send_gdb "print buf\n" | |
119 | gdb_expect { | |
120 | -re ".*\"test string\",.*repeats 88 times.*$gdb_prompt $" { | |
121 | pass "print buf" | |
122 | } | |
123 | -re ".*$gdb_prompt $" { fail "print buf" } | |
124 | timeout { fail "(timeout) print buf" } | |
125 | } | |
126 | ||
127 | ||
128 | #print s | |
129 | send_gdb "print s\n" | |
130 | gdb_expect { | |
131 | -re ".*= \"test string\".*$gdb_prompt $" { | |
132 | pass "print s" | |
133 | } | |
134 | -re ".*$gdb_prompt $" { fail "print s" } | |
135 | timeout { fail "(timeout) print sum_array_print(10, *list1, *list2, *list3, *list4)" } | |
136 | } | |
137 | ||
138 | ||
139 | #print str_func1(s) | |
140 | send_gdb "print str_func1(s)\n" | |
141 | gdb_expect { | |
142 | -re "first string arg is: test string.*\"test string\".*$gdb_prompt $" { | |
143 | pass "print str_func1(s)" | |
144 | } | |
145 | -re ".*$gdb_prompt $" { fail "print str_func1(s)" } | |
146 | timeout { fail "(timeout) print str_func1(s)" } | |
147 | } | |
148 | ||
149 | ||
150 | #print str_func1("test string") | |
151 | send_gdb "print str_func1(\"test string\")\n" | |
152 | gdb_expect { | |
153 | -re "first string arg is: test string.*\"test string\".*$gdb_prompt $" { | |
154 | pass "print str_func1(\"test string\")" | |
155 | } | |
156 | -re ".*$gdb_prompt $" { fail "print str_func1(\"test string\")" } | |
157 | timeout { fail "(timeout) print str_func1(\"test string\")" } | |
158 | } | |
159 | ||
160 | #call str_func1(s) | |
161 | send_gdb "call str_func1(s)\n" | |
162 | gdb_expect { | |
163 | -re "first string arg is: test string.*\"test string\".*$gdb_prompt $" { | |
164 | pass "call str_func1(s)" | |
165 | } | |
166 | -re ".*$gdb_prompt $" { fail "call str_func1(s)" } | |
167 | timeout { fail "(timeout) call str_func1(s)" } | |
168 | } | |
169 | ||
170 | #call str_func1("test string") | |
171 | send_gdb "call str_func1(\"test string\")\n" | |
172 | gdb_expect { | |
173 | -re "first string arg is: test string.*\"test string\".*$gdb_prompt $" { | |
174 | pass "call str_func1(\"test string\")" | |
175 | } | |
176 | -re ".*$gdb_prompt $" { fail "call str_func1(\"test string\")" } | |
177 | timeout { fail "(timeout) call str_func1(\"test string\")" } | |
178 | } | |
179 | ||
180 | #print str_func1(buf) | |
181 | send_gdb "print str_func1(buf)\n" | |
182 | gdb_expect { | |
183 | -re "first string arg is: test string.*\"test string\".*$gdb_prompt $" { | |
184 | pass "print str_func1(buf)" | |
185 | } | |
186 | -re ".*$gdb_prompt $" { fail "print str_func1(buf)" } | |
187 | timeout { fail "(timeout) print str_func1(buf)" } | |
188 | } | |
189 | ||
190 | #call str_func1(buf) | |
191 | send_gdb "call str_func1(buf)\n" | |
192 | gdb_expect { | |
193 | -re "first string arg is: test string.*\"test string\".*$gdb_prompt $" { | |
194 | pass "call str_func1(buf)" | |
195 | } | |
196 | -re ".*$gdb_prompt $" { fail "call str_func1(buf)" } | |
197 | timeout { fail "(timeout) call str_func1(buf)" } | |
198 | } | |
199 | ||
200 | #print str_func("a","b","c","d","e","f","g") | |
201 | send_gdb "print str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")\n" | |
202 | gdb_expect { | |
203 | -re "first string arg is: a\[ \t\r\n\]+second string arg is: b\[ \t\r\n\]+third string arg is: c\[ \t\r\n\]+fourth string arg is: d\[ \t\r\n\]+fifth string arg is: e\[ \t\r\n\]+sixth string arg is: f\[ \t\r\n\]+seventh string arg is: g\[ \t\r\n\]+.*= \"abcdefg\".*$gdb_prompt $" { | |
204 | pass "print str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")" | |
205 | } | |
206 | -re ".*$gdb_prompt $" { fail "print str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")" } | |
207 | timeout { fail "(timeout) print str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")" } | |
208 | } | |
209 | ||
210 | #call str_func("a","b","c","d","e","f","g") | |
211 | send_gdb "call str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")\n" | |
212 | gdb_expect { | |
213 | -re "first string arg is: a\[ \t\r\n\]+second string arg is: b\[ \t\r\n\]+third string arg is: c\[ \t\r\n\]+fourth string arg is: d\[ \t\r\n\]+fifth string arg is: e\[ \t\r\n\]+sixth string arg is: f\[ \t\r\n\]+seventh string arg is: g\[ \t\r\n\]+.*= \"abcdefg\".*$gdb_prompt $" { | |
214 | pass "call str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")" | |
215 | } | |
216 | -re ".*$gdb_prompt $" { fail "call str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")" } | |
217 | timeout { fail "(timeout) call str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")" } | |
218 | } | |
219 | ||
085dd6e6 JM |
220 | #print str_func(s,s,s,s,s,s,s) |
221 | send_gdb "print str_func(s,s,s,s,s,s,s)\n" | |
c906108c SS |
222 | gdb_expect { |
223 | -re "first string arg is: test string\[ \t\r\n\]+second string arg is: test string\[ \t\r\n\]+third string arg is: test string\[ \t\r\n\]+fourth string arg is: test string\[ \t\r\n\]+fifth string arg is: test string\[ \t\r\n\]+sixth string arg is: test string\[ \t\r\n\]+seventh string arg is: test string\[ \t\r\n\]+.*\"test stringtest stringtest stringtest stringtest stringtest stringtest string\".*$gdb_prompt $" { | |
085dd6e6 | 224 | pass "print str_func(s,s,s,s,s,s,s)" |
c906108c | 225 | } |
085dd6e6 JM |
226 | -re ".*$gdb_prompt $" { fail "print str_func(s,s,s,s,s,s,s)" } |
227 | timeout { fail "(timeout) print str_func(s,s,s,s,s,s,s)" } | |
c906108c SS |
228 | } |
229 | ||
085dd6e6 JM |
230 | #call str_func(s,s,s,s,s,s,s) |
231 | send_gdb "call str_func(s,s,s,s,s,s,s)\n" | |
c906108c SS |
232 | gdb_expect { |
233 | -re "first string arg is: test string\[ \t\r\n\]+second string arg is: test string\[ \t\r\n\]+third string arg is: test string\[ \t\r\n\]+fourth string arg is: test string\[ \t\r\n\]+fifth string arg is: test string\[ \t\r\n\]+sixth string arg is: test string\[ \t\r\n\]+seventh string arg is: test string\[ \t\r\n\]+.*\"test stringtest stringtest stringtest stringtest stringtest stringtest string\".*$gdb_prompt $" { | |
085dd6e6 | 234 | pass "call str_func(s,s,s,s,s,s,s)" |
c906108c | 235 | } |
085dd6e6 JM |
236 | -re ".*$gdb_prompt $" { fail "call str_func(s,s,s,s,s,s,s)" } |
237 | timeout { fail "(timeout) call str_func(s,s,s,s,s,s,s)" } | |
c906108c SS |
238 | } |
239 | ||
240 | gdb_exit | |
241 | return 0 |