1 # Copyright 1999 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 2 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, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
28 # test only on a remote target board
29 if {! [is_remote target]} {
35 set srcfile ${testfile}.c
36 set binfile ${objdir}/${subdir}/${testfile}
40 set result [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}]
41 if {$result != "" } then {
42 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
47 # Part ONE: Check the down load commands
50 gdb_test "show download-write-size" \
51 "The write size used when downloading a program is 512." \
52 "download limit default"
54 gdb_test "set download-write-size" "Argument required.*"
56 gdb_test "set download-write-size 0" ""
57 gdb_test "show download-write-size" \
58 "The write size used when downloading a program is unlimited." \
59 "set download limit - unlimited"
61 gdb_test "show remote memory-write-packet-size" \
62 "The memory-write-packet-size is 0. Packets are limited to \[0-9\]+ bytes." \
63 "write-packet default"
65 gdb_test "set remote memory-write-packet-size" \
66 "Argument required .integer, `fixed' or `limited'.\." \
67 "set write-packet - NULL"
69 gdb_test "set remote memory-write-packet-size 16" ""
70 gdb_test "show remote memory-write-packet-size" \
71 "The memory-write-packet-size is 16. Packets are limited to 16 bytes." \
72 "set write-packet - small"
74 gdb_test "set remote memory-write-packet-size 1" ""
75 gdb_test "show remote memory-write-packet-size" \
76 "The memory-write-packet-size is 1. Packets are limited to 16 bytes." \
77 "set write-packet - very-small"
80 # Part TWO: Check the download behavour
83 proc gdb_load_timed {executable downloadsize class writesize} {
84 global test gdb_prompt
85 set test "timed download `[file tail $executable]' - $downloadsize, $class, $writesize"
87 if {$writesize != ""} then {
88 gdb_test "set remote memory-write-packet-size $writesize" \
89 "" "$test - set packet size"
92 if {$downloadsize != ""} then {
93 gdb_test "set download-write-size $downloadsize" \
94 "" "$test - set download size"
97 if {$downloadsize != ""} then {
98 send_gdb "set remote memory-write-packet-size $class\n"
100 -re ".*Change the packet size.*$" {
103 -re ".*$gdb_prompt $" {
104 pass "$test - set write size class"
107 fail "$test - set write size class"
112 -re ".*$gdb_prompt $" { }
114 fail "$test - set write size class"
120 set load_begin_time [clock clicks]
121 set result [gdb_load $executable]
122 set load_end_time [clock clicks]
123 if {$result < 0} then { fail "$test - loading executable"; return }
124 verbose "$test - time [expr ($load_end_time - $load_begin_time) / 1000] ms"
128 gdb_load_timed $binfile {} "" {}
130 # Typically about 400-1 bytes can be downloaded
131 gdb_load_timed $binfile 0 "limit" 398
132 gdb_load_timed $binfile 0 "limit" 400
134 # Absolute max is 16384
135 gdb_load_timed $binfile 0 "fixed" 0
136 gdb_load_timed $binfile 0 "fixed" 16385
138 # fall back to the default
139 gdb_load_timed $binfile 0 "limit" 0
143 # Part THREE: Check the upload behavour
146 # Carefully check memory around each of the most common packet edge
149 gdb_test "x/8ub random_data" \
150 "<random_data>:\[ \t\]+60\[ \t\]+74\[ \t\]+216\[ \t\]+38\[ \t\]+149\[ \t\]+49\[ \t\]+207\[ \t\]+44"
152 gdb_test "x/8ub random_data + 400 - 4" \
153 "<random_data\\+396>:\[ \t\]+185\[ \t\]+255\[ \t\]+50\[ \t\]+140\[ \t\]+237\[ \t\]+172\[ \t\]+143\[ \t\]+93"
155 gdb_test "x/8ub random_data + 16384 - 4" \
156 "<random_data\\+16380>:\[ \t\]+178\[ \t\]+180\[ \t\]+135\[ \t\]+93\[ \t\]+70\[ \t\]+62\[ \t\]+205\[ \t\]+76"
159 # Read a chunk just larger than the packet size (reduce the packet
160 # size to make life easier)
161 gdb_test "set remote memory-read-packet-size 16" \
163 gdb_test "show remote memory-read-packet-size" \
164 "The memory-read-packet-size is 16. Packets are limited to 16 bytes."
165 gdb_test "x/17ub random_data" \
166 "<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"