Commit | Line | Data |
---|---|---|
32d0add0 | 1 | # Copyright 1998-2015 Free Software Foundation, Inc. |
c906108c SS |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
c906108c SS |
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. | |
e22f8b7c | 12 | # |
c906108c | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 15 | |
c906108c SS |
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 | ||
c906108c | 25 | |
f76495c8 | 26 | standard_testfile |
c906108c | 27 | |
1960c400 MS |
28 | # Test depends on printf, which the sparclet stub doesn't support. |
29 | if { [istarget "sparclet-*-*"] } { | |
ae59b1da | 30 | return 0 |
1960c400 MS |
31 | } |
32 | ||
9fbfe2dc AC |
33 | # Some targets can't call functions, so don't even bother with this |
34 | # test. | |
c906108c SS |
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 | ||
c906108c | 41 | |
f76495c8 TT |
42 | if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} { |
43 | untested $testfile.exp | |
44 | return -1 | |
45 | } | |
c906108c | 46 | |
ad3986f0 MS |
47 | gdb_test_no_output "set print sevenbit-strings" |
48 | gdb_test_no_output "set print address off" | |
9cb709b6 | 49 | gdb_test_no_output "set print symbol off" |
ad3986f0 | 50 | gdb_test_no_output "set width 0" |
c906108c | 51 | |
c906108c SS |
52 | if ![runto_main] then { |
53 | perror "couldn't run to breakpoint" | |
54 | continue | |
55 | } | |
56 | ||
97f2ed50 DJ |
57 | set prev_timeout $timeout |
58 | set timeout 120 | |
59 | ||
c906108c | 60 | #step |
ad3986f0 MS |
61 | gdb_test "step" \ |
62 | "strcpy\\(buf, \"test string\"\\);" \ | |
63 | "step after assignment to s" | |
c906108c | 64 | |
37f8da45 | 65 | #next |
ad3986f0 MS |
66 | gdb_test "next" \ |
67 | "str_func\\(\"abcd\", \"efgh\", \"ijkl\", \"mnop\", \"qrst\", \"uvwx\", \"yz12\"\\);" \ | |
68 | "next over strcpy" | |
c906108c SS |
69 | |
70 | #print buf | |
ad3986f0 MS |
71 | gdb_test "print buf" \ |
72 | "\"test string\",.*repeats 88 times.*" | |
c906108c SS |
73 | |
74 | #print s | |
ad3986f0 MS |
75 | gdb_test "print s" \ |
76 | " = \"test string\".*" | |
c906108c SS |
77 | |
78 | #print str_func1(s) | |
13a5e3b8 | 79 | if ![gdb_skip_stdio_test "print str_func1(s)"] { |
452397af PA |
80 | gdb_test_stdio "print str_func1(s)" \ |
81 | "first string arg is: test string" \ | |
82 | "\"test string\".*" | |
13a5e3b8 | 83 | } |
c906108c | 84 | |
c906108c | 85 | #print str_func1("test string") |
13a5e3b8 | 86 | if ![gdb_skip_stdio_test "print str_func1(teststring)"] { |
452397af PA |
87 | gdb_test_stdio "print str_func1(\"test string\")" \ |
88 | "first string arg is: test string" \ | |
89 | "\"test string\".*" | |
13a5e3b8 | 90 | } |
c906108c SS |
91 | |
92 | #call str_func1(s) | |
13a5e3b8 | 93 | if ![gdb_skip_stdio_test "call str_func1(s)"] { |
452397af PA |
94 | gdb_test_stdio "call str_func1(s)" \ |
95 | "first string arg is: test string" \ | |
96 | "\"test string\".*" | |
13a5e3b8 | 97 | } |
c906108c SS |
98 | |
99 | #call str_func1("test string") | |
13a5e3b8 | 100 | if ![gdb_skip_stdio_test "call str_func1 (...)"] { |
452397af PA |
101 | gdb_test_stdio "call str_func1(\"test string\")" \ |
102 | "first string arg is: test string" \ | |
103 | "\"test string\".*" | |
13a5e3b8 | 104 | } |
c906108c SS |
105 | |
106 | #print str_func1(buf) | |
13a5e3b8 | 107 | if ![gdb_skip_stdio_test "print str_func1(buf)"] { |
452397af PA |
108 | gdb_test_stdio "print str_func1(buf)" \ |
109 | "first string arg is: test string" \ | |
110 | "\"test string\".*" | |
13a5e3b8 | 111 | } |
c906108c SS |
112 | |
113 | #call str_func1(buf) | |
13a5e3b8 | 114 | if ![gdb_skip_stdio_test "call str_func1(buf)"] { |
452397af PA |
115 | gdb_test_stdio "call str_func1(buf)" \ |
116 | "first string arg is: test string" \ | |
117 | "\"test string\".*" | |
13a5e3b8 | 118 | } |
c906108c SS |
119 | |
120 | #print str_func("a","b","c","d","e","f","g") | |
13a5e3b8 | 121 | if ![gdb_skip_stdio_test "print str_func(a,b,c,d,e,f,g)"] { |
452397af PA |
122 | gdb_test_stdio "print 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\]+" \ | |
124 | "= \"abcdefg\".*" | |
13a5e3b8 | 125 | } |
c906108c SS |
126 | |
127 | #call str_func("a","b","c","d","e","f","g") | |
13a5e3b8 | 128 | if ![gdb_skip_stdio_test "call str_func(a,b,c,d,e,f,g)"] { |
452397af PA |
129 | gdb_test_stdio "call 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\]+" \ | |
131 | "= \"abcdefg\".*" | |
13a5e3b8 | 132 | } |
c906108c | 133 | |
085dd6e6 | 134 | #print str_func(s,s,s,s,s,s,s) |
13a5e3b8 | 135 | if ![gdb_skip_stdio_test "print str_func(s,s,s,s,s,s,s,s)"] { |
452397af PA |
136 | gdb_test_stdio "print str_func(s,s,s,s,s,s,s)" \ |
137 | "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\]+" \ | |
138 | "\"test stringtest stringtest stringtest stringtest stringtest stringtest string\".*" | |
13a5e3b8 | 139 | } |
c906108c | 140 | |
085dd6e6 | 141 | #call str_func(s,s,s,s,s,s,s) |
13a5e3b8 | 142 | if ![gdb_skip_stdio_test "call str_func(s,s,s,s,s,s,s,s)"] { |
452397af PA |
143 | gdb_test_stdio "call str_func(s,s,s,s,s,s,s)" \ |
144 | "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\]+" \ | |
145 | "\"test stringtest stringtest stringtest stringtest stringtest stringtest string\".*" | |
13a5e3b8 | 146 | } |
c906108c SS |
147 | |
148 | gdb_exit | |
97f2ed50 DJ |
149 | |
150 | set timeout $prev_timeout | |
151 |