aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2007-09-17 15:38:05 +0000
committerDaniel Jacobowitz <drow@false.org>2007-09-17 15:38:05 +0000
commit18ecae383162b8c1be40030cddd69f12d718c689 (patch)
treee1e055f7aa4c4f513383fa7e888ff949207b64eb /gdb
parenteff4f95e29ab873b801945b3e6478089b0c1a934 (diff)
downloadgdb-18ecae383162b8c1be40030cddd69f12d718c689.zip
gdb-18ecae383162b8c1be40030cddd69f12d718c689.tar.gz
gdb-18ecae383162b8c1be40030cddd69f12d718c689.tar.bz2
* schedlock.c (NUM): Change to 1.
(main): Use args[0] for the main thread. * schedlock.exp: Only expect two threads. Only issue one pass or fail regardless of the number of threads.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/testsuite/ChangeLog7
-rw-r--r--gdb/testsuite/gdb.threads/schedlock.c8
-rw-r--r--gdb/testsuite/gdb.threads/schedlock.exp51
3 files changed, 44 insertions, 22 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 188db16..491124a 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2007-09-17 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * schedlock.c (NUM): Change to 1.
+ (main): Use args[0] for the main thread.
+ * schedlock.exp: Only expect two threads. Only issue one pass or fail
+ regardless of the number of threads.
+
2007-09-14 Maciej W. Rozycki <macro@mips.com>
* gdb.mi/mi-watch.exp (test_watchpoint_all): Pass the watchpoint
diff --git a/gdb/testsuite/gdb.threads/schedlock.c b/gdb/testsuite/gdb.threads/schedlock.c
index c1b9069..b364dd4 100644
--- a/gdb/testsuite/gdb.threads/schedlock.c
+++ b/gdb/testsuite/gdb.threads/schedlock.c
@@ -22,7 +22,7 @@
void *thread_function(void *arg); /* Pointer to function executed by each thread */
-#define NUM 5
+#define NUM 1
unsigned int args[NUM+1];
@@ -32,7 +32,7 @@ int main() {
void *thread_result;
long i;
- for (i = 0; i < NUM; i++)
+ for (i = 1; i <= NUM; i++)
{
args[i] = 1;
res = pthread_create(&threads[i],
@@ -42,8 +42,8 @@ int main() {
}
/* schedlock.exp: last thread start. */
- args[i] = 1;
- thread_function ((void *) i);
+ args[0] = 1;
+ thread_function ((void *) 0);
exit(EXIT_SUCCESS);
}
diff --git a/gdb/testsuite/gdb.threads/schedlock.exp b/gdb/testsuite/gdb.threads/schedlock.exp
index cc9a53b..c2ec57a 100644
--- a/gdb/testsuite/gdb.threads/schedlock.exp
+++ b/gdb/testsuite/gdb.threads/schedlock.exp
@@ -32,6 +32,9 @@ set testfile "schedlock"
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
}
@@ -44,11 +47,11 @@ proc get_args { } {
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"
{
@@ -112,7 +115,7 @@ proc my_continue { msg } {
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
}
@@ -198,13 +201,17 @@ my_continue "initial"
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.
@@ -230,7 +237,7 @@ set start_args $cont_args
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)"
@@ -248,9 +255,9 @@ for {set i 0} {[expr $i < 6]} {set i [expr $i + 1]} {
}
}
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
@@ -269,21 +276,25 @@ if {$curthread == $newthread} {
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"
@@ -299,12 +310,11 @@ if {$curthread == $newthread} {
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} {
@@ -314,9 +324,14 @@ for {set i 0} {[expr $i < 6]} {set i [expr $i + 1]} {
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