-# Copyright 2004, 2007 Free Software Foundation, Inc.
+# Copyright 2004-2016 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
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# Please email any bugs, comments, and/or additions to this file to:
-# bug-gdb@prep.ai.mit.edu
-
# 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
}
-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
}
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" ""
+# As this test only runs a single inferior, $_thread and $_gthread
+# should match throughout.
+gdb_test {print $_thread} ".* = 0" "thread var when not running"
+gdb_test {print $_gthread} ".* = 0" "gthread var when not running"
runto_main
return 1
}
+gdb_test {print $_thread} ".* = [lindex $threads 0]" "thread var in main"
+gdb_test {print $_gthread} ".* = [lindex $threads 0]" "gthread var in main"
+
gdb_test_multiple "break $line thread [lindex $threads 0]" \
"breakpoint $line main thread" {
-re "Breakpoint (\[0-9\]*) at.* file .*$srcfile, line.*$gdb_prompt $" {
gdb_breakpoint "$line thread $thread"
}
+set this_breakpoint -1
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"
}
}
+set this_thread -1
+if { $this_breakpoint != -1 } {
+ 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"
+ }
+ }
+} else {
+ untested "info on bp"
+}
+
+if { $this_thread != -1 } {
+ gdb_test {print $_thread} ".* = $this_thread" "thread var at break"
+ gdb_test {print $_gthread} ".* = $this_thread" "gthread var at break"
+} else {
+ untested "thread var at break"
+}
+
return 0