]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/break-probes.exp
Update copyright year range in all GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / break-probes.exp
CommitLineData
3666a048 1# Copyright 2012-2021 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
2f413264 33if { [gdb_compile_shlib $srcfile_lib $binfile_lib {}] != "" } {
84c93cd5 34 untested "failed to compile shared library"
afacd7f3
GB
35 return -1
36}
37
5b362f04 38if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
db86b02b 39 [list debug shlib_load additional_flags=-DSHLIB_NAME=\"$binfile_lib\"]] } {
afacd7f3
GB
40 return -1
41}
42
43# Enable stop-on-solib-events
44gdb_test_no_output "set stop-on-solib-events 1"
45
46# Start the inferior and run to the first stop
47gdb_run_cmd
48gdb_test "" ".*Stopped due to shared library event.*"
49
50# XFAIL if we are not using probes
51set test "ensure using probes"
52set using_probes 0
53gdb_test_multiple "bt" $test {
54 -re "#0 +\[^\r\n\]*\\m(__GI_)?$normal_bp\\M.*$gdb_prompt $" {
55 untested "probes not present on this system"
56 }
57 -re "#0 +\[^\r\n\]*\\m(__GI_)?$probes_bp\\M.*$gdb_prompt $" {
58 pass $test
59 set using_probes 1
60 }
61}
62
63if { $using_probes } {
10e79639
YQ
64 set sysroot ""
65 set test "show sysroot"
66 gdb_test_multiple $test $test {
67 -re "The current system root is \"(.*)\"\..*${gdb_prompt} $" {
68 set sysroot $expect_out(1,string)
69 }
70 }
71
fed040c6
GB
72 # GDB strips "target:" from the start of filenames
73 # when operating on the local filesystem
74 regsub "^target:" "$sysroot" "(target:)?" sysroot
75
afacd7f3
GB
76 # Run til it loads our library
77 set test "run til our library loads"
78 set not_loaded_library 1
79 while { $not_loaded_library } {
80 set not_loaded_library 0
81 gdb_test_multiple "c" $test {
10e79639 82 -re "Inferior loaded $sysroot$binfile_lib\\M.*$gdb_prompt $" {
afacd7f3
GB
83 pass $test
84 }
85 -re "Stopped due to shared library event\\M.*$gdb_prompt $" {
86 set not_loaded_library 1
87 }
88 }
89 }
90
91 # Call something to ensure that relocation occurred
7022349d 92 gdb_test "call (int) foo(23)" "\\\$.* = 31.*\\\M.*"
afacd7f3 93}