-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUCallStack.cpp
More file actions
36 lines (34 loc) · 1.22 KB
/
Copy pathUCallStack.cpp
File metadata and controls
36 lines (34 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "UCallStack.h"
#include "Engine/Engine.h"
#include "Engine/World.h"
#include "Components/SceneComponent.h"
#include "DrawDebugHelpers.h"
#include "HAL/PlatformStackWalk.h"
#include "Misc/OutputDeviceRedirector.h"
FString UCallStack::GetCallerName()
{
// I set the IgnoreCount to 1 to ignore this function.
TArray<FProgramCounterSymbolInfo> CurrentInfo = FPlatformStackWalk::GetStack(1, 1, nullptr);
if (CurrentInfo.Num() == 0)
{
return TEXT("[unknown]");
}
const FString CallerInfo = CurrentInfo[0].FunctionName;
// Trim the trailing parenthesis pair
return CallerInfo.LeftChop(2);
}
FString UCallStack::GetCallerInfo()
{
// I set the IgnoreCount to 1 to ignore this function.
TArray<FProgramCounterSymbolInfo> CurrentInfo = FPlatformStackWalk::GetStack(1, 1, nullptr);
if (CurrentInfo.Num() == 0)
{
return TEXT("[unknown]");
}
const FString CallerFile = CurrentInfo[0].Filename;
const FString CallerInfo = CurrentInfo[0].FunctionName;
const FString CallerNameSanitized = CallerInfo.LeftChop(2);
const FString CallerLine = FString::Printf(TEXT("%d"), CurrentInfo[0].LineNumber);
// Trim the trailing parenthesis pair
return FString::Printf(TEXT("%s@%s:%s"), *CallerFile, *CallerNameSanitized, *CallerLine);
}