OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.base/] [call-strs.exp] - Blame information for rev 178

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.