public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Add more 'step' tests to gdb.base/watchpoint.exp
@ 2023-12-03  3:06 Kevin Buettner
  2023-12-04 17:46 ` John Baldwin
  0 siblings, 1 reply; 2+ messages in thread
From: Kevin Buettner @ 2023-12-03  3:06 UTC (permalink / raw)
  To: gdb-patches; +Cc: Kevin Buettner

The test gdb.base/watchpoint.exp has a proc named 'test_stepping'
which claims to "Test stepping and other mundane operations with
watchpoints enabled".  It sets a watchpoint on ival2, performs an
inferior function call (which is not at all mundane), and uses 'next',
'until', and, finally, does a 'step'.

However, that final 'step' command steps to (but not over/through) the
line at which the assignment to ival2 takes place.  At no time while
performing these operations is a watchpoint hit.

This commit adds a test to see what happens when stepping over/through
the assignment to ival2.  The watchpoint on ival2 should be triggered
during this step.  I've added another 'step' to make sure that the
correct statement is reached after performing the watchpoint-hitting
step.

After running the 'test_stepping' proc, gdb.base/watchpoint.exp does
a clean_restart before doing further tests, so nothing depends upon
'test_stepping' to stop at the particular statement at which it had
been stopping.

I've examined all tests which set watchpoints and step.  I haven't
been able to identify a(nother) test case which tests what happens
when stepping over/through a statement which triggers a watchpoint.
Therefore, adding these new 'step' tests is testing something which
hasn't being tested elsewhere.
---
 gdb/testsuite/gdb.base/watchpoint.exp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gdb/testsuite/gdb.base/watchpoint.exp b/gdb/testsuite/gdb.base/watchpoint.exp
index 70864655c6d..24bc8276951 100644
--- a/gdb/testsuite/gdb.base/watchpoint.exp
+++ b/gdb/testsuite/gdb.base/watchpoint.exp
@@ -340,6 +340,15 @@ proc test_stepping {} {
 	}
 
 	gdb_test "step" "ival2 = count.*" "step to ival2 assignment"
+
+	# Check that the watchpoint is triggered during a step.
+	gdb_test "step" \
+		 "\[Ww\]atchpoint.*: ival2.*Old value = -1.*New value = 4.*ival3 = count; ival4 = count;" \
+		 "step over ival2 assignment"
+
+	# Step again and check that correct statement is reached after
+	# hitting a watchpoint during a step.
+	gdb_test "step" "marker2 \\(\\);.*" "step to marker2"
     }
 }
 
-- 
2.43.0


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

* Re: [PATCH] Add more 'step' tests to gdb.base/watchpoint.exp
  2023-12-03  3:06 [PATCH] Add more 'step' tests to gdb.base/watchpoint.exp Kevin Buettner
@ 2023-12-04 17:46 ` John Baldwin
  0 siblings, 0 replies; 2+ messages in thread
From: John Baldwin @ 2023-12-04 17:46 UTC (permalink / raw)
  To: Kevin Buettner, gdb-patches

On 12/2/23 7:06 PM, Kevin Buettner wrote:
> The test gdb.base/watchpoint.exp has a proc named 'test_stepping'
> which claims to "Test stepping and other mundane operations with
> watchpoints enabled".  It sets a watchpoint on ival2, performs an
> inferior function call (which is not at all mundane), and uses 'next',
> 'until', and, finally, does a 'step'.
> 
> However, that final 'step' command steps to (but not over/through) the
> line at which the assignment to ival2 takes place.  At no time while
> performing these operations is a watchpoint hit.
> 
> This commit adds a test to see what happens when stepping over/through
> the assignment to ival2.  The watchpoint on ival2 should be triggered
> during this step.  I've added another 'step' to make sure that the
> correct statement is reached after performing the watchpoint-hitting
> step.
> 
> After running the 'test_stepping' proc, gdb.base/watchpoint.exp does
> a clean_restart before doing further tests, so nothing depends upon
> 'test_stepping' to stop at the particular statement at which it had
> been stopping.
> 
> I've examined all tests which set watchpoints and step.  I haven't
> been able to identify a(nother) test case which tests what happens
> when stepping over/through a statement which triggers a watchpoint.
> Therefore, adding these new 'step' tests is testing something which
> hasn't being tested elsewhere.
> ---
>   gdb/testsuite/gdb.base/watchpoint.exp | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/gdb/testsuite/gdb.base/watchpoint.exp b/gdb/testsuite/gdb.base/watchpoint.exp
> index 70864655c6d..24bc8276951 100644
> --- a/gdb/testsuite/gdb.base/watchpoint.exp
> +++ b/gdb/testsuite/gdb.base/watchpoint.exp
> @@ -340,6 +340,15 @@ proc test_stepping {} {
>   	}
>   
>   	gdb_test "step" "ival2 = count.*" "step to ival2 assignment"
> +
> +	# Check that the watchpoint is triggered during a step.
> +	gdb_test "step" \
> +		 "\[Ww\]atchpoint.*: ival2.*Old value = -1.*New value = 4.*ival3 = count; ival4 = count;" \
> +		 "step over ival2 assignment"
> +
> +	# Step again and check that correct statement is reached after
> +	# hitting a watchpoint during a step.
> +	gdb_test "step" "marker2 \\(\\);.*" "step to marker2"
>       }
>   }
>   

This definitely sounds like a useful thing to test, and the new test
seems correct to me AFAICT.  I'll defer to you that the test suite
doesn't already cover this case.

Reviewed-By: John Baldwin <jhb@FreeBSD.org>

-- 
John Baldwin


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

end of thread, other threads:[~2023-12-04 17:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-03  3:06 [PATCH] Add more 'step' tests to gdb.base/watchpoint.exp Kevin Buettner
2023-12-04 17:46 ` John Baldwin

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