binutils-gdb/gdb/testsuite/gdb.threads/staticthreads.exp

112 lines
2.7 KiB
Plaintext
Raw Normal View History

# static.exp -- test script, for GDB, the GNU debugger.
# Copyright 2004-2016 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/>.
# Based on manythreads written by Jeff Johnston, contributed by Red
# Hat.
* gdb.threads/watchpoint-fork.exp (test): Use standard_output_file. Don't declare objdir. * gdb.threads/attach-into-signal.exp: Use standard_testfile, standard_output_file. * gdb.threads/attach-stopped.exp: Use standard_testfile. * gdb.threads/bp_in_thread.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/corethreads.exp: Use standard_testfile. * gdb.threads/execl.exp: Use standard_testfile, standard_output_file, clean_restart. * gdb.threads/fork-child-threads.exp: Use standard_testfile, clean_restart. * gdb.threads/fork-thread-pending.exp: Use standard_testfile, clean_restart. * gdb.threads/gcore-thread.exp: Use standard_testfile. Remove incdir. * gdb.threads/hand-call-in-threads.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/ia64-sigill.exp: Use standard_testfile. * gdb.threads/interrupted-hand-call.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/killed.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/leader-exit.exp: Use standard_testfile. * gdb.threads/linux-dp.exp: Use standard_testfile, clean_restart. * gdb.threads/local-watch-wrong-thread.exp: Use standard_testfile, clean_restart. * gdb.threads/manythreads.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/multi-create.exp: Use standard_testfile, clean_restart. * gdb.threads/no-unwaited-for-left.exp: Use standard_testfile. * gdb.threads/non-ldr-exc-1.exp: Use standard_testfile. * gdb.threads/non-ldr-exc-2.exp: Use standard_testfile. * gdb.threads/non-ldr-exc-3.exp: Use standard_testfile. * gdb.threads/non-ldr-exc-4.exp: Use standard_testfile. * gdb.threads/pending-step.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/print-threads.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/pthread_cond_wait.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/pthreads.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/schedlock.exp: Use standard_testfile. Remove incdir. * gdb.threads/sigthread.exp: Use standard_testfile, clean_restart. * gdb.threads/staticthreads.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/switch-threads.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/thread-execl.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/thread-find.exp: Use standard_testfile, clean_restart. * gdb.threads/thread-specific.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/thread-unwindonsignal.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/thread_check.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/thread_events.exp: Use standard_testfile. Remove incdir. * gdb.threads/threadapply.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/threxit-hop-specific.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/tls-nodebug.exp: Use standard_testfile, clean_restart. * gdb.threads/tls-shared.exp: Use standard_testfile, clean_restart, standard_output_file. * gdb.threads/tls-var.exp: Use standard_testfile, standard_output_file. * gdb.threads/tls.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/watchthreads-reorder.exp: Use standard_testfile. * gdb.threads/watchthreads.exp: Use standard_testfile. Remove incdir. * gdb.threads/watchthreads2.exp: Use standard_testfile, clean_restart. Remove incdir.
2012-06-26 21:23:20 +02:00
standard_testfile
set static_flag "-static"
Fix TLS access for -static -pthread I have posted: TLS variables access for -static -lpthread executables https://sourceware.org/ml/libc-help/2014-03/msg00024.html and the GDB patch below has been confirmed as OK for current glibcs. Further work should be done for newer glibcs: Improve TLS variables glibc compatibility https://sourceware.org/bugzilla/show_bug.cgi?id=16954 Still the patch below implements the feature in a fully functional way backward compatible with current glibcs, it depends on the following glibc source line: csu/libc-tls.c main_map->l_tls_modid = 1; gdb/ 2014-05-21 Jan Kratochvil <jan.kratochvil@redhat.com> Fix TLS access for -static -pthread. * linux-thread-db.c (struct thread_db_info): Add td_thr_tlsbase_p. (try_thread_db_load_1): Initialize it. (thread_db_get_thread_local_address): Call it if LM is zero. * target.c (target_translate_tls_address): Remove LM_ADDR zero check. * target.h (struct target_ops) (to_get_thread_local_address): Add load_module_addr comment. gdb/gdbserver/ 2014-05-21 Jan Kratochvil <jan.kratochvil@redhat.com> Fix TLS access for -static -pthread. * gdbserver/thread-db.c (struct thread_db): Add td_thr_tlsbase_p. (thread_db_get_tls_address): Call it if LOAD_MODULE is zero. (thread_db_load_search, try_thread_db_load_1): Initialize it. gdb/testsuite/ 2014-05-21 Jan Kratochvil <jan.kratochvil@redhat.com> Fix TLS access for -static -pthread. * gdb.threads/staticthreads.c <HAVE_TLS> (tlsvar): New. <HAVE_TLS> (thread_function, main): Initialize it. * gdb.threads/staticthreads.exp: Try gdb_compile_pthreads for $have_tls. Add clean_restart. <$have_tls != "">: Check TLSVAR. Message-ID: <20140410115204.GB16411@host2.jankratochvil.net>
2014-05-21 16:25:53 +02:00
foreach have_tls { "-DHAVE_TLS" "" } {
if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
executable \
[list debug "additional_flags=${static_flag} ${have_tls}" \
]] == "" } {
break
}
if { $have_tls == "" } {
return -1
}
}
* gdb.threads/watchpoint-fork.exp (test): Use standard_output_file. Don't declare objdir. * gdb.threads/attach-into-signal.exp: Use standard_testfile, standard_output_file. * gdb.threads/attach-stopped.exp: Use standard_testfile. * gdb.threads/bp_in_thread.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/corethreads.exp: Use standard_testfile. * gdb.threads/execl.exp: Use standard_testfile, standard_output_file, clean_restart. * gdb.threads/fork-child-threads.exp: Use standard_testfile, clean_restart. * gdb.threads/fork-thread-pending.exp: Use standard_testfile, clean_restart. * gdb.threads/gcore-thread.exp: Use standard_testfile. Remove incdir. * gdb.threads/hand-call-in-threads.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/ia64-sigill.exp: Use standard_testfile. * gdb.threads/interrupted-hand-call.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/killed.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/leader-exit.exp: Use standard_testfile. * gdb.threads/linux-dp.exp: Use standard_testfile, clean_restart. * gdb.threads/local-watch-wrong-thread.exp: Use standard_testfile, clean_restart. * gdb.threads/manythreads.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/multi-create.exp: Use standard_testfile, clean_restart. * gdb.threads/no-unwaited-for-left.exp: Use standard_testfile. * gdb.threads/non-ldr-exc-1.exp: Use standard_testfile. * gdb.threads/non-ldr-exc-2.exp: Use standard_testfile. * gdb.threads/non-ldr-exc-3.exp: Use standard_testfile. * gdb.threads/non-ldr-exc-4.exp: Use standard_testfile. * gdb.threads/pending-step.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/print-threads.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/pthread_cond_wait.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/pthreads.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/schedlock.exp: Use standard_testfile. Remove incdir. * gdb.threads/sigthread.exp: Use standard_testfile, clean_restart. * gdb.threads/staticthreads.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/switch-threads.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/thread-execl.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/thread-find.exp: Use standard_testfile, clean_restart. * gdb.threads/thread-specific.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/thread-unwindonsignal.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/thread_check.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/thread_events.exp: Use standard_testfile. Remove incdir. * gdb.threads/threadapply.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/threxit-hop-specific.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/tls-nodebug.exp: Use standard_testfile, clean_restart. * gdb.threads/tls-shared.exp: Use standard_testfile, clean_restart, standard_output_file. * gdb.threads/tls-var.exp: Use standard_testfile, standard_output_file. * gdb.threads/tls.exp: Use standard_testfile, clean_restart. Remove incdir. * gdb.threads/watchthreads-reorder.exp: Use standard_testfile. * gdb.threads/watchthreads.exp: Use standard_testfile. Remove incdir. * gdb.threads/watchthreads2.exp: Use standard_testfile, clean_restart. Remove incdir.
2012-06-26 21:23:20 +02:00
clean_restart ${binfile}
gdb_test_no_output "set print sevenbit-strings"
# See if the static multi-threaded program runs.
runto_main
gdb_test "break sem_post"
set test "Continue to main's call of sem_post"
gdb_test_multiple "continue" "$test" {
-re "Breakpoint .*, .*sem_post .*$gdb_prompt " {
pass "$test"
}
-re " received signal .*$gdb_prompt " {
kfail gdb/1328 "$test"
}
}
# See if handle SIG32 helps (a little) with a static multi-threaded
# program.
set sig "SIG32"
Remove HP-UX references fom testsuite This patch removes all special cases for HP-UX, for which support has been removed earlier, that I found in the testsuite. Note that the hppa architecture != HP-UX, since other OSes can run on hppa, so I tried to leave everything that is not HP-UX specific. Two complete tests were completely HP-UX specific, so I removed them. I ran the testsuite on Linux x86-64, native and native-gdbserver, and noticed no regressions. gdb/testsuite/ChangeLog: * gdb.asm/asm-source.exp: Remove HP-UX references. * gdb.base/annota1.exp: Likewise. * gdb.base/annota3.exp: Likewise. * gdb.base/attach.exp: Likewise. * gdb.base/bigcore.exp: Likewise. * gdb.base/break.exp: Likewise. * gdb.base/call-ar-st.exp: Likewise. * gdb.base/callfuncs.exp: Likewise. * gdb.base/catch-fork-static.exp: Likewise. * gdb.base/display.exp: Likewise. * gdb.base/foll-exec-mode.exp: Likewise. * gdb.base/foll-exec.exp: Likewise. * gdb.base/foll-fork.exp: Likewise. * gdb.base/foll-vfork.exp: Likewise. * gdb.base/funcargs.exp: Likewise. * gdb.base/hbreak2.exp: Likewise. * gdb.base/inferior-died.exp: Likewise. * gdb.base/interrupt.exp: Likewise. * gdb.base/multi-forks.exp: Likewise. * gdb.base/nodebug.exp: Likewise. * gdb.base/sepdebug.exp: Likewise. * gdb.base/solib1.c: Likewise. * gdb.base/step-test.exp: Likewise. * gdb.mi/non-stop.c: Likewise. * gdb.mi/pthreads.c: Likewise. * gdb.multi/bkpt-multi-exec.ex: Likewise. * gdb.threads/pthreads.c: Likewise. * gdb.threads/staticthreads.exp: Likewise. * lib/future.exp: Likewise. * lib/gdb.exp: Likewise. * gdb.base/so-indr-cl.c: Remove. * gdb.base/so-indr-cl.exp: Likewise. * gdb.base/solib.c: Likewise. * gdb.base/solib.exp: Likewise. * gdb.base/solib2.c: Likewise.
2015-12-21 18:51:54 +01:00
# SIGRTMIN is 37 on hppa-linux
if [istarget hppa*-*-*] {
set sig "SIG37"
}
rerun_to_main
gdb_test "handle $sig nostop noprint pass"
set test "Handle $sig helps"
gdb_test "continue" " .*sem_post .*" "handle $sig helps"
# See if info threads produces anything approaching a thread list.
set test "info threads"
gdb_test_multiple "info threads" "$test" {
-re " Thread .*$gdb_prompt " {
pass "$test"
}
-re "$gdb_prompt " {
kfail gdb/1328 "$test"
}
}
# Check that the program can be quit.
set test "GDB exits with static thread program"
gdb_test_multiple "quit" "$test" {
-re "Quit anyway\\? \\(y or n\\) $" {
send_gdb "y\n"
exp_continue
}
eof {
pass "$test"
}
}
Fix TLS access for -static -pthread I have posted: TLS variables access for -static -lpthread executables https://sourceware.org/ml/libc-help/2014-03/msg00024.html and the GDB patch below has been confirmed as OK for current glibcs. Further work should be done for newer glibcs: Improve TLS variables glibc compatibility https://sourceware.org/bugzilla/show_bug.cgi?id=16954 Still the patch below implements the feature in a fully functional way backward compatible with current glibcs, it depends on the following glibc source line: csu/libc-tls.c main_map->l_tls_modid = 1; gdb/ 2014-05-21 Jan Kratochvil <jan.kratochvil@redhat.com> Fix TLS access for -static -pthread. * linux-thread-db.c (struct thread_db_info): Add td_thr_tlsbase_p. (try_thread_db_load_1): Initialize it. (thread_db_get_thread_local_address): Call it if LM is zero. * target.c (target_translate_tls_address): Remove LM_ADDR zero check. * target.h (struct target_ops) (to_get_thread_local_address): Add load_module_addr comment. gdb/gdbserver/ 2014-05-21 Jan Kratochvil <jan.kratochvil@redhat.com> Fix TLS access for -static -pthread. * gdbserver/thread-db.c (struct thread_db): Add td_thr_tlsbase_p. (thread_db_get_tls_address): Call it if LOAD_MODULE is zero. (thread_db_load_search, try_thread_db_load_1): Initialize it. gdb/testsuite/ 2014-05-21 Jan Kratochvil <jan.kratochvil@redhat.com> Fix TLS access for -static -pthread. * gdb.threads/staticthreads.c <HAVE_TLS> (tlsvar): New. <HAVE_TLS> (thread_function, main): Initialize it. * gdb.threads/staticthreads.exp: Try gdb_compile_pthreads for $have_tls. Add clean_restart. <$have_tls != "">: Check TLSVAR. Message-ID: <20140410115204.GB16411@host2.jankratochvil.net>
2014-05-21 16:25:53 +02:00
clean_restart ${binfile}
if { "$have_tls" != "" } {
if ![runto_main] {
return -1
}
gdb_breakpoint [gdb_get_line_number "tlsvar-is-set"]
gdb_continue_to_breakpoint "tlsvar-is-set" ".* tlsvar-is-set .*"
gdb_test "p tlsvar" " = 2" "tlsvar in thread"
gdb_test "thread 1" ".*"
# Unwind to main.
Fix TLS access for -static -pthread I have posted: TLS variables access for -static -lpthread executables https://sourceware.org/ml/libc-help/2014-03/msg00024.html and the GDB patch below has been confirmed as OK for current glibcs. Further work should be done for newer glibcs: Improve TLS variables glibc compatibility https://sourceware.org/bugzilla/show_bug.cgi?id=16954 Still the patch below implements the feature in a fully functional way backward compatible with current glibcs, it depends on the following glibc source line: csu/libc-tls.c main_map->l_tls_modid = 1; gdb/ 2014-05-21 Jan Kratochvil <jan.kratochvil@redhat.com> Fix TLS access for -static -pthread. * linux-thread-db.c (struct thread_db_info): Add td_thr_tlsbase_p. (try_thread_db_load_1): Initialize it. (thread_db_get_thread_local_address): Call it if LM is zero. * target.c (target_translate_tls_address): Remove LM_ADDR zero check. * target.h (struct target_ops) (to_get_thread_local_address): Add load_module_addr comment. gdb/gdbserver/ 2014-05-21 Jan Kratochvil <jan.kratochvil@redhat.com> Fix TLS access for -static -pthread. * gdbserver/thread-db.c (struct thread_db): Add td_thr_tlsbase_p. (thread_db_get_tls_address): Call it if LOAD_MODULE is zero. (thread_db_load_search, try_thread_db_load_1): Initialize it. gdb/testsuite/ 2014-05-21 Jan Kratochvil <jan.kratochvil@redhat.com> Fix TLS access for -static -pthread. * gdb.threads/staticthreads.c <HAVE_TLS> (tlsvar): New. <HAVE_TLS> (thread_function, main): Initialize it. * gdb.threads/staticthreads.exp: Try gdb_compile_pthreads for $have_tls. Add clean_restart. <$have_tls != "">: Check TLSVAR. Message-ID: <20140410115204.GB16411@host2.jankratochvil.net>
2014-05-21 16:25:53 +02:00
gdb_test "up 10" " in main .*"
gdb_test "p tlsvar" " = 1" "tlsvar in main"
}