1 # Copyright 2020-2024 Free Software Foundation, Inc.
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.
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.
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/>.
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.
21 require allow_hw_breakpoint_tests
25 if { [prepare_for_testing "failed to prepare" ${test} ${srcfile}] } {
35 gdb_test_no_output "set breakpoint always-inserted on"
36 gdb_test_no_output "set breakpoint condition-evaluation host"
37 gdb_test_no_output "set confirm off"
39 # Test inserting a hw breakpoint first, then a sw breakpoint at the
41 with_test_prefix "hw-sw" {
42 gdb_test "hbreak -q main" \
43 "Hardware assisted breakpoint .* at .*" \
46 gdb_test "break -q main" \
47 "Note: breakpoint .* also set at .*\r\nBreakpoint .* at .*" \
50 # A bad GDB debugging against GDBserver would output a warning
53 # warning: error removing breakpoint 3 at <ADDRESS>
54 # (gdb) FAIL: gdb.base/hw-sw-break-same-address.exp: hw-sw: delete breakpoints
55 gdb_test_no_output "delete breakpoints"
58 # Now the opposite: test inserting a sw breakpoint first, then a hw
59 # breakpoint at the same address.
60 with_test_prefix "sw-hw" {
61 gdb_test "break -q main" \
62 "Breakpoint .* at .*" \
65 gdb_test "hbreak -q main" \
66 "Note: breakpoint .* also set at .*\r\nHardware assisted breakpoint .* at .*" \
69 gdb_test_no_output "delete breakpoints"