1 # Copyright 1998-2000, 2007-2012 Free Software Foundation, Inc.
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.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # This file was written by Elena Zannoni (ezannoni@cygnus.com)
18 # This test deals with calling functions which have strings as parameters.
19 # it plays around with constant strings.
20 # the corresponding source file is call-strs.c
26 set testfile "call-strs"
27 set srcfile ${testfile}.c
28 set binfile ${objdir}/${subdir}/${testfile}
30 # Test depends on printf, which the sparclet stub doesn't support.
31 if { [istarget "sparclet-*-*"] } {
35 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
36 untested call-strs.exp
42 # Some targets can't call functions, so don't even bother with this
44 if [target_info exists gdb,cannot_call_functions] {
45 setup_xfail "*-*-*" 2416
46 fail "This target can not call functions"
51 # Start with a fresh gdb.
55 gdb_reinitialize_dir $srcdir/$subdir
57 gdb_test_no_output "set print sevenbit-strings"
58 gdb_test_no_output "set print address off"
59 gdb_test_no_output "set print symbol off"
60 gdb_test_no_output "set width 0"
62 if ![runto_main] then {
63 perror "couldn't run to breakpoint"
67 set prev_timeout $timeout
72 "strcpy\\(buf, \"test string\"\\);" \
73 "step after assignment to s"
77 "str_func\\(\"abcd\", \"efgh\", \"ijkl\", \"mnop\", \"qrst\", \"uvwx\", \"yz12\"\\);" \
81 gdb_test "print buf" \
82 "\"test string\",.*repeats 88 times.*"
86 " = \"test string\".*"
89 if ![gdb_skip_stdio_test "print str_func1(s)"] {
90 gdb_test "print str_func1(s)" \
91 "first string arg is: test string.*\"test string\".*"
94 #print str_func1("test string")
95 if ![gdb_skip_stdio_test "print str_func1(teststring)"] {
96 gdb_test "print str_func1(\"test string\")" \
97 "first string arg is: test string.*\"test string\".*"
101 if ![gdb_skip_stdio_test "call str_func1(s)"] {
102 gdb_test "call str_func1(s)" \
103 "first string arg is: test string.*\"test string\".*"
106 #call str_func1("test string")
107 if ![gdb_skip_stdio_test "call str_func1 (...)"] {
108 gdb_test "call str_func1(\"test string\")" \
109 "first string arg is: test string.*\"test string\".*"
112 #print str_func1(buf)
113 if ![gdb_skip_stdio_test "print str_func1(buf)"] {
114 gdb_test "print str_func1(buf)" \
115 "first string arg is: test string.*\"test string\".*"
119 if ![gdb_skip_stdio_test "call str_func1(buf)"] {
120 gdb_test "call str_func1(buf)" \
121 "first string arg is: test string.*\"test string\".*"
124 #print str_func("a","b","c","d","e","f","g")
125 if ![gdb_skip_stdio_test "print str_func(a,b,c,d,e,f,g)"] {
126 gdb_test "print str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")" \
127 "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\".*"
130 #call str_func("a","b","c","d","e","f","g")
131 if ![gdb_skip_stdio_test "call str_func(a,b,c,d,e,f,g)"] {
132 gdb_test "call str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")" \
133 "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\".*"
136 #print str_func(s,s,s,s,s,s,s)
137 if ![gdb_skip_stdio_test "print str_func(s,s,s,s,s,s,s,s)"] {
138 gdb_test "print str_func(s,s,s,s,s,s,s)" \
139 "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\".*"
142 #call str_func(s,s,s,s,s,s,s)
143 if ![gdb_skip_stdio_test "call str_func(s,s,s,s,s,s,s,s)"] {
144 gdb_test "call str_func(s,s,s,s,s,s,s)" \
145 "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\".*"
150 set timeout $prev_timeout