Debugging UFunction::Invoke

A few weeks ago Nick Penwarden highlighted several improvements that we made to Unreal Engine 4 while working on Fortnite Battle Royale.

One of the things that didn't make the list above is a little debugging gem I added while working on Battle Royale. In Fortnite the team used a fair amount of Blueprint based Widgets, which means inevitably you'll throw in a breakpoint in C++ but end up seeing a callstack like this when you're looking for who is calling your code,

[Your C++ Code]
UFunction::Invoke(...)  
UObject::ProcessEvent(...)  
AActor::ProcessEvent(...)  
[Rest of the stack]

I was working with a lot of code in Fortnite I was unfamiliar with, so it wasn't always obvious where the calls might be coming from. So I added a C command you can run from the Immediate Window in Visual Studio that will print the current Blueprint/Scripting callstack.

When running an Editor build of your game, you would use the command, {,,UE4Editor-Core}::PrintScriptCallstack()

In a monolithic build you would use, ::PrintScriptCallstack()

This command is available in 4.18.

Immediate Window