Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Fix hardware watchpoint check in tests gdb.base/watchpoint.exp and gdb.base/wachpoint-stops-at-right-insn.exp
@ 2022-08-12 17:39 Carl Love via Gdb-patches
  0 siblings, 0 replies; only message in thread
From: Carl Love via Gdb-patches @ 2022-08-12 17:39 UTC (permalink / raw)
  To: Ulrich Weigand, gdb-patches


GDB maintainers:

There are two additional HW watchpoint tests, gdb.base/watchpoint.exp
and gdb.base/wachpoint-stops-at-right-insn.exp, that use 

if { ![target_info exists gdb,no_hardware_watchpoints]}

and need to be updated to use skip_hw_watchpoint_tests to determine if
the test should be run with HW watchpoints.  The issue is due to HW
watchpoints being disabled on Power 9 due to a HW bug.  The proc
skip_hw_watchpoint_tests needs to be used to properly check for HW
watchpoint support.

This patch replaces the [target_info exists gdb,
no_hardware_watchpoints] with the skip_hw_watchpoint_tests
check to properly determine if the processor supports HW watchpoints.

The fix disables the HW watchpoint tests on Power 9 for these tests 
thus eliminating 4 test errors on gdb.base/watchpoint-stops-at-right-
insn.exp generates and 2 errors for test gdb.base/watchpoint.exp on
Power 9.

The patch has been tested on Power 9, Power 10 and x86-64 with no
regressions.

Please let me know if this patch is acceptable for mainline.  Thanks.

                              Carl Love
------------------------------------------------------------------
[PATCH] Fix hardware watchpoint check in tests gdb.base/watchpoint.exp and gdb.base/wachpoint-stops-at-right-insn.exp

Test gdb.base/watchpoint-stops-at-right-insn.exp generates 4 test errors and
test gdb.base/watchpoint.exp generates 2 errors on Power 9 when testing with
HW watchpoints enabled.  The tests use [target_info exists gdb,
no_hardware_watchpoints] to check for HW watchpoint support.  Due to a HW
bug hardware watchpoints are disabled on Power 9.  The skip_hw_watchpoint_tests
proc must be used to correctly determine if the processor supports HW
watchpoints.

This patch replaces the [target_info exists gdb,no_hardware_watchpoints]
with the skip_hw_watchpoint_tests check and thus fix the test failures.

This patch was tested on Power 9, Power 10 and X86-64 with no regressions.
---
 .../watchpoint-stops-at-right-insn.exp        |  2 +-
 gdb/testsuite/gdb.base/watchpoint.exp         | 21 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.exp b/gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.exp
index f9adb1f4f91..6c445d4cbd8 100644
--- a/gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.exp
+++ b/gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.exp
@@ -71,7 +71,7 @@
 standard_testfile
 
 # No use testing this if we can't use hardware watchpoints.
-if {[target_info exists gdb,no_hardware_watchpoints]} {
+if {[skip_hw_watchpoint_tests]} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.base/watchpoint.exp b/gdb/testsuite/gdb.base/watchpoint.exp
index 01abff5336a..b01e81392c3 100644
--- a/gdb/testsuite/gdb.base/watchpoint.exp
+++ b/gdb/testsuite/gdb.base/watchpoint.exp
@@ -15,6 +15,13 @@
 
 # This file was written by Fred Fish. (fnf@cygnus.com)
 
+# The skip_hw_watchpoint_tests checks if watchpoints are supported by the
+# processor.  On PowerPC, the check runs a small test program under gdb
+# to determine if the Power processor supports HW watchpoints.  The check
+# must be done before starting the test so as to not disrupt the execution
+# of the actual test.
+
+set skip_hw_watchpoint_tests_p [skip_hw_watchpoint_tests]
 
 standard_testfile
 
@@ -630,7 +637,7 @@ proc test_wide_location_1 {} {
 
     # Platforms where the target can't watch such a large region
     # should clear hw_expected below.
-    if { $no_hw || [target_info exists gdb,no_hardware_watchpoints]
+    if { $no_hw || [skip_hw_breakpoint_tests]
          || [istarget arm*-*-*]
          || ([istarget powerpc*-*-*] && ![is_lp64_target])} {
 	set hw_expected 0
@@ -677,7 +684,7 @@ proc test_wide_location_2 {} {
 
     # Platforms where the target can't watch such a large region
     # should clear hw_expected below.
-    if { $no_hw || [target_info exists gdb,no_hardware_watchpoints]
+    if { $no_hw || [skip_hw_breakpoint_tests]
          || [istarget arm*-*-*]
          || [istarget powerpc*-*-*]} {
 	set hw_expected 0
@@ -839,7 +846,7 @@ proc test_no_hw_watchpoints {} {
 
 
     # Re-enable hardware watchpoints if necessary.
-    if ![target_info exists gdb,no_hardware_watchpoints] {
+    if ![skip_hw_breakpoint_tests] {
         gdb_test_no_output "set can-use-hw-watchpoints 1" ""
     }
 }
@@ -892,7 +899,7 @@ proc test_watchpoint_in_big_blob {} {
 proc test_watch_register_location {} {
     global no_hw
 
-    if {!$no_hw && ![target_info exists gdb,no_hardware_watchpoints]} {
+    if {!$no_hw && ![skip_hw_breakpoint_tests]} {
 	# Non-memory read/access watchpoints are not supported, they would
 	# require software read/access watchpoint support (which is not
 	# currently available).
@@ -919,7 +926,7 @@ proc do_tests {} {
 
     clean_restart $testfile
 
-    if {$no_hw || [target_info exists gdb,no_hardware_watchpoints]} {
+    if {$no_hw || [skip_hw_breakpoint_tests]} {
 	gdb_test_no_output "set can-use-hw-watchpoints 0"\
 	    "disable fast watches, 1"
     }
@@ -939,7 +946,7 @@ proc do_tests {} {
     # `initialize' anymore.
     clean_restart $testfile
 
-    if {$no_hw || [target_info exists gdb,no_hardware_watchpoints]} {
+    if {$no_hw || [skip_hw_breakpoint_tests]} {
 	gdb_test_no_output "set can-use-hw-watchpoints 0" \
 	    "disable fast watches, 2"
     }
@@ -977,7 +984,7 @@ proc do_tests {} {
 # watchpoints force-disabled.
 
 do_tests
-if ![target_info exists gdb,no_hardware_watchpoints] {
+if ![skip_hw_breakpoint_tests] {
     with_test_prefix "no-hw" {
 	set no_hw 1
 	do_tests
-- 
2.31.1



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-12 17:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-12 17:39 [PATCH] Fix hardware watchpoint check in tests gdb.base/watchpoint.exp and gdb.base/wachpoint-stops-at-right-insn.exp Carl Love via Gdb-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox