public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb Power 9 add test for HW watchpoint support.
@ 2021-12-10 16:16 Carl Love
  2021-12-16 13:06 ` Ulrich Weigand
  0 siblings, 1 reply; 2+ messages in thread
From: Carl Love @ 2021-12-10 16:16 UTC (permalink / raw)
  To: gdb-patches, cel, Ulrich Weigand; +Cc: Rogerio Alves, Will Schmidt

GDB maintainers:

The following patch adds a runtime check for hardware watchpoints on
PowerPC platforms.  The Power9 processor version 2.2 has a hardware bug
in the DAWR support.  The hardware watch point support is disabled on
this version of the processor. It necessary to check the underlying
hardware to determine if the hardware watchpoint support is available. 
This patch adds the runtime check for PowerPC to
skip_hw_watchpoint_tests to correctly determine if the the hardware
watchpoint tests should be enabled.

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

                      Carl 


---------------------------------------------------------

gdb Power 9 add test for HW watchpoint support.

The Power 9 processor revision 2.2 has HW watchpoint support disabled due
to a HW bug.  The support is fixed in Power 9 processor revision 2.3.  This
patch add a test to lib/gdb.exp for Power to determine if the processor
supports HW watchpoints or not.  If the Power processor doesn't support HW
watchpoints the proceedure skip_hw_watchpoint_tests will return 1 to
disable the various HW watchpoint tests.

The patch has been tested on Power 9, processor revesions 2.2 and 2.3.  The
patch has also been tested on Power 10.  No regression test failures were
found.

---
 gdb/testsuite/lib/gdb.exp | 62 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 61 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index deb1b8f2138..07b288eced6 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3715,12 +3715,15 @@ proc skip_hw_watchpoint_tests {} {
     }
 
     # These targets support hardware watchpoints natively
+    # Note, not all Power 9 processors support hardware watchpoints due to a HW
+    # bug.  Use has_hw_wp_support to check do a runtime check for hardware
+    # watchpoint support on Powerpc.
     if { [istarget "i?86-*-*"] 
 	 || [istarget "x86_64-*-*"]
 	 || [istarget "ia64-*-*"] 
 	 || [istarget "arm*-*-*"]
 	 || [istarget "aarch64*-*-*"]
-	 || [istarget "powerpc*-*-linux*"]
+	 || ([istarget "powerpc*-*-linux*"] && [has_hw_wp_support])
 	 || [istarget "s390*-*-*"] } {
 	return 0
     }
@@ -8291,5 +8294,62 @@ proc require { fn arg1 {arg2 ""} } {
     return -code return 0
 }
 
+gdb_caching_proc has_hw_wp_support {
+    # Power 9, proc rev 2.2 does not support HW watchpoints due to HW bug.
+    # Need to use a runtime test to determine if the Power processor has
+    # support for HW watchpoints.
+    global srcdir subdir gdb_prompt inferior_exited_re
+
+    set compile_flags {debug nowarnings quiet}
+    set me "has_hw_wp_support"
+
+    # Compile a test program to test if HW watchpoints are supported
+    set src {
+	int main (void) {
+	    volatile int local;
+	    local = 1;
+	    if (local == 1)
+		return 1;
+	    return 0;
+	}
+    }
+
+    if {![gdb_simple_compile $me $src executable $compile_flags]} {
+        return 0
+    }
+
+    gdb_exit
+    gdb_start
+    gdb_reinitialize_dir $srcdir/$subdir
+    gdb_load "$obj"
+
+    if ![runto_main] {
+	set has_hw_wp_support 0
+	return $has_hw_wp_support
+    }
+
+    # The goal is to determine if HW watchpoints are available in general.
+    # Use "watch" and then check if gdb responds with hardware watch point.
+    set test "watch local"
+
+    gdb_test_multiple  $test "Check for HW watchpoint support" {
+	-re ".*Hardware watchpoint.*" {
+	    #  HW watchpoint supported by platform
+	    verbose -log "\n$me: Hardware watchpoint detected"
+            set has_hw_wp_support 1
+	}
+	-re ".*$gdb_prompt $" {
+	    set has_hw_wp_support 0
+	    verbose -log "\n$me: Default, hardware watchpoint not deteced"
+	}
+    }
+
+    gdb_exit
+    remote_file build delete $obj
+
+    verbose "$me: returning $has_hw_wp_support" 2
+    return $has_hw_wp_support
+}
+
 # Always load compatibility stuff.
 load_lib future.exp
-- 
2.30.2



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] gdb Power 9 add test for HW watchpoint support.
  2021-12-10 16:16 [PATCH] gdb Power 9 add test for HW watchpoint support Carl Love
@ 2021-12-16 13:06 ` Ulrich Weigand
  0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Weigand @ 2021-12-16 13:06 UTC (permalink / raw)
  To: Carl Love; +Cc: gdb-patches, Rogerio Alves, Will Schmidt



"Carl Love" <cel@us.ibm.com> wrote on 10.12.2021 17:16:18:

> gdb Power 9 add test for HW watchpoint support.
>
> The Power 9 processor revision 2.2 has HW watchpoint support disabled due
> to a HW bug.  The support is fixed in Power 9 processor revision 2.3.
This
> patch add a test to lib/gdb.exp for Power to determine if the processor
> supports HW watchpoints or not.  If the Power processor doesn't support
HW
> watchpoints the proceedure skip_hw_watchpoint_tests will return 1 to
> disable the various HW watchpoint tests.
>
> The patch has been tested on Power 9, processor revesions 2.2 and 2.3.
The
> patch has also been tested on Power 10.  No regression test failures were
> found.

This is OK.

Thanks,
Ulrich

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-16 13:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-10 16:16 [PATCH] gdb Power 9 add test for HW watchpoint support Carl Love
2021-12-16 13:06 ` Ulrich Weigand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).