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