[binutils-gdb] gdb.rocm/watchpoint-basic: add XFAILs for known configurations

Shahab Vahedi via Gdb-cvs <[email protected]> Mon, 27 Jul 2026 08:55:23 +0000 (GMT)
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D71dc6d78f936=
73499fa712ca818984775223a6f3

commit 71dc6d78f93673499fa712ca818984775223a6f3
Author: Shahab Vahedi <[email protected]>
Date:   Mon Jul 13 16:46:09 2026 +0200

    gdb.rocm/watchpoint-basic: add XFAILs for known configurations
   =20
    Some of the tests in gdb.rom/watchpoint-basic are destined to fail
    due to a problem in KFD.  This patch marks those tests as such on
    configurations that this can happen.
   =20
    Reviewed-by: Tankut Baris Aktemur <[email protected]>
    Approved-by: Luis Machado <[email protected]>

Diff:
---
 gdb/testsuite/gdb.rocm/watchpoint-basic.exp | 78 ++++++++++++++++++++++++-=
----
 1 file changed, 66 insertions(+), 12 deletions(-)

diff --git a/gdb/testsuite/gdb.rocm/watchpoint-basic.exp b/gdb/testsuite/gd=
b.rocm/watchpoint-basic.exp
index 9626b32d5d2..bc30726515e 100644
--- a/gdb/testsuite/gdb.rocm/watchpoint-basic.exp
+++ b/gdb/testsuite/gdb.rocm/watchpoint-basic.exp
@@ -26,14 +26,25 @@ if {[build_executable "failed to prepare" $testfile $sr=
cfile {debug hip}]} {
 }
=20
 proc continue_to_watchpoint_hit { old_value new_value test } {
-    gdb_test "continue" \
-	[multi_line \
-	    "hit Hardware watchpoint $::decimal:.*" \
-	    "" \
-	    "Old value =3D $old_value" \
-	    "New value =3D $new_value" \
-	    ".*"] \
-	$test
+    set hit_re [multi_line \
+		   "hit Hardware watchpoint $::decimal:.*" \
+		   "" \
+		   "Old value =3D $old_value" \
+		   "New value =3D $new_value" \
+		   ".*"]
+
+    set ret false
+    gdb_test_multiple "continue" "$test" {
+	-re -wrap $hit_re {
+	    pass "$gdb_test_name"
+	    set ret true
+	}
+	-re -wrap ".*$::inferior_exited_re.*" {
+	    fail "$gdb_test_name"
+	    set ret false
+	}
+    }
+    return $ret
 }
=20
 # Test inserting a watchpoint on a host variable before the runtime loads,=
 and
@@ -78,6 +89,37 @@ proc_with_prefix test_host_watchpoint_after_runtime_load=
 {} {
     }
 }
=20
+# On some systems, KFD corrupts the watchpoint configurations
+# during the first dispatch's queue mapping.  This leads to
+# watchpoints not being triggered, if they were set before the
+# first dispatch.  As a result, those test scenarios run to the
+# end and exit prematurely.
+
+gdb_caching_proc target_has_xfail {} {
+    set xfail_arches {gfx1201}
+
+    set targets [find_amdgpu_devices]
+    if {[llength $targets] =3D=3D 0} {
+	# Can't determine GPU type, don't set up xfail.  The test will probably
+	# not run correctly anyway.
+	return 0
+    }
+
+    # The test will run on GPU-0, so it should be the first of the list.
+    set target [lindex $targets 0]
+
+    return [expr {[lsearch -exact $xfail_arches $target] !=3D -1}]
+}
+
+# This is used when dealing with the first watchpoints that are
+# set before the first dispatch.
+
+proc maybe_xfail {} {
+    if {[target_has_xfail]} {
+	setup_xfail "*-*-*" "watchpoint configuration corruption in kfd."
+    }
+}
+
 # Test inserting a watchpoint before the kernel is launched, then hitting
 # it when the kernel runs.
=20
@@ -93,7 +135,10 @@ proc_with_prefix test_watchpoint_before_kernel {} {
 	    "Hardware watchpoint $::decimal: .*" \
 	    "set watchpoint on *ptr1"
=20
-	continue_to_watchpoint_hit 0 10 "continue to watchpoint hit 1"
+	maybe_xfail
+	if {![continue_to_watchpoint_hit 0 10 "continue to watchpoint hit 1"]} {
+	    return
+	}
 	continue_to_watchpoint_hit 10 30 "continue to watchpoint hit 2"
 	continue_to_watchpoint_hit 30 40 "continue to watchpoint hit 3"
 	continue_to_watchpoint_hit 40 60 "continue to watchpoint hit 4"
@@ -145,7 +190,10 @@ proc_with_prefix test_remove_watchpoint_inside_kernel =
{} {
 	    "Hardware watchpoint $::decimal: .*" \
 	    "set watchpoint"
=20
-	continue_to_watchpoint_hit 0 10 "continue to watchpoint hit"
+	maybe_xfail
+	if {![continue_to_watchpoint_hit 0 10 "continue to watchpoint hit"]} {
+	    return
+	}
 	gdb_test "with confirm off -- delete" "" "delete all breakpoints"
=20
 	gdb_continue_to_end "" continue 1
@@ -170,7 +218,10 @@ proc_with_prefix test_multiple_watchpoints {} {
 	    "Hardware watchpoint $::decimal: .*" \
 	    "set watchpoint on *ptr2"
=20
-	continue_to_watchpoint_hit 0 10 "continue to watchpoint hit 1"
+	maybe_xfail
+	if {![continue_to_watchpoint_hit 0 10 "continue to watchpoint hit 1"]} {
+	    return
+	}
 	continue_to_watchpoint_hit 0 100 "continue to watchpoint hit 2"
 	continue_to_watchpoint_hit 10 30 "continue to watchpoint hit 3"
 	continue_to_watchpoint_hit 100 300 "continue to watchpoint hit 4"
@@ -210,7 +261,10 @@ proc_with_prefix test_disable_enable_watchpoint {} {
 	    }
 	}
=20
-	continue_to_watchpoint_hit 0 10 "continue to watchpoint hit 1"
+	maybe_xfail
+	if {![continue_to_watchpoint_hit 0 10 "continue to watchpoint hit 1"]} {
+	    return
+	}
=20
 	gdb_test_no_output "disable $wp1_num" "disable watchpoint"