set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
+# The number of threads, including the main thread.
+set NUM 2
+
if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
return -1
}
send_gdb "print args\n"
gdb_expect {
- -re "\\\$\[0-9\]+ = {(\[0-9\]+), (\[0-9\]+), (\[0-9\]+), (\[0-9\]+), (\[0-9\]+), (\[0-9\]+)}.*$gdb_prompt"
+ -re "\\\$\[0-9\]+ = {(\[0-9\]+), (\[0-9\]+)}.*$gdb_prompt"
{
set list_count [expr $list_count + 1]
pass "listed args ($list_count)"
- return [list $expect_out(1,string) $expect_out(2,string) $expect_out(3,string) $expect_out(4,string) $expect_out(5,string) $expect_out(6,string)]
+ return [list $expect_out(1,string) $expect_out(2,string)]
}
-re "$gdb_prompt"
{
stop_process "stop all threads ($msg)"
# Make sure we're in one of the non-main looping threads.
- gdb_breakpoint [concat [gdb_get_line_number "schedlock.exp: main loop"] " if arg != 5"]
+ gdb_breakpoint [concat [gdb_get_line_number "schedlock.exp: main loop"] " if arg != 0"]
gdb_continue_to_breakpoint "return to loop ($msg)"
delete_breakpoints
}
set cont_args [get_args]
-for {set i 0} {[expr $i < 6]} {set i [expr $i + 1]} {
+set ok 1
+for {set i 0} {[expr $i < $NUM]} {set i [expr $i + 1]} {
if {[lindex $start_args $i] == [lindex $cont_args $i]} {
- fail "thread $i ran (didn't run)"
- } else {
- pass "thread $i ran"
+ set ok 0
}
}
+if { $ok } {
+ pass "all threads alive"
+} else {
+ fail "all threads alive"
+}
# We can't change threads, unfortunately, in current GDB. Use
# whichever we stopped in.
set cont_args [get_args]
set num_other_threads 0
-for {set i 0} {[expr $i < 6]} {set i [expr $i + 1]} {
+for {set i 0} {[expr $i < $NUM]} {set i [expr $i + 1]} {
if {[lindex $start_args $i] == [lindex $cont_args $i]} {
if {$i == $curthread} {
fail "current thread stepped (didn't run)"
}
}
if {$num_other_threads > 0} {
- pass "other threads ran (1)"
+ pass "other threads ran - unlocked"
} else {
- fail "other threads ran (no other threads ran) (1)"
+ fail "other threads ran - unlocked"
}
# Test continue with scheduler locking
set start_args $cont_args
set cont_args [get_args]
-for {set i 0} {[expr $i < 6]} {set i [expr $i + 1]} {
+set num_other_threads 0
+for {set i 0} {[expr $i < $NUM]} {set i [expr $i + 1]} {
if {[lindex $start_args $i] == [lindex $cont_args $i]} {
if {$i == $curthread} {
fail "current thread ran (didn't run)"
- } else {
- pass "other thread $i didn't run"
}
} else {
if {$i == $curthread} {
pass "current thread ran"
} else {
- fail "other thread $i didn't run (ran)"
+ incr num_other_threads
}
}
}
+if {$num_other_threads > 0} {
+ fail "other threads didn't run - locked"
+} else {
+ pass "other threads didn't run - locked"
+}
# Test stepping with scheduler locking
step_ten_loops "locked"
set start_args $cont_args
set cont_args [get_args]
-for {set i 0} {[expr $i < 6]} {set i [expr $i + 1]} {
+set num_other_threads 0
+for {set i 0} {[expr $i < $NUM]} {set i [expr $i + 1]} {
if {[lindex $start_args $i] == [lindex $cont_args $i]} {
if {$i == $curthread} {
fail "current thread stepped locked (didn't run)"
- } else {
- pass "other thread $i didn't run (stepping)"
}
} else {
if {$i == $curthread} {
fail "current thread stepped locked (wrong amount)"
}
} else {
- fail "other thread $i didn't run (stepping) (ran)"
+ incr num_other_threads
}
}
}
+if {$num_other_threads > 0} {
+ fail "other threads didn't run - step locked"
+} else {
+ pass "other threads didn't run - step locked"
+}
return 0