1 # Copyright 2020 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 if {[skip_hw_breakpoint_tests]} {
27 if { [prepare_for_testing "failed to prepare" ${test} ${srcfile}] } {
32 fail "can't run to main"
38 gdb_test_no_output "set breakpoint always-inserted on"
39 gdb_test_no_output "set breakpoint condition-evaluation host"
40 gdb_test_no_output "set confirm off"
42 # Test inserting a hw breakpoint first, then a sw breakpoint at the
44 with_test_prefix "hw-sw" {
45 gdb_test "hbreak main" \
46 "Hardware assisted breakpoint .* at .*" \
49 gdb_test "break main" \
50 "Note: breakpoint .* also set at .*\r\nBreakpoint .* at .*" \
53 # A bad GDB debugging against GDBserver would output a warning
56 # warning: Error removing breakpoint 3
57 # (gdb) FAIL: gdb.base/hw-sw-break-same-address.exp: hw-sw: delete breakpoints
58 gdb_test_no_output "delete breakpoints"
61 # Now the opposite: test inserting a sw breakpoint first, then a hw
62 # breakpoint at the same address.
63 with_test_prefix "sw-hw" {
64 gdb_test "break main" \
65 "Breakpoint .* at .*" \
68 gdb_test "hbreak main" \
69 "Note: breakpoint .* also set at .*\r\nHardware assisted breakpoint .* at .*" \
72 gdb_test_no_output "delete breakpoints"