1 # Copyright 2011-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 isnative allow_shlib_tests
17 if {![istarget *-linux*]} {
21 load_lib prelink-support.exp
23 set testfile "dlopen-libpthread"
24 set srcmainfile ${testfile}.c
25 set srclibfile ${testfile}-lib.c
26 set executable ${testfile}
27 set binfile_lib [standard_output_file ${executable}.so]
28 set lib_dlopen [shlib_target_file ${executable}.so]
30 # Use build_executable_own_libs as prelinked libpthread.so can produce false
31 # PASS - it is OK if GDB processes it still before relocation.
33 set relink_args [build_executable_own_libs ${testfile}.exp ${executable}.so $srclibfile {debug shlib_pthreads} no]
34 if {$relink_args == "" || ![prelink_no $relink_args]
35 || [prepare_for_testing "failed to prepare" ${executable} ${srcmainfile} {debug shlib_load}] } {
38 gdb_load_shlib $binfile_lib
40 if { ![runto_main] } {
45 # Fedora 17 name. There's specific code in
46 # svr4_find_and_create_probe_breakpoints to deal with this.
47 lappend probe_names rtld_map_complete
49 lappend probe_names map_complete
52 foreach probe_name $probe_names {
53 set cmd "info probes all rtld ^$probe_name$"
54 gdb_test_multiple $cmd "" {
55 -re -wrap "\[ \t\]$probe_name\[ \t\]+0x\[0-9a-f\]+.*" {
58 -re -wrap "No probes matched\\." {
64 untested "no matching probes"
68 # We link the exec without -lpthread, but libpthread.so may already be loaded at main
70 set libpthread_maybe_preloaded 0
71 set binfile [standard_output_file $executable]
72 if { [has_dependency $binfile /libpthread\\.so] == 1 } {
73 set libpthread_maybe_preloaded 1
76 # We link the shlib with -lpthread, but since glibc 2.34 libpthread has been
77 # merged with libc, so libpthread.so may not be a dependency.
78 set libpthread_missing 0
79 if { [has_dependency $binfile_lib /libpthread\\.so] == 0 } {
80 set libpthread_missing 1
83 set test "libpthread.so not found"
84 gdb_test_multiple "info sharedlibrary" $test {
85 -re "/libpthread\\.so.*\r\n$gdb_prompt $" {
86 if { $libpthread_maybe_preloaded } {
92 -re "/libc\\.so.*\r\n$gdb_prompt $" {
97 gdb_test "set variable filename=\"$lib_dlopen\""
99 gdb_breakpoint "notify"
102 # Cannot find new threads: generic error
103 gdb_continue_to_breakpoint "notify" ".* notify-here .*"
105 if { !$libpthread_missing } {
106 gdb_test "info sharedlibrary" {/libpthread\.so.*} "libpthread.so found"