gdb
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / remote.exp
CommitLineData
7b6bb8da 1# Copyright 1999, 2001, 2004, 2007, 2008, 2009, 2010, 2011
4c38e0a4 2# Free Software Foundation, Inc.
5c44784c
JM
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
5c44784c 7# (at your option) any later version.
e22f8b7c 8#
5c44784c
JM
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
e22f8b7c 13#
5c44784c 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
5c44784c 16
5c44784c
JM
17if $tracelevel then {
18 strace $tracelevel
19}
20
5c44784c
JM
21
22
23# test only on a remote target board
24if {! [is_remote target]} {
25 return
26}
27
5c44784c
JM
28set testfile "remote"
29set srcfile ${testfile}.c
30set binfile ${objdir}/${subdir}/${testfile}
31
11cf8741
JM
32gdb_start
33
34set result [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}]
35if {$result != "" } then {
b60f0898
JB
36 untested remote.exp
37 return -1
11cf8741
JM
38}
39
40
41#
42# Part ONE: Check the down load commands
43#
44
11cf8741
JM
45gdb_test "show remote memory-write-packet-size" \
46 "The memory-write-packet-size is 0. Packets are limited to \[0-9\]+ bytes." \
47 "write-packet default"
48
49gdb_test "set remote memory-write-packet-size" \
50 "Argument required .integer, `fixed' or `limited'.\." \
51 "set write-packet - NULL"
5c44784c 52
27d3a1a2 53gdb_test_no_output "set remote memory-write-packet-size 20"
11cf8741 54gdb_test "show remote memory-write-packet-size" \
f6c957d2 55 "The memory-write-packet-size is 20. Packets are limited to 20 bytes." \
11cf8741
JM
56 "set write-packet - small"
57
27d3a1a2 58gdb_test_no_output "set remote memory-write-packet-size 1"
11cf8741 59gdb_test "show remote memory-write-packet-size" \
f6c957d2 60 "The memory-write-packet-size is 1. Packets are limited to 20 bytes." \
11cf8741
JM
61 "set write-packet - very-small"
62
63#
64# Part TWO: Check the download behavour
65#
66
3d00d119 67proc gdb_load_timed {executable class writesize} {
5c44784c 68 global test gdb_prompt
3d00d119 69 set test "timed download `[file tail $executable]' - $class, $writesize"
5c44784c
JM
70
71 if {$writesize != ""} then {
27d3a1a2
MS
72 gdb_test_no_output "set remote memory-write-packet-size $writesize" \
73 "$test - set packet size"
11cf8741 74
11cf8741 75 send_gdb "set remote memory-write-packet-size $class\n"
5c44784c 76 gdb_expect 5 {
11cf8741
JM
77 -re ".*Change the packet size.*$" {
78 send_gdb "y\n"
79 gdb_expect 5 {
80 -re ".*$gdb_prompt $" {
81 pass "$test - set write size class"
82 }
83 timeout {
84 fail "$test - set write size class"
85 return
86 }
87 }
88 }
5c44784c 89 -re ".*$gdb_prompt $" { }
11cf8741
JM
90 timeout {
91 fail "$test - set write size class"
92 return
93 }
5c44784c
JM
94 }
95 }
96
4ac4dd3f
DJ
97 # Do not try to load using fixed sizes; we may overflow the remote target.
98 if { $class == "fixed" } {
99 return
100 }
101
5c44784c
JM
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
c2d11a7d 113# Typically about 400-1 bytes can be downloaded
3d00d119
DJ
114gdb_load_timed $binfile "limit" 398
115gdb_load_timed $binfile "limit" 400
5c44784c 116
11cf8741 117# Absolute max is 16384
3d00d119
DJ
118gdb_load_timed $binfile "fixed" 0
119gdb_load_timed $binfile "fixed" 16385
5c44784c 120
c2d11a7d 121# fall back to the default
3d00d119 122gdb_load_timed $binfile "limit" 0
c2d11a7d 123
de58f10f
SC
124# Get size of data uploaded
125
126#
127# Query GDB for the size of various types
128#
129
de58f10f
SC
130# Get the size of random_data table (defaults to 48K).
131set sizeof_random_data [get_sizeof "random_data" 48*1024]
c2d11a7d
JM
132
133#
134# Part THREE: Check the upload behavour
135#
de58f10f
SC
136if ![runto_main] then {
137 fail "Cannot run to main"
138}
c2d11a7d
JM
139
140# Carefully check memory around each of the most common packet edge
141# conditions
142
143gdb_test "x/8ub random_data" \
144 "<random_data>:\[ \t\]+60\[ \t\]+74\[ \t\]+216\[ \t\]+38\[ \t\]+149\[ \t\]+49\[ \t\]+207\[ \t\]+44"
145
146gdb_test "x/8ub random_data + 400 - 4" \
147 "<random_data\\+396>:\[ \t\]+185\[ \t\]+255\[ \t\]+50\[ \t\]+140\[ \t\]+237\[ \t\]+172\[ \t\]+143\[ \t\]+93"
148
de58f10f
SC
149if {$sizeof_random_data > 16380 } then {
150 gdb_test "x/8ub random_data + 16384 - 4" \
c2d11a7d 151 "<random_data\\+16380>:\[ \t\]+178\[ \t\]+180\[ \t\]+135\[ \t\]+93\[ \t\]+70\[ \t\]+62\[ \t\]+205\[ \t\]+76"
de58f10f 152}
c2d11a7d
JM
153
154# Read a chunk just larger than the packet size (reduce the packet
155# size to make life easier)
27d3a1a2
MS
156gdb_test_no_output "set remote memory-read-packet-size 16"
157
c2d11a7d 158gdb_test "show remote memory-read-packet-size" \
f6c957d2 159 "The memory-read-packet-size is 16. Packets are limited to 20 bytes."
c2d11a7d
JM
160gdb_test "x/17ub random_data" \
161 "<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"
162
5c44784c 163gdb_exit
This page took 1.074023 seconds and 4 git commands to generate.