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