]>
Commit | Line | Data |
---|---|---|
618f726f | 1 | # Copyright 1998-2016 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 | |
9fbfe2dc AC |
28 | # Some targets can't call functions, so don't even bother with this |
29 | # test. | |
c906108c SS |
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 | ||
c906108c | 36 | |
f76495c8 TT |
37 | if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} { |
38 | untested $testfile.exp | |
39 | return -1 | |
40 | } | |
c906108c | 41 | |
ad3986f0 MS |
42 | gdb_test_no_output "set print sevenbit-strings" |
43 | gdb_test_no_output "set print address off" | |
9cb709b6 | 44 | gdb_test_no_output "set print symbol off" |
ad3986f0 | 45 | gdb_test_no_output "set width 0" |
c906108c | 46 | |
c906108c SS |
47 | if ![runto_main] then { |
48 | perror "couldn't run to breakpoint" | |
49 | continue | |
50 | } | |
51 | ||
97f2ed50 DJ |
52 | set prev_timeout $timeout |
53 | set timeout 120 | |
54 | ||
dedad4e3 | 55 | gdb_test "next 2" \ |
ad3986f0 MS |
56 | "strcpy\\(buf, \"test string\"\\);" \ |
57 | "step after assignment to s" | |
c906108c | 58 | |
37f8da45 | 59 | #next |
ad3986f0 MS |
60 | gdb_test "next" \ |
61 | "str_func\\(\"abcd\", \"efgh\", \"ijkl\", \"mnop\", \"qrst\", \"uvwx\", \"yz12\"\\);" \ | |
62 | "next over strcpy" | |
c906108c SS |
63 | |
64 | #print buf | |
ad3986f0 MS |
65 | gdb_test "print buf" \ |
66 | "\"test string\",.*repeats 88 times.*" | |
c906108c SS |
67 | |
68 | #print s | |
ad3986f0 MS |
69 | gdb_test "print s" \ |
70 | " = \"test string\".*" | |
c906108c SS |
71 | |
72 | #print str_func1(s) | |
13a5e3b8 | 73 | if ![gdb_skip_stdio_test "print str_func1(s)"] { |
452397af PA |
74 | gdb_test_stdio "print str_func1(s)" \ |
75 | "first string arg is: test string" \ | |
76 | "\"test string\".*" | |
13a5e3b8 | 77 | } |
c906108c | 78 | |
c906108c | 79 | #print str_func1("test string") |
13a5e3b8 | 80 | if ![gdb_skip_stdio_test "print str_func1(teststring)"] { |
452397af PA |
81 | gdb_test_stdio "print str_func1(\"test string\")" \ |
82 | "first string arg is: test string" \ | |
83 | "\"test string\".*" | |
13a5e3b8 | 84 | } |
c906108c SS |
85 | |
86 | #call str_func1(s) | |
13a5e3b8 | 87 | if ![gdb_skip_stdio_test "call str_func1(s)"] { |
452397af PA |
88 | gdb_test_stdio "call str_func1(s)" \ |
89 | "first string arg is: test string" \ | |
90 | "\"test string\".*" | |
13a5e3b8 | 91 | } |
c906108c SS |
92 | |
93 | #call str_func1("test string") | |
13a5e3b8 | 94 | if ![gdb_skip_stdio_test "call str_func1 (...)"] { |
452397af PA |
95 | gdb_test_stdio "call str_func1(\"test string\")" \ |
96 | "first string arg is: test string" \ | |
97 | "\"test string\".*" | |
13a5e3b8 | 98 | } |
c906108c SS |
99 | |
100 | #print str_func1(buf) | |
13a5e3b8 | 101 | if ![gdb_skip_stdio_test "print str_func1(buf)"] { |
452397af PA |
102 | gdb_test_stdio "print str_func1(buf)" \ |
103 | "first string arg is: test string" \ | |
104 | "\"test string\".*" | |
13a5e3b8 | 105 | } |
c906108c SS |
106 | |
107 | #call str_func1(buf) | |
13a5e3b8 | 108 | if ![gdb_skip_stdio_test "call str_func1(buf)"] { |
452397af PA |
109 | gdb_test_stdio "call str_func1(buf)" \ |
110 | "first string arg is: test string" \ | |
111 | "\"test string\".*" | |
13a5e3b8 | 112 | } |
c906108c SS |
113 | |
114 | #print str_func("a","b","c","d","e","f","g") | |
13a5e3b8 | 115 | if ![gdb_skip_stdio_test "print str_func(a,b,c,d,e,f,g)"] { |
452397af PA |
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\".*" | |
13a5e3b8 | 119 | } |
c906108c SS |
120 | |
121 | #call str_func("a","b","c","d","e","f","g") | |
13a5e3b8 | 122 | if ![gdb_skip_stdio_test "call str_func(a,b,c,d,e,f,g)"] { |
452397af PA |
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\".*" | |
13a5e3b8 | 126 | } |
c906108c | 127 | |
085dd6e6 | 128 | #print str_func(s,s,s,s,s,s,s) |
13a5e3b8 | 129 | if ![gdb_skip_stdio_test "print str_func(s,s,s,s,s,s,s,s)"] { |
452397af PA |
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\".*" | |
13a5e3b8 | 133 | } |
c906108c | 134 | |
085dd6e6 | 135 | #call str_func(s,s,s,s,s,s,s) |
13a5e3b8 | 136 | if ![gdb_skip_stdio_test "call str_func(s,s,s,s,s,s,s,s)"] { |
452397af PA |
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\".*" | |
13a5e3b8 | 140 | } |
c906108c SS |
141 | |
142 | gdb_exit | |
97f2ed50 DJ |
143 | |
144 | set timeout $prev_timeout | |
145 |