mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-24 20:28:28 +08:00
Add test for use of "<block>::<variable>" syntax for locals in watch.
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. 2012-01-11 Paul Hilfinger <hilfingr@adacore.com> * 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'.
This commit is contained in:
@ -1,3 +1,10 @@
|
|||||||
|
2012-01-11 Paul Hilfinger <hilfingr@adacore.com>
|
||||||
|
|
||||||
|
* 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'.
|
||||||
|
|
||||||
2012-01-11 Paul Hilfinger <hilfingr@adacore.com>
|
2012-01-11 Paul Hilfinger <hilfingr@adacore.com>
|
||||||
Joel Brobecker <brobecker@adacore.com>
|
Joel Brobecker <brobecker@adacore.com>
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ void recurser (int x)
|
|||||||
void recurser (x) int x;
|
void recurser (x) int x;
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
int local_x;
|
int local_x = 0;
|
||||||
|
|
||||||
if (x > 0)
|
if (x > 0)
|
||||||
recurser (x-1);
|
recurser (x-1);
|
||||||
@ -232,6 +232,12 @@ int main ()
|
|||||||
marker6 ();
|
marker6 ();
|
||||||
recurser (2);
|
recurser (2);
|
||||||
|
|
||||||
|
/* This invocation is used for watches of a local variable with explicitly
|
||||||
|
specified scope when recursion happens.
|
||||||
|
*/
|
||||||
|
marker6 ();
|
||||||
|
recurser (2);
|
||||||
|
|
||||||
marker6 ();
|
marker6 ();
|
||||||
|
|
||||||
func3 ();
|
func3 ();
|
||||||
|
@ -580,6 +580,7 @@ proc test_complex_watchpoint {} {
|
|||||||
#
|
#
|
||||||
gdb_test "tbreak recurser" ".*breakpoint.*"
|
gdb_test "tbreak recurser" ".*breakpoint.*"
|
||||||
gdb_test "cont" "Continuing.*recurser.*"
|
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" \
|
gdb_test "watch local_x" ".*\[Ww\]atchpoint \[0-9\]*: local_x" \
|
||||||
"set local watch in recursive call"
|
"set local watch in recursive call"
|
||||||
gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_x.*New value = 2.*" \
|
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.*" \
|
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"
|
"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
|
# Disable everything so we can finish the program at full speed
|
||||||
gdb_test_no_output "disable" "disable in test_complex_watchpoint"
|
gdb_test_no_output "disable" "disable in test_complex_watchpoint"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user