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