Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,52 @@

#include "GenericPlatform/GenericPlatformSentryScope.h"

#if UE_VERSION_NEWER_THAN(5, 7, 0) && WITH_ADDITIONAL_CRASH_CONTEXTS
struct FSentryCrashContextExtendedWriter : public FCrashContextExtendedWriter
{
public:
TMap<FString, FSentryVariant> Values;

void OutputBuffer(const TCHAR* Identifier, const FString& Data)
{
Values.Add(Identifier, Data);
}

virtual void AddBuffer(const TCHAR* Identifier, const uint8* Data, uint32 DataSize) override
{
OutputBuffer(Identifier, FBase64::Encode(Data, DataSize));
}

virtual void AddString(const TCHAR* Identifier, const TCHAR* DataStr) override
{
return OutputBuffer(Identifier, DataStr);
}

static void Apply(TSharedPtr<ISentryScope> Scope)
{
if (!Scope.IsValid())
{
return;
}

FSentryCrashContextExtendedWriter Writer;
FGenericCrashContext::OnAdditionalCrashContextDelegate().Broadcast(Writer);
FAdditionalCrashContextStack::ExecuteProviders(Writer);

Scope->SetContext(TEXT("AdditionalCrashContext"), Writer.Values);
}
};
#else
struct FSentryCrashContextExtendedWriter
{
private:
FSentryCrashContextExtendedWriter() {}

public:
static void Apply(TSharedPtr<ISentryScope> Scope) {}
};
#endif

FGenericPlatformSentryCrashContext::FGenericPlatformSentryCrashContext(TSharedPtr<FSharedCrashContext> Context)
#if UE_VERSION_OLDER_THAN(5, 3, 0)
: FGenericCrashContext(Context->CrashType, Context->ErrorMessage)
Expand Down Expand Up @@ -56,6 +102,8 @@ void FGenericPlatformSentryCrashContext::Apply(TSharedPtr<ISentryScope> Scope)
ContextValues.Add("Memory Stats Total Virtual", FString::Printf(TEXT("%lld"), SessionContext.MemoryStats.TotalVirtual));

Scope->SetContext(TEXT("Crash Info"), ContextValues);

FSentryCrashContextExtendedWriter::Apply(Scope);
}

FString FGenericPlatformSentryCrashContext::GetGameData(const FString& Key)
Expand Down
Loading