set target_cflags ""
}
set why_msg "unrecognized error"
-foreach lib {-lpthreads -lpthread} {
+foreach lib {-lpthreads -lpthread -lthread} {
set options "debug"
lappend options "incdir=${objdir}/${subdir}"
lappend options "libs=$lib"
# been called 15 times. This should be plenty of time to allow
# every thread to run at least once, since each thread sleeps for
# one second between calls to common_routine.
- gdb_test "tbreak common_routine if hits == 15" ""
+ gdb_test "tbreak common_routine if hits >= 15" ""
# Start all the threads running again and wait for the inferior
# to stop. Since no other breakpoints are set at this time
# Check that we stopped when we actually expected to stop, by
# verifying that there have been 15 previous hits.
+ # NOTE: Because of synchronization behavior, it is possible for
+ # more than one thread to increment "hits" between one breakpoint
+ # trap and the next. So stopping after 16 or 17 hits should be
+ # considered acceptable.
+
send_gdb "p common_routine::hits\n"
gdb_expect {
- -re ".*= 15\r\n$gdb_prompt $" {}
+ -re ".*= 15\r\n$gdb_prompt $" {
+ pass "stopped before calling common_routine 15 times"
+ }
+ -re ".*= 16\r\n$gdb_prompt $" {
+ pass "stopped before calling common_routine 15 times (16 times)"
+ }
+ -re ".*= 17\r\n$gdb_prompt $" {
+ pass "stopped before calling common_routine 15 times (17 times)"
+ }
default {
fail "stopped before calling common_routine 15 times"
return 0
send_gdb "p common_routine::full_coverage\n"
gdb_expect {
- -re ".*= 1\r\n$gdb_prompt $" {}
+ -re ".* = 1.*$gdb_prompt $" {}
+ -re ".* = 0.*$gdb_prompt $" {
+ fail "some threads didn't run"
+ return 0
+ }
default {
fail "some threads didn't run"
return 0
# We should be able to do an info threads before starting any others.
send_gdb "info threads\n"
gdb_expect {
- -re ".*Thread.*LWP.*main.*$gdb_prompt $" {
+ -re ".*Thread.*main.*$gdb_prompt $" {
pass "info threads"
}
-re "\r\n$gdb_prompt $" {
- pass "info threads"
- setup_xfail "*-*-*"
- fail "gdb does not support pthreads for this machine"
+ unsupported "gdb does not support pthreads for this machine"
return 0
}
}
# Send a continue followed by ^C to the process to stop it.
send_gdb "continue\n"
+ gdb_expect {
+ -re "Continuing." {
+ pass "Continue with all threads running"
+ }
+ timeout {
+ fail "Continue with all threads running (timeout)"
+ }
+ }
+ sleep 1
set description "Stopped with a ^C"
after 1000 [send_gdb "\003"]
gdb_expect {
}
timeout {
fail "$description (timeout)"
+ return 1;
}
}
gdb_test "bt" ""
if [all_threads_running] then {
pass "All threads running after continuing from ^C stop"
}
+ return 0;
}
proc check_backtraces {} {
send_gdb "continue\n"
gdb_expect {
-re "Breakpoint .* common_routine \\(arg=2\\).*" {
+ pass "continue to bkpt at common_routine in thread 2"
send_gdb "backtrace\n"
gdb_expect {
-re "#0.*common_routine \\(arg=2\\).*#1.*thread2.*" {
}
}
-re "Breakpoint .* common_routine \\(arg=0\\).*" {
- fail "stopped in main thread at breakpoint for thread 2"
+ fail "continue to bkpt at common_routine in thread 2 (arg=0)"
}
-re "Breakpoint .* common_routine \\(arg=1\\).*" {
- fail "stopped in main thread at breakpoint for thread 1"
+ fail "continue to bkpt at common_routine in thread 2 (arg=1)"
}
-re ".*$gdb_prompt" {
fail "continue to bkpt at common_routine in thread 2"
}
default {
- fail "continue to bkpt at common_routine in thread 2"
+ fail "continue to bkpt at common_routine in thread 2 (default)"
}
timeout {
fail "continue to bkpt at common_routine in thread 2 (timeout)"
if [runto_main] then {
clear_xfail "alpha-*-osf*"
if [test_startup] then {
- check_control_c
+ if [check_control_c] then {
+ warning "Could not stop child with ^C; skipping rest of tests.\n"
+ return;
+ }
check_backtraces
}
}