]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/testsuite/gdb.threads/thread-specific.exp
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.threads / thread-specific.exp
index c69dd98d8d9556bd1d82569e39fd8b9b0a37e168..112dfb0f9e52b07316975df2a36dad9a9690d2d9 100644 (file)
@@ -1,38 +1,26 @@
-# Copyright 2004 Free Software Foundation, Inc.
+# Copyright 2004-2013 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+# the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
-
-# Please email any bugs, comments, and/or additions to this file to:
-# bug-gdb@prep.ai.mit.edu
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # This file was written by Daniel Jacobowitz <drow@mvista.com>.
 # It tests that the correct breakpoint is reported when we hit a
 # thread-specific breakpoint inserted for several threads.
 
-if $tracelevel then {
-       strace $tracelevel
-}
-
-set prms_id 0
-set bug_id 0
 
-set testfile "thread-specific"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
-if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug] != "" } {
     return -1
 }
 
@@ -47,11 +35,17 @@ proc get_thread_list { } {
     -re "info threads\r\n" {
       exp_continue
     }
-    -re "^\\*  *(\[0-9\]*) Thread \[^\n\]*main\[^\n\]*\n" {
+    -re "New Thread \[^\n\]*\n" {
+      exp_continue
+    }
+    -re "^ *Id *Target Id\[^\n\]*\n" {
+      exp_continue
+    }
+    -re "^\\*  *(\[0-9\]*) *Thread \[^\n\]*main\[^\n\]*\n" {
       set thr_list "$expect_out(1,string) $thr_list"
       exp_continue
     }
-    -re "^  *(\[0-9\]*) Thread \[^\n\]*\n" {
+    -re "^  *(\[0-9\]*) *Thread \[^\n\]*\n" {
       lappend thr_list $expect_out(1,string)
       exp_continue
     }
@@ -67,16 +61,12 @@ proc get_thread_list { } {
   return $thr_list
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart ${binfile}
 
-gdb_load ${binfile}
+gdb_test_no_output "set print sevenbit-strings"
+gdb_test_no_output "set width 0"
 
-gdb_test "set print sevenbit-strings" ""
-gdb_test "set width 0" ""
+gdb_test {print $_thread} ".* = 0" "thread var when not running"
 
 runto_main
 
@@ -86,9 +76,16 @@ gdb_continue_to_breakpoint "all threads started"
 set line [gdb_get_line_number "thread-specific.exp: thread loop"]
 set threads [get_thread_list]
 
+if {[llength $threads] == 0} {
+  # We have already issued a FAIL above.
+  return 1
+}
+
+gdb_test {print $_thread} ".* = [lindex $threads 0]" "thread var in main"
+
 gdb_test_multiple "break $line thread [lindex $threads 0]" \
   "breakpoint $line main thread" {
-    -re "Breakpoint (\[0-9\]*) at.* file .*$srcfile, line.*" {
+    -re "Breakpoint (\[0-9\]*) at.* file .*$srcfile, line.*$gdb_prompt $" {
       set main_breakpoint $expect_out(1,string)
       pass "breakpoint $line main thread"
     }
@@ -102,9 +99,19 @@ gdb_test_multiple "continue" "continue to thread-specific breakpoint" {
        -re "Breakpoint $main_breakpoint, .* at .*\r\n$gdb_prompt $" {
            fail "continue to thread-specific breakpoint (wrong breakpoint)"
        }
-       -re "Breakpoint .* at .*\r\n$gdb_prompt $" {
+       -re "Breakpoint (\[0-9\]*), .* at .*\r\n$gdb_prompt $" {
+           set this_breakpoint $expect_out(1,string)
            pass "continue to thread-specific breakpoint"
        }
 }
 
+gdb_test_multiple "info breakpoint $this_breakpoint" "info on bp" {
+    -re ".*stop only in thread (\[0-9\]*).*$gdb_prompt $" {
+       set this_thread $expect_out(1,string)
+       pass "found breakpoint for thread number"
+    }
+}
+
+gdb_test {print $_thread} ".* = $this_thread" "thread var at break"
+
 return 0