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