Hello World Hello World - 2 months ago 3x
C++ Question

GDB:: Call Stack incomplete for overridden operator new function?

I have overridden the new(unsigned int) and delete(void*) operators to keep track and information about the heap manually as a learning process. Though I'm having trouble tracing the new operator function.

I am using CodeBlocks with GDB. Regardless whether I Step Into the operator function or I breakpoint into it, if I Step Into the return instruction, it fails to follow to the caller function. The Call Stack window does not display the caller function address either.

Any clue? Thanks in advance!


Although there is not really enough information in the question to answer definitively, I'll venture a guess.

My guess is that you are trying to debug an optimized build, maybe even without debug symbols.

If you build without optimization (-O0) the generated code will more closely match the source since the optimizer won't have inlined functions, moved code around etc. And if you enable debug symbols (-g) the compiler will put more information into the binary that the debugger can use to give you more accurate information on symbols and values.