Don't suppress errors inserting/removing hardware breakpoints in shared
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / hbreak-in-shr-unsupported.exp
1 # Copyright 2014 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 trying to inserting a hw breakpoint in a shared library
17 # when the target doesn't support hw breakpoints doesn't silently
18 # error out without informing the user.
19
20 if {[skip_shlib_tests]} {
21 return -1
22 }
23
24 set main_src hbreak-in-shr-unsupported.c
25 set lib_src hbreak-in-shr-unsupported-shr.c
26 standard_testfile ${main_src} ${lib_src}
27 set lib_basename hbreak-in-shr-unsupported-shr.so
28 set lib_so [standard_output_file ${lib_basename}]
29
30 set lib_opts "debug"
31 set exec_opts [list debug shlib=${lib_so}]
32
33 if [get_compiler_info] {
34 return -1
35 }
36
37 if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib_src} ${lib_so} $lib_opts] != ""
38 || [gdb_compile ${srcdir}/${subdir}/${main_src} ${binfile} executable $exec_opts] != ""} {
39 untested "Could not compile ${subdir}/$lib_src or ${subdir}/$srcfile."
40 return -1
41 }
42
43 clean_restart $binfile
44 gdb_load_shlibs $lib_so
45
46 if ![runto_main] then {
47 fail "Can't run to main"
48 return -1
49 }
50
51 set is_target_remote [gdb_is_target_remote]
52
53 # Get main breakpoint out of the way.
54 delete_breakpoints
55
56 # Easier to test if GDB inserts breakpoints immediately.
57 gdb_test_no_output "set breakpoint always-inserted on"
58
59 # Force-disable Z1 packets, in case the target actually supports
60 # these.
61 if {$is_target_remote} {
62 gdb_test_no_output "set remote Z-packet off"
63 }
64
65 # Probe for hw breakpoints support. With Z packets disabled, this
66 # should always fail with remote targets. For other targets, with no
67 # way to force-disable hw breakpoints support, best we can do is skip
68 # the remainder of the test if hardware breakpoint insertion in a
69 # function in the main executable succeeds.
70 set cant_insert_hbreak 0
71 set supports_hbreak 0
72 set test "probe hbreak support"
73 gdb_test_multiple "hbreak main" $test {
74 -re "No hardware breakpoint support in the target.*$gdb_prompt $" {
75 pass $test
76 }
77 -re "Hardware breakpoints used exceeds limit.*$gdb_prompt $" {
78 pass $test
79 }
80 -re "Cannot insert hardware breakpoint.*$gdb_prompt $" {
81 set cant_insert_hbreak 1
82 set supports_hbreak 1
83 pass $test
84 }
85 -re "Hardware assisted breakpoint.*at.* file .*$srcfile, line.*$gdb_prompt $" {
86 set supports_hbreak 1
87 if {$is_target_remote} {
88 # Z-packets have been force-disabled, so this shouldn't
89 # happen.
90 fail $test
91 } else {
92 pass $test
93 }
94 }
95 }
96
97 if {!$supports_hbreak} {
98 unsupported "no hbreak support"
99 return
100 }
101
102 if {!$cant_insert_hbreak} {
103 unsupported "can't disable hw breakpoint support"
104 return
105 }
106
107 # Get previous hw breakpoint out of the way.
108 delete_breakpoints
109
110 # Without target support, this should always complain. GDB used to
111 # suppress the error if the breakpoint was set in a shared library.
112 # While that makes sense for software breakpoints (the memory might be
113 # unmapped), it doesn't for hardware breakpoints, as those by
114 # definition are implemented using a mechanism that is not dependent
115 # on being able to modify the target's memory.
116 gdb_test "hbreak shrfunc" "Cannot insert hardware breakpoint.*" \
117 "hbreak shrfunc complains"
118
119 gdb_test "info break" "hw breakpoint.*y.*$hex.*in shrfunc at.*" \
120 "breakpoint not pending"
This page took 0.051435 seconds and 4 git commands to generate.