gdb: Allow GDB to _not_ load a previous command history
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.arch / riscv-bp-infcall.exp
CommitLineData
b811d2c2 1# Copyright 2019-2020 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
19if {![istarget "riscv*-*-*"]} {
20 verbose "Skipping ${gdb_test_file_name}."
21 return
22}
23
24standard_testfile
25
26if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
27 return -1
28}
29
30if ![runto_main] then {
31 fail "can't run to main"
32 return 0
33}
34
35# Figure out where the breakpoint will be placed taking account for
36# stack alignment, and allocation of the dummy code area.
37set bp_addr [get_valueof "/x" "\$sp" 0]
38set bp_addr [format 0x%x [expr ($bp_addr & ~0xf) - 0x20]]
39
40# Fill the region we know will be used as the scratch area with the
41# compressed nop instruction. If GDB fails to overwrite this with an
42# uncompressed nop then a compressed breakpoint will be used in the
43# following inferior call.
44for {set i 0} {$i < 16} {incr i 2} {
45 gdb_test_no_output "set *((unsigned short *) (${bp_addr} + $i))=0x1" \
46 "place compressed nop in scratch area at offset $i"
47}
48
49# Make an inferior call. GDB should write an uncompressed nop into
50# the scratch area and so force the use of an uncompressed breakpoint,
51# however, if this mechanism fails and GDB uses a compressed
52# breakpoint, and the target doesn't support compressed instructions,
53# then we would expect weird things to happen here.
54gdb_test_no_output "set debug riscv breakpoints 1"
55gdb_test "call dummy_call ()" \
56 ".*Using EBREAK for breakpoint at $bp_addr \\(instruction length 4\\).*"
This page took 0.12745 seconds and 4 git commands to generate.