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