Commit | Line | Data |
---|---|---|
28e7fd62 | 1 | # Copyright 1999-2013 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 | |
5c44784c JM |
16 | |
17 | ||
18 | # test only on a remote target board | |
19 | if {! [is_remote target]} { | |
20 | return | |
21 | } | |
22 | ||
822bd149 | 23 | standard_testfile .c |
5c44784c | 24 | |
11cf8741 JM |
25 | gdb_start |
26 | ||
27 | set result [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] | |
28 | if {$result != "" } then { | |
b60f0898 JB |
29 | untested remote.exp |
30 | return -1 | |
11cf8741 JM |
31 | } |
32 | ||
33 | ||
34 | # | |
35 | # Part ONE: Check the down load commands | |
36 | # | |
37 | ||
11cf8741 JM |
38 | gdb_test "show remote memory-write-packet-size" \ |
39 | "The memory-write-packet-size is 0. Packets are limited to \[0-9\]+ bytes." \ | |
40 | "write-packet default" | |
41 | ||
42 | gdb_test "set remote memory-write-packet-size" \ | |
43 | "Argument required .integer, `fixed' or `limited'.\." \ | |
44 | "set write-packet - NULL" | |
5c44784c | 45 | |
27d3a1a2 | 46 | gdb_test_no_output "set remote memory-write-packet-size 20" |
11cf8741 | 47 | gdb_test "show remote memory-write-packet-size" \ |
f6c957d2 | 48 | "The memory-write-packet-size is 20. Packets are limited to 20 bytes." \ |
11cf8741 JM |
49 | "set write-packet - small" |
50 | ||
27d3a1a2 | 51 | gdb_test_no_output "set remote memory-write-packet-size 1" |
11cf8741 | 52 | gdb_test "show remote memory-write-packet-size" \ |
f6c957d2 | 53 | "The memory-write-packet-size is 1. Packets are limited to 20 bytes." \ |
11cf8741 JM |
54 | "set write-packet - very-small" |
55 | ||
56 | # | |
57 | # Part TWO: Check the download behavour | |
58 | # | |
59 | ||
3d00d119 | 60 | proc gdb_load_timed {executable class writesize} { |
5c44784c | 61 | global test gdb_prompt |
3d00d119 | 62 | set test "timed download `[file tail $executable]' - $class, $writesize" |
5c44784c JM |
63 | |
64 | if {$writesize != ""} then { | |
27d3a1a2 MS |
65 | gdb_test_no_output "set remote memory-write-packet-size $writesize" \ |
66 | "$test - set packet size" | |
11cf8741 | 67 | |
11cf8741 | 68 | send_gdb "set remote memory-write-packet-size $class\n" |
5c44784c | 69 | gdb_expect 5 { |
11cf8741 JM |
70 | -re ".*Change the packet size.*$" { |
71 | send_gdb "y\n" | |
72 | gdb_expect 5 { | |
73 | -re ".*$gdb_prompt $" { | |
74 | pass "$test - set write size class" | |
75 | } | |
76 | timeout { | |
77 | fail "$test - set write size class" | |
78 | return | |
79 | } | |
80 | } | |
81 | } | |
5c44784c | 82 | -re ".*$gdb_prompt $" { } |
11cf8741 JM |
83 | timeout { |
84 | fail "$test - set write size class" | |
85 | return | |
86 | } | |
5c44784c JM |
87 | } |
88 | } | |
89 | ||
4ac4dd3f DJ |
90 | # Do not try to load using fixed sizes; we may overflow the remote target. |
91 | if { $class == "fixed" } { | |
92 | return | |
93 | } | |
94 | ||
5c44784c JM |
95 | set load_begin_time [clock clicks] |
96 | set result [gdb_load $executable] | |
97 | set load_end_time [clock clicks] | |
2db8e78e | 98 | if { $result != 0 } then { |
3e3ffd2b MC |
99 | fail "$test - loading executable" |
100 | return | |
101 | } | |
5c44784c JM |
102 | verbose "$test - time [expr ($load_end_time - $load_begin_time) / 1000] ms" |
103 | pass $test | |
104 | } | |
105 | ||
c2d11a7d | 106 | # Typically about 400-1 bytes can be downloaded |
3d00d119 DJ |
107 | gdb_load_timed $binfile "limit" 398 |
108 | gdb_load_timed $binfile "limit" 400 | |
5c44784c | 109 | |
11cf8741 | 110 | # Absolute max is 16384 |
3d00d119 DJ |
111 | gdb_load_timed $binfile "fixed" 0 |
112 | gdb_load_timed $binfile "fixed" 16385 | |
5c44784c | 113 | |
c2d11a7d | 114 | # fall back to the default |
3d00d119 | 115 | gdb_load_timed $binfile "limit" 0 |
c2d11a7d | 116 | |
de58f10f SC |
117 | # Get size of data uploaded |
118 | ||
119 | # | |
120 | # Query GDB for the size of various types | |
121 | # | |
122 | ||
de58f10f SC |
123 | # Get the size of random_data table (defaults to 48K). |
124 | set sizeof_random_data [get_sizeof "random_data" 48*1024] | |
c2d11a7d JM |
125 | |
126 | # | |
127 | # Part THREE: Check the upload behavour | |
128 | # | |
de58f10f SC |
129 | if ![runto_main] then { |
130 | fail "Cannot run to main" | |
131 | } | |
c2d11a7d JM |
132 | |
133 | # Carefully check memory around each of the most common packet edge | |
134 | # conditions | |
135 | ||
136 | gdb_test "x/8ub random_data" \ | |
137 | "<random_data>:\[ \t\]+60\[ \t\]+74\[ \t\]+216\[ \t\]+38\[ \t\]+149\[ \t\]+49\[ \t\]+207\[ \t\]+44" | |
138 | ||
139 | gdb_test "x/8ub random_data + 400 - 4" \ | |
140 | "<random_data\\+396>:\[ \t\]+185\[ \t\]+255\[ \t\]+50\[ \t\]+140\[ \t\]+237\[ \t\]+172\[ \t\]+143\[ \t\]+93" | |
141 | ||
de58f10f SC |
142 | if {$sizeof_random_data > 16380 } then { |
143 | gdb_test "x/8ub random_data + 16384 - 4" \ | |
c2d11a7d | 144 | "<random_data\\+16380>:\[ \t\]+178\[ \t\]+180\[ \t\]+135\[ \t\]+93\[ \t\]+70\[ \t\]+62\[ \t\]+205\[ \t\]+76" |
de58f10f | 145 | } |
c2d11a7d JM |
146 | |
147 | # Read a chunk just larger than the packet size (reduce the packet | |
148 | # size to make life easier) | |
27d3a1a2 MS |
149 | gdb_test_no_output "set remote memory-read-packet-size 16" |
150 | ||
c2d11a7d | 151 | gdb_test "show remote memory-read-packet-size" \ |
f6c957d2 | 152 | "The memory-read-packet-size is 16. Packets are limited to 20 bytes." |
c2d11a7d JM |
153 | gdb_test "x/17ub random_data" \ |
154 | "<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" | |
155 | ||
ef0026f0 PA |
156 | # Regression test for gdb/15289. Make sure -1 is accepted and handled |
157 | # as "unlimited". | |
158 | gdb_test_no_output "set remote hardware-watchpoint-limit -1" | |
159 | gdb_test_no_output "set remote hardware-breakpoint-limit -1" | |
160 | ||
161 | # This is just being thorough. Assume (at least) a 32-bit host int, | |
162 | # and make sure 32-bit INT_MAX is accepted by a zinteger command. | |
163 | gdb_test_no_output "set remote hardware-watchpoint-limit 2147483647" | |
164 | gdb_test_no_output "set remote hardware-breakpoint-limit 2147483647" | |
165 | ||
5c44784c | 166 | gdb_exit |