Imported Upstream version 7.5
[platform/upstream/gdb.git] / gdb / testsuite / gdb.base / call-strs.exp
1 # Copyright 1998-2000, 2007-2012 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 <http://www.gnu.org/licenses/>.
15
16 # This file was written by Elena Zannoni (ezannoni@cygnus.com)
17
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
21 #
22
23 #debug strarg
24
25
26 set testfile "call-strs"
27 set srcfile ${testfile}.c
28 set binfile ${objdir}/${subdir}/${testfile}
29
30 # Test depends on printf, which the sparclet stub doesn't support.  
31 if { [istarget "sparclet-*-*"] } {
32     return 0;
33 }
34
35 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
36     untested call-strs.exp
37     return -1
38 }
39
40
41
42 # Some targets can't call functions, so don't even bother with this
43 # test.
44 if [target_info exists gdb,cannot_call_functions] {
45     setup_xfail "*-*-*" 2416
46     fail "This target can not call functions"
47     continue
48 }
49
50
51 # Start with a fresh gdb.
52
53 gdb_exit
54 gdb_start
55 gdb_reinitialize_dir $srcdir/$subdir
56 gdb_load ${binfile}
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"
61
62 if ![runto_main] then {
63     perror "couldn't run to breakpoint"
64     continue
65 }
66
67 set prev_timeout $timeout
68 set timeout 120
69
70 #step
71 gdb_test "step" \
72     "strcpy\\(buf, \"test string\"\\);" \
73     "step after assignment to s"
74
75 #next
76 gdb_test "next" \
77     "str_func\\(\"abcd\", \"efgh\", \"ijkl\", \"mnop\", \"qrst\", \"uvwx\", \"yz12\"\\);" \
78     "next over strcpy"
79
80 #print buf
81 gdb_test "print buf" \
82     "\"test string\",.*repeats 88 times.*"
83
84 #print s
85 gdb_test "print s" \
86     " = \"test string\".*"
87
88 #print str_func1(s)
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\".*"
92 }
93
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\".*"
98 }
99
100 #call str_func1(s)
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\".*"
104 }
105
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\".*"
110 }
111
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\".*"
116 }
117
118 #call str_func1(buf)
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\".*"
122 }
123
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\".*"
128 }
129
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\".*"
134 }
135
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\".*"
140 }
141
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\".*"
146 }
147
148 gdb_exit
149
150 set timeout $prev_timeout
151