Commit | Line | Data |
---|---|---|
7f32a4d5 PA |
1 | # Copyright 2020 Free Software Foundation, Inc. |
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 | ||
21 | if {[skip_hw_breakpoint_tests]} { | |
22 | return 0 | |
23 | } | |
24 | ||
25 | set test hbreak | |
26 | set srcfile ${test}.c | |
27 | if { [prepare_for_testing "failed to prepare" ${test} ${srcfile}] } { | |
28 | return -1 | |
29 | } | |
30 | ||
31 | if ![runto_main] { | |
32 | fail "can't run to main" | |
33 | return -1 | |
34 | } | |
35 | ||
36 | delete_breakpoints | |
37 | ||
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" | |
41 | ||
42 | # Test inserting a hw breakpoint first, then a sw breakpoint at the | |
43 | # same address. | |
44 | with_test_prefix "hw-sw" { | |
45 | gdb_test "hbreak main" \ | |
46 | "Hardware assisted breakpoint .* at .*" \ | |
47 | "hbreak" | |
48 | ||
49 | gdb_test "break main" \ | |
50 | "Note: breakpoint .* also set at .*\r\nBreakpoint .* at .*" \ | |
51 | "break" | |
52 | ||
53 | # A bad GDB debugging against GDBserver would output a warning | |
54 | # here: | |
55 | # delete breakpoints | |
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" | |
59 | } | |
60 | ||
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 .*" \ | |
66 | "break" | |
67 | ||
68 | gdb_test "hbreak main" \ | |
69 | "Note: breakpoint .* also set at .*\r\nHardware assisted breakpoint .* at .*" \ | |
70 | "hbreak" | |
71 | ||
72 | gdb_test_no_output "delete breakpoints" | |
73 | } |