How to print callstack into log?

Hey guys,

How can i print call stack into log ? In blueprint there is Stack Trace node but I can not call that directly in c++ because of linker errors.

What is the best way to print callstack in code ?

1 Like

Yes, I know but I can’t belive there is not some simple function for that. But yeah, I am looking for CPU call stack, same stack which crash reporter shows.

Then look up source code how this node do it, it seems oyu need to get FFrame and from there call GetStackTrace()

There also seem to be more global version which is static function:

Note that this only give you VM that powers blueprints call stack not native CPU call stack

Supposing the PDBs are loaded, you could look at / trace FWindwsPlatformStackWalk::StackWalkAndDump – for other platforms there are other classes, each implements StackWalkAndDump.

That’s what the crash reporter uses for the call stack.

I found an easy way by actually causing a CallStack to happen by referencing a null pointer when the suspicious activity is believed to be happening. This, mixed with print logs helped me out. I used to do this when working with build scripts.

I know it’s 2 years late, but FDebug::DumpStackTraceToLog() will do exactly this.


Even later, but to see Stack Trace in the log file, add this to the DefaultEngine.ini

1 Like