[3/3] Adjust gdb.threads/step-over-trips-on-watchpoint.exp for Cygwin
Commit Message
gdb.threads/step-over-trips-on-watchpoint.exp fails on Cygwin with
many casding timeouts:
Running /home/alves/rocm/gdb/src/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.exp ...
FAIL: gdb.threads/step-over-trips-on-watchpoint.exp: displaced=off: no thread-specific bp: step: continue to breakpoint: run to breakpoint in thread 2 (timeout)
FAIL: gdb.threads/step-over-trips-on-watchpoint.exp: displaced=off: no thread-specific bp: step: find addresses: clear watch_me (timeout)
FAIL: gdb.threads/step-over-trips-on-watchpoint.exp: displaced=off: no thread-specific bp: step: find addresses: watch watch_me (timeout)
FAIL: gdb.threads/step-over-trips-on-watchpoint.exp: displaced=off: no thread-specific bp: step: find addresses: continue to watchpoint (timeout)
FAIL: gdb.threads/step-over-trips-on-watchpoint.exp: displaced=off: no thread-specific bp: step: find addresses: find addresses (timeout)
FAIL: gdb.threads/step-over-trips-on-watchpoint.exp: displaced=off: no thread-specific bp: step: find addresses: delete all breakpoints, watchpoints, tracepoints, and catchpoints in delete_breakpoints (timeout)
... many more ...
The problem is that the testcase assumes that the program's child
thread is GDB thread ID 2. This commit removes that assumption. It
now passes cleanly on Cygwin.
Change-Id: Ief28e6ebf47abdcd2e71c5f2c70caf2d8753ef5e
commit-id: 7207e3c2
---
.../step-over-trips-on-watchpoint.exp | 22 ++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
@@ -53,6 +53,20 @@ proc do_test { displaced with_bp } {
continue
}
+ gdb_breakpoint "child_function"
+
+ # Don't assume the testcase's child thread has GDB
+ # thread id 2. On some systems, like e.g.,
+ # Cygwin/Windows the OS/runtime spawns helper threads
+ # before the child thread is spawned.
+ set thr_child "unknown"
+ gdb_test_multiple "c" "run to child thread" {
+ -re -wrap "Thread ($::decimal) .*hit Breakpoint .*, child_function.*" {
+ set thr_child $expect_out(1,string)
+ pass $gdb_test_name
+ }
+ }
+
gdb_test_no_output "set displaced-stepping $displaced"
set line [gdb_get_line_number "set wait-thread breakpoint here"]
@@ -60,15 +74,17 @@ proc do_test { displaced with_bp } {
return
}
gdb_continue_to_breakpoint "run to wait-thread breakpoint"
- gdb_test "info threads" "\\\* 1 .* 2 .*" "info threads shows all threads"
+ gdb_test "info threads" "\\\* 1 .* $thr_child .*" \
+ "info threads shows all threads"
gdb_test_no_output "set scheduler-locking on"
delete_breakpoints
gdb_breakpoint [gdb_get_line_number "set breakpoint child here"]
- gdb_test "thread 2" "Switching to .*"
- gdb_continue_to_breakpoint "run to breakpoint in thread 2"
+ gdb_test "thread $thr_child" "Switching to .*" \
+ "switch to child thread"
+ gdb_continue_to_breakpoint "run to breakpoint in child thread"
set address_triggers_watch "<invalid>"
set after_address_triggers_watch "<invalid>"