From f10b16d41ffcdab3f103f57035c3cf958f1d4022 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Wed, 15 Dec 2004 18:28:54 +0000 Subject: [PATCH] * gdb.threads/linux-dp.exp: Fix output regexp to handle output under NPTL when there is debugging info available for libpthread. --- gdb/testsuite/ChangeLog | 5 +++ gdb/testsuite/gdb.threads/linux-dp.exp | 67 ++++++++++++++++++++++++++++++---- 2 files changed, 64 insertions(+), 8 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 0e5bcf7..9dd1858 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-12-15 Jim Blandy + + * gdb.threads/linux-dp.exp: Fix output regexp to handle output + under NPTL when there is debugging info available for libpthread. + 2004-12-13 Jerome Guitton * gdb.ada/fixed_points.c: New file. diff --git a/gdb/testsuite/gdb.threads/linux-dp.exp b/gdb/testsuite/gdb.threads/linux-dp.exp index e6baffe..0b54d64 100644 --- a/gdb/testsuite/gdb.threads/linux-dp.exp +++ b/gdb/testsuite/gdb.threads/linux-dp.exp @@ -91,7 +91,12 @@ for {set i 0} {$i < 5} {incr i} { 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" @@ -99,11 +104,7 @@ for {set i 0} {$i < 5} {incr 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"] @@ -112,12 +113,62 @@ set info_threads_ptn "" 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 -- 2.7.4