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