Commit | Line | Data |
---|---|---|
42a4f53d | 1 | # Copyright 1999-2019 Free Software Foundation, Inc. |
5c44784c JM |
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 |
5c44784c | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
5c44784c JM |
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 | # |
5c44784c | 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/>. |
5c44784c | 15 | |
23fb630a PA |
16 | # Test only on boards that actually use the remote protocol. |
17 | if {[target_info gdb_protocol] != "remote" | |
18 | && [target_info gdb_protocol] != "extended-remote"} { | |
5c44784c JM |
19 | return |
20 | } | |
21 | ||
822bd149 | 22 | standard_testfile .c |
5c44784c | 23 | |
11cf8741 JM |
24 | set result [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] |
25 | if {$result != "" } then { | |
84c93cd5 | 26 | untested "failed to compile" |
b60f0898 | 27 | return -1 |
11cf8741 JM |
28 | } |
29 | ||
035522c0 PA |
30 | gdb_start |
31 | ||
32 | # Make sure we're disconnected, in case we're testing with an | |
33 | # extended-remote board, therefore already connected. | |
34 | gdb_test "disconnect" ".*" | |
11cf8741 JM |
35 | |
36 | # | |
37 | # Part ONE: Check the down load commands | |
38 | # | |
39 | ||
11cf8741 | 40 | gdb_test "show remote memory-write-packet-size" \ |
cc0be08f | 41 | "The memory-write-packet-size is 0 \\(default\\). The actual limit will be further reduced dependent on the target\." \ |
11cf8741 JM |
42 | "write-packet default" |
43 | ||
44 | gdb_test "set remote memory-write-packet-size" \ | |
45 | "Argument required .integer, `fixed' or `limited'.\." \ | |
46 | "set write-packet - NULL" | |
5c44784c | 47 | |
27d3a1a2 | 48 | gdb_test_no_output "set remote memory-write-packet-size 20" |
11cf8741 | 49 | gdb_test "show remote memory-write-packet-size" \ |
cc0be08f | 50 | "The memory-write-packet-size is 20. The actual limit will be further reduced dependent on the target\." \ |
11cf8741 JM |
51 | "set write-packet - small" |
52 | ||
27d3a1a2 | 53 | gdb_test_no_output "set remote memory-write-packet-size 1" |
11cf8741 | 54 | gdb_test "show remote memory-write-packet-size" \ |
cc0be08f | 55 | "The memory-write-packet-size is 1. The actual limit will be further reduced dependent on the target\." \ |
11cf8741 JM |
56 | "set write-packet - very-small" |
57 | ||
cc0be08f PA |
58 | gdb_test_no_output "set remote memory-write-packet-size 0" |
59 | gdb_test "show remote memory-write-packet-size" \ | |
60 | "The memory-write-packet-size is 0 \\(default\\). The actual limit will be further reduced dependent on the target\." \ | |
61 | "write-packet default again" | |
62 | ||
63 | set test "set remote memory-write-packet-size fixed" | |
64 | gdb_test_multiple $test $test { | |
65 | -re "Change the packet size. .y or n. " { | |
66 | gdb_test_multiple "y" $test { | |
67 | -re "$gdb_prompt $" { | |
68 | pass $test | |
69 | } | |
70 | } | |
71 | } | |
72 | } | |
73 | gdb_test "show remote memory-write-packet-size" \ | |
74 | "The memory-write-packet-size is 0 \\(default\\). Packets are fixed at 16384 bytes\." \ | |
75 | "write-packet default fixed" | |
76 | ||
77 | gdb_test_no_output "set remote memory-write-packet-size limit" | |
78 | gdb_test "show remote memory-write-packet-size" \ | |
79 | "The memory-write-packet-size is 0 \\(default\\). The actual limit will be further reduced dependent on the target\." \ | |
80 | "write-packet default limit again" | |
81 | ||
11cf8741 | 82 | # |
cc77b1dc | 83 | # Part TWO: Check the download behavior. |
11cf8741 JM |
84 | # |
85 | ||
3d00d119 | 86 | proc gdb_load_timed {executable class writesize} { |
5c44784c | 87 | global test gdb_prompt |
3d00d119 | 88 | set test "timed download `[file tail $executable]' - $class, $writesize" |
5c44784c JM |
89 | |
90 | if {$writesize != ""} then { | |
27d3a1a2 MS |
91 | gdb_test_no_output "set remote memory-write-packet-size $writesize" \ |
92 | "$test - set packet size" | |
11cf8741 | 93 | |
11cf8741 | 94 | send_gdb "set remote memory-write-packet-size $class\n" |
5c44784c | 95 | gdb_expect 5 { |
11cf8741 JM |
96 | -re ".*Change the packet size.*$" { |
97 | send_gdb "y\n" | |
98 | gdb_expect 5 { | |
99 | -re ".*$gdb_prompt $" { | |
100 | pass "$test - set write size class" | |
101 | } | |
102 | timeout { | |
103 | fail "$test - set write size class" | |
104 | return | |
105 | } | |
106 | } | |
107 | } | |
5c44784c | 108 | -re ".*$gdb_prompt $" { } |
11cf8741 JM |
109 | timeout { |
110 | fail "$test - set write size class" | |
111 | return | |
112 | } | |
5c44784c JM |
113 | } |
114 | } | |
115 | ||
4ac4dd3f DJ |
116 | # Do not try to load using fixed sizes; we may overflow the remote target. |
117 | if { $class == "fixed" } { | |
118 | return | |
119 | } | |
120 | ||
5c44784c JM |
121 | set load_begin_time [clock clicks] |
122 | set result [gdb_load $executable] | |
123 | set load_end_time [clock clicks] | |
2db8e78e | 124 | if { $result != 0 } then { |
3e3ffd2b MC |
125 | fail "$test - loading executable" |
126 | return | |
127 | } | |
5c44784c JM |
128 | verbose "$test - time [expr ($load_end_time - $load_begin_time) / 1000] ms" |
129 | pass $test | |
130 | } | |
131 | ||
035522c0 PA |
132 | clean_restart $binfile |
133 | ||
23fb630a PA |
134 | # These download tests won't actually download anything on !is_remote |
135 | # target boards, but we run them anyway because it's simpler, and | |
136 | # harmless. | |
137 | ||
c2d11a7d | 138 | # Typically about 400-1 bytes can be downloaded |
3d00d119 DJ |
139 | gdb_load_timed $binfile "limit" 398 |
140 | gdb_load_timed $binfile "limit" 400 | |
5c44784c | 141 | |
11cf8741 | 142 | # Absolute max is 16384 |
3d00d119 DJ |
143 | gdb_load_timed $binfile "fixed" 0 |
144 | gdb_load_timed $binfile "fixed" 16385 | |
5c44784c | 145 | |
c2d11a7d | 146 | # fall back to the default |
3d00d119 | 147 | gdb_load_timed $binfile "limit" 0 |
c2d11a7d | 148 | |
de58f10f SC |
149 | # Get size of data uploaded |
150 | ||
151 | # | |
152 | # Query GDB for the size of various types | |
153 | # | |
154 | ||
de58f10f SC |
155 | # Get the size of random_data table (defaults to 48K). |
156 | set sizeof_random_data [get_sizeof "random_data" 48*1024] | |
c2d11a7d JM |
157 | |
158 | # | |
159 | # Part THREE: Check the upload behavour | |
160 | # | |
de58f10f | 161 | if ![runto_main] then { |
bc6c7af4 | 162 | fail "cannot run to main" |
cc77b1dc | 163 | return |
de58f10f | 164 | } |
c2d11a7d JM |
165 | |
166 | # Carefully check memory around each of the most common packet edge | |
167 | # conditions | |
168 | ||
169 | gdb_test "x/8ub random_data" \ | |
170 | "<random_data>:\[ \t\]+60\[ \t\]+74\[ \t\]+216\[ \t\]+38\[ \t\]+149\[ \t\]+49\[ \t\]+207\[ \t\]+44" | |
171 | ||
172 | gdb_test "x/8ub random_data + 400 - 4" \ | |
173 | "<random_data\\+396>:\[ \t\]+185\[ \t\]+255\[ \t\]+50\[ \t\]+140\[ \t\]+237\[ \t\]+172\[ \t\]+143\[ \t\]+93" | |
174 | ||
de58f10f SC |
175 | if {$sizeof_random_data > 16380 } then { |
176 | gdb_test "x/8ub random_data + 16384 - 4" \ | |
c2d11a7d | 177 | "<random_data\\+16380>:\[ \t\]+178\[ \t\]+180\[ \t\]+135\[ \t\]+93\[ \t\]+70\[ \t\]+62\[ \t\]+205\[ \t\]+76" |
de58f10f | 178 | } |
c2d11a7d JM |
179 | |
180 | # Read a chunk just larger than the packet size (reduce the packet | |
181 | # size to make life easier) | |
27d3a1a2 MS |
182 | gdb_test_no_output "set remote memory-read-packet-size 16" |
183 | ||
c2d11a7d | 184 | gdb_test "show remote memory-read-packet-size" \ |
f6c957d2 | 185 | "The memory-read-packet-size is 16. Packets are limited to 20 bytes." |
c2d11a7d JM |
186 | gdb_test "x/17ub random_data" \ |
187 | "<random_data>:\[ \t\]+60\[ \t\]+74\[ \t\]+216\[ \t\]+38\[ \t\]+149\[ \t\]+49\[ \t\]+207\[ \t\]+44.*<random_data\\+8>:\[ \t\]+124\[ \t\]+38\[ \t\]+93\[ \t\]+125\[ \t\]+232\[ \t\]+67\[ \t\]+228\[ \t\]+56.*<random_data\\+16>:\[ \t\]+161" | |
188 | ||
ef0026f0 PA |
189 | # Regression test for gdb/15289. Make sure -1 is accepted and handled |
190 | # as "unlimited". | |
191 | gdb_test_no_output "set remote hardware-watchpoint-limit -1" | |
192 | gdb_test_no_output "set remote hardware-breakpoint-limit -1" | |
193 | ||
194 | # This is just being thorough. Assume (at least) a 32-bit host int, | |
195 | # and make sure 32-bit INT_MAX is accepted by a zinteger command. | |
196 | gdb_test_no_output "set remote hardware-watchpoint-limit 2147483647" | |
197 | gdb_test_no_output "set remote hardware-breakpoint-limit 2147483647" | |
198 | ||
5c44784c | 199 | gdb_exit |