gdb's fundamental problem
Posted May 3, 2007 17:40 UTC (Thu) by JoeBuck
In reply to: an intermediate example
Parent article: A tale of two release cycles
gdb is architected to assume that there is a one-to-one correspondence between source code lines and object code positions. This obviously breaks with templates, but what isn't as widely known is that constructors and destructors also have an issue.
The reason that breakpoints in constructors often fail is that g++ (actually, any C++ compiler I know of) creates multiple copies of a constructor or destructor under most circumstances (the so-called in-charge and not-in-charge cases, depending on whether the complete object is being constructed or it's only the base of a derived class), likewise the destructor (whether it's a delete call or not).
The result is that there are two code positions associated with the same source line. Ideally, when you set a breakpoint based on a source line, gdb would put a breakpoint in all code positions matching this source line. Instead, it arbitrarily chooses one.
to post comments)