blob: 3990cf331f65a212026e654999c8300be4c2f8d5 [file] [log] [blame]
# Copyright 2017 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This test only works for native processes on Linux.
if { ![isnative] || [is_remote host] || [target_info exists use_gdb_stub]
|| ![istarget *-linux*] } {
continue
}
standard_testfile
if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
executable debug] != "" } {
return -1
}
# TEST 1: Manual check with libthread_db not loaded.
clean_restart ${binfile}
gdb_test "maint show check-libthread-db" \
"Whether to check libthread_db at load time is off."
gdb_test_no_output "set stop-on-solib-events 1"
gdb_run_cmd
gdb_test "" \
".*Stopped due to shared library event.*no libraries added or removed.*"
gdb_test "maint check libthread-db" \
"No libthread_db loaded" \
"libpthread.so not loaded"
# TEST 2: Manual check with NPTL uninitialized.
# libthread_db should fake a single thread with th_unique == NULL.
gdb_test "continue" \
".*Stopped due to shared library event.*Inferior loaded .*libpthread.*"
gdb_test_sequence "maint check libthread-db" \
"libpthread.so not initialized (manual)" {
"\[\r\n\]+Running libthread_db integrity checks:"
"\[\r\n\]+\[ \]+Got thread 0x0 => \[0-9\]+ => 0x0 ... OK"
"\[\r\n\]+libthread_db integrity checks passed."
}
# TEST 3: Manual check with NPTL fully operational.
gdb_test_no_output "set stop-on-solib-events 0"
gdb_breakpoint break_here
gdb_continue_to_breakpoint break_here
gdb_test_sequence "maint check libthread-db" \
"libpthread.so fully initialized (manual)" {
"\[\r\n\]+Running libthread_db integrity checks:"
"\[\r\n\]+\[ \]+Got thread 0x\[1-9a-f\]\[0-9a-f\]+ => \[0-9\]+ => 0x\[1-9a-f\]\[0-9a-f\]+; errno = 23 ... OK"
"\[\r\n\]+\[ \]+Got thread 0x\[1-9a-f\]\[0-9a-f\]+ => \[0-9\]+ => 0x\[1-9a-f\]\[0-9a-f\]+; errno = 42 ... OK"
"\[\r\n\]+libthread_db integrity checks passed."
}
# TEST 4: Automated check with NPTL uninitialized.
clean_restart ${binfile}
gdb_test_no_output "maint set check-libthread-db 1"
gdb_test_no_output "set debug libthread-db 1"
gdb_breakpoint break_here
gdb_run_cmd
gdb_test_sequence "" \
"libpthread.so not initialized (automated)" {
"\[\r\n\]+Running libthread_db integrity checks:"
"\[\r\n\]+\[ \]+Got thread 0x0 => \[0-9\]+ => 0x0 ... OK"
"\[\r\n\]+libthread_db integrity checks passed."
"\[\r\n\]+[Thread debugging using libthread_db enabled]"
}
# TEST 5: Automated check with NPTL fully operational.
clean_restart ${binfile}
gdb_test_no_output "maint set check-libthread-db 1"
gdb_test_no_output "set debug libthread-db 1"
set test_spawn_id [spawn_wait_for_attach $binfile]
set testpid [spawn_id_get_pid $test_spawn_id]
gdb_test_sequence "attach $testpid" \
"libpthread.so fully initialized (automated)" {
"\[\r\n\]+Running libthread_db integrity checks:"
"\[\r\n\]+\[ \]+Got thread 0x\[1-9a-f\]\[0-9a-f\]+ => \[0-9\]+ => 0x\[1-9a-f\]\[0-9a-f\]+ ... OK"
"\[\r\n\]+\[ \]+Got thread 0x\[1-9a-f\]\[0-9a-f\]+ => \[0-9\]+ => 0x\[1-9a-f\]\[0-9a-f\]+ ... OK"
"\[\r\n\]+libthread_db integrity checks passed."
"\[\r\n\]+[Thread debugging using libthread_db enabled]"
}
gdb_exit
kill_wait_spawned_process $test_spawn_id