From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5107 invoked by alias); 27 Nov 2006 18:07:21 -0000 Received: (qmail 5066 invoked by uid 22791); 27 Nov 2006 18:07:18 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 27 Nov 2006 18:07:10 +0000 Received: (qmail 20934 invoked from network); 27 Nov 2006 18:07:09 -0000 Received: from unknown (HELO ?192.168.189.103?) (nathan@127.0.0.2) by mail.codesourcery.com with ESMTPA; 27 Nov 2006 18:07:09 -0000 Message-ID: <456B2998.9040309@codesourcery.com> Date: Mon, 27 Nov 2006 18:07:00 -0000 From: Nathan Sidwell User-Agent: Thunderbird 1.5.0.8 (X11/20061115) MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: linux thread creation test Content-Type: multipart/mixed; boundary="------------010309060406080302020807" Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-11/txt/msg00300.txt.bz2 This is a multi-part message in MIME format. --------------010309060406080302020807 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 472 This patch robustifies gdb.thread/linux-dp.exp. gdbserver cannot report thread creation events, rather than mark such non-appearances as unresolved, this marks them as unsupported. It also checks the thread table before and after thread creation to make sure the expected threads show up there. ok? nathan -- Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk --------------010309060406080302020807 Content-Type: text/x-patch; name="thread.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="thread.patch" Content-length: 4152 2006-11-27 Nathan Sidwell gdb/testsuite/ * gdb.threads/linux-dp.exp: Read thread table before and after creating each philosopher and verify it. Index: gdb/testsuite/gdb.threads/linux-dp.exp =================================================================== --- gdb/testsuite/gdb.threads/linux-dp.exp (revision 155657) +++ gdb/testsuite/gdb.threads/linux-dp.exp (working copy) @@ -67,21 +67,37 @@ gdb_breakpoint [gdb_get_line_number "lin set expect_manager -1 for {set i 0} {$i < 5} {incr i} { gdb_continue_to_breakpoint "about to create philosopher: $i" + send_gdb "info threads\n" + set threads_before {} + gdb_expect { + -re "info threads\r\n" { + exp_continue + } + -re "^\\*? +(\[0-9\]+ Thread \[0-9\]+) \[^\n\]*\n" { + verbose -log "found thread $expect_out(1,string)" 2 + lappend threads_before $expect_out(1,string) + exp_continue + } + -re "^$gdb_prompt $" { + } + timeout { + fail "(timeout) info threads" + } + } send_gdb "next\n" + set threads_created 0 gdb_expect { - -re "\\\[New .*\\\].*\\\[New .*\\\].*$gdb_prompt $" { - # Two threads are created the first time in LinuxThreads, - # where the second is the manager thread. In NPTL, there is none. - if {$i == 0} { - set expect_manager 1 - } - pass "create philosopher: $i" + -re "^next\r\n" { + exp_continue } - -re "\\\[New .*\\\].*$gdb_prompt $" { - if {$i == 0} { - set expect_manager 0 - } - pass "create philosopher: $i" + -re "^\\\[New \[^\]\n\]+\\\]\[^\n\]+\n" { + incr threads_created + exp_continue + } + -re "^189\[^\n\]+\n" { + exp_continue + } + -re "^$gdb_prompt $" { } -re "Program received signal.*(Unknown signal|SIGUSR|Real-time event).*$gdb_prompt $" { # It would be nice if we could catch the message that GDB prints @@ -91,17 +107,72 @@ for {set i 0} {$i < 5} {incr i} { return -1 } -re "$gdb_prompt $" { - # 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 { $threads_created == 0 } { + # 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'. + unsupported "create philosopher: $i" + } elseif { $threads_created == 1 } { + if { $expect_manager < 0 } { + set expect_manager 0 + } + pass "create philosopher: $i" + } elseif { !$i && $threads_created == 2 } { + # Two threads are created the first time in LinuxThreads, + # where the second is the manager thread. In NPTL, there is none. + set expect_manager 1 + pass "create philosopher: $i" + } else { + fail "create philosopher: $i" + } + + send_gdb "info threads\n" + set threads_after {} + gdb_expect { + -re "info threads\r\n" { + exp_continue + } + -re "^\\*? +(\[0-9\]+ Thread \[0-9\]+) \[^\n\]+\n" { + set name $expect_out(1,string) + for {set j 0} {$j != [llength $threads_before] } {incr j} { + if {$name == [lindex $threads_before $j]} { + set threads_before [lreplace $threads_before $j $j] + set name "" + break + } + } + if { $name != "" } { + lappend threads_after $name + } + exp_continue + } + -re "^$gdb_prompt $" { + if { [llength $threads_before] != 0 } { + fail "create philosopher: $i" + } elseif { !$i && [llength $threads_after] == 2 } { + set expect_manager 1 + pass "create philosopher: $i" + } elseif { [llength $threads_after] == 1 } { + if { $expect_manager < 0 } { + set expect_manager 0 + } + pass "create philosopher: $i" + } else { + fail "create philosopher: $i" + } + } + timeout { + fail "(timeout) info threads" + } + } + } set nthreads 6 --------------010309060406080302020807--