//StackDepth:堆栈深度
static void PrintStack(int StackDepth = 15)
{
FString StackInfo = "Stack Info:";
UE_LOG(LogTemp, Error, TEXT("%s"), *StackInfo);
TArray<FProgramCounterSymbolInfo> Stacks = FPlatformStackWalk::GetStack(1, StackDepth);
for (int i = 0; i < Stacks.Num(); i++)
{
StackInfo = FString("\r\n\t") + FString::Printf(TEXT("%s (%s Line:%d"),
ANSI_TO_TCHAR(Stacks[i].FunctionName), ANSI_TO_TCHAR(Stacks[i].Filename), Stacks[i].LineNumber);
UE_LOG(LogTemp, Error, TEXT("%s"), *StackInfo);
}
}
UE5 堆栈信息打印
于 2024-08-06 17:41:09 首次发布