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