public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Guinevere Larsen <blarsen@redhat.com>
To: gdb-patches@sourceware.org
Cc: Guinevere Larsen <blarsen@redhat.com>
Subject: [PATCH] gdb/testsuite: Work around clang fails in gdb.base/watchpoint.exp
Date: Thu, 26 Oct 2023 11:04:48 +0200	[thread overview]
Message-ID: <20231026090448.1182959-1-blarsen@redhat.com> (raw)

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


             reply	other threads:[~2023-10-26  9:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-26  9:04 Guinevere Larsen [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231026090448.1182959-1-blarsen@redhat.com \
    --to=blarsen@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).