1 # Copyright 2012-2024 Free Software Foundation, Inc.
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.
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.
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/>.
16 require allow_shlib_tests
20 set libname $testfile-solib
21 set srcfile_lib $srcdir/$subdir/$libname.c
22 set binfile_lib [standard_output_file $libname.so]
24 if { [gdb_compile_shlib $srcfile_lib $binfile_lib {}] != "" } {
25 untested "failed to compile shared library"
29 set binfile_lib_target [gdb_download_shlib $binfile_lib]
31 if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
32 [list debug shlib_load additional_flags=-DSHLIB_NAME=\"$binfile_lib_target\"]] } {
36 gdb_locate_shlib $binfile_lib
38 # Enable stop-on-solib-events
39 gdb_test_no_output "set stop-on-solib-events 1"
41 # Start the inferior and run to the first stop
43 gdb_test "" ".*Stopped due to shared library event.*" \
44 "run to shared library event"
46 # Check if we're using probes.
51 gdb_test_multiple "p /x \$pc" "" {
52 -re -wrap " = ($hex)" {
53 set pc $expect_out(1,string)
59 unsupported "Couldn't get $pc"
62 regsub "0x0*" $pc "" pc
64 # Verify that pc is at info_start probe address.
65 gdb_test_multiple "info probes stap rtld" "" {
66 -re -wrap "init_start +0x0*$pc .*" {
73 if { ! $using_probes } {
74 unsupported "probes not present on this system"
79 set test "show sysroot"
80 gdb_test_multiple $test $test {
81 -re "The current system root is \"(.*)\"\..*${gdb_prompt} $" {
82 set sysroot $expect_out(1,string)
86 # GDB strips "target:" from the start of filenames
87 # when operating on the local filesystem
88 if { ![is_remote target] } {
89 regsub "^target:" "$sysroot" "(target:)?" sysroot
92 # Run til it loads our library
93 set test "run til our library loads"
94 set not_loaded_library 1
95 while { $not_loaded_library } {
96 set not_loaded_library 0
97 gdb_test_multiple "c" $test {
98 -re "Inferior loaded $sysroot\[^\r\n\]*$binfile_lib_target\\M.*$gdb_prompt $" {
101 -re "Stopped due to shared library event\\M.*$gdb_prompt $" {
102 set not_loaded_library 1
107 # Call something to ensure that relocation occurred
108 gdb_test "call (int) foo(23)" "\\\$.* = 31.*\\\M.*"