]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 1998-2024 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. | |
450d26c8 | 30 | require {!target_info exists gdb,cannot_call_functions} |
c906108c | 31 | |
d1de9f5c TV |
32 | set flags {} |
33 | lappend flags debug | |
34 | lappend_include_file flags $srcdir/lib/unbuffer_output.c | |
c906108c | 35 | |
d1de9f5c | 36 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile $flags]} { |
f76495c8 TT |
37 | return -1 |
38 | } | |
c906108c | 39 | |
ad3986f0 MS |
40 | gdb_test_no_output "set print sevenbit-strings" |
41 | gdb_test_no_output "set print address off" | |
9cb709b6 | 42 | gdb_test_no_output "set print symbol off" |
ad3986f0 | 43 | gdb_test_no_output "set width 0" |
c906108c | 44 | |
65a33d75 | 45 | if {![runto_main]} { |
cdd42066 | 46 | return |
c906108c SS |
47 | } |
48 | ||
97f2ed50 DJ |
49 | set prev_timeout $timeout |
50 | set timeout 120 | |
51 | ||
dedad4e3 | 52 | gdb_test "next 2" \ |
ad3986f0 MS |
53 | "strcpy\\(buf, \"test string\"\\);" \ |
54 | "step after assignment to s" | |
c906108c | 55 | |
37f8da45 | 56 | #next |
ad3986f0 MS |
57 | gdb_test "next" \ |
58 | "str_func\\(\"abcd\", \"efgh\", \"ijkl\", \"mnop\", \"qrst\", \"uvwx\", \"yz12\"\\);" \ | |
59 | "next over strcpy" | |
c906108c SS |
60 | |
61 | #print buf | |
ad3986f0 MS |
62 | gdb_test "print buf" \ |
63 | "\"test string\",.*repeats 88 times.*" | |
c906108c SS |
64 | |
65 | #print s | |
ad3986f0 MS |
66 | gdb_test "print s" \ |
67 | " = \"test string\".*" | |
c906108c SS |
68 | |
69 | #print str_func1(s) | |
13a5e3b8 | 70 | if ![gdb_skip_stdio_test "print str_func1(s)"] { |
452397af PA |
71 | gdb_test_stdio "print str_func1(s)" \ |
72 | "first string arg is: test string" \ | |
73 | "\"test string\".*" | |
13a5e3b8 | 74 | } |
c906108c | 75 | |
c906108c | 76 | #print str_func1("test string") |
13a5e3b8 | 77 | if ![gdb_skip_stdio_test "print str_func1(teststring)"] { |
452397af PA |
78 | gdb_test_stdio "print str_func1(\"test string\")" \ |
79 | "first string arg is: test string" \ | |
80 | "\"test string\".*" | |
13a5e3b8 | 81 | } |
c906108c SS |
82 | |
83 | #call str_func1(s) | |
13a5e3b8 | 84 | if ![gdb_skip_stdio_test "call str_func1(s)"] { |
452397af PA |
85 | gdb_test_stdio "call str_func1(s)" \ |
86 | "first string arg is: test string" \ | |
87 | "\"test string\".*" | |
13a5e3b8 | 88 | } |
c906108c SS |
89 | |
90 | #call str_func1("test string") | |
13a5e3b8 | 91 | if ![gdb_skip_stdio_test "call str_func1 (...)"] { |
452397af PA |
92 | gdb_test_stdio "call str_func1(\"test string\")" \ |
93 | "first string arg is: test string" \ | |
94 | "\"test string\".*" | |
13a5e3b8 | 95 | } |
c906108c SS |
96 | |
97 | #print str_func1(buf) | |
13a5e3b8 | 98 | if ![gdb_skip_stdio_test "print str_func1(buf)"] { |
452397af PA |
99 | gdb_test_stdio "print str_func1(buf)" \ |
100 | "first string arg is: test string" \ | |
101 | "\"test string\".*" | |
13a5e3b8 | 102 | } |
c906108c SS |
103 | |
104 | #call str_func1(buf) | |
13a5e3b8 | 105 | if ![gdb_skip_stdio_test "call str_func1(buf)"] { |
452397af PA |
106 | gdb_test_stdio "call str_func1(buf)" \ |
107 | "first string arg is: test string" \ | |
108 | "\"test string\".*" | |
13a5e3b8 | 109 | } |
c906108c SS |
110 | |
111 | #print str_func("a","b","c","d","e","f","g") | |
13a5e3b8 | 112 | if ![gdb_skip_stdio_test "print str_func(a,b,c,d,e,f,g)"] { |
452397af PA |
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\".*" | |
13a5e3b8 | 116 | } |
c906108c SS |
117 | |
118 | #call str_func("a","b","c","d","e","f","g") | |
13a5e3b8 | 119 | if ![gdb_skip_stdio_test "call str_func(a,b,c,d,e,f,g)"] { |
452397af PA |
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\".*" | |
13a5e3b8 | 123 | } |
c906108c | 124 | |
085dd6e6 | 125 | #print str_func(s,s,s,s,s,s,s) |
13a5e3b8 | 126 | if ![gdb_skip_stdio_test "print str_func(s,s,s,s,s,s,s,s)"] { |
452397af PA |
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\".*" | |
13a5e3b8 | 130 | } |
c906108c | 131 | |
085dd6e6 | 132 | #call str_func(s,s,s,s,s,s,s) |
13a5e3b8 | 133 | if ![gdb_skip_stdio_test "call str_func(s,s,s,s,s,s,s,s)"] { |
452397af PA |
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\".*" | |
13a5e3b8 | 137 | } |
c906108c SS |
138 | |
139 | gdb_exit | |
97f2ed50 DJ |
140 | |
141 | set timeout $prev_timeout | |
142 |