* gdb.threads/linux-dp.exp: Fix output regexp to handle output
authorJim Blandy <jimb@codesourcery.com>
Wed, 15 Dec 2004 18:28:54 +0000 (18:28 +0000)
committerJim Blandy <jimb@codesourcery.com>
Wed, 15 Dec 2004 18:28:54 +0000 (18:28 +0000)
under NPTL when there is debugging info available for libpthread.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.threads/linux-dp.exp

index 0e5bcf7e32247714d3d372ec8078fba7ca01a57a..9dd18587a5be509a82159ec6f499126b4b6bb994 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-15  Jim Blandy  <jimb@redhat.com>
+
+       * 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  <guitton@gnat.com>
 
        * gdb.ada/fixed_points.c: New file.
index e6baffecddb87dccea5519afb9c3caa96b40865c..0b54d64153a0c8b8f9d7a7cb0b9bd7366e5a7829 100644 (file)
@@ -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