aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2015-09-16 15:51:36 +0100
committerPedro Alves <palves@redhat.com>2015-09-16 15:51:36 +0100
commitd136eff549649f23b12121575362dfa09343ea0a (patch)
tree84c8cc62c220415efabb2c7dac8fa083d4c7bbca
parent991f019c506528fa94ac173db6f1120f8b2373bf (diff)
downloadfsf-binutils-gdb-d136eff549649f23b12121575362dfa09343ea0a.zip
fsf-binutils-gdb-d136eff549649f23b12121575362dfa09343ea0a.tar.gz
fsf-binutils-gdb-d136eff549649f23b12121575362dfa09343ea0a.tar.bz2
Make it easier to debug non-stop-fair-events.exp
If we enable infrun debug running this test, it quickly fails with a full expect buffer. That can be simply handled with a couple exp_continues. As it's annoying to hack this every time we need to debug the test, this patch adds bits to enable debugging support easily, with a one-line change. And then, if any iteration of the test fails, we end up with a long cascade of time outs. Just bail out when we see the first fail. gdb/testsuite/ 2015-09-16 Pedro Alves <palves@redhat.com> * gdb.threads/non-stop-fair-events.exp (gdb_test_no_anchor) (enable_debug): New procedures. (test): Use them. Bail out if waiting for threads fails. (top level): Bail out if a test fails.
-rw-r--r--gdb/testsuite/ChangeLog7
-rw-r--r--gdb/testsuite/gdb.threads/non-stop-fair-events.exp57
2 files changed, 61 insertions, 3 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index de503ac..ca2dfde 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2015-09-16 Pedro Alves <palves@redhat.com>
+
+ * gdb.threads/non-stop-fair-events.exp (gdb_test_no_anchor)
+ (enable_debug): New procedures.
+ (test): Use them. Bail out if waiting for threads fails.
+ (top level): Bail out if a test fails.
+
2015-09-16 Yao Qi <yao.qi@linaro.org>
* gdb.asm/asm-source.exp: Set asm-arch for
diff --git a/gdb/testsuite/gdb.threads/non-stop-fair-events.exp b/gdb/testsuite/gdb.threads/non-stop-fair-events.exp
index e2d3f7d..37f5bcb 100644
--- a/gdb/testsuite/gdb.threads/non-stop-fair-events.exp
+++ b/gdb/testsuite/gdb.threads/non-stop-fair-events.exp
@@ -98,6 +98,29 @@ proc restart {} {
delete_breakpoints
}
+# Run command and wait for the prompt, without end anchor.
+
+proc gdb_test_no_anchor {cmd} {
+ global gdb_prompt
+
+ gdb_test_multiple $cmd $cmd {
+ -re "$gdb_prompt " {
+ pass $cmd
+ }
+ }
+}
+
+# Enable/disable debugging.
+
+proc enable_debug {enable} {
+
+ # Comment out to debug problems with the test.
+ return
+
+ gdb_test_no_anchor "set debug infrun $enable"
+ gdb_test_no_anchor "set debug displaced $enable"
+}
+
# The test proper. SIGNAL_THREAD is the thread that has been elected
# to receive the SIGUSR1 signal.
@@ -126,30 +149,55 @@ proc test {signal_thread} {
# Let the main thread queue the signal.
gdb_breakpoint "loop_broke"
+
+ enable_debug 1
+
+ set saw_continuing 0
set test "continue &"
gdb_test_multiple $test $test {
- -re "Continuing.\r\n$gdb_prompt " {
- pass $test
+ -re "Continuing.\r\n" {
+ set saw_continuing 1
+ exp_continue
+ }
+ -re "$gdb_prompt " {
+ gdb_assert $saw_continuing $test
+ }
+ -re "infrun:" {
+ exp_continue
}
}
+ set gotit 0
+
# Wait for all threads to finish their steps, and for the main
# thread to hit the breakpoint.
for {set i 1} { $i <= $NUM_THREADS } { incr i } {
set test "thread $i broke out of loop"
+ set gotit 0
gdb_test_multiple "" $test {
-re "loop_broke" {
# The prompt was already matched in the "continue
# &" test above. We're now consuming asynchronous
# output that comes after the prompt.
+ set gotit 1
pass $test
}
+ -re "infrun:" {
+ exp_continue
+ }
+ }
+ if {!$gotit} {
+ break
}
}
+ enable_debug 0
+
# It's helpful to have this in the log if the test ever
# happens to fail.
gdb_test "info threads"
+
+ return $gotit
}
}
@@ -158,5 +206,8 @@ proc test {signal_thread} {
# with lowest kernel thread ID. So test once with the signal pending
# in each thread, except the main thread.
for {set i 2} { $i <= $NUM_THREADS } { incr i } {
- test $i
+ if {![test $i]} {
+ # Avoid cascading timeouts, and bail out.
+ return
+ }
}