Commit | Line | Data |
---|---|---|
4c38e0a4 JB |
1 | # Copyright 1998, 1999, 2000, 2007, 2008, 2009, 2010 |
2 | # Free Software Foundation, Inc. | |
c906108c SS |
3 | |
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
e22f8b7c | 6 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 7 | # (at your option) any later version. |
e22f8b7c | 8 | # |
c906108c SS |
9 | # This program is distributed in the hope that it will be useful, |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
e22f8b7c | 13 | # |
c906108c | 14 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 16 | |
c906108c SS |
17 | # This file was written by Elena Zannoni (ezannoni@cygnus.com) |
18 | ||
19 | # This test deals with calling functions which have strings as parameters. | |
20 | # it plays around with constant strings. | |
21 | # the corresponding source file is call-strs.c | |
22 | # | |
23 | ||
24 | #debug strarg | |
25 | ||
26 | if $tracelevel then { | |
27 | strace $tracelevel | |
28 | } | |
29 | ||
c906108c SS |
30 | |
31 | set testfile "call-strs" | |
32 | set srcfile ${testfile}.c | |
33 | set binfile ${objdir}/${subdir}/${testfile} | |
34 | ||
1960c400 MS |
35 | # Test depends on printf, which the sparclet stub doesn't support. |
36 | if { [istarget "sparclet-*-*"] } { | |
37 | return 0; | |
38 | } | |
39 | ||
c906108c | 40 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { |
b60f0898 JB |
41 | untested call-strs.exp |
42 | return -1 | |
c906108c SS |
43 | } |
44 | ||
45 | ||
46 | ||
9fbfe2dc AC |
47 | # Some targets can't call functions, so don't even bother with this |
48 | # test. | |
c906108c SS |
49 | if [target_info exists gdb,cannot_call_functions] { |
50 | setup_xfail "*-*-*" 2416 | |
51 | fail "This target can not call functions" | |
52 | continue | |
53 | } | |
54 | ||
c906108c SS |
55 | |
56 | # Start with a fresh gdb. | |
57 | ||
58 | gdb_exit | |
59 | gdb_start | |
60 | gdb_reinitialize_dir $srcdir/$subdir | |
61 | gdb_load ${binfile} | |
ad3986f0 MS |
62 | gdb_test_no_output "set print sevenbit-strings" |
63 | gdb_test_no_output "set print address off" | |
64 | gdb_test_no_output "set width 0" | |
c906108c | 65 | |
c906108c SS |
66 | if ![runto_main] then { |
67 | perror "couldn't run to breakpoint" | |
68 | continue | |
69 | } | |
70 | ||
97f2ed50 DJ |
71 | set prev_timeout $timeout |
72 | set timeout 120 | |
73 | ||
c906108c | 74 | #step |
ad3986f0 MS |
75 | gdb_test "step" \ |
76 | "strcpy\\(buf, \"test string\"\\);" \ | |
77 | "step after assignment to s" | |
c906108c | 78 | |
37f8da45 | 79 | #next |
ad3986f0 MS |
80 | gdb_test "next" \ |
81 | "str_func\\(\"abcd\", \"efgh\", \"ijkl\", \"mnop\", \"qrst\", \"uvwx\", \"yz12\"\\);" \ | |
82 | "next over strcpy" | |
c906108c SS |
83 | |
84 | #print buf | |
ad3986f0 MS |
85 | gdb_test "print buf" \ |
86 | "\"test string\",.*repeats 88 times.*" | |
c906108c SS |
87 | |
88 | #print s | |
ad3986f0 MS |
89 | gdb_test "print s" \ |
90 | " = \"test string\".*" | |
c906108c SS |
91 | |
92 | #print str_func1(s) | |
13a5e3b8 | 93 | if ![gdb_skip_stdio_test "print str_func1(s)"] { |
ad3986f0 MS |
94 | gdb_test "print str_func1(s)" \ |
95 | "first string arg is: test string.*\"test string\".*" | |
13a5e3b8 | 96 | } |
c906108c | 97 | |
c906108c | 98 | #print str_func1("test string") |
13a5e3b8 | 99 | if ![gdb_skip_stdio_test "print str_func1(teststring)"] { |
ad3986f0 MS |
100 | gdb_test "print str_func1(\"test string\")" \ |
101 | "first string arg is: test string.*\"test string\".*" | |
13a5e3b8 | 102 | } |
c906108c SS |
103 | |
104 | #call str_func1(s) | |
13a5e3b8 | 105 | if ![gdb_skip_stdio_test "call str_func1(s)"] { |
ad3986f0 MS |
106 | gdb_test "call str_func1(s)" \ |
107 | "first string arg is: test string.*\"test string\".*" | |
13a5e3b8 | 108 | } |
c906108c SS |
109 | |
110 | #call str_func1("test string") | |
13a5e3b8 | 111 | if ![gdb_skip_stdio_test "call str_func1 (...)"] { |
ad3986f0 MS |
112 | gdb_test "call str_func1(\"test string\")" \ |
113 | "first string arg is: test string.*\"test string\".*" | |
13a5e3b8 | 114 | } |
c906108c SS |
115 | |
116 | #print str_func1(buf) | |
13a5e3b8 | 117 | if ![gdb_skip_stdio_test "print str_func1(buf)"] { |
ad3986f0 MS |
118 | gdb_test "print str_func1(buf)" \ |
119 | "first string arg is: test string.*\"test string\".*" | |
13a5e3b8 | 120 | } |
c906108c SS |
121 | |
122 | #call str_func1(buf) | |
13a5e3b8 | 123 | if ![gdb_skip_stdio_test "call str_func1(buf)"] { |
ad3986f0 MS |
124 | gdb_test "call str_func1(buf)" \ |
125 | "first string arg is: test string.*\"test string\".*" | |
13a5e3b8 | 126 | } |
c906108c SS |
127 | |
128 | #print str_func("a","b","c","d","e","f","g") | |
13a5e3b8 | 129 | if ![gdb_skip_stdio_test "print str_func(a,b,c,d,e,f,g)"] { |
ad3986f0 MS |
130 | gdb_test "print str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")" \ |
131 | "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\".*" | |
13a5e3b8 | 132 | } |
c906108c SS |
133 | |
134 | #call str_func("a","b","c","d","e","f","g") | |
13a5e3b8 | 135 | if ![gdb_skip_stdio_test "call str_func(a,b,c,d,e,f,g)"] { |
ad3986f0 MS |
136 | gdb_test "call str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")" \ |
137 | "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\".*" | |
13a5e3b8 | 138 | } |
c906108c | 139 | |
085dd6e6 | 140 | #print str_func(s,s,s,s,s,s,s) |
13a5e3b8 | 141 | if ![gdb_skip_stdio_test "print str_func(s,s,s,s,s,s,s,s)"] { |
ad3986f0 MS |
142 | gdb_test "print str_func(s,s,s,s,s,s,s)" \ |
143 | "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\".*" | |
13a5e3b8 | 144 | } |
c906108c | 145 | |
085dd6e6 | 146 | #call str_func(s,s,s,s,s,s,s) |
13a5e3b8 | 147 | if ![gdb_skip_stdio_test "call str_func(s,s,s,s,s,s,s,s)"] { |
ad3986f0 MS |
148 | gdb_test "call str_func(s,s,s,s,s,s,s)" \ |
149 | "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\".*" | |
13a5e3b8 | 150 | } |
c906108c SS |
151 | |
152 | gdb_exit | |
97f2ed50 DJ |
153 | |
154 | set timeout $prev_timeout | |
155 |