[binutils-gdb] gdb Power 9 add test for HW watchpoint support.

Carl Love carll@sourceware.org
Wed Jan 12 17:57:43 GMT 2022


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8d4e4d13afbca26b6cfebf7221973bb21c40677e

commit 8d4e4d13afbca26b6cfebf7221973bb21c40677e
Author: Carl Love <cel@us.ibm.com>
Date:   Wed Jan 12 11:56:58 2022 -0600

    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.

Diff:
---
 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 c69cb0070ef..a3717a40229 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3740,12 +3740,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
     }
@@ -8331,5 +8334,62 @@ proc target_file_exists_with_timeout { path } {
     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


More information about the Gdb-cvs mailing list