X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Ftestsuite%2Fgdb.base%2Fwatchpoint.c;h=92fb3b18647688be5ec58b016c8d865bb55685a9;hb=7c647d615590f8d1c4cca70f547534a9792f45c3;hp=edb996d7402970ba5d0972ba6c7a4dbfdd806059;hpb=e98fe4f7b54cbdf29aef9287bbb1bea8801dd05a;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/testsuite/gdb.base/watchpoint.c b/gdb/testsuite/gdb.base/watchpoint.c index edb996d740..92fb3b1864 100644 --- a/gdb/testsuite/gdb.base/watchpoint.c +++ b/gdb/testsuite/gdb.base/watchpoint.c @@ -1,5 +1,5 @@ #include -#include +#include /* * 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 @@ -29,7 +29,8 @@ int ival1 = -1; int ival2 = -1; int ival3 = -1; int ival4 = -1; -char buf[10]; +int ival5 = -1; +char buf[30] = "testtesttesttesttesttesttestte"; struct foo { int val; @@ -38,6 +39,28 @@ struct foo struct1, struct2, *ptr1, *ptr2; int doread = 0; +char *global_ptr; +char **global_ptr_ptr; + +struct foo2 +{ + int val[2]; +}; +struct foo2 foo2; + +struct foo4 +{ + int val[4]; +}; +struct foo4 foo4; + +struct foo5 +{ + struct { int x; } *p; +}; + +struct foo5 *nullptr; + void marker1 () { } @@ -54,9 +77,46 @@ void marker5 () { } +void marker6 () +{ +} + +#ifdef PROTOTYPES +void recurser (int x) +#else +void recurser (x) int x; +#endif +{ + int local_x = 0; + + if (x > 0) + recurser (x-1); + local_x = x; +} + void func2 () { + int local_a = 0; + static int static_b; + + /* func2 breakpoint here */ + ival5++; + local_a = ival5; + static_b = local_a; +} + +void +func3 () +{ + int x; + int y; + + x = 0; + x = 1; /* second x assignment */ + y = 1; + y = 2; + buf[26] = 3; } int @@ -74,6 +134,45 @@ func1 () return 73; } +void +func4 () +{ + buf[0] = 3; + global_ptr = buf; + buf[0] = 7; + buf[1] = 5; + global_ptr_ptr = &global_ptr; + buf[0] = 9; + global_ptr++; +} + +void +func5 () +{ + int val = 0, val2 = 23; + int *x = &val; + + /* func5 breakpoint here */ + x = &val2; + val = 27; +} + +void +func6 (void) +{ + /* func6 breakpoint here */ + foo2.val[1] = 0; + foo2.val[1] = 11; +} + +void +func7 (void) +{ + /* func7 breakpoint here */ + foo4.val[3] = 0; + foo4.val[3] = 33; +} + int main () { struct1.val = 1; @@ -91,7 +190,11 @@ int main () ival3 = count; ival4 = count; marker2 (); if (doread) - read (0, &buf[0], 5); + { + static char msg[] = "type stuff for buf now:"; + write (1, msg, sizeof (msg) - 1); + read (0, &buf[0], 5); + } marker4 (); /* We have a watchpoint on ptr1->val. It should be triggered if @@ -103,9 +206,6 @@ int main () are not evaluating the watchpoint expression correctly. */ struct1.val = 5; marker5 (); - if (doread) - read (0, &buf[0], 5); - marker4 (); /* We have a watchpoint on ptr1->val. It should be triggered if ptr1's value changes. */ @@ -116,5 +216,47 @@ 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); + + /* This invocation is used for watches of a local variable with explicitly + specified scope when recursion happens. + */ + marker6 (); + recurser (2); + + marker6 (); + + func3 (); + + func4 (); + + func5 (); + + func6 (); + + func7 (); + return 0; }