]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/hbreak-in-shr-unsupported.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / hbreak-in-shr-unsupported.exp
CommitLineData
1d506c26 1# Copyright 2014-2024 Free Software Foundation, Inc.
076855f9
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 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
d6195dc9 20require allow_shlib_tests
076855f9
PA
21
22set main_src hbreak-in-shr-unsupported.c
23set lib_src hbreak-in-shr-unsupported-shr.c
24standard_testfile ${main_src} ${lib_src}
25set lib_basename hbreak-in-shr-unsupported-shr.so
26set lib_so [standard_output_file ${lib_basename}]
27
28set lib_opts "debug"
29set exec_opts [list debug shlib=${lib_so}]
30
076855f9
PA
31if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib_src} ${lib_so} $lib_opts] != ""
32 || [gdb_compile ${srcdir}/${subdir}/${main_src} ${binfile} executable $exec_opts] != ""} {
84c93cd5 33 untested "failed to compile"
076855f9
PA
34 return -1
35}
36
37clean_restart $binfile
d9019901 38gdb_load_shlib $lib_so
076855f9 39
65a33d75 40if {![runto_main]} {
076855f9
PA
41 return -1
42}
43
44set is_target_remote [gdb_is_target_remote]
45
46# Get main breakpoint out of the way.
47delete_breakpoints
48
49# Easier to test if GDB inserts breakpoints immediately.
50gdb_test_no_output "set breakpoint always-inserted on"
51
52# Force-disable Z1 packets, in case the target actually supports
53# these.
54if {$is_target_remote} {
ff52c073
CS
55 gdb_test \
56 "set remote Z-packet off" \
57 "Use of Z packets on the current remote target is set to \"off\"."
076855f9
PA
58}
59
60# Probe for hw breakpoints support. With Z packets disabled, this
61# should always fail with remote targets. For other targets, with no
62# way to force-disable hw breakpoints support, best we can do is skip
63# the remainder of the test if hardware breakpoint insertion in a
64# function in the main executable succeeds.
65set cant_insert_hbreak 0
66set supports_hbreak 0
67set test "probe hbreak support"
e777225b 68gdb_test_multiple "hbreak -q main" $test {
076855f9
PA
69 -re "No hardware breakpoint support in the target.*$gdb_prompt $" {
70 pass $test
71 }
72 -re "Hardware breakpoints used exceeds limit.*$gdb_prompt $" {
73 pass $test
74 }
75 -re "Cannot insert hardware breakpoint.*$gdb_prompt $" {
76 set cant_insert_hbreak 1
77 set supports_hbreak 1
78 pass $test
79 }
80 -re "Hardware assisted breakpoint.*at.* file .*$srcfile, line.*$gdb_prompt $" {
81 set supports_hbreak 1
82 if {$is_target_remote} {
83 # Z-packets have been force-disabled, so this shouldn't
84 # happen.
85 fail $test
86 } else {
87 pass $test
88 }
89 }
90}
91
92if {!$supports_hbreak} {
93 unsupported "no hbreak support"
94 return
95}
96
97if {!$cant_insert_hbreak} {
98 unsupported "can't disable hw breakpoint support"
99 return
100}
101
102# Get previous hw breakpoint out of the way.
103delete_breakpoints
104
105# Without target support, this should always complain. GDB used to
106# suppress the error if the breakpoint was set in a shared library.
107# While that makes sense for software breakpoints (the memory might be
108# unmapped), it doesn't for hardware breakpoints, as those by
109# definition are implemented using a mechanism that is not dependent
110# on being able to modify the target's memory.
111gdb_test "hbreak shrfunc" "Cannot insert hardware breakpoint.*" \
112 "hbreak shrfunc complains"
113
114gdb_test "info break" "hw breakpoint.*y.*$hex.*in shrfunc at.*" \
115 "breakpoint not pending"