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