2014-12-07 19:09:38 -05:00
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
2014-03-14 14:13:41 -04:00
# pragma once
2015-03-02 07:52:38 -05:00
# include "Core.h"
2014-05-29 17:21:16 -04:00
struct FPDBCacheEntry ;
2014-03-14 14:13:41 -04:00
enum EProcessorArchitecture
{
PA_UNKNOWN ,
PA_ARM ,
PA_X86 ,
PA_X64 ,
} ;
/**
* Details of a module from a crash dump
*/
class FCrashModuleInfo
{
public :
FString Report ;
FString Name ;
FString Extension ;
uint64 BaseOfImage ;
uint32 SizeOfImage ;
uint16 Major ;
uint16 Minor ;
2014-07-14 06:53:12 -04:00
uint16 Patch ;
2014-03-14 14:13:41 -04:00
uint16 Revision ;
FCrashModuleInfo ( )
: BaseOfImage ( 0 )
, SizeOfImage ( 0 )
, Major ( 0 )
, Minor ( 0 )
2014-07-14 06:53:12 -04:00
, Patch ( 0 )
2014-03-14 14:13:41 -04:00
, Revision ( 0 )
{
}
} ;
/**
* Details about a thread from a crash dump
*/
class FCrashThreadInfo
{
public :
FString Report ;
uint32 ThreadId ;
uint32 SuspendCount ;
TArray < uint64 > CallStack ;
FCrashThreadInfo ( )
: ThreadId ( 0 )
, SuspendCount ( 0 )
{
}
~ FCrashThreadInfo ( )
{
}
} ;
/**
* Details about the exception in the crash dump
*/
class FCrashExceptionInfo
{
public :
FString Report ;
uint32 ProcessId ;
uint32 ThreadId ;
uint32 Code ;
FString ExceptionString ;
TArray < FString > CallStackString ;
FCrashExceptionInfo ( )
: ProcessId ( 0 )
, ThreadId ( 0 )
, Code ( 0 )
{
}
~ FCrashExceptionInfo ( )
{
}
} ;
/**
* Details about the system the crash dump occurred on
*/
class FCrashSystemInfo
{
public :
FString Report ;
EProcessorArchitecture ProcessorArchitecture ;
uint32 ProcessorCount ;
uint16 OSMajor ;
uint16 OSMinor ;
uint16 OSBuild ;
uint16 OSRevision ;
FCrashSystemInfo ( )
: ProcessorArchitecture ( PA_UNKNOWN )
, ProcessorCount ( 0 )
, OSMajor ( 0 )
, OSMinor ( 0 )
, OSBuild ( 0 )
, OSRevision ( 0 )
{
}
} ;
2015-07-27 06:33:11 -04:00
// #YRX_Crash: 2015-07-24 Merge with FCrashDescription
2014-03-14 14:13:41 -04:00
/** A platform independent representation of a crash */
class CRASHDEBUGHELPER_API FCrashInfo
{
public :
2014-07-14 06:53:12 -04:00
enum
{
/** An invalid changelist, something went wrong. */
INVALID_CHANGELIST = - 1 ,
} ;
/** Report log. */
2014-03-14 14:13:41 -04:00
FString Report ;
2014-07-14 06:53:12 -04:00
/** The depot name, indicate where the executables and symbols are stored. */
FString DepotName ;
/** Product version, based on FEngineVersion. */
2015-03-02 07:52:38 -05:00
FString EngineVersion ;
2014-07-14 06:53:12 -04:00
/** CL built from. */
2015-01-22 08:03:55 -05:00
int32 BuiltFromCL ;
2014-07-14 06:53:12 -04:00
/** The label the describes the executables and symbols. */
2014-03-14 14:13:41 -04:00
FString LabelName ;
2014-07-14 06:53:12 -04:00
/** The network path where the executables are stored. */
2015-01-22 08:03:55 -05:00
FString ExecutablesPath ;
/** The network path where the symbols are stored. */
FString SymbolsPath ;
2014-07-14 06:53:12 -04:00
2014-03-14 14:13:41 -04:00
FString SourceFile ;
2015-03-02 07:52:38 -05:00
uint32 SourceLineNumber ;
2014-03-14 14:13:41 -04:00
TArray < FString > SourceContext ;
2014-07-14 06:53:12 -04:00
/** Only modules names, retrieved from the minidump file. */
TArray < FString > ModuleNames ;
2014-03-14 14:13:41 -04:00
FCrashSystemInfo SystemInfo ;
FCrashExceptionInfo Exception ;
TArray < FCrashThreadInfo > Threads ;
TArray < FCrashModuleInfo > Modules ;
2014-05-29 17:21:16 -04:00
/** Shared pointer to the PDB Cache entry, if valid contains all information about synced PDBs. */
2015-03-02 07:52:38 -05:00
TSharedPtr < FPDBCacheEntry > PDBCacheEntry ;
2014-05-29 17:21:16 -04:00
2014-03-14 14:13:41 -04:00
FCrashInfo ( )
2015-01-22 08:03:55 -05:00
: BuiltFromCL ( INVALID_CHANGELIST )
2014-03-14 14:13:41 -04:00
, SourceLineNumber ( 0 )
{
}
~ FCrashInfo ( )
{
}
/**
* Generate a report for the crash in the requested path
*/
void GenerateReport ( const FString & DiagnosticsPath ) ;
/**
* Handle logging
*/
void Log ( FString Line ) ;
private :
2015-03-02 07:52:38 -05:00
/**
* Convert the processor architecture to a human readable string
*/
2014-03-14 14:13:41 -04:00
const TCHAR * GetProcessorArchitecture ( EProcessorArchitecture PA ) ;
2015-03-02 07:52:38 -05:00
/**
* Calculate the byte size of a UTF - 8 string
*/
2014-03-14 14:13:41 -04:00
int64 StringSize ( const ANSICHAR * Line ) ;
2015-03-02 07:52:38 -05:00
/**
* Write a line of UTF - 8 to a file
*/
2014-03-14 14:13:41 -04:00
void WriteLine ( FArchive * ReportFile , const ANSICHAR * Line = NULL ) ;
} ;
2015-03-02 07:52:38 -05:00
2014-03-14 14:13:41 -04:00
/** Helper structure for tracking crash debug information */
2015-03-02 07:52:38 -05:00
struct FCrashDebugInfo
2014-03-14 14:13:41 -04:00
{
/** The name of the crash dump file */
FString CrashDumpName ;
/** The engine version of the crash dump build */
int32 EngineVersion ;
/** The platform of the crash dump build */
FString PlatformName ;
/** The source control label of the crash dump build */
FString SourceControlLabel ;
} ;
/** The public interface for the crash dump handler singleton. */
class CRASHDEBUGHELPER_API ICrashDebugHelper
{
2015-03-02 07:52:38 -05:00
public :
static const TCHAR * P4_DEPOT_PREFIX ;
2014-07-14 06:53:12 -04:00
2015-03-03 12:24:16 -05:00
/** Replaces %DEPOT_INDEX% with the command line DepotIndex in the specified path. */
static void SetDepotIndex ( FString & PathToChange ) ;
2015-03-02 07:52:38 -05:00
protected :
2014-07-14 06:53:12 -04:00
/**
* Pattern to search in source control for the label .
* This somehow works for older crashes , before 4.2 and for the newest one ,
* bur for the newest we also need to look for the executables on the network drive .
* This may change in future .
*/
2014-03-14 14:13:41 -04:00
FString SourceControlBuildLabelPattern ;
2014-07-14 06:53:12 -04:00
/**
2015-03-02 07:52:38 -05:00
* Patterns to search in the network driver for the executables / the symbols .
2014-07-14 06:53:12 -04:00
* Valid from 4.2 UE builds . ( CL - 2068994 )
* This may change in future .
*/
2015-03-02 07:52:38 -05:00
TArray < FString > Branches ;
TArray < FString > ExecutablePathPatterns ;
TArray < FString > SymbolPathPatterns ;
2014-05-29 17:21:16 -04:00
2014-03-14 14:13:41 -04:00
/** Indicates that the crash handler is ready to do work */
bool bInitialized ;
public :
/** A platform independent representation of a crash */
FCrashInfo CrashInfo ;
2014-05-29 17:21:16 -04:00
2014-03-14 14:13:41 -04:00
/** Virtual destructor */
virtual ~ ICrashDebugHelper ( )
2014-05-29 17:21:16 -04:00
{ }
2014-03-14 14:13:41 -04:00
/**
* Initialize the helper
*
* @ return bool true if successful , false if not
*/
virtual bool Init ( ) ;
/**
* Parse the given crash dump , determining EngineVersion of the build that produced it - if possible .
*
* @ param InCrashDumpName The crash dump file to process
* @ param OutCrashDebugInfo The crash dump info extracted from the file
*
* @ return bool true if successful , false if not
2015-07-27 06:33:11 -04:00
*
* Only used by Mac , to be removed .
2014-03-14 14:13:41 -04:00
*/
virtual bool ParseCrashDump ( const FString & InCrashDumpName , FCrashDebugInfo & OutCrashDebugInfo )
{
return false ;
}
/**
* Parse the given crash dump , and generate a report .
*
* @ param InCrashDumpName The crash dump file to process
*
* @ return bool true if successful , false if not
*/
virtual bool CreateMinidumpDiagnosticReport ( const FString & InCrashDumpName )
{
return false ;
}
/**
2015-03-02 07:52:38 -05:00
* Sync the branch root relative file names to the requested label
2014-03-14 14:13:41 -04:00
*/
2014-07-14 06:53:12 -04:00
virtual bool SyncModules ( ) ;
2014-03-14 14:13:41 -04:00
/**
2015-01-22 08:03:55 -05:00
* Sync a single source file to the requested CL .
2014-03-14 14:13:41 -04:00
*/
2014-07-14 06:53:12 -04:00
virtual bool SyncSourceFile ( ) ;
2014-03-14 14:13:41 -04:00
/**
* Extract lines from a source file , and add to the crash report .
*/
2014-07-14 06:53:12 -04:00
virtual void AddSourceToReport ( ) ;
2014-03-14 14:13:41 -04:00
/**
* Extract annotated lines from a source file stored in Perforce , and add to the crash report .
*/
2014-07-14 06:53:12 -04:00
virtual bool AddAnnotatedSourceToReport ( ) ;
2014-03-14 14:13:41 -04:00
protected :
2015-03-02 07:52:38 -05:00
/** Finds the storage of the symbols and the executables for the specified changelist and the depot name, it can be Perforce, network drive or stored locally. */
void FindSymbolsAndBinariesStorage ( ) ;
2014-03-14 14:13:41 -04:00
/**
2015-03-02 07:52:38 -05:00
* Load the given ANSI text file to an array of strings - one FString per line of the file .
* Intended for use in simple text parsing actions
2014-03-14 14:13:41 -04:00
*
2015-03-02 07:52:38 -05:00
* @ param OutStrings The array of FStrings to fill in
*
* @ return bool true if successful , false if not
2014-03-14 14:13:41 -04:00
*/
2015-03-07 06:46:11 -05:00
bool ReadSourceFile ( TArray < FString > & OutStrings ) ;
2015-03-02 07:52:38 -05:00
2014-03-14 14:13:41 -04:00
public :
bool InitSourceControl ( bool bShowLogin ) ;
void ShutdownSourceControl ( ) ;
} ;