]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.threads/check-libthread-db.exp
Update copyright year range in all GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.threads / check-libthread-db.exp
1 # Copyright 2017-2020 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 # This test only works for native processes on GNU/Linux.
17 if {[target_info gdb_protocol] != "" || ![istarget *-linux*]} {
18 continue
19 }
20
21 # Test relies on checking gdb debug output. Do not run if gdb debug is
22 # enabled as any debug will be redirected to the log.
23 if [gdb_debug_enabled] {
24 untested "debug is enabled"
25 return 0
26 }
27
28 standard_testfile
29
30 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
31 executable debug] != "" } {
32 return -1
33 }
34
35 with_test_prefix "user-initiated check" {
36
37 # User-initiated check with libthread_db not loaded.
38 clean_restart ${binfile}
39
40 gdb_test "maint show check-libthread-db" \
41 "Whether to check libthread_db at load time is off."
42
43 gdb_test_no_output "set stop-on-solib-events 1"
44 gdb_run_cmd
45 gdb_test "" \
46 ".*Stopped due to shared library event.*no libraries added or removed.*"
47
48 gdb_test "maint check libthread-db" \
49 "No libthread_db loaded" \
50 "no libpthread.so loaded"
51
52
53 # User-initiated check with NPTL uninitialized.
54 # libthread_db should fake a single thread with th_unique == NULL.
55 gdb_test "continue" \
56 ".*Stopped due to shared library event.*Inferior loaded .*libpthread.*"
57
58 gdb_test_sequence "maint check libthread-db" \
59 "libpthread.so not initialized" {
60 "\[\r\n\]+Running libthread_db integrity checks:"
61 "\[\r\n\]+\[ \]+Got thread 0x0 => \[0-9\]+ => 0x0 ... OK"
62 "\[\r\n\]+libthread_db integrity checks passed."
63 }
64
65 # User-initiated check with NPTL fully operational.
66 gdb_test_no_output "set stop-on-solib-events 0"
67 gdb_breakpoint break_here
68 gdb_continue_to_breakpoint break_here
69
70 gdb_test_sequence "maint check libthread-db" \
71 "libpthread.so fully initialized" {
72 "\[\r\n\]+Running libthread_db integrity checks:"
73 "\[\r\n\]+\[ \]+Got thread 0x\[1-9a-f\]\[0-9a-f\]+ => \[0-9\]+ => 0x\[1-9a-f\]\[0-9a-f\]+; errno = 23 ... OK"
74 "\[\r\n\]+\[ \]+Got thread 0x\[1-9a-f\]\[0-9a-f\]+ => \[0-9\]+ => 0x\[1-9a-f\]\[0-9a-f\]+; errno = 42 ... OK"
75 "\[\r\n\]+libthread_db integrity checks passed."
76 }
77 }
78
79 with_test_prefix "automated load-time check" {
80
81 # Automated load-time check with NPTL uninitialized.
82 with_test_prefix "libpthread.so not initialized" {
83 clean_restart ${binfile}
84
85 gdb_test_no_output "maint set check-libthread-db 1"
86 gdb_test_no_output "set debug libthread-db 1"
87 gdb_breakpoint break_here
88 gdb_run_cmd
89
90 gdb_test_sequence "" \
91 "check debug libthread-db output" {
92 "\[\r\n\]+Running libthread_db integrity checks:"
93 "\[\r\n\]+\[ \]+Got thread 0x0 => \[0-9\]+ => 0x0 ... OK"
94 "\[\r\n\]+libthread_db integrity checks passed."
95 "\[\r\n\]+[Thread debugging using libthread_db enabled]"
96 }
97 }
98
99 # Automated load-time check with NPTL fully operational.
100 with_test_prefix "libpthread.so fully initialized" {
101 clean_restart ${binfile}
102
103 gdb_test_no_output "maint set check-libthread-db 1"
104 gdb_test_no_output "set debug libthread-db 1"
105
106 set test_spawn_id [spawn_wait_for_attach $binfile]
107 set testpid [spawn_id_get_pid $test_spawn_id]
108
109 gdb_test_sequence "attach $testpid" \
110 "check debug libthread-db output" {
111 "\[\r\n\]+Running libthread_db integrity checks:"
112 "\[\r\n\]+\[ \]+Got thread 0x\[1-9a-f\]\[0-9a-f\]+ => \[0-9\]+ => 0x\[1-9a-f\]\[0-9a-f\]+ ... OK"
113 "\[\r\n\]+\[ \]+Got thread 0x\[1-9a-f\]\[0-9a-f\]+ => \[0-9\]+ => 0x\[1-9a-f\]\[0-9a-f\]+ ... OK"
114 "\[\r\n\]+libthread_db integrity checks passed."
115 "\[\r\n\]+[Thread debugging using libthread_db enabled]"
116 }
117
118 gdb_exit
119 kill_wait_spawned_process $test_spawn_id
120 }
121 }