]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.arch/riscv-bp-infcall.exp
Automatic date update in version.in
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / riscv-bp-infcall.exp
1 # Copyright 2019-2024 Free Software Foundation, Inc.
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 3 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, see <http://www.gnu.org/licenses/>.
15
16 # Test GDB for RISC-V always uses an uncompressed breakpoint when
17 # setting up for an inferior call.
18
19 require {istarget "riscv*-*-*"}
20
21 standard_testfile
22
23 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
24 return -1
25 }
26
27 if {![runto_main]} {
28 return 0
29 }
30
31 # Figure out where the breakpoint will be placed taking account for
32 # stack alignment, and allocation of the dummy code area.
33 set bp_addr [get_valueof "/x" "\$sp" 0]
34 set bp_addr [format 0x%x [expr ($bp_addr & ~0xf) - 0x20]]
35
36 # Fill the region we know will be used as the scratch area with the
37 # compressed nop instruction. If GDB fails to overwrite this with an
38 # uncompressed nop then a compressed breakpoint will be used in the
39 # following inferior call.
40 for {set i 0} {$i < 16} {incr i 2} {
41 gdb_test_no_output "set *((unsigned short *) (${bp_addr} + $i))=0x1" \
42 "place compressed nop in scratch area at offset $i"
43 }
44
45 # Make an inferior call. GDB should write an uncompressed nop into
46 # the scratch area and so force the use of an uncompressed breakpoint,
47 # however, if this mechanism fails and GDB uses a compressed
48 # breakpoint, and the target doesn't support compressed instructions,
49 # then we would expect weird things to happen here.
50 gdb_test_no_output "set debug riscv breakpoints 1"
51 gdb_test "call dummy_call ()" \
52 ".*Using EBREAK for breakpoint at $bp_addr \\(instruction length 4\\).*"