]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/remote.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / remote.exp
CommitLineData
1d506c26 1# Copyright 1999-2024 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
23fb630a
PA
16# Test only on boards that actually use the remote protocol.
17if {[target_info gdb_protocol] != "remote"
18 && [target_info gdb_protocol] != "extended-remote"} {
e0a8643d 19 unsupported "requires remote protocol"
5c44784c
JM
20 return
21}
22
822bd149 23standard_testfile .c
5c44784c 24
11cf8741 25set result [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}]
65a33d75 26if {$result != ""} {
84c93cd5 27 untested "failed to compile"
b60f0898 28 return -1
11cf8741
JM
29}
30
035522c0
PA
31gdb_start
32
33# Make sure we're disconnected, in case we're testing with an
34# extended-remote board, therefore already connected.
35gdb_test "disconnect" ".*"
11cf8741
JM
36
37#
38# Part ONE: Check the down load commands
39#
40
11cf8741 41gdb_test "show remote memory-write-packet-size" \
fe4c3ca0 42 "The memory-write-packet-size on future remote targets is 0 \\(default\\). The actual limit will be further reduced dependent on the target\." \
11cf8741
JM
43 "write-packet default"
44
45gdb_test "set remote memory-write-packet-size" \
fe4c3ca0 46 "Argument required .integer, \"fixed\" or \"limit\".\." \
11cf8741 47 "set write-packet - NULL"
5c44784c 48
fe4c3ca0
CS
49gdb_test "set remote memory-write-packet-size 20" \
50 "The memory-write-packet-size on future remote targets is set to \"20\"."
51
11cf8741 52gdb_test "show remote memory-write-packet-size" \
fe4c3ca0 53 "The memory-write-packet-size on future remote targets is 20. The actual limit will be further reduced dependent on the target\." \
11cf8741
JM
54 "set write-packet - small"
55
fe4c3ca0
CS
56gdb_test "set remote memory-write-packet-size 1" \
57 "The memory-write-packet-size on future remote targets is set to \"1\"."
58
11cf8741 59gdb_test "show remote memory-write-packet-size" \
fe4c3ca0 60 "The memory-write-packet-size on future remote targets is 1. The actual limit will be further reduced dependent on the target\." \
11cf8741
JM
61 "set write-packet - very-small"
62
fe4c3ca0
CS
63gdb_test "set remote memory-write-packet-size 0" \
64 "The memory-write-packet-size on future remote targets is set to \"0\"."
65
cc0be08f 66gdb_test "show remote memory-write-packet-size" \
fe4c3ca0 67 "The memory-write-packet-size on future remote targets is 0 \\(default\\). The actual limit will be further reduced dependent on the target\." \
cc0be08f
PA
68 "write-packet default again"
69
70set test "set remote memory-write-packet-size fixed"
71gdb_test_multiple $test $test {
fe4c3ca0 72 -re "Change the packet size for future remote targets. .y or n. " {
cc0be08f
PA
73 gdb_test_multiple "y" $test {
74 -re "$gdb_prompt $" {
75 pass $test
76 }
77 }
78 }
79}
fe4c3ca0 80
cc0be08f 81gdb_test "show remote memory-write-packet-size" \
fe4c3ca0 82 "The memory-write-packet-size on future remote targets is 0 \\(default\\). Packets are fixed at 16384 bytes\." \
cc0be08f
PA
83 "write-packet default fixed"
84
fe4c3ca0
CS
85gdb_test "set remote memory-write-packet-size limit" \
86 "The memory-write-packet-size on future remote targets is set to \"limit\"."
87
cc0be08f 88gdb_test "show remote memory-write-packet-size" \
fe4c3ca0 89 "The memory-write-packet-size on future remote targets is 0 \\(default\\). The actual limit will be further reduced dependent on the target\." \
cc0be08f
PA
90 "write-packet default limit again"
91
11cf8741 92#
cc77b1dc 93# Part TWO: Check the download behavior.
11cf8741
JM
94#
95
3d00d119 96proc gdb_load_timed {executable class writesize} {
5c44784c 97 global test gdb_prompt
3d00d119 98 set test "timed download `[file tail $executable]' - $class, $writesize"
5c44784c 99
65a33d75 100 if {$writesize != ""} {
fe4c3ca0
CS
101 gdb_test "set remote memory-write-packet-size $writesize" \
102 "The memory-write-packet-size on future remote targets is set to \"$writesize\"." \
27d3a1a2 103 "$test - set packet size"
11cf8741 104
11cf8741 105 send_gdb "set remote memory-write-packet-size $class\n"
5c44784c 106 gdb_expect 5 {
11cf8741
JM
107 -re ".*Change the packet size.*$" {
108 send_gdb "y\n"
109 gdb_expect 5 {
110 -re ".*$gdb_prompt $" {
111 pass "$test - set write size class"
112 }
113 timeout {
114 fail "$test - set write size class"
115 return
116 }
117 }
118 }
5c44784c 119 -re ".*$gdb_prompt $" { }
11cf8741
JM
120 timeout {
121 fail "$test - set write size class"
122 return
123 }
5c44784c
JM
124 }
125 }
126
4ac4dd3f
DJ
127 # Do not try to load using fixed sizes; we may overflow the remote target.
128 if { $class == "fixed" } {
129 return
130 }
131
5c44784c
JM
132 set load_begin_time [clock clicks]
133 set result [gdb_load $executable]
134 set load_end_time [clock clicks]
65a33d75 135 if {$result != 0} {
3e3ffd2b
MC
136 fail "$test - loading executable"
137 return
138 }
5c44784c
JM
139 verbose "$test - time [expr ($load_end_time - $load_begin_time) / 1000] ms"
140 pass $test
141}
142
23fb630a
PA
143# These download tests won't actually download anything on !is_remote
144# target boards, but we run them anyway because it's simpler, and
145# harmless.
146
c2d11a7d 147# Typically about 400-1 bytes can be downloaded
3d00d119
DJ
148gdb_load_timed $binfile "limit" 398
149gdb_load_timed $binfile "limit" 400
5c44784c 150
11cf8741 151# Absolute max is 16384
3d00d119
DJ
152gdb_load_timed $binfile "fixed" 0
153gdb_load_timed $binfile "fixed" 16385
5c44784c 154
c2d11a7d 155# fall back to the default
3d00d119 156gdb_load_timed $binfile "limit" 0
c2d11a7d 157
de58f10f
SC
158# Get size of data uploaded
159
160#
161# Query GDB for the size of various types
162#
163
de58f10f
SC
164# Get the size of random_data table (defaults to 48K).
165set sizeof_random_data [get_sizeof "random_data" 48*1024]
c2d11a7d 166
fe4c3ca0
CS
167clean_restart $binfile
168
c2d11a7d
JM
169#
170# Part THREE: Check the upload behavour
171#
65a33d75 172if {![runto_main]} {
cc77b1dc 173 return
de58f10f 174}
c2d11a7d
JM
175
176# Carefully check memory around each of the most common packet edge
177# conditions
178
179gdb_test "x/8ub random_data" \
180 "<random_data>:\[ \t\]+60\[ \t\]+74\[ \t\]+216\[ \t\]+38\[ \t\]+149\[ \t\]+49\[ \t\]+207\[ \t\]+44"
181
182gdb_test "x/8ub random_data + 400 - 4" \
183 "<random_data\\+396>:\[ \t\]+185\[ \t\]+255\[ \t\]+50\[ \t\]+140\[ \t\]+237\[ \t\]+172\[ \t\]+143\[ \t\]+93"
184
65a33d75 185if {$sizeof_random_data > 16380} {
de58f10f 186 gdb_test "x/8ub random_data + 16384 - 4" \
c2d11a7d 187 "<random_data\\+16380>:\[ \t\]+178\[ \t\]+180\[ \t\]+135\[ \t\]+93\[ \t\]+70\[ \t\]+62\[ \t\]+205\[ \t\]+76"
de58f10f 188}
c2d11a7d
JM
189
190# Read a chunk just larger than the packet size (reduce the packet
191# size to make life easier)
fe4c3ca0
CS
192gdb_test "set remote memory-read-packet-size 16" \
193 "The memory-read-packet-size on the current remote target is set to \"16\"."
27d3a1a2 194
c2d11a7d 195gdb_test "show remote memory-read-packet-size" \
fe4c3ca0 196 "The memory-read-packet-size on the current remote target is 16. Packets are limited to 20 bytes."
c2d11a7d
JM
197gdb_test "x/17ub random_data" \
198 "<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"
199
ef0026f0
PA
200# Regression test for gdb/15289. Make sure -1 is accepted and handled
201# as "unlimited".
202gdb_test_no_output "set remote hardware-watchpoint-limit -1"
203gdb_test_no_output "set remote hardware-breakpoint-limit -1"
204
205# This is just being thorough. Assume (at least) a 32-bit host int,
206# and make sure 32-bit INT_MAX is accepted by a zinteger command.
207gdb_test_no_output "set remote hardware-watchpoint-limit 2147483647"
208gdb_test_no_output "set remote hardware-breakpoint-limit 2147483647"
209
5f21c7aa
AB
210# Check the X/P/p alias commands display the correct packet names.
211foreach pkt {X P p} {
ff52c073 212 gdb_test "show remote ${pkt}-packet" "Support for the '${pkt}' packet on the current remote target is .*"
5f21c7aa
AB
213}
214
5c44784c 215gdb_exit