]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/break-probes.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / break-probes.exp
1 # Copyright 2012-2023 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 if { [skip_shlib_tests] } {
17 return 0
18 }
19
20 standard_testfile
21
22 set libname $testfile-solib
23 set srcfile_lib $srcdir/$subdir/$libname.c
24 set binfile_lib [standard_output_file $libname.so]
25
26 if { [gdb_compile_shlib $srcfile_lib $binfile_lib {}] != "" } {
27 untested "failed to compile shared library"
28 return -1
29 }
30
31 if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
32 [list debug shlib_load additional_flags=-DSHLIB_NAME=\"$binfile_lib\"]] } {
33 return -1
34 }
35
36 # Enable stop-on-solib-events
37 gdb_test_no_output "set stop-on-solib-events 1"
38
39 # Start the inferior and run to the first stop
40 gdb_run_cmd
41 gdb_test "" ".*Stopped due to shared library event.*" \
42 "run to shared library event"
43
44 # Check if we're using probes.
45 set using_probes 0
46
47 # Get PC.
48 set pc ""
49 gdb_test_multiple "p /x \$pc" "" {
50 -re -wrap " = ($hex)" {
51 set pc $expect_out(1,string)
52 }
53 -re -wrap "" {
54 }
55 }
56 if { $pc == "" } {
57 unsupported "Couldn't get $pc"
58 return -1
59 }
60 regsub "0x0*" $pc "" pc
61
62 # Verify that pc is at info_start probe address.
63 gdb_test_multiple "info probes stap rtld" "" {
64 -re -wrap "init_start +0x0*$pc .*" {
65 set using_probes 1
66 }
67 -re -wrap "" {
68 }
69 }
70
71 if { ! $using_probes } {
72 unsupported "probes not present on this system"
73 return -1
74 }
75
76 set sysroot ""
77 set test "show sysroot"
78 gdb_test_multiple $test $test {
79 -re "The current system root is \"(.*)\"\..*${gdb_prompt} $" {
80 set sysroot $expect_out(1,string)
81 }
82 }
83
84 # GDB strips "target:" from the start of filenames
85 # when operating on the local filesystem
86 regsub "^target:" "$sysroot" "(target:)?" sysroot
87
88 # Run til it loads our library
89 set test "run til our library loads"
90 set not_loaded_library 1
91 while { $not_loaded_library } {
92 set not_loaded_library 0
93 gdb_test_multiple "c" $test {
94 -re "Inferior loaded $sysroot$binfile_lib\\M.*$gdb_prompt $" {
95 pass $test
96 }
97 -re "Stopped due to shared library event\\M.*$gdb_prompt $" {
98 set not_loaded_library 1
99 }
100 }
101 }
102
103 # Call something to ensure that relocation occurred
104 gdb_test "call (int) foo(23)" "\\\$.* = 31.*\\\M.*"