]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/hw-sw-break-same-address.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / hw-sw-break-same-address.exp
CommitLineData
1d506c26 1# Copyright 2020-2024 Free Software Foundation, Inc.
7f32a4d5
PA
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 that inserting a hardware and a software breakpoint at the same
17# address behaves as expected. GDB used to consider hw and sw
18# breakpoint locations as duplicate locations, which would lead to bad
19# behavior. See PR gdb/25741.
20
e0c86460 21require allow_hw_breakpoint_tests
7f32a4d5
PA
22
23set test hbreak
24set srcfile ${test}.c
25if { [prepare_for_testing "failed to prepare" ${test} ${srcfile}] } {
26 return -1
27}
28
29if ![runto_main] {
7f32a4d5
PA
30 return -1
31}
32
33delete_breakpoints
34
35gdb_test_no_output "set breakpoint always-inserted on"
36gdb_test_no_output "set breakpoint condition-evaluation host"
37gdb_test_no_output "set confirm off"
38
39# Test inserting a hw breakpoint first, then a sw breakpoint at the
40# same address.
41with_test_prefix "hw-sw" {
e777225b 42 gdb_test "hbreak -q main" \
7f32a4d5
PA
43 "Hardware assisted breakpoint .* at .*" \
44 "hbreak"
45
e777225b 46 gdb_test "break -q main" \
7f32a4d5
PA
47 "Note: breakpoint .* also set at .*\r\nBreakpoint .* at .*" \
48 "break"
49
50 # A bad GDB debugging against GDBserver would output a warning
51 # here:
52 # delete breakpoints
a500c3d8 53 # warning: error removing breakpoint 3 at <ADDRESS>
7f32a4d5
PA
54 # (gdb) FAIL: gdb.base/hw-sw-break-same-address.exp: hw-sw: delete breakpoints
55 gdb_test_no_output "delete breakpoints"
56}
57
58# Now the opposite: test inserting a sw breakpoint first, then a hw
59# breakpoint at the same address.
60with_test_prefix "sw-hw" {
e777225b 61 gdb_test "break -q main" \
7f32a4d5
PA
62 "Breakpoint .* at .*" \
63 "break"
64
e777225b 65 gdb_test "hbreak -q main" \
7f32a4d5
PA
66 "Note: breakpoint .* also set at .*\r\nHardware assisted breakpoint .* at .*" \
67 "hbreak"
68
69 gdb_test_no_output "delete breakpoints"
70}