void PrintJournalHeader(out_ctx* ctx, const journal_header* record) { /* int32_t magic; int32_t endian; volatile off_t start; // zero-based byte offset of the start of the first transaction volatile off_t end; // zero-based byte offset of where free space begins off_t size; // size in bytes of the entire journal int32_t blhdr_size; // size in bytes of each block_list_header in the journal int32_t checksum; int32_t jhdr_size; // block size (in bytes) of the journal header uint32_t sequence_num; // NEW FIELD: a monotonically increasing value assigned to all txn's */ BeginSection(ctx, "Journal Header"); PrintUIChar(ctx, record, magic); PrintUIHex(ctx, record, endian); PrintUI(ctx, record, start); PrintUI(ctx, record, end); PrintDataLength(ctx, record, size); PrintDataLength(ctx, record, blhdr_size); PrintUIHex(ctx, record, checksum); PrintDataLength(ctx, record, jhdr_size); PrintUI(ctx, record, sequence_num); EndSection(ctx); }
void PrintJournalInfoBlock(out_ctx* ctx, const JournalInfoBlock* record) { /* struct JournalInfoBlock { uint32_t flags; uint32_t device_signature[8]; // signature used to locate our device. uint64_t offset; // byte offset to the journal on the device uint64_t size; // size in bytes of the journal uuid_string_t ext_jnl_uuid; char machine_serial_num[48]; char reserved[JIB_RESERVED_SIZE]; } __attribute__((aligned(2), packed)); typedef struct JournalInfoBlock JournalInfoBlock; */ BeginSection(ctx, "Journal Info Block"); PrintRawAttribute(ctx, record, flags, 2); PrintUIFlagIfMatch(ctx, record->flags, kJIJournalInFSMask); PrintUIFlagIfMatch(ctx, record->flags, kJIJournalOnOtherDeviceMask); PrintUIFlagIfMatch(ctx, record->flags, kJIJournalNeedInitMask); _PrintRawAttribute(ctx, "device_signature", &record->device_signature[0], 32, 16); PrintDataLength(ctx, record, offset); PrintDataLength(ctx, record, size); char uuid_str[sizeof(uuid_string_t) + 1]; (void)strlcpy(uuid_str, &record->ext_jnl_uuid[0], sizeof(uuid_str)); PrintAttribute(ctx, "ext_jnl_uuid", uuid_str); char serial[49]; (void)strlcpy(serial, &record->machine_serial_num[0], 49); PrintAttribute(ctx, "machine_serial_num", serial); // (uint32_t) reserved[32] EndSection(ctx); }
void FGenericCrashContext::SerializeContentToBuffer() { // Must conform against: // https://www.securecoding.cert.org/confluence/display/seccode/SIG30-C.+Call+only+asynchronous-safe+functions+within+signal+handlers AddHeader(); BeginSection( TEXT( "RuntimeProperties" ) ); AddCrashProperty( TEXT( "Version" ), (int32)ECrashDescVersions::VER_2_AddedNewProperties ); // ProcessId will be used by the crash report client to get more information about the crashed process. // It should be enough to open the process, get the memory stats, a list of loaded modules etc. // It means that the crashed process needs to be alive as long as the crash report client is working on the process. // Proposal, not implemented yet. AddCrashProperty( TEXT( "ProcessId" ), FPlatformProcess::GetCurrentProcessId() ); AddCrashProperty( TEXT( "IsInternalBuild" ), (int32)NCachedCrashContextProperties::bIsInternalBuild ); AddCrashProperty( TEXT( "IsPerforceBuild" ), (int32)NCachedCrashContextProperties::bIsPerforceBuild ); AddCrashProperty( TEXT( "IsSourceDistribution" ), (int32)NCachedCrashContextProperties::bIsSourceDistribution ); // Added 'editor/game open time till crash' // Add common crash properties. AddCrashProperty( TEXT( "GameName" ), FApp::GetGameName() ); AddCrashProperty(TEXT("ExecutableName"), *NCachedCrashContextProperties::ExecutableName); AddCrashProperty( TEXT( "BuildConfiguration" ), EBuildConfigurations::ToString( FApp::GetBuildConfiguration() ) ); AddCrashProperty(TEXT("PlatformName"), *NCachedCrashContextProperties::PlatformName); AddCrashProperty(TEXT("PlatformNameIni"), *NCachedCrashContextProperties::PlatformNameIni); AddCrashProperty( TEXT( "EngineMode" ), FPlatformMisc::GetEngineMode() ); AddCrashProperty( TEXT( "EngineVersion" ), *GEngineVersion.ToString() ); AddCrashProperty( TEXT( "CommandLine" ), FCommandLine::IsInitialized() ? FCommandLine::Get() : TEXT("") ); AddCrashProperty( TEXT( "LanguageLCID" ), FInternationalization::Get().GetCurrentCulture()->GetLCID() ); AddCrashProperty(TEXT("DefaultLocale"), *NCachedCrashContextProperties::DefaultLocale); AddCrashProperty( TEXT( "IsUE4Release" ), (int32)NCachedCrashContextProperties::bIsUE4Release); // Remove periods from user names to match AutoReporter user names // The name prefix is read by CrashRepository.AddNewCrash in the website code const bool bSendUserName = NCachedCrashContextProperties::bIsInternalBuild; AddCrashProperty( TEXT( "UserName" ), bSendUserName ? *NCachedCrashContextProperties::UserName.Replace( TEXT( "." ), TEXT( "" ) ) : TEXT( "" ) ); AddCrashProperty(TEXT("BaseDir"), *NCachedCrashContextProperties::BaseDir); AddCrashProperty(TEXT("RootDir"), *NCachedCrashContextProperties::RootDir); AddCrashProperty(TEXT("MachineId"), *NCachedCrashContextProperties::MachineIdStr); AddCrashProperty(TEXT("EpicAccountId"), *NCachedCrashContextProperties::EpicAccountId); AddCrashProperty( TEXT( "CallStack" ), TEXT( "" ) ); AddCrashProperty( TEXT( "SourceContext" ), TEXT( "" ) ); AddCrashProperty( TEXT( "UserDescription" ), TEXT( "" ) ); AddCrashProperty( TEXT( "ErrorMessage" ), (const TCHAR*)GErrorMessage ); // GErrorMessage may be broken. // Add misc stats. AddCrashProperty(TEXT("MiscNumberOfCores"), NCachedCrashContextProperties::NumberOfCores); AddCrashProperty(TEXT("MiscNumberOfCoresIncludingHyperthreads"), NCachedCrashContextProperties::NumberOfCoresIncludingHyperthreads); AddCrashProperty( TEXT( "MiscIs64bitOperatingSystem" ), (int32)FPlatformMisc::Is64bitOperatingSystem() ); AddCrashProperty(TEXT("MiscCPUVendor"), *NCachedCrashContextProperties::CPUVendor); AddCrashProperty(TEXT("MiscCPUBrand"), *NCachedCrashContextProperties::CPUBrand); AddCrashProperty(TEXT("MiscPrimaryGPUBrand"), *NCachedCrashContextProperties::PrimaryGPUBrand); AddCrashProperty(TEXT("MiscOSVersionMajor"), *NCachedCrashContextProperties::OsVersion); AddCrashProperty(TEXT("MiscOSVersionMinor"), *NCachedCrashContextProperties::OsSubVersion); AddCrashProperty( TEXT( "CrashDumpMode" ), NCachedCrashContextProperties::CrashDumpMode ); // @TODO yrx 2014-10-08 Move to the crash report client. /*if( CanUseUnsafeAPI() ) { uint64 AppDiskTotalNumberOfBytes = 0; uint64 AppDiskNumberOfFreeBytes = 0; FPlatformMisc::GetDiskTotalAndFreeSpace( FPlatformProcess::BaseDir(), AppDiskTotalNumberOfBytes, AppDiskNumberOfFreeBytes ); AddCrashProperty( TEXT( "MiscAppDiskTotalNumberOfBytes" ), AppDiskTotalNumberOfBytes ); AddCrashProperty( TEXT( "MiscAppDiskNumberOfFreeBytes" ), AppDiskNumberOfFreeBytes ); }*/ // FPlatformMemory::GetConstants is called in the GCreateMalloc, so we can assume it is always valid. { // Add memory stats. const FPlatformMemoryConstants& MemConstants = FPlatformMemory::GetConstants(); AddCrashProperty( TEXT( "MemoryStatsTotalPhysical" ), (uint64)MemConstants.TotalPhysical ); AddCrashProperty( TEXT( "MemoryStatsTotalVirtual" ), (uint64)MemConstants.TotalVirtual ); AddCrashProperty( TEXT( "MemoryStatsPageSize" ), (uint64)MemConstants.PageSize ); AddCrashProperty( TEXT( "MemoryStatsTotalPhysicalGB" ), MemConstants.TotalPhysicalGB ); } AddCrashProperty( TEXT( "MemoryStatsAvailablePhysical" ), (uint64)CrashMemoryStats.AvailablePhysical ); AddCrashProperty( TEXT( "MemoryStatsAvailableVirtual" ), (uint64)CrashMemoryStats.AvailableVirtual ); AddCrashProperty( TEXT( "MemoryStatsUsedPhysical" ), (uint64)CrashMemoryStats.UsedPhysical ); AddCrashProperty( TEXT( "MemoryStatsPeakUsedPhysical" ), (uint64)CrashMemoryStats.PeakUsedPhysical ); AddCrashProperty( TEXT( "MemoryStatsUsedVirtual" ), (uint64)CrashMemoryStats.UsedVirtual ); AddCrashProperty( TEXT( "MemoryStatsPeakUsedVirtual" ), (uint64)CrashMemoryStats.PeakUsedVirtual ); AddCrashProperty( TEXT( "MemoryStatsbIsOOM" ), (int32)FPlatformMemory::bIsOOM ); AddCrashProperty( TEXT( "MemoryStatsOOMAllocationSize"), (uint64)FPlatformMemory::OOMAllocationSize ); AddCrashProperty( TEXT( "MemoryStatsOOMAllocationAlignment"), (int32)FPlatformMemory::OOMAllocationAlignment ); //Architecture //CrashedModuleName //LoadedModules EndSection( TEXT( "RuntimeProperties" ) ); // Add platform specific properties. BeginSection( TEXT("PlatformProperties") ); AddPlatformSpecificProperties(); EndSection( TEXT( "PlatformProperties" ) ); AddFooter(); }
void FGenericCrashContext::AddHeader() { CommonBuffer += TEXT( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" ) LINE_TERMINATOR; BeginSection( TEXT("FGenericCrashContext") ); }
void FGenericCrashContext::SerializeContentToBuffer() { // Must conform against: // https://www.securecoding.cert.org/confluence/display/seccode/SIG30-C.+Call+only+asynchronous-safe+functions+within+signal+handlers AddHeader(); BeginSection( *RuntimePropertiesTag ); AddCrashProperty( TEXT( "CrashVersion" ), (int32)ECrashDescVersions::VER_3_CrashContext ); AddCrashProperty( TEXT( "CrashGUID" ), *NCachedCrashContextProperties::CrashGUID ); AddCrashProperty( TEXT( "ProcessId" ), FPlatformProcess::GetCurrentProcessId() ); AddCrashProperty( TEXT( "IsInternalBuild" ), NCachedCrashContextProperties::bIsInternalBuild ); AddCrashProperty( TEXT( "IsPerforceBuild" ), NCachedCrashContextProperties::bIsPerforceBuild ); AddCrashProperty( TEXT( "IsSourceDistribution" ), NCachedCrashContextProperties::bIsSourceDistribution ); AddCrashProperty( TEXT( "SecondsSinceStart" ), NCachedCrashContextProperties::SecondsSinceStart ); // Add common crash properties. AddCrashProperty( TEXT( "GameName" ), *NCachedCrashContextProperties::GameName ); AddCrashProperty( TEXT( "ExecutableName" ), *NCachedCrashContextProperties::ExecutableName ); AddCrashProperty( TEXT( "BuildConfiguration" ), EBuildConfigurations::ToString( FApp::GetBuildConfiguration() ) ); AddCrashProperty( TEXT( "PlatformName" ), *NCachedCrashContextProperties::PlatformName ); AddCrashProperty( TEXT( "PlatformNameIni" ), *NCachedCrashContextProperties::PlatformNameIni ); AddCrashProperty( TEXT( "EngineMode" ), FPlatformMisc::GetEngineMode() ); AddCrashProperty( TEXT( "EngineVersion" ), *GEngineVersion.ToString() ); AddCrashProperty( TEXT( "CommandLine" ), FCommandLine::IsInitialized() ? FCommandLine::Get() : TEXT( "" ) ); AddCrashProperty( TEXT( "LanguageLCID" ), FInternationalization::Get().GetCurrentCulture()->GetLCID() ); AddCrashProperty( TEXT( "AppDefaultLocale" ), *NCachedCrashContextProperties::DefaultLocale ); AddCrashProperty( TEXT( "IsUE4Release" ), NCachedCrashContextProperties::bIsUE4Release ); // Remove periods from user names to match AutoReporter user names // The name prefix is read by CrashRepository.AddNewCrash in the website code const bool bSendUserName = NCachedCrashContextProperties::bIsInternalBuild; AddCrashProperty( TEXT( "UserName" ), bSendUserName ? *NCachedCrashContextProperties::UserName.Replace( TEXT( "." ), TEXT( "" ) ) : TEXT( "" ) ); AddCrashProperty( TEXT( "BaseDir" ), *NCachedCrashContextProperties::BaseDir ); AddCrashProperty( TEXT( "RootDir" ), *NCachedCrashContextProperties::RootDir ); AddCrashProperty( TEXT( "MachineId" ), *NCachedCrashContextProperties::MachineIdStr ); AddCrashProperty( TEXT( "EpicAccountId" ), *NCachedCrashContextProperties::EpicAccountId ); AddCrashProperty( TEXT( "CallStack" ), TEXT( "" ) ); AddCrashProperty( TEXT( "SourceContext" ), TEXT( "" ) ); AddCrashProperty( TEXT( "UserDescription" ), TEXT( "" ) ); AddCrashProperty( TEXT( "ErrorMessage" ), (const TCHAR*)GErrorMessage ); // GErrorMessage may be broken. AddCrashProperty( TEXT( "CrashDumpMode" ), NCachedCrashContextProperties::CrashDumpMode ); // Add misc stats. AddCrashProperty( TEXT( "Misc.NumberOfCores" ), NCachedCrashContextProperties::NumberOfCores ); AddCrashProperty( TEXT( "Misc.NumberOfCoresIncludingHyperthreads" ), NCachedCrashContextProperties::NumberOfCoresIncludingHyperthreads ); AddCrashProperty( TEXT( "Misc.Is64bitOperatingSystem" ), (int32)FPlatformMisc::Is64bitOperatingSystem() ); AddCrashProperty( TEXT( "Misc.CPUVendor" ), *NCachedCrashContextProperties::CPUVendor ); AddCrashProperty( TEXT( "Misc.CPUBrand" ), *NCachedCrashContextProperties::CPUBrand ); AddCrashProperty( TEXT( "Misc.PrimaryGPUBrand" ), *NCachedCrashContextProperties::PrimaryGPUBrand ); AddCrashProperty( TEXT( "Misc.OSVersionMajor" ), *NCachedCrashContextProperties::OsVersion ); AddCrashProperty( TEXT( "Misc.OSVersionMinor" ), *NCachedCrashContextProperties::OsSubVersion ); // #YRX_Crash: 2015-07-21 Move to the crash report client. /*{ uint64 AppDiskTotalNumberOfBytes = 0; uint64 AppDiskNumberOfFreeBytes = 0; FPlatformMisc::GetDiskTotalAndFreeSpace( FPlatformProcess::BaseDir(), AppDiskTotalNumberOfBytes, AppDiskNumberOfFreeBytes ); AddCrashProperty( TEXT( "Misc.AppDiskTotalNumberOfBytes" ), AppDiskTotalNumberOfBytes ); AddCrashProperty( TEXT( "Misc.AppDiskNumberOfFreeBytes" ), AppDiskNumberOfFreeBytes ); }*/ // FPlatformMemory::GetConstants is called in the GCreateMalloc, so we can assume it is always valid. { // Add memory stats. const FPlatformMemoryConstants& MemConstants = FPlatformMemory::GetConstants(); AddCrashProperty( TEXT( "MemoryStats.TotalPhysical" ), (uint64)MemConstants.TotalPhysical ); AddCrashProperty( TEXT( "MemoryStats.TotalVirtual" ), (uint64)MemConstants.TotalVirtual ); AddCrashProperty( TEXT( "MemoryStats.PageSize" ), (uint64)MemConstants.PageSize ); AddCrashProperty( TEXT( "MemoryStats.TotalPhysicalGB" ), MemConstants.TotalPhysicalGB ); } AddCrashProperty( TEXT( "MemoryStats.AvailablePhysical" ), (uint64)CrashMemoryStats.AvailablePhysical ); AddCrashProperty( TEXT( "MemoryStats.AvailableVirtual" ), (uint64)CrashMemoryStats.AvailableVirtual ); AddCrashProperty( TEXT( "MemoryStats.UsedPhysical" ), (uint64)CrashMemoryStats.UsedPhysical ); AddCrashProperty( TEXT( "MemoryStats.PeakUsedPhysical" ), (uint64)CrashMemoryStats.PeakUsedPhysical ); AddCrashProperty( TEXT( "MemoryStats.UsedVirtual" ), (uint64)CrashMemoryStats.UsedVirtual ); AddCrashProperty( TEXT( "MemoryStats.PeakUsedVirtual" ), (uint64)CrashMemoryStats.PeakUsedVirtual ); AddCrashProperty( TEXT( "MemoryStats.bIsOOM" ), (int32)FPlatformMemory::bIsOOM ); AddCrashProperty( TEXT( "MemoryStats.OOMAllocationSize"), (uint64)FPlatformMemory::OOMAllocationSize ); AddCrashProperty( TEXT( "MemoryStats.OOMAllocationAlignment"), (int32)FPlatformMemory::OOMAllocationAlignment ); //Architecture //CrashedModuleName //LoadedModules EndSection( *RuntimePropertiesTag ); // Add platform specific properties. BeginSection( *PlatformPropertiesTag ); AddPlatformSpecificProperties(); EndSection( *PlatformPropertiesTag ); AddFooter(); }