gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / break-probes.exp
CommitLineData
b811d2c2 1# Copyright 2012-2020 Free Software Foundation, Inc.
afacd7f3
GB
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
16if { [skip_shlib_tests] } {
17 return 0
18}
19
20standard_testfile
21
22set libname $testfile-solib
23set srcfile_lib $srcdir/$subdir/$libname.c
24set binfile_lib [standard_output_file $libname.so]
25
db86b02b
RS
26if { [istarget "*bsd*"] } {
27 set normal_bp "r_debug_state"
28} else {
29 set normal_bp "_dl_debug_state"
30}
afacd7f3
GB
31set probes_bp "dl_main"
32
33if { [gdb_compile_shlib $srcfile_lib $binfile_lib \
34 [list additional_flags=-fPIC]] != "" } {
84c93cd5 35 untested "failed to compile shared library"
afacd7f3
GB
36 return -1
37}
38
5b362f04 39if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
db86b02b 40 [list debug shlib_load additional_flags=-DSHLIB_NAME=\"$binfile_lib\"]] } {
afacd7f3
GB
41 return -1
42}
43
44# Enable stop-on-solib-events
45gdb_test_no_output "set stop-on-solib-events 1"
46
47# Start the inferior and run to the first stop
48gdb_run_cmd
49gdb_test "" ".*Stopped due to shared library event.*"
50
51# XFAIL if we are not using probes
52set test "ensure using probes"
53set using_probes 0
54gdb_test_multiple "bt" $test {
55 -re "#0 +\[^\r\n\]*\\m(__GI_)?$normal_bp\\M.*$gdb_prompt $" {
56 untested "probes not present on this system"
57 }
58 -re "#0 +\[^\r\n\]*\\m(__GI_)?$probes_bp\\M.*$gdb_prompt $" {
59 pass $test
60 set using_probes 1
61 }
62}
63
64if { $using_probes } {
10e79639
YQ
65 set sysroot ""
66 set test "show sysroot"
67 gdb_test_multiple $test $test {
68 -re "The current system root is \"(.*)\"\..*${gdb_prompt} $" {
69 set sysroot $expect_out(1,string)
70 }
71 }
72
fed040c6
GB
73 # GDB strips "target:" from the start of filenames
74 # when operating on the local filesystem
75 regsub "^target:" "$sysroot" "(target:)?" sysroot
76
afacd7f3
GB
77 # Run til it loads our library
78 set test "run til our library loads"
79 set not_loaded_library 1
80 while { $not_loaded_library } {
81 set not_loaded_library 0
82 gdb_test_multiple "c" $test {
10e79639 83 -re "Inferior loaded $sysroot$binfile_lib\\M.*$gdb_prompt $" {
afacd7f3
GB
84 pass $test
85 }
86 -re "Stopped due to shared library event\\M.*$gdb_prompt $" {
87 set not_loaded_library 1
88 }
89 }
90 }
91
92 # Call something to ensure that relocation occurred
7022349d 93 gdb_test "call (int) foo(23)" "\\\$.* = 31.*\\\M.*"
afacd7f3 94}
This page took 0.80481 seconds and 4 git commands to generate.