old-cross-binutils/gdb/testsuite/gdb.threads/manythreads.exp

180 lines
4.7 KiB
Text
Raw Normal View History

# manythreads.exp -- Expect script to test stopping many threads
# Copyright (C) 2004-2015 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 file was written by Jeff Johnston. (jjohnstn@redhat.com)
* 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
set opts { debug }
if [info exists DEBUG] {
# make check RUNTESTFLAGS='gdb.threads/manythreads.exp DEBUG=1'
lappend opts "additional_flags=-DDEBUG"
}
if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $opts] != "" } {
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 19:23:20 +00:00
clean_restart ${binfile}
gdb_test_no_output "set print sevenbit-strings"
runto_main
# 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.
gdb_test "shell stty intr '^C'" ".*"
set message "first continue"
gdb_test_multiple "continue" "first continue" {
-re "error:.*$gdb_prompt $" {
fail "$message"
}
-re "Continuing" {
pass "$message"
}
}
# Wait one second. This is better than the TCL "after" command, because
# we don't lose GDB's output while we do it.
remote_expect host 1 { timeout { } }
gdb.threads/manythreads.exp: clean up and add comment In git b57bacec, I said: > With that in place, the need to delay "Program received signal FOO" > was actually caught by the manythreads.exp test. Without that bit, I > was getting: > > [Thread 0x7ffff7f13700 (LWP 4499) exited] > [New Thread 0x7ffff7f0b700 (LWP 4500)] > ^C > Program received signal SIGINT, Interrupt. > [New Thread 0x7ffff7f03700 (LWP 4501)] <<< new output > [Switching to Thread 0x7ffff7f0b700 (LWP 4500)] > __GI___nptl_death_event () at events.c:31 > 31 { > (gdb) FAIL: gdb.threads/manythreads.exp: stop threads 1 > > That is, I was now getting "New Thread" lines after the "Program > received signal" line, and the test doesn't expect them. As the > number of new threads discovered before and after the "Program > received signal" output is unbounded, it's much nicer to defer > "Program received signal" until after synching the thread list, thus > close to the "switching to thread" output and "current frame/source" > info: > > [Thread 0x7ffff7863700 (LWP 7647) exited] > ^C[New Thread 0x7ffff786b700 (LWP 7648)] > > Program received signal SIGINT, Interrupt. > [Switching to Thread 0x7ffff7fc4740 (LWP 6243)] > __GI___nptl_create_event () at events.c:25 > 25 { > (gdb) PASS: gdb.threads/manythreads.exp: stop threads 1 This commit factors out the two places in the test that are effected by this, and adds there a destilled version of the comment above. gdb/testsuite/ 2014-10-02 Pedro Alves <palves@redhat.com> * gdb.threads/manythreads.exp (interrupt_and_wait): New procedure. (top level) <stop threads 1, stop threads 2>: Use it.
2014-09-24 17:59:42 +00:00
# Send a Ctrl-C and wait for the SIGINT.
proc interrupt_and_wait { message } {
global gdb_prompt
send_gdb "\003"
gdb_test_multiple "" $message {
-re "\\\[New \[^\]\]*\\\]\r\n" {
exp_continue
}
-re "\\\[\[^\]\]* exited\\\]\r\n" {
exp_continue
}
-re "Program received signal SIGINT.*$gdb_prompt $" {
pass "$message"
}
-re "$gdb_prompt $" {
# Note that with this regex order, if GDB emits [New
# Thread ...] output between "Program received signal" and
# the prompt, the "Program received signal" regex won't
# match. That's good, as if we see that happening, it's a
# regression.
#
# GDB makes sure to notify about signal stops, end of
# stepping ranges, etc., only after updating the thread
# list, otherwise that stop info would be easy to miss.
#
# A BROKEN example would be:
#
# ... pages of new threads output ...
# [New Thread NNN]
# ^C
# ... more new threads output ...
# [New Thread NNN]
# [New Thread NNN]
# Program received signal SIGINT, Interrupt.
# [New Thread NNN]
# [New Thread NNN]
# ... pages of new threads output ...
# [Switching to Thread NNN]
# foo () at foo.c:31
# 31 bar ();
#
fail $message
gdb.threads/manythreads.exp: clean up and add comment In git b57bacec, I said: > With that in place, the need to delay "Program received signal FOO" > was actually caught by the manythreads.exp test. Without that bit, I > was getting: > > [Thread 0x7ffff7f13700 (LWP 4499) exited] > [New Thread 0x7ffff7f0b700 (LWP 4500)] > ^C > Program received signal SIGINT, Interrupt. > [New Thread 0x7ffff7f03700 (LWP 4501)] <<< new output > [Switching to Thread 0x7ffff7f0b700 (LWP 4500)] > __GI___nptl_death_event () at events.c:31 > 31 { > (gdb) FAIL: gdb.threads/manythreads.exp: stop threads 1 > > That is, I was now getting "New Thread" lines after the "Program > received signal" line, and the test doesn't expect them. As the > number of new threads discovered before and after the "Program > received signal" output is unbounded, it's much nicer to defer > "Program received signal" until after synching the thread list, thus > close to the "switching to thread" output and "current frame/source" > info: > > [Thread 0x7ffff7863700 (LWP 7647) exited] > ^C[New Thread 0x7ffff786b700 (LWP 7648)] > > Program received signal SIGINT, Interrupt. > [Switching to Thread 0x7ffff7fc4740 (LWP 6243)] > __GI___nptl_create_event () at events.c:25 > 25 { > (gdb) PASS: gdb.threads/manythreads.exp: stop threads 1 This commit factors out the two places in the test that are effected by this, and adds there a destilled version of the comment above. gdb/testsuite/ 2014-10-02 Pedro Alves <palves@redhat.com> * gdb.threads/manythreads.exp (interrupt_and_wait): New procedure. (top level) <stop threads 1, stop threads 2>: Use it.
2014-09-24 17:59:42 +00:00
}
}
}
gdb.threads/manythreads.exp: clean up and add comment In git b57bacec, I said: > With that in place, the need to delay "Program received signal FOO" > was actually caught by the manythreads.exp test. Without that bit, I > was getting: > > [Thread 0x7ffff7f13700 (LWP 4499) exited] > [New Thread 0x7ffff7f0b700 (LWP 4500)] > ^C > Program received signal SIGINT, Interrupt. > [New Thread 0x7ffff7f03700 (LWP 4501)] <<< new output > [Switching to Thread 0x7ffff7f0b700 (LWP 4500)] > __GI___nptl_death_event () at events.c:31 > 31 { > (gdb) FAIL: gdb.threads/manythreads.exp: stop threads 1 > > That is, I was now getting "New Thread" lines after the "Program > received signal" line, and the test doesn't expect them. As the > number of new threads discovered before and after the "Program > received signal" output is unbounded, it's much nicer to defer > "Program received signal" until after synching the thread list, thus > close to the "switching to thread" output and "current frame/source" > info: > > [Thread 0x7ffff7863700 (LWP 7647) exited] > ^C[New Thread 0x7ffff786b700 (LWP 7648)] > > Program received signal SIGINT, Interrupt. > [Switching to Thread 0x7ffff7fc4740 (LWP 6243)] > __GI___nptl_create_event () at events.c:25 > 25 { > (gdb) PASS: gdb.threads/manythreads.exp: stop threads 1 This commit factors out the two places in the test that are effected by this, and adds there a destilled version of the comment above. gdb/testsuite/ 2014-10-02 Pedro Alves <palves@redhat.com> * gdb.threads/manythreads.exp (interrupt_and_wait): New procedure. (top level) <stop threads 1, stop threads 2>: Use it.
2014-09-24 17:59:42 +00:00
# Send a Ctrl-C and verify that we can do info threads and continue
interrupt_and_wait "stop threads 1"
set cmd "info threads"
set ok 0
gdb_test_multiple $cmd $cmd {
-re " 1 *Thread " {
set ok 1
exp_continue
}
-re ".*\r\n" {
# Eat this line and continue, to prevent the buffer overflowing.
exp_continue
}
-re "$gdb_prompt $" {
if { $ok } {
pass $cmd
} else {
fail $cmd
}
}
}
gdb_test_no_output "thread name zardoz" "give a name to the thread"
gdb_test "info threads" ".*zardoz.*" "check thread name"
set message "second continue"
gdb_test_multiple "continue" "second continue" {
-re "error:.*$gdb_prompt $" {
fail "$message"
}
-re "Continuing" {
pass "$message"
}
}
# Wait another second. If the program stops on its own, GDB has failed
# to handle duplicate SIGINTs sent to multiple threads.
set failed 0
remote_expect host 1 {
-re "\\\[New \[^\]\]*\\\]\r\n" {
exp_continue -continue_timer
}
-re "\\\[\[^\]\]* exited\\\]\r\n" {
exp_continue -continue_timer
}
-re "Program received signal SIGINT.*$gdb_prompt $" {
if { $failed == 0 } {
fail "check for duplicate SIGINT"
}
send_gdb "continue\n"
set failed 1
exp_continue
}
timeout {
if { $failed == 0 } {
pass "check for duplicate SIGINT"
}
}
}
# Send another Ctrl-C and verify that we can do info threads and quit
gdb.threads/manythreads.exp: clean up and add comment In git b57bacec, I said: > With that in place, the need to delay "Program received signal FOO" > was actually caught by the manythreads.exp test. Without that bit, I > was getting: > > [Thread 0x7ffff7f13700 (LWP 4499) exited] > [New Thread 0x7ffff7f0b700 (LWP 4500)] > ^C > Program received signal SIGINT, Interrupt. > [New Thread 0x7ffff7f03700 (LWP 4501)] <<< new output > [Switching to Thread 0x7ffff7f0b700 (LWP 4500)] > __GI___nptl_death_event () at events.c:31 > 31 { > (gdb) FAIL: gdb.threads/manythreads.exp: stop threads 1 > > That is, I was now getting "New Thread" lines after the "Program > received signal" line, and the test doesn't expect them. As the > number of new threads discovered before and after the "Program > received signal" output is unbounded, it's much nicer to defer > "Program received signal" until after synching the thread list, thus > close to the "switching to thread" output and "current frame/source" > info: > > [Thread 0x7ffff7863700 (LWP 7647) exited] > ^C[New Thread 0x7ffff786b700 (LWP 7648)] > > Program received signal SIGINT, Interrupt. > [Switching to Thread 0x7ffff7fc4740 (LWP 6243)] > __GI___nptl_create_event () at events.c:25 > 25 { > (gdb) PASS: gdb.threads/manythreads.exp: stop threads 1 This commit factors out the two places in the test that are effected by this, and adds there a destilled version of the comment above. gdb/testsuite/ 2014-10-02 Pedro Alves <palves@redhat.com> * gdb.threads/manythreads.exp (interrupt_and_wait): New procedure. (top level) <stop threads 1, stop threads 2>: Use it.
2014-09-24 17:59:42 +00:00
interrupt_and_wait "stop threads 2"
gdb_test_multiple "quit" "GDB exits after stopping multithreaded program" {
-re "Quit anyway\\? \\(y or n\\) $" {
send_gdb "y\n"
exp_continue
}
eof {
pass "GDB exits after stopping multithreaded program"
}
timeout {
fail "GDB exits after stopping multithreaded program (timeout)"
}
}