Re: watchpoint on variable in function scope

Sterling Augustine
2011-06-02T18:43:26Z

Tom's test case works fine for me if I compile it as a C program.
However, it fails if I compile it as a C++ program. (Using gcc 4.4.3.)

Looking at the assembly, the C code names the static "i.1591", but the
C++ code uses "_ZZ3foovE1i".

So this seems to be a C++ name look up failure. Not sure it how should work.

$ gcc ~/bar.c -g
$ ./gdb ./a.out
GNU gdb (GDB) 7.2.90.20110513-cvs
...
(gdb) watch foo::i
Watchpoint 1: foo::i
(gdb) run
Starting program: ./a.out
Hardware watchpoint 1: foo::i

Old value = 0
New value = 1
foo () at /home/saugustine/bar.c:4
4 }