From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1983) id A320B3858406; Wed, 12 Jan 2022 17:57:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A320B3858406 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Carl Love To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb Power 9 add test for HW watchpoint support. X-Act-Checkin: binutils-gdb X-Git-Author: Carl Love X-Git-Refname: refs/heads/master X-Git-Oldrev: 61671e97927dcc1b302bd01fd59bc61c27972839 X-Git-Newrev: 8d4e4d13afbca26b6cfebf7221973bb21c40677e Message-Id: <20220112175743.A320B3858406@sourceware.org> Date: Wed, 12 Jan 2022 17:57:43 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jan 2022 17:57:43 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D8d4e4d13afbc= a26b6cfebf7221973bb21c40677e commit 8d4e4d13afbca26b6cfebf7221973bb21c40677e Author: Carl Love Date: Wed Jan 12 11:56:58 2022 -0600 gdb Power 9 add test for HW watchpoint support. =20 The Power 9 processor revision 2.2 has HW watchpoint support disabled d= ue 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. =20 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 we= re 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 {} { } =20 # 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-*-*"]=20 || [istarget "x86_64-*-*"] || [istarget "ia64-*-*"]=20 || [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 } =20 +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 =3D 1; + if (local =3D=3D 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