[gdb/testsuite] Test sw watchpoint in gdb.threads/process-dies-while-detaching.exp
authorTom de Vries <tdevries@suse.de>
Mon, 27 Sep 2021 08:16:57 +0000 (10:16 +0200)
committerTom de Vries <tdevries@suse.de>
Mon, 27 Sep 2021 08:16:57 +0000 (10:16 +0200)
The test-case gdb.threads/process-dies-while-detaching.exp takes about 20s
when using hw watchpoints, but when forcing sw watchpoints (using the patch
mentioned in PR28375#c0), the test-case takes instead 3m14s.

Also, it show a FAIL:
...
(gdb) continue^M
Continuing.^M
Cannot find user-level thread for LWP 10324: generic error^M
(gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process:
continue: watchpoint: continue
...
for which PR28375 was filed.

Modify the test-case to:
- add the hw/sw axis to the watchpoint testing, to ensure that we
  observe the sw watchpoint behaviour also on can-use-hw-watchpoints
  architectures.
- skip the hw breakpoint testing if not supported
- set the sw watchpoint later to avoid making the test
  too slow.  This still triggers the same PR, but now takes just 24s.

This patch adds a KFAIL for PR28375.

Tested on x86_64-linux.

gdb/testsuite/gdb.threads/process-dies-while-detaching.exp

index ac1aad26ec5776c0e30acc583ca8967c1d9b79e9..ab5a82bef71edf4e0c5c98b4b773d31a9c7b7c7e 100644 (file)
@@ -235,8 +235,12 @@ proc test_detach {multi_process cmd} {
 
 # Same as test_detach, except set a watchpoint before detaching.
 
-proc test_detach_watch {multi_process cmd} {
-    with_test_prefix "watchpoint" {
+proc test_detach_watch {wp multi_process cmd} {
+    if { $wp == "hw" && [skip_hw_watchpoint_tests] } {
+       unsupported "hw watchpoint"
+       return
+    }
+    with_test_prefix "watchpoint:$wp" {
        global binfile decimal
 
        clean_restart ${binfile}
@@ -254,15 +258,28 @@ proc test_detach_watch {multi_process cmd} {
            gdb_continue_to_breakpoint "child_function" ".*"
        }
 
-       # Set a watchpoint in the child.
-       gdb_test "watch globalvar" ".* watchpoint $decimal: globalvar"
+       if { $wp == "hw" } {
+           # Set a watchpoint in the child.
+           gdb_test "watch globalvar" ".* watchpoint $decimal: globalvar"
 
-       # Continue to the _exit breakpoint.  This arms the watchpoint
-       # registers in all threads.  Detaching will thus need to clear
-       # them out, and handle the case of the thread disappearing
-       # while doing that (on targets that need to detach from each
-       # thread individually).
-       continue_to_exit_bp
+           # Continue to the _exit breakpoint.  This arms the watchpoint
+           # registers in all threads.  Detaching will thus need to clear
+           # them out, and handle the case of the thread disappearing
+           # while doing that (on targets that need to detach from each
+           # thread individually).
+           continue_to_exit_bp
+       } else {
+           # Force software watchpoints.
+           gdb_test_no_output "set can-use-hw-watchpoints 0"
+
+           # As above, but flip order, other wise things take too long.
+           continue_to_exit_bp
+           gdb_test "watch globalvar" "Watchpoint $decimal: globalvar"
+
+           if { $multi_process == 0 && $cmd == "continue" } {
+               setup_kfail "gdb/28375" "*-*-*"
+           }
+       }
 
        do_detach $multi_process $cmd "normal"
     }
@@ -332,7 +349,9 @@ proc do_test {multi_process cmd} {
     }
 
     test_detach $multi_process $cmd
-    test_detach_watch $multi_process $cmd
+    foreach wp {"sw" "hw"} {
+       test_detach_watch $wp $multi_process $cmd
+    }
     test_detach_killed_outside $multi_process $cmd
 }