1 # Copyright 1999, 2001, 2004, 2007-2012 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 # test only on a remote target board
23 if {! [is_remote target]} {
28 set srcfile ${testfile}.c
29 set binfile ${objdir}/${subdir}/${testfile}
33 set result [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}]
34 if {$result != "" } then {
41 # Part ONE: Check the down load commands
44 gdb_test "show remote memory-write-packet-size" \
45 "The memory-write-packet-size is 0. Packets are limited to \[0-9\]+ bytes." \
46 "write-packet default"
48 gdb_test "set remote memory-write-packet-size" \
49 "Argument required .integer, `fixed' or `limited'.\." \
50 "set write-packet - NULL"
52 gdb_test_no_output "set remote memory-write-packet-size 20"
53 gdb_test "show remote memory-write-packet-size" \
54 "The memory-write-packet-size is 20. Packets are limited to 20 bytes." \
55 "set write-packet - small"
57 gdb_test_no_output "set remote memory-write-packet-size 1"
58 gdb_test "show remote memory-write-packet-size" \
59 "The memory-write-packet-size is 1. Packets are limited to 20 bytes." \
60 "set write-packet - very-small"
63 # Part TWO: Check the download behavour
66 proc gdb_load_timed {executable class writesize} {
67 global test gdb_prompt
68 set test "timed download `[file tail $executable]' - $class, $writesize"
70 if {$writesize != ""} then {
71 gdb_test_no_output "set remote memory-write-packet-size $writesize" \
72 "$test - set packet size"
74 send_gdb "set remote memory-write-packet-size $class\n"
76 -re ".*Change the packet size.*$" {
79 -re ".*$gdb_prompt $" {
80 pass "$test - set write size class"
83 fail "$test - set write size class"
88 -re ".*$gdb_prompt $" { }
90 fail "$test - set write size class"
96 # Do not try to load using fixed sizes; we may overflow the remote target.
97 if { $class == "fixed" } {
101 set load_begin_time [clock clicks]
102 set result [gdb_load $executable]
103 set load_end_time [clock clicks]
104 if { $result != 0 } then {
105 fail "$test - loading executable"
108 verbose "$test - time [expr ($load_end_time - $load_begin_time) / 1000] ms"
112 # Typically about 400-1 bytes can be downloaded
113 gdb_load_timed $binfile "limit" 398
114 gdb_load_timed $binfile "limit" 400
116 # Absolute max is 16384
117 gdb_load_timed $binfile "fixed" 0
118 gdb_load_timed $binfile "fixed" 16385
120 # fall back to the default
121 gdb_load_timed $binfile "limit" 0
123 # Get size of data uploaded
126 # Query GDB for the size of various types
129 # Get the size of random_data table (defaults to 48K).
130 set sizeof_random_data [get_sizeof "random_data" 48*1024]
133 # Part THREE: Check the upload behavour
135 if ![runto_main] then {
136 fail "Cannot run to main"
139 # Carefully check memory around each of the most common packet edge
142 gdb_test "x/8ub random_data" \
143 "<random_data>:\[ \t\]+60\[ \t\]+74\[ \t\]+216\[ \t\]+38\[ \t\]+149\[ \t\]+49\[ \t\]+207\[ \t\]+44"
145 gdb_test "x/8ub random_data + 400 - 4" \
146 "<random_data\\+396>:\[ \t\]+185\[ \t\]+255\[ \t\]+50\[ \t\]+140\[ \t\]+237\[ \t\]+172\[ \t\]+143\[ \t\]+93"
148 if {$sizeof_random_data > 16380 } then {
149 gdb_test "x/8ub random_data + 16384 - 4" \
150 "<random_data\\+16380>:\[ \t\]+178\[ \t\]+180\[ \t\]+135\[ \t\]+93\[ \t\]+70\[ \t\]+62\[ \t\]+205\[ \t\]+76"
153 # Read a chunk just larger than the packet size (reduce the packet
154 # size to make life easier)
155 gdb_test_no_output "set remote memory-read-packet-size 16"
157 gdb_test "show remote memory-read-packet-size" \
158 "The memory-read-packet-size is 16. Packets are limited to 20 bytes."
159 gdb_test "x/17ub random_data" \
160 "<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"