public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/testsuite: Work around clang fails in gdb.base/watchpoint.exp
@ 2023-10-26  9:04 Guinevere Larsen
  2023-10-27 13:56 ` Andrew Burgess
  2023-11-02  9:50 ` [PATCH v2] gdb: register frame_destroyed function for amd64 gdbarch Guinevere Larsen
  0 siblings, 2 replies; 8+ messages in thread
From: Guinevere Larsen @ 2023-10-26  9:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Guinevere Larsen

as mentioned in commit def86538a46f7ce6fbb215cfb184e23015b5d538, clang
doesn't use the CFA information for variable locations, making it so
software watchpoints get false hits when exiting a function. Differently
to that commit, however, gdb.base/watchpoint.exp also needs to be
explicitly continued so the inferior will remain in sync with what the
exp file expects, so this commit uses gdb_test_multiple to identify that
situation.

I also chose to keep the test passing in that scenario because the GDB
feature being tested, software watchpoints, is working as expected.
---
 gdb/testsuite/gdb.base/watchpoint.exp | 82 +++++++++++++++++++++++++--
 1 file changed, 76 insertions(+), 6 deletions(-)

diff --git a/gdb/testsuite/gdb.base/watchpoint.exp b/gdb/testsuite/gdb.base/watchpoint.exp
index 70864655c6d..5d8d6b9cb31 100644
--- a/gdb/testsuite/gdb.base/watchpoint.exp
+++ b/gdb/testsuite/gdb.base/watchpoint.exp
@@ -30,6 +30,11 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
      return -1
 }
 
+set using_clang 0
+if {[test_compiler_info "clang-*"]} {
+    set using_clang 1
+}
+
 # True if we're forcing no hardware watchpoints.
 set no_hw 0
 
@@ -486,6 +491,20 @@ proc test_complex_watchpoint {} {
 		}
 		fail $test
 	    }
+	    -re -wrap ".*Continuing.*\[Ww\]atchpoint.*" {
+		global no_hw
+		global using_clang
+		# Clang doesn't use the CFA, so software watchpoints get one
+		# false hit here.  Detect if we're in that situation and
+		# ignore the false hit.  For more info, see:
+		# https://github.com/llvm/llvm-project/issues/64390
+		if {$using_clang == 1 && $no_hw == 1} {
+		    send_gdb "cont\n"
+		    exp_continue
+		} else {
+		    fail $gdb_test_name
+		}
+	    }
 	}
 
 	gdb_continue_to_breakpoint "func2 breakpoint here, second time"
@@ -501,8 +520,25 @@ proc test_complex_watchpoint {} {
                  "trigger1 partially local watch"
         gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_a . ival5.*" \
                  "trigger2 partially local watch"
-        gdb_test "cont" "Continuing.*\[Ww\]atchpoint .* deleted because the program has left the block in.*which its expression is valid.*" \
-                 "self-delete partially local watch"
+        gdb_test_multiple "cont" "self-delete partially local watch" {
+	    -re -wrap "Continuing.*\[Ww\]atchpoint .* deleted because the program has left the block in.*which its expression is valid.*" {
+		pass $gdb_test_name
+	    }
+	    -re -wrap ".*Continuing.*\[Ww\]atchpoint.*" {
+		global no_hw
+		global using_clang
+		# Clang doesn't use the CFA, so software watchpoints get one
+		# false hit here.  Detect if we're in that situation and
+		# ignore the false hit.  For more info, see:
+		# https://github.com/llvm/llvm-project/issues/64390
+		if {$using_clang == 1 && $no_hw == 1} {
+		    send_gdb "cont\n"
+		    exp_continue
+		} else {
+		    fail $gdb_test_name
+		}
+	    }
+	}
 
         # We should be in "func2" again now.  Test a watch of a
         # static (non-stack-based) local.  Since this has scope
@@ -535,8 +571,25 @@ proc test_complex_watchpoint {} {
 		"set local watch in recursive call"
 	    gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_x.*New value = 2.*" \
 		"trigger local watch in recursive call"
-	    gdb_test "cont" "Continuing.*\[Ww\]atchpoint .* deleted because the program has left the block in.*which its expression is valid.*" \
-		"self-delete local watch in recursive call"
+	    gdb_test_multiple "cont" "self-delete local watch in recursive call" {
+		-re -wrap "Continuing.*\[Ww\]atchpoint .* deleted because the program has left the block in.*which its expression is valid.*" {
+		    pass $gdb_test_name
+		}
+		-re -wrap ".*Continuing.*\[Ww\]atchpoint.*" {
+		    global no_hw
+		    global using_clang
+		    # Clang doesn't use the CFA, so software watchpoints get one
+		    # false hit here.  Detect if we're in that situation and
+		    # ignore the false hit.  For more info, see:
+		    # https://github.com/llvm/llvm-project/issues/64390
+		    if {$using_clang == 1 && $no_hw == 1} {
+			send_gdb "cont\n"
+			exp_continue
+		    } else {
+			fail $gdb_test_name
+		    }
+		}
+	    }
 	}
 
         # Repeat the preceding test, but this time use "recurser::local_x" as
@@ -551,8 +604,25 @@ proc test_complex_watchpoint {} {
 		"set local watch in recursive call with explicit scope"
 	    gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: recurser::local_x.*New value = 2.*" \
 		"trigger local watch with explicit scope in recursive call"
-	    gdb_test "cont" "Continuing.*\[Ww\]atchpoint .* deleted because the program has left the block in.*which its expression is valid.*" \
-		"self-delete local watch with explicit scope in recursive call (2)"
+	    gdb_test_multiple "cont" "self-delete local watch with explicit scope in recursive call (2)" {
+		-re -wrap "Continuing.*\[Ww\]atchpoint .* deleted because the program has left the block in.*which its expression is valid.*" {
+		    pass $gdb_test_name
+		}
+		-re -wrap ".*Continuing.*\[Ww\]atchpoint.*" {
+		    global no_hw
+		    global using_clang
+		    # Clang doesn't use the CFA, so software watchpoints get one
+		    # false hit here.  Detect if we're in that situation and
+		    # ignore the false hit.  For more info, see:
+		    # https://github.com/llvm/llvm-project/issues/64390
+		    if {$using_clang == 1 && $no_hw == 1} {
+			send_gdb "cont\n"
+			exp_continue
+		    } else {
+			fail $gdb_test_name
+		    }
+		}
+	    }
 	}
 
 	# Disable everything so we can finish the program at full speed
-- 
2.41.0


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

end of thread, other threads:[~2023-12-19 11:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-26  9:04 [PATCH] gdb/testsuite: Work around clang fails in gdb.base/watchpoint.exp Guinevere Larsen
2023-10-27 13:56 ` Andrew Burgess
2023-11-02  9:50 ` [PATCH v2] gdb: register frame_destroyed function for amd64 gdbarch Guinevere Larsen
2023-11-07 15:38   ` Andrew Burgess
2023-11-08 14:24   ` [PATCH v3] " Guinevere Larsen
2023-12-07 17:36     ` [PING][PATCH " Guinevere Larsen
2023-12-18 10:24       ` [PINGv2][PATCH " Guinevere Larsen
2023-12-19 11:51     ` [PATCH " Andrew Burgess

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).