2012-01-04 08:28:28 +00:00
|
|
|
# Copyright (C) 1996-1997, 2002-2003, 2007-2012 Free Software
|
|
|
|
# Foundation, Inc.
|
2002-08-23 20:32:02 +00:00
|
|
|
|
|
|
|
# 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
|
2007-08-23 18:14:19 +00:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
2002-08-23 20:32:02 +00:00
|
|
|
# (at your option) any later version.
|
2007-08-23 18:14:19 +00:00
|
|
|
#
|
2002-08-23 20:32:02 +00:00
|
|
|
# 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.
|
2007-08-23 18:14:19 +00:00
|
|
|
#
|
2002-08-23 20:32:02 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-08-23 18:14:19 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2002-08-23 20:32:02 +00:00
|
|
|
|
|
|
|
# This file was written by Daniel Jacobowitz <drow@mvista.com>
|
|
|
|
# (parts based on pthreads.exp by Fred Fish (fnf@cygnus.com).
|
|
|
|
#
|
|
|
|
# It tests miscellaneous actions with multiple threads, including
|
|
|
|
# handling for thread exit.
|
|
|
|
|
|
|
|
|
* 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 19:23:20 +00:00
|
|
|
standard_testfile
|
2002-08-23 20:32:02 +00:00
|
|
|
|
|
|
|
# regexp for "horizontal" text (i.e. doesn't include newline or
|
|
|
|
# carriage return)
|
|
|
|
set horiz "\[^\n\r\]*"
|
|
|
|
|
* 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 19:23:20 +00:00
|
|
|
if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug] != "" } {
|
2002-08-23 20:32:02 +00:00
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Now we can proceed with the real testing.
|
|
|
|
|
* 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 19:23:20 +00:00
|
|
|
clean_restart ${binfile}
|
2002-08-23 20:32:02 +00:00
|
|
|
|
2010-06-02 21:53:28 +00:00
|
|
|
gdb_test_no_output "set print sevenbit-strings"
|
|
|
|
#gdb_test_no_output "set print address off"
|
|
|
|
gdb_test_no_output "set width 0"
|
2002-08-23 20:32:02 +00:00
|
|
|
|
|
|
|
# We'll need this when we send_gdb a ^C to GDB. Need to do it before we
|
|
|
|
# run the program and gdb starts saving and restoring tty states.
|
|
|
|
# On Ultrix, we don't need it and it is really slow (because shell_escape
|
|
|
|
# doesn't use vfork).
|
|
|
|
if ![istarget "*-*-ultrix*"] then {
|
2010-06-10 19:48:20 +00:00
|
|
|
gdb_test "shell stty intr '^C'" ".*"
|
2002-08-23 20:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
proc test_all_threads { name kill } {
|
2011-03-07 16:03:04 +00:00
|
|
|
global gdb_prompt inferior_exited_re
|
2002-08-23 20:32:02 +00:00
|
|
|
|
|
|
|
set i 0
|
|
|
|
set j 0
|
2010-06-02 19:58:21 +00:00
|
|
|
gdb_test_multiple "continue" "all threads ran once" {
|
2002-08-23 20:32:02 +00:00
|
|
|
-re "Breakpoint \[0-9\]+, thread_function \\(arg=.*\\) at .*print-threads.c:\[0-9\]+.*$gdb_prompt" {
|
|
|
|
set i [expr $i + 1]
|
|
|
|
pass "Hit thread_function breakpoint, $i ($name)"
|
|
|
|
send_gdb "continue\n"
|
|
|
|
exp_continue
|
|
|
|
}
|
|
|
|
-re "Breakpoint \[0-9\]+, .* kill \\(.*\\) .*$gdb_prompt" {
|
|
|
|
set j [expr $j + 1]
|
|
|
|
if { $kill == 1 } {
|
|
|
|
pass "Hit kill breakpoint, $j ($name)"
|
|
|
|
} else {
|
|
|
|
fail "Hit kill breakpoint, $j ($name) (unexpected)"
|
|
|
|
}
|
|
|
|
send_gdb "continue\n"
|
|
|
|
exp_continue
|
|
|
|
}
|
2011-03-07 16:03:04 +00:00
|
|
|
-re "$inferior_exited_re normally.\[\r\n\]+$gdb_prompt" {
|
2002-08-23 20:32:02 +00:00
|
|
|
pass "program exited normally"
|
|
|
|
if {$i == 5} {
|
|
|
|
pass "all threads ran once ($name)"
|
|
|
|
} else {
|
|
|
|
fail "all threads ran once ($name) (total $i threads ran)"
|
|
|
|
}
|
|
|
|
}
|
2007-05-14 16:52:13 +00:00
|
|
|
-re "Program received signal SIGTRAP.*(Thread \[-0-9a-fx\]* \\(zombie\\)|0x00000000 in ).*$gdb_prompt $" {
|
2003-06-29 19:29:42 +00:00
|
|
|
if { $kill == 1 } {
|
|
|
|
kfail "gdb/1265" "Running threads ($name) (zombie thread)"
|
|
|
|
} else {
|
|
|
|
fail "Running threads ($name) (unknown output)"
|
|
|
|
}
|
|
|
|
}
|
2002-08-23 20:32:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-11 17:36:07 +00:00
|
|
|
# Record the old timeout, we need to extend it for slower tests.
|
|
|
|
set oldtimeout $timeout
|
|
|
|
|
2002-08-23 20:32:02 +00:00
|
|
|
runto_main
|
|
|
|
gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\."
|
2010-06-02 21:53:28 +00:00
|
|
|
gdb_test_no_output "set var slow = 0"
|
2002-08-23 20:32:02 +00:00
|
|
|
test_all_threads "fast" 0
|
|
|
|
|
|
|
|
runto_main
|
|
|
|
gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\." "break thread_function (2)"
|
2010-06-02 21:53:28 +00:00
|
|
|
gdb_test_no_output "set var slow = 1"
|
2011-11-11 17:36:07 +00:00
|
|
|
# Extend the timeout for slower tests.
|
|
|
|
set timeout [expr $oldtimeout + 120]
|
2002-08-23 20:32:02 +00:00
|
|
|
test_all_threads "slow" 0
|
2011-11-11 17:36:07 +00:00
|
|
|
set timeout $oldtimeout
|
2002-08-23 20:32:02 +00:00
|
|
|
|
|
|
|
runto_main
|
|
|
|
gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\." "break thread_function (3)"
|
2010-06-02 21:53:28 +00:00
|
|
|
gdb_test_no_output "set var slow = 1" "set var slow = 1 (2)"
|
2006-07-18 19:37:23 +00:00
|
|
|
gdb_breakpoint "kill"
|
2011-11-11 17:36:07 +00:00
|
|
|
# Extend the timeout for slower tests.
|
|
|
|
set timeout [expr $oldtimeout + 120]
|
2002-08-23 20:32:02 +00:00
|
|
|
test_all_threads "slow with kill breakpoint" 1
|
2011-11-11 17:36:07 +00:00
|
|
|
set timeout $oldtimeout
|
2002-08-23 20:32:02 +00:00
|
|
|
|
|
|
|
return 0
|