1 # Copyright 1998, 1999, 2000, 2007, 2008, 2009, 2010, 2011
2 # Free Software Foundation, Inc.
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
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # This file was written by Elena Zannoni (ezannoni@cygnus.com)
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
31 set testfile "call-strs"
32 set srcfile ${testfile}.c
33 set binfile ${objdir}/${subdir}/${testfile}
35 # Test depends on printf, which the sparclet stub doesn't support.
36 if { [istarget "sparclet-*-*"] } {
40 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
41 untested call-strs.exp
47 # Some targets can't call functions, so don't even bother with this
49 if [target_info exists gdb,cannot_call_functions] {
50 setup_xfail "*-*-*" 2416
51 fail "This target can not call functions"
56 # Start with a fresh gdb.
60 gdb_reinitialize_dir $srcdir/$subdir
62 gdb_test_no_output "set print sevenbit-strings"
63 gdb_test_no_output "set print address off"
64 gdb_test_no_output "set width 0"
66 if ![runto_main] then {
67 perror "couldn't run to breakpoint"
71 set prev_timeout $timeout
76 "strcpy\\(buf, \"test string\"\\);" \
77 "step after assignment to s"
81 "str_func\\(\"abcd\", \"efgh\", \"ijkl\", \"mnop\", \"qrst\", \"uvwx\", \"yz12\"\\);" \
85 gdb_test "print buf" \
86 "\"test string\",.*repeats 88 times.*"
90 " = \"test string\".*"
93 if ![gdb_skip_stdio_test "print str_func1(s)"] {
94 gdb_test "print str_func1(s)" \
95 "first string arg is: test string.*\"test string\".*"
98 #print str_func1("test string")
99 if ![gdb_skip_stdio_test "print str_func1(teststring)"] {
100 gdb_test "print str_func1(\"test string\")" \
101 "first string arg is: test string.*\"test string\".*"
105 if ![gdb_skip_stdio_test "call str_func1(s)"] {
106 gdb_test "call str_func1(s)" \
107 "first string arg is: test string.*\"test string\".*"
110 #call str_func1("test string")
111 if ![gdb_skip_stdio_test "call str_func1 (...)"] {
112 gdb_test "call str_func1(\"test string\")" \
113 "first string arg is: test string.*\"test string\".*"
116 #print str_func1(buf)
117 if ![gdb_skip_stdio_test "print str_func1(buf)"] {
118 gdb_test "print str_func1(buf)" \
119 "first string arg is: test string.*\"test string\".*"
123 if ![gdb_skip_stdio_test "call str_func1(buf)"] {
124 gdb_test "call str_func1(buf)" \
125 "first string arg is: test string.*\"test string\".*"
128 #print str_func("a","b","c","d","e","f","g")
129 if ![gdb_skip_stdio_test "print str_func(a,b,c,d,e,f,g)"] {
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\".*"
134 #call str_func("a","b","c","d","e","f","g")
135 if ![gdb_skip_stdio_test "call str_func(a,b,c,d,e,f,g)"] {
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\".*"
140 #print str_func(s,s,s,s,s,s,s)
141 if ![gdb_skip_stdio_test "print str_func(s,s,s,s,s,s,s,s)"] {
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\".*"
146 #call str_func(s,s,s,s,s,s,s)
147 if ![gdb_skip_stdio_test "call str_func(s,s,s,s,s,s,s,s)"] {
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\".*"
154 set timeout $prev_timeout