Capture Call Stack


Is there any way to capture the call stack in c++? For example, unwind the call stack to see where the call to my function originated?


Launch Unreal Editor from Visual Studio, with breakpoints

Thanks for the reply, I should have been more clear in my original post. I would like to be able to get the callstack at runtime. Do you have any idea how I can do this?

FPlatformStackWalk::ThreadStackWalkAndDump is the function you are looking for. See example code in Source\Runtime\Core\Private\HAL\ThreadHeartBeat.cpp

Was exactly that. Thanks for the help! :slight_smile:

Hello, I am trying to get the call stack.
Is this well done?
At the moment, with this code, Unreal freezes when I press play.

Hi! Call ::StackWalkAndDump instead.
::ThreadStackWalkAndDump is for cases when you need callstack of different thread (like from GameThread you need RenderThread) - it suspends thread which you send as last parameter.