Breakpoint GDB same function appears more times

Using gdb I ran into some weird problem: there is a method that 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 Logger.cpp, it can be inferred that they actually refer to the same method. What does this mean? Constructor Logger :: Logger accidentally hit the binary three times, or is it a gdb bug?

+1


a source to share


3 answers


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

There was a bug in GDB where they neglected to set a breakpoint on all versions, resulting in your breakpoint never hitting at all. Now that the GDB bug has been fixed, you are getting multiple breakpoints.



Select all

, then execute info break

and note that the addresses of the three breakpoints are different and are actually in different functions.

+5


a source


Either the method got an inline method because it gcc

thought it would perform better, or it was used in a template that got an instance in several ways. Any path can lead to multiple versions of the executable binary.



0


a source


You can use "information break" and disable, enable perhaps a breakpoint set on the same line .... however, you should also know the step or step (stepi will execute one command of machine code, not source level, which is what it does).

You can also C #, to continue for a specific amount of time, pass this breakpoint ... so if it is 1 breakpoint in a loop that is evaluated 3 times, you go c 3 and you pass that to a percular loop ...

0


a source







All Articles