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