diff options
Diffstat (limited to 'gdb/testsuite/gdb.base/watchpoint.c')
-rw-r--r-- | gdb/testsuite/gdb.base/watchpoint.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.base/watchpoint.c b/gdb/testsuite/gdb.base/watchpoint.c index bd54f3e9621..14ccecd5253 100644 --- a/gdb/testsuite/gdb.base/watchpoint.c +++ b/gdb/testsuite/gdb.base/watchpoint.c @@ -1,4 +1,5 @@ #include <stdio.h> +#include <unistd.h> /* * Since using watchpoints can be very slow, we have to take some pains to * ensure that we don't run too long with them enabled or we run the risk @@ -28,6 +29,7 @@ int ival1 = -1; int ival2 = -1; int ival3 = -1; int ival4 = -1; +int ival5 = -1; char buf[10]; struct foo { @@ -53,9 +55,32 @@ void marker5 () { } +void marker6 () +{ +} + +#ifdef PROTOTYPES +void recurser (int x) +#else +void recurser (x) int x; +#endif +{ + int local_x; + + if (x > 0) + recurser (x-1); + local_x = x; +} + void func2 () { + int local_a; + static int static_b; + + ival5++; + local_a = ival5; + static_b = local_a; } int @@ -120,5 +145,30 @@ int main () are not evaluating the watchpoint expression correctly. */ struct1.val = 5; marker5 (); + + /* We're going to watch locals of func2, to see that out-of-scope + watchpoints are detected and properly deleted. + */ + marker6 (); + + /* This invocation is used for watches of a single + local variable. */ + func2 (); + + /* This invocation is used for watches of an expression + involving a local variable. */ + func2 (); + + /* This invocation is used for watches of a static + (non-stack-based) local variable. */ + func2 (); + + /* This invocation is used for watches of a local variable + when recursion happens. + */ + marker6 (); + recurser (2); + + marker6 (); return 0; } |