return -1
}
-re "$gdb_prompt $" {
- fail "create philosopher: $i"
+ # We used to fail here, but not all targets announce new
+ # threads as they are created. For example, the GDB
+ # remote protocol target only finds out about threads when
+ # they actually report some event like a breakpoint hit,
+ # or when the user types 'info threads'.
+ unresolved "create philosopher: $i"
}
timeout {
fail "(timeout) create philosopher: $i"
}
}
-if {$expect_manager} {
- set nthreads 7
-} else {
- set nthreads 6
-}
+set nthreads 6
# Run until there are some threads.
gdb_breakpoint [gdb_get_line_number "linuxthreads.exp: info threads 2"]
for {set i $nthreads} {$i > 0} {incr i -1} {
append info_threads_ptn "$i Thread .*"
}
-gdb_test "info threads" $info_threads_ptn "info threads 2"
+append info_threads_ptn "\[\r\n\]+$gdb_prompt $"
+set info_threads_manager_ptn "[expr $nthreads + 1] Thread .*$info_threads_ptn"
+
+gdb_test_multiple "info threads" "info threads 2" {
+ -re "$info_threads_manager_ptn" {
+ # We did see a manager thread. Check that against what we expected.
+ switch -exact -- $expect_manager {
+ -1 {
+ # We weren't sure whether to expect a manager thread.
+ pass "info threads 2"
+ }
+ 1 {
+ # We were expecting a manager thread.
+ pass "info threads 2"
+ }
+ 0 {
+ # We were not expecting to see the manager thread.
+ fail "info threads 2"
+ }
+ }
+ set expect_manager 1
+ incr nthreads
+ }
+ -re "$info_threads_ptn" {
+ # We did not see a manager thread. Check that against what we
+ # expected.
+ switch -exact -- $expect_manager {
+ -1 {
+ # We weren't sure whether to expect a manager thread.
+ # Don't expect it from here on out.
+ pass "info threads 2"
+ }
+ 1 {
+ # We were expecting a manager thread, but we didn't see one.
+ fail "info threads 2"
+ }
+ 0 {
+ # We were not expecting to see the manager thread.
+ pass "info threads 2"
+ }
+ }
+ set expect_manager 0
+ }
+}
+
# Try setting a thread-specific breakpoint.
gdb_breakpoint "print_philosopher thread 5"
gdb_continue_to_breakpoint "thread 5's print"
-gdb_test "where" "print_philosopher.*philosopher.* from .*libpthread.*" \
+# When there is no debugging info available for the thread library,
+# the backtrace entry for philosopher's caller looks like:
+# #1 0x4001c548 in pthread_create () from /lib/libpthread.so.0
+# If you do have debug info, the output obviously depends more on the
+# exact library in use; under NPTL, you get:
+# #2 0x0012b7fc in start_thread (arg=0x21) at pthread_create.c:264
+gdb_test "where" "print_philosopher.*philosopher.* \(from .*libpthread\|at pthread_create\).*" \
"first thread-specific breakpoint hit"
# Make sure it's catching the right thread. Try hitting the