GDB copyright headers update after running GDB's copyright.py script.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / call-strs.exp
1 # Copyright 1998-2016 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 # Some targets can't call functions, so don't even bother with this
29 # test.
30 if [target_info exists gdb,cannot_call_functions] {
31 setup_xfail "*-*-*" 2416
32 fail "This target can not call functions"
33 continue
34 }
35
36
37 if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
38 untested $testfile.exp
39 return -1
40 }
41
42 gdb_test_no_output "set print sevenbit-strings"
43 gdb_test_no_output "set print address off"
44 gdb_test_no_output "set print symbol off"
45 gdb_test_no_output "set width 0"
46
47 if ![runto_main] then {
48 perror "couldn't run to breakpoint"
49 continue
50 }
51
52 set prev_timeout $timeout
53 set timeout 120
54
55 gdb_test "next 2" \
56 "strcpy\\(buf, \"test string\"\\);" \
57 "step after assignment to s"
58
59 #next
60 gdb_test "next" \
61 "str_func\\(\"abcd\", \"efgh\", \"ijkl\", \"mnop\", \"qrst\", \"uvwx\", \"yz12\"\\);" \
62 "next over strcpy"
63
64 #print buf
65 gdb_test "print buf" \
66 "\"test string\",.*repeats 88 times.*"
67
68 #print s
69 gdb_test "print s" \
70 " = \"test string\".*"
71
72 #print str_func1(s)
73 if ![gdb_skip_stdio_test "print str_func1(s)"] {
74 gdb_test_stdio "print str_func1(s)" \
75 "first string arg is: test string" \
76 "\"test string\".*"
77 }
78
79 #print str_func1("test string")
80 if ![gdb_skip_stdio_test "print str_func1(teststring)"] {
81 gdb_test_stdio "print str_func1(\"test string\")" \
82 "first string arg is: test string" \
83 "\"test string\".*"
84 }
85
86 #call str_func1(s)
87 if ![gdb_skip_stdio_test "call str_func1(s)"] {
88 gdb_test_stdio "call str_func1(s)" \
89 "first string arg is: test string" \
90 "\"test string\".*"
91 }
92
93 #call str_func1("test string")
94 if ![gdb_skip_stdio_test "call str_func1 (...)"] {
95 gdb_test_stdio "call str_func1(\"test string\")" \
96 "first string arg is: test string" \
97 "\"test string\".*"
98 }
99
100 #print str_func1(buf)
101 if ![gdb_skip_stdio_test "print str_func1(buf)"] {
102 gdb_test_stdio "print str_func1(buf)" \
103 "first string arg is: test string" \
104 "\"test string\".*"
105 }
106
107 #call str_func1(buf)
108 if ![gdb_skip_stdio_test "call str_func1(buf)"] {
109 gdb_test_stdio "call str_func1(buf)" \
110 "first string arg is: test string" \
111 "\"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_stdio "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\]+" \
118 "= \"abcdefg\".*"
119 }
120
121 #call str_func("a","b","c","d","e","f","g")
122 if ![gdb_skip_stdio_test "call str_func(a,b,c,d,e,f,g)"] {
123 gdb_test_stdio "call str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")" \
124 "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\]+" \
125 "= \"abcdefg\".*"
126 }
127
128 #print str_func(s,s,s,s,s,s,s)
129 if ![gdb_skip_stdio_test "print str_func(s,s,s,s,s,s,s,s)"] {
130 gdb_test_stdio "print str_func(s,s,s,s,s,s,s)" \
131 "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\]+" \
132 "\"test stringtest stringtest stringtest stringtest stringtest stringtest string\".*"
133 }
134
135 #call str_func(s,s,s,s,s,s,s)
136 if ![gdb_skip_stdio_test "call str_func(s,s,s,s,s,s,s,s)"] {
137 gdb_test_stdio "call str_func(s,s,s,s,s,s,s)" \
138 "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\]+" \
139 "\"test stringtest stringtest stringtest stringtest stringtest stringtest string\".*"
140 }
141
142 gdb_exit
143
144 set timeout $prev_timeout
145
This page took 0.033091 seconds and 4 git commands to generate.