]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.threads/dlopen-libpthread.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.threads / dlopen-libpthread.exp
1 # Copyright 2011-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 {![isnative] || ![istarget *-linux*] || [skip_shlib_tests]} {
17 return 0
18 }
19
20 load_lib prelink-support.exp
21
22 set testfile "dlopen-libpthread"
23 set srcmainfile ${testfile}.c
24 set srclibfile ${testfile}-lib.c
25 set executable ${testfile}
26 set binfile_lib [standard_output_file ${executable}.so]
27 set lib_dlopen [shlib_target_file ${executable}.so]
28
29 # Use build_executable_own_libs as prelinked libpthread.so can produce false
30 # PASS - it is OK if GDB processes it still before relocation.
31
32 set relink_args [build_executable_own_libs ${testfile}.exp ${executable}.so $srclibfile {debug shlib_pthreads} no]
33 if {$relink_args == "" || ![prelink_no $relink_args]
34 || [prepare_for_testing "failed to prepare" ${executable} ${srcmainfile} {debug shlib_load}] } {
35 return -1
36 }
37 gdb_load_shlib $binfile_lib
38
39 if { ![runto_main] } {
40 return -1
41 }
42
43 set probe_names {}
44 # Fedora 17 name. There's specific code in
45 # svr4_find_and_create_probe_breakpoints to deal with this.
46 lappend probe_names rtld_map_complete
47 # Upstream name.
48 lappend probe_names map_complete
49
50 set have_probe 0
51 foreach probe_name $probe_names {
52 set cmd "info probes all rtld ^$probe_name$"
53 gdb_test_multiple $cmd "" {
54 -re -wrap "\[ \t\]$probe_name\[ \t\]+0x\[0-9a-f\]+.*" {
55 set have_probe 1
56 }
57 -re -wrap "No probes matched\\." {
58 }
59 }
60 }
61
62 if { !$have_probe } {
63 untested "no matching probes"
64 }
65
66 set test "libpthread.so not found"
67 gdb_test_multiple "info sharedlibrary" $test {
68 -re "/libpthread\\.so.*\r\n$gdb_prompt $" {
69 # With newer glibc, libpthread has been integrated into glibc so we
70 # can expect it to be already loaded at main. This means we no longer
71 # excercise the scenario we're trying to trigger, but continue
72 # nevertheless.
73 unsupported $test
74 }
75 -re "/libc\\.so.*\r\n$gdb_prompt $" {
76 pass $test
77 }
78 }
79
80 gdb_test "set variable filename=\"$lib_dlopen\""
81
82 gdb_breakpoint "notify"
83
84 # The error was:
85 # Cannot find new threads: generic error
86 gdb_continue_to_breakpoint "notify" ".* notify-here .*"
87
88 gdb_test "info sharedlibrary" {/libpthread\.so.*} "libpthread.so found"