tags:

views:

285

answers:

3

Hello!

Using gdb, I have encountered a strange issue: there is a method which appears three times:

(gdb) b Logger::Logger
[0] cancel
[1] all
[2] Logger at src/Logger.cpp:52
[3] Logger at src/Logger.cpp:52
[4] Logger at src/Logger.cpp:52

From the fact that all three instances are on line 552 of the file Logger.cpp, it can be deduced, that they are in fact referring to the same method. What is the meaning of this? Has Logger::Logger constructor accidentally got into the binary three times, or is this a gdb bug?

+2  A: 

Recent versions of GCC (and many other compilers) create several versions of constructors and destructors.

There was a bug in GDB, where it neglected to set a breakpoint on all versions, which resulted in your breakpoint never firing at all. Now, with the GDB bug corrected, you get multiple breakpoints.

Select all, then do info break, and note that the addresses of the 3 breakpoints all differ, and are in fact in different functions.

Employed Russian
A: 

Either the method got inlined because gcc thought it would perform better, or it was used in a template which got instantiated in more than one way. Either path could lead to multiple versions in the executable binary.

Norman Ramsey
A: 

You can use "info break" and disable, enable for perhaps a breakpoint set to the same line.... however, you should also know, step vs. stepi (stepi will execute single machiene code instruction, not by source level, which is what step does).

You can also c #, to continue a specific amoutn of times, to pass that breakpoint... so if it's 1 breakpoint in a loop, which is being evaluated 3 times, you go c 3, and you will pass this perticular loop...

RandomNickName42