That one surprised me, when doing tab for auto complete for a breakpoint it appeared two options to the same method.
test::TestFoo::SendFoo(short)
test::TestFoo::SendFoo(short)::fooID
On cpp:
bool TestFoo::SendFoo( short x )
{
...
static unsigned int fooID = 0;
Why gdb differs? what’s the benefit of using one or another?
Question tagged as C++ to avoid any missunderstanding from C static.
gdb --version
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-56.el6)
...
SendFoo::fooIDandSendFooare two different kinds of symbols, and I can imagine there will be a difference in the two breakpoints gdb offers you – although I am not very familiar with it:The line where
fooIDis defined/initialized will be only hit once in the whole program, so a breakpoint in that line should be hit only once as well. A function level breakpoint should be hit every time the function gets called, so there is a major difference.AFAIK the function scope
staticmeans the same for both C and C++ – a variable that is shared between all calls of that function and initialized the first time the function gets called.