Update copyright year range in header of all files managed by GDB
[binutils-gdb.git] / gdb / testsuite / gdb.base / call-strs.exp
blob90fe1763db8a906a08e820a3e604102a4c9607da
1 # Copyright 1998-2023 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
23 #debug strarg
26 standard_testfile
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     unsupported "this target can not call functions"
32     return
36 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
37     return -1
40 gdb_test_no_output "set print sevenbit-strings"
41 gdb_test_no_output "set print address off"
42 gdb_test_no_output "set print symbol off"
43 gdb_test_no_output "set width 0"
45 if {![runto_main]} {
46     return
49 set prev_timeout $timeout
50 set timeout 120
52 gdb_test "next 2" \
53     "strcpy\\(buf, \"test string\"\\);" \
54     "step after assignment to s"
56 #next
57 gdb_test "next" \
58     "str_func\\(\"abcd\", \"efgh\", \"ijkl\", \"mnop\", \"qrst\", \"uvwx\", \"yz12\"\\);" \
59     "next over strcpy"
61 #print buf
62 gdb_test "print buf" \
63     "\"test string\",.*repeats 88 times.*"
65 #print s
66 gdb_test "print s" \
67     " = \"test string\".*"
69 #print str_func1(s)
70 if ![gdb_skip_stdio_test "print str_func1(s)"] {
71     gdb_test_stdio "print str_func1(s)" \
72         "first string arg is: test string" \
73         "\"test string\".*"
76 #print str_func1("test string")
77 if ![gdb_skip_stdio_test "print str_func1(teststring)"] {
78     gdb_test_stdio "print str_func1(\"test string\")" \
79         "first string arg is: test string" \
80         "\"test string\".*"
83 #call str_func1(s)
84 if ![gdb_skip_stdio_test "call str_func1(s)"] {
85     gdb_test_stdio "call str_func1(s)" \
86         "first string arg is: test string" \
87         "\"test string\".*"
90 #call str_func1("test string")
91 if ![gdb_skip_stdio_test "call str_func1 (...)"] {
92     gdb_test_stdio "call str_func1(\"test string\")" \
93         "first string arg is: test string" \
94         "\"test string\".*"
97 #print str_func1(buf)
98 if ![gdb_skip_stdio_test "print str_func1(buf)"] {
99     gdb_test_stdio "print str_func1(buf)" \
100         "first string arg is: test string" \
101         "\"test string\".*"
104 #call str_func1(buf)
105 if ![gdb_skip_stdio_test "call str_func1(buf)"] {
106     gdb_test_stdio "call str_func1(buf)" \
107         "first string arg is: test string" \
108         "\"test string\".*"
111 #print str_func("a","b","c","d","e","f","g")
112 if ![gdb_skip_stdio_test "print str_func(a,b,c,d,e,f,g)"] {
113     gdb_test_stdio "print str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")" \
114         "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\]+" \
115         "= \"abcdefg\".*"
118 #call str_func("a","b","c","d","e","f","g")
119 if ![gdb_skip_stdio_test "call str_func(a,b,c,d,e,f,g)"] {
120     gdb_test_stdio "call str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")" \
121         "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\]+" \
122         "= \"abcdefg\".*"
125 #print str_func(s,s,s,s,s,s,s)
126 if ![gdb_skip_stdio_test "print str_func(s,s,s,s,s,s,s,s)"] {
127     gdb_test_stdio "print str_func(s,s,s,s,s,s,s)" \
128         "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\]+" \
129     "\"test stringtest stringtest stringtest stringtest stringtest stringtest string\".*"
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_stdio "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\]+" \
136         "\"test stringtest stringtest stringtest stringtest stringtest stringtest string\".*"
139 gdb_exit
141 set timeout $prev_timeout