public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFA] Add test for use of "<block>::<variable>" syntax for locals in watch.
@ 2012-01-09  7:26 Paul Hilfinger
  2012-01-09  7:53 ` Yao Qi
  2012-01-10 19:02 ` Tom Tromey
  0 siblings, 2 replies; 4+ messages in thread
From: Paul Hilfinger @ 2012-01-09  7:26 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1518 bytes --]

This patch augments watchpoint.c to check the BLOCK::VARIABLE syntax
in watched expressions when it refers to local variables (and also to
fix a small bug I found in the existing version of the file).
However, as things stand, the test is not particularly stringent,
since the relevant part is restricted to the hppa, sparc SunOS, and
m32r platforms.  I modified the restriction temporarily to check that
the test now works on i686 Linux, but did not make that a part of the
patch, since I think that someone who knows more about the reason for
the restriction ought to decide whether it is time to remove it.

First, fix a technical problem with the function recurser.  The test sets a
watch on local_x at a point where its value is technically undefined.  The
test is written assuming that the value is not initially 2, but nothing in the
C standard guarantees that.

Second, augment the existing test for variables in recursive calls to check an
equivalent expression that explicitly sets the scope of the local variable
being tracked.

Paul N. Hilfinger
(Hilfinger@adacore.com)


2012-01-07  Paul Hilfinger  <brobecker@adacore.com>

* gdb/testsuite/gdb.base/watchpoint.c (recurser): Initialize local_x.
  (main) Repeat recurser call.
* gdb/testsuite/gdb.base/watchpoint.exp: Check that 'watch recurser::local_x' is
  equivalent to 'local_x'.
---
 gdb/testsuite/gdb.base/watchpoint.c   |    8 +++++++-
 gdb/testsuite/gdb.base/watchpoint.exp |   14 ++++++++++++++
 2 files changed, 21 insertions(+), 1 deletions(-)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0003-Add-test-for-use-of-block-variable-syntax-for-locals.patch --]
[-- Type: text/x-patch; name="0003-Add-test-for-use-of-block-variable-syntax-for-locals.patch", Size: 2598 bytes --]

diff --git a/gdb/testsuite/gdb.base/watchpoint.c b/gdb/testsuite/gdb.base/watchpoint.c
index 50f0a83..88c110f 100644
--- a/gdb/testsuite/gdb.base/watchpoint.c
+++ b/gdb/testsuite/gdb.base/watchpoint.c
@@ -80,7 +80,7 @@ void recurser (int  x)
 void recurser (x) int  x;
 #endif
 {
-  int  local_x;
+  int  local_x = 0;
 
   if (x > 0)
     recurser (x-1);
@@ -232,6 +232,12 @@ int main ()
   marker6 ();
   recurser (2);
 
+  /* This invocation is used for watches of a local variable with explicitly
+     specified scope when recursion happens.
+     */
+  marker6 ();
+  recurser (2);
+
   marker6 ();
 
   func3 ();
diff --git a/gdb/testsuite/gdb.base/watchpoint.exp b/gdb/testsuite/gdb.base/watchpoint.exp
index f321de5..1860368 100644
--- a/gdb/testsuite/gdb.base/watchpoint.exp
+++ b/gdb/testsuite/gdb.base/watchpoint.exp
@@ -580,6 +580,7 @@ proc test_complex_watchpoint {} {
         #
         gdb_test "tbreak recurser" ".*breakpoint.*"
         gdb_test "cont" "Continuing.*recurser.*"
+        gdb_test "next" "if \\(x > 0.*" "next past local_x initialization"
         gdb_test "watch local_x" ".*\[Ww\]atchpoint \[0-9\]*: local_x" \
                  "set local watch in recursive call"
         gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_x.*New value = 2.*" \
@@ -587,6 +588,19 @@ proc test_complex_watchpoint {} {
         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"
 
+        # Repeat the preceding test, but this time use "recurser::local_x" as
+        # the variable to track.
+        gdb_test "cont" "Continuing.*marker6.*"
+        gdb_test "tbreak recurser" ".*breakpoint.*"
+        gdb_test "cont" "Continuing.*recurser.*"
+        gdb_test "next" "if \\(x > 0.*" "next past local_x initialization"
+        gdb_test "watch recurser::local_x" ".*\[Ww\]atchpoint \[0-9\]*: recurser::local_x" \
+                 "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)"
+
 	# Disable everything so we can finish the program at full speed
 	gdb_test_no_output "disable" "disable in test_complex_watchpoint"
 

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

* Re: [RFA] Add test for use of "<block>::<variable>" syntax for locals in watch.
  2012-01-09  7:26 [RFA] Add test for use of "<block>::<variable>" syntax for locals in watch Paul Hilfinger
@ 2012-01-09  7:53 ` Yao Qi
  2012-01-09 20:02   ` Paul Hilfinger
  2012-01-10 19:02 ` Tom Tromey
  1 sibling, 1 reply; 4+ messages in thread
From: Yao Qi @ 2012-01-09  7:53 UTC (permalink / raw)
  To: gdb-patches

On 01/09/2012 03:26 PM, Paul Hilfinger wrote:
> 2012-01-07  Paul Hilfinger  <brobecker@adacore.com>
> 

Your mail address is not correct :)

I am not familiar with this test, but have some comments on format of
changelog.

> * gdb/testsuite/gdb.base/watchpoint.c (recurser): Initialize local_x.
>   (main) Repeat recurser call.
          ^^ Miss ":" here.
> * gdb/testsuite/gdb.base/watchpoint.exp: Check that 'watch recurser::local_x' is
>   equivalent to 'local_x'.

Each changelog entry is started from a tab.  Since we have a ChangeLog
file under gdb/testsuite, so we don't have to include "gdb/testuite" in
file name.  It can be like this,

	* gdb.base/watchpoint.c (recurser): Initialize local_x.
	(main): Repeat recurser call.
	* gdb.base/watchpoint.exp: Check that 'watch recurser::local_x' is
	equivalent to 'local_x'.

-- 
Yao (齐尧)

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

* Re: [RFA] Add test for use of "<block>::<variable>" syntax for locals in watch.
  2012-01-09  7:53 ` Yao Qi
@ 2012-01-09 20:02   ` Paul Hilfinger
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Hilfinger @ 2012-01-09 20:02 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches


Oops.  Thanks for pointing out the typos.




> On 01/09/2012 03:26 PM, Paul Hilfinger wrote:
> > 2012-01-07  Paul Hilfinger  <brobecker@adacore.com>
> > 
> 
> Your mail address is not correct :)
> 
> I am not familiar with this test, but have some comments on format of
> changelog.
> 
> > * gdb/testsuite/gdb.base/watchpoint.c (recurser): Initialize local_x.
> >   (main) Repeat recurser call.
>           ^^ Miss ":" here.
> > * gdb/testsuite/gdb.base/watchpoint.exp: Check that 'watch recurser::local_
> x' is
> >   equivalent to 'local_x'.
> 
> Each changelog entry is started from a tab.  Since we have a ChangeLog
> file under gdb/testsuite, so we don't have to include "gdb/testuite" in
> file name.  It can be like this,
> 
> 	* gdb.base/watchpoint.c (recurser): Initialize local_x.
> 	(main): Repeat recurser call.
> 	* gdb.base/watchpoint.exp: Check that 'watch recurser::local_x' is
> 	equivalent to 'local_x'.
> 
> -- 
> Yao (齐尧)

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

* Re: [RFA] Add test for use of "<block>::<variable>" syntax for locals in watch.
  2012-01-09  7:26 [RFA] Add test for use of "<block>::<variable>" syntax for locals in watch Paul Hilfinger
  2012-01-09  7:53 ` Yao Qi
@ 2012-01-10 19:02 ` Tom Tromey
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2012-01-10 19:02 UTC (permalink / raw)
  To: Hilfinger; +Cc: gdb-patches

>>>>> "Paul" == Paul Hilfinger <Hilfinger@adacore.com> writes:

Paul> 2012-01-07  Paul Hilfinger  <brobecker@adacore.com>
Paul> * gdb/testsuite/gdb.base/watchpoint.c (recurser): Initialize local_x.
Paul>   (main) Repeat recurser call.
Paul> * gdb/testsuite/gdb.base/watchpoint.exp: Check that 'watch recurser::local_x' is
Paul>   equivalent to 'local_x'.

Ok with the changes Yao suggests.

Tom

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

end of thread, other threads:[~2012-01-10 18:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-09  7:26 [RFA] Add test for use of "<block>::<variable>" syntax for locals in watch Paul Hilfinger
2012-01-09  7:53 ` Yao Qi
2012-01-09 20:02   ` Paul Hilfinger
2012-01-10 19:02 ` Tom Tromey

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