]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - 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
CommitLineData
1d506c26 1# Copyright 2019-2024 Free Software Foundation, Inc.
01e175fe
AB
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
73c06197 19require {istarget "riscv*-*-*"}
01e175fe
AB
20
21standard_testfile
22
23if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
24 return -1
25}
26
75b6f386 27if {![runto_main]} {
01e175fe
AB
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.
33set bp_addr [get_valueof "/x" "\$sp" 0]
34set 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.
40for {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.
50gdb_test_no_output "set debug riscv breakpoints 1"
51gdb_test "call dummy_call ()" \
52 ".*Using EBREAK for breakpoint at $bp_addr \\(instruction length 4\\).*"