When do watchpoints go out of scope?
Daniel Jacobowitz
drow@false.org
Sun Sep 25 17:25:00 GMT 2005
On Sun, Sep 25, 2005 at 07:37:34AM -0700, Thomas Covenant wrote:
> Consider this program:
>
> 1 int main(void)
> 2 {
> 3 {
> 4 int i = 2;
> 5 printf("i is %d.\n", i);
> 6 i = 3;
> 7 printf("i is %d.\n", i);
> 8 }
> 9 // lots more code
> ...
> 90 return 0;
> 100 }
>
> The variable i goes in scope at line 4, out of scope
> at line 8.
>
> If I set:
>
> watch i
>
> at line 4, I would assume the watchpoint would be
> deleted at line 8, since i is no longer in scope.
This depends on your compiler and the debug information it generates.
If GDB still has location information, it will continue to watch the
variable. If it doesn't, it will stop. You didn't say what your
platform or compiler was, so it's hard to guess, but many older
versions of GCC and most targets using the stabs format do not have
accurate endings for lifetimes.
--
Daniel Jacobowitz
CodeSourcery, LLC
More information about the Gdb
mailing list