1 # Copyright 2012-2023 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 if { [skip_shlib_tests] } {
22 set libname $testfile-solib
23 set srcfile_lib $srcdir/$subdir/$libname.c
24 set binfile_lib [standard_output_file $libname.so]
26 if { [gdb_compile_shlib $srcfile_lib $binfile_lib {}] != "" } {
27 untested "failed to compile shared library"
31 if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
32 [list debug shlib_load additional_flags=-DSHLIB_NAME=\"$binfile_lib\"]] } {
36 # Enable stop-on-solib-events
37 gdb_test_no_output "set stop-on-solib-events 1"
39 # Start the inferior and run to the first stop
41 gdb_test "" ".*Stopped due to shared library event.*" \
42 "run to shared library event"
44 # Check if we're using probes.
49 gdb_test_multiple "p /x \$pc" "" {
50 -re -wrap " = ($hex)" {
51 set pc $expect_out(1,string)
57 unsupported "Couldn't get $pc"
60 regsub "0x0*" $pc "" pc
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 .*" {
71 if { ! $using_probes } {
72 unsupported "probes not present on this system"
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)
84 # GDB strips "target:" from the start of filenames
85 # when operating on the local filesystem
86 regsub "^target:" "$sysroot" "(target:)?" sysroot
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 $" {
97 -re "Stopped due to shared library event\\M.*$gdb_prompt $" {
98 set not_loaded_library 1
103 # Call something to ensure that relocation occurred
104 gdb_test "call (int) foo(23)" "\\\$.* = 31.*\\\M.*"