gdb:
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / call-strs.exp
CommitLineData
4c38e0a4
JB
1# Copyright 1998, 1999, 2000, 2007, 2008, 2009, 2010
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# This test deals with calling functions which have strings as parameters.
20# it plays around with constant strings.
21# the corresponding source file is call-strs.c
22#
23
24#debug strarg
25
26if $tracelevel then {
27 strace $tracelevel
28}
29
c906108c
SS
30
31set testfile "call-strs"
32set srcfile ${testfile}.c
33set binfile ${objdir}/${subdir}/${testfile}
34
1960c400
MS
35# Test depends on printf, which the sparclet stub doesn't support.
36if { [istarget "sparclet-*-*"] } {
37 return 0;
38}
39
c906108c 40if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
b60f0898
JB
41 untested call-strs.exp
42 return -1
c906108c
SS
43}
44
45
46
9fbfe2dc
AC
47# Some targets can't call functions, so don't even bother with this
48# test.
c906108c
SS
49if [target_info exists gdb,cannot_call_functions] {
50 setup_xfail "*-*-*" 2416
51 fail "This target can not call functions"
52 continue
53}
54
c906108c
SS
55
56# Start with a fresh gdb.
57
58gdb_exit
59gdb_start
60gdb_reinitialize_dir $srcdir/$subdir
61gdb_load ${binfile}
ad3986f0
MS
62gdb_test_no_output "set print sevenbit-strings"
63gdb_test_no_output "set print address off"
64gdb_test_no_output "set width 0"
c906108c 65
c906108c
SS
66if ![runto_main] then {
67 perror "couldn't run to breakpoint"
68 continue
69}
70
97f2ed50
DJ
71set prev_timeout $timeout
72set timeout 120
73
c906108c 74#step
ad3986f0
MS
75gdb_test "step" \
76 "strcpy\\(buf, \"test string\"\\);" \
77 "step after assignment to s"
c906108c 78
37f8da45 79#next
ad3986f0
MS
80gdb_test "next" \
81 "str_func\\(\"abcd\", \"efgh\", \"ijkl\", \"mnop\", \"qrst\", \"uvwx\", \"yz12\"\\);" \
82 "next over strcpy"
c906108c
SS
83
84#print buf
ad3986f0
MS
85gdb_test "print buf" \
86 "\"test string\",.*repeats 88 times.*"
c906108c
SS
87
88#print s
ad3986f0
MS
89gdb_test "print s" \
90 " = \"test string\".*"
c906108c
SS
91
92#print str_func1(s)
13a5e3b8 93if ![gdb_skip_stdio_test "print str_func1(s)"] {
ad3986f0
MS
94 gdb_test "print str_func1(s)" \
95 "first string arg is: test string.*\"test string\".*"
13a5e3b8 96}
c906108c 97
c906108c 98#print str_func1("test string")
13a5e3b8 99if ![gdb_skip_stdio_test "print str_func1(teststring)"] {
ad3986f0
MS
100 gdb_test "print str_func1(\"test string\")" \
101 "first string arg is: test string.*\"test string\".*"
13a5e3b8 102}
c906108c
SS
103
104#call str_func1(s)
13a5e3b8 105if ![gdb_skip_stdio_test "call str_func1(s)"] {
ad3986f0
MS
106 gdb_test "call str_func1(s)" \
107 "first string arg is: test string.*\"test string\".*"
13a5e3b8 108}
c906108c
SS
109
110#call str_func1("test string")
13a5e3b8 111if ![gdb_skip_stdio_test "call str_func1 (...)"] {
ad3986f0
MS
112 gdb_test "call str_func1(\"test string\")" \
113 "first string arg is: test string.*\"test string\".*"
13a5e3b8 114}
c906108c
SS
115
116#print str_func1(buf)
13a5e3b8 117if ![gdb_skip_stdio_test "print str_func1(buf)"] {
ad3986f0
MS
118 gdb_test "print str_func1(buf)" \
119 "first string arg is: test string.*\"test string\".*"
13a5e3b8 120}
c906108c
SS
121
122#call str_func1(buf)
13a5e3b8 123if ![gdb_skip_stdio_test "call str_func1(buf)"] {
ad3986f0
MS
124 gdb_test "call str_func1(buf)" \
125 "first string arg is: test string.*\"test string\".*"
13a5e3b8 126}
c906108c
SS
127
128#print str_func("a","b","c","d","e","f","g")
13a5e3b8 129if ![gdb_skip_stdio_test "print str_func(a,b,c,d,e,f,g)"] {
ad3986f0
MS
130 gdb_test "print str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")" \
131 "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\".*"
13a5e3b8 132}
c906108c
SS
133
134#call str_func("a","b","c","d","e","f","g")
13a5e3b8 135if ![gdb_skip_stdio_test "call str_func(a,b,c,d,e,f,g)"] {
ad3986f0
MS
136 gdb_test "call str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")" \
137 "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\".*"
13a5e3b8 138}
c906108c 139
085dd6e6 140#print str_func(s,s,s,s,s,s,s)
13a5e3b8 141if ![gdb_skip_stdio_test "print str_func(s,s,s,s,s,s,s,s)"] {
ad3986f0
MS
142 gdb_test "print str_func(s,s,s,s,s,s,s)" \
143 "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\".*"
13a5e3b8 144}
c906108c 145
085dd6e6 146#call str_func(s,s,s,s,s,s,s)
13a5e3b8 147if ![gdb_skip_stdio_test "call str_func(s,s,s,s,s,s,s,s)"] {
ad3986f0
MS
148 gdb_test "call str_func(s,s,s,s,s,s,s)" \
149 "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\".*"
13a5e3b8 150}
c906108c
SS
151
152gdb_exit
97f2ed50
DJ
153
154set timeout $prev_timeout
155
This page took 1.050312 seconds and 4 git commands to generate.