Copy as Markdown

Other Tools

/* This file was autogenerated by toolkit/crashreporter/generate_crash_reporter_sources.py. DO NOT EDIT */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef CrashAnnotations_h
#define CrashAnnotations_h
#include <cstddef>
#include <cstdint>
namespace CrashReporter {
// Typed enum representing all crash annotations
enum class Annotation : uint32_t {
AbortMessage = 0,
Accessibility = 1,
AccessibilityClient = 2,
AccessibilityInProcClient = 3,
AdapterDeviceID = 4,
AdapterDriverVendor = 5,
AdapterDriverVersion = 6,
AdapterSubsysID = 7,
AdapterVendorID = 8,
Addons = 9,
Android_Board = 10,
Android_Brand = 11,
Android_CPU_ABI = 12,
Android_CPU_ABI2 = 13,
Android_Device = 14,
Android_Display = 15,
Android_Fingerprint = 16,
Android_Hardware = 17,
Android_Manufacturer = 18,
Android_Model = 19,
Android_PackageName = 20,
Android_Version = 21,
AppInitDLLs = 22,
ApplicationBuildID = 23,
AsyncShutdownTimeout = 24,
AvailablePageFile = 25,
AvailablePhysicalMemory = 26,
AvailableSwapMemory = 27,
AvailableVirtualMemory = 28,
BackgroundTaskMode = 29,
BackgroundTaskName = 30,
BlockedDllList = 31,
BlocklistInitFailed = 32,
Breadcrumbs = 33,
BuildID = 34,
CPUMicrocodeVersion = 35,
ContentSandboxCapabilities = 36,
ContentSandboxCapable = 37,
ContentSandboxEnabled = 38,
ContentSandboxLevel = 39,
ContentSandboxWin32kState = 40,
CrashTime = 41,
CycleCollector = 42,
DOMFissionEnabled = 43,
DOMIPCEnabled = 44,
DesktopEnvironment = 45,
DeviceResetReason = 46,
DumperError = 47,
EMCheckCompatibility = 48,
EventLoopNestingLevel = 49,
ExperimentalFeatures = 50,
FontName = 51,
GMPLibraryPath = 52,
GMPPlugin = 53,
GPUProcessLaunchCount = 54,
GPUProcessStatus = 55,
GpuSandboxLevel = 56,
GraphicsCompileShader = 57,
GraphicsCriticalError = 58,
GraphicsDrawShader = 59,
GraphicsNumActiveRenderers = 60,
GraphicsNumRenderers = 61,
GraphicsStartupTest = 62,
Hang = 63,
HasDeviceTouchScreen = 64,
HeadlessMode = 65,
IPCFatalErrorMsg = 66,
IPCFatalErrorProtocol = 67,
IPCMessageName = 68,
IPCMessageSize = 69,
IPCReadErrorReason = 70,
IPCShutdownState = 71,
IPCSystemError = 72,
InstallTime = 73,
IpcCreatePipeCloExecErrno = 74,
IpcCreatePipeFcntlErrno = 75,
IpcCreatePipeSocketPairErrno = 76,
IsGarbageCollecting = 77,
IsWayland = 78,
IsWebRenderResourcePathOverridden = 79,
JSActorMessage = 80,
JSActorName = 81,
JSLargeAllocationFailure = 82,
JSModuleLoadError = 83,
JSOutOfMemory = 84,
JavaException = 85,
JavaStackTrace = 86,
LastInteractionDuration = 87,
LastStartupWasCrash = 88,
LauncherProcessState = 89,
LinuxUnderMemoryPressure = 90,
LowPhysicalMemoryEvents = 91,
MacAvailableMemorySysctl = 92,
MacMemoryPressure = 93,
MacMemoryPressureCriticalTime = 94,
MacMemoryPressureNormalTime = 95,
MacMemoryPressureSysctl = 96,
MacMemoryPressureWarningTime = 97,
MainThreadRunnableName = 98,
MozCrashReason = 99,
Notes = 100,
OOMAllocationSize = 101,
PHCAllocStack = 102,
PHCBaseAddress = 103,
PHCFreeStack = 104,
PHCKind = 105,
PHCUsableSize = 106,
PluginFilename = 107,
PluginName = 108,
PluginVersion = 109,
ProcessType = 110,
ProductID = 111,
ProductName = 112,
ProfilerChildShutdownPhase = 113,
PurgeablePhysicalMemory = 114,
QuotaManagerShutdownTimeout = 115,
QuotaManagerStorageIsNetworkResource = 116,
RDDProcessStatus = 117,
ReleaseChannel = 118,
RemoteType = 119,
SafeMode = 120,
SecondsSinceLastCrash = 121,
ServerURL = 122,
ShutdownProgress = 123,
ShutdownReason = 124,
StartupCacheValid = 125,
StartupCrash = 126,
StartupTime = 127,
StorageConnectionNotClosed = 128,
SubmittedFrom = 129,
SystemMemoryUsePercentage = 130,
TelemetryClientId = 131,
TelemetryEnvironment = 132,
TelemetryServerURL = 133,
TelemetrySessionId = 134,
TestKey = 135,
TestUnicode = 136,
TextureUsage = 137,
Throttleable = 138,
TotalPageFile = 139,
TotalPhysicalMemory = 140,
TotalVirtualMemory = 141,
URL = 142,
URLSegments = 143,
UnknownNetAddrSocketFamily = 144,
UptimeTS = 145,
User32BeforeBlocklist = 146,
UtilityActorsName = 147,
UtilityProcessStatus = 148,
VRProcessStatus = 149,
Vendor = 150,
Version = 151,
WasmLibrarySandboxMallocFailed = 152,
WindowsErrorReporting = 153,
WindowsFileDialogErrorCode = 154,
WindowsPackageFamilyName = 155,
Winsock_LSP = 156,
XPCOMSpinEventLoopStack = 157,
additional_minidumps = 158,
ipc_channel_error = 159,
useragent_locale = 160,
Count = 161
};
// Stringified crash annotation names
const char* const kAnnotationStrings[] = {
"AbortMessage",
"Accessibility",
"AccessibilityClient",
"AccessibilityInProcClient",
"AdapterDeviceID",
"AdapterDriverVendor",
"AdapterDriverVersion",
"AdapterSubsysID",
"AdapterVendorID",
"Add-ons",
"Android_Board",
"Android_Brand",
"Android_CPU_ABI",
"Android_CPU_ABI2",
"Android_Device",
"Android_Display",
"Android_Fingerprint",
"Android_Hardware",
"Android_Manufacturer",
"Android_Model",
"Android_PackageName",
"Android_Version",
"AppInitDLLs",
"ApplicationBuildID",
"AsyncShutdownTimeout",
"AvailablePageFile",
"AvailablePhysicalMemory",
"AvailableSwapMemory",
"AvailableVirtualMemory",
"BackgroundTaskMode",
"BackgroundTaskName",
"BlockedDllList",
"BlocklistInitFailed",
"Breadcrumbs",
"BuildID",
"CPUMicrocodeVersion",
"ContentSandboxCapabilities",
"ContentSandboxCapable",
"ContentSandboxEnabled",
"ContentSandboxLevel",
"ContentSandboxWin32kState",
"CrashTime",
"CycleCollector",
"DOMFissionEnabled",
"DOMIPCEnabled",
"DesktopEnvironment",
"DeviceResetReason",
"DumperError",
"EMCheckCompatibility",
"EventLoopNestingLevel",
"ExperimentalFeatures",
"FontName",
"GMPLibraryPath",
"GMPPlugin",
"GPUProcessLaunchCount",
"GPUProcessStatus",
"GpuSandboxLevel",
"GraphicsCompileShader",
"GraphicsCriticalError",
"GraphicsDrawShader",
"GraphicsNumActiveRenderers",
"GraphicsNumRenderers",
"GraphicsStartupTest",
"Hang",
"HasDeviceTouchScreen",
"HeadlessMode",
"IPCFatalErrorMsg",
"IPCFatalErrorProtocol",
"IPCMessageName",
"IPCMessageSize",
"IPCReadErrorReason",
"IPCShutdownState",
"IPCSystemError",
"InstallTime",
"IpcCreatePipeCloExecErrno",
"IpcCreatePipeFcntlErrno",
"IpcCreatePipeSocketPairErrno",
"IsGarbageCollecting",
"IsWayland",
"IsWebRenderResourcePathOverridden",
"JSActorMessage",
"JSActorName",
"JSLargeAllocationFailure",
"JSModuleLoadError",
"JSOutOfMemory",
"JavaException",
"JavaStackTrace",
"LastInteractionDuration",
"LastStartupWasCrash",
"LauncherProcessState",
"LinuxUnderMemoryPressure",
"LowPhysicalMemoryEvents",
"MacAvailableMemorySysctl",
"MacMemoryPressure",
"MacMemoryPressureCriticalTime",
"MacMemoryPressureNormalTime",
"MacMemoryPressureSysctl",
"MacMemoryPressureWarningTime",
"MainThreadRunnableName",
"MozCrashReason",
"Notes",
"OOMAllocationSize",
"PHCAllocStack",
"PHCBaseAddress",
"PHCFreeStack",
"PHCKind",
"PHCUsableSize",
"PluginFilename",
"PluginName",
"PluginVersion",
"ProcessType",
"ProductID",
"ProductName",
"ProfilerChildShutdownPhase",
"PurgeablePhysicalMemory",
"QuotaManagerShutdownTimeout",
"QuotaManagerStorageIsNetworkResource",
"RDDProcessStatus",
"ReleaseChannel",
"RemoteType",
"SafeMode",
"SecondsSinceLastCrash",
"ServerURL",
"ShutdownProgress",
"ShutdownReason",
"StartupCacheValid",
"StartupCrash",
"StartupTime",
"StorageConnectionNotClosed",
"SubmittedFrom",
"SystemMemoryUsePercentage",
"TelemetryClientId",
"TelemetryEnvironment",
"TelemetryServerURL",
"TelemetrySessionId",
"TestKey",
"TestUnicode",
"TextureUsage",
"Throttleable",
"TotalPageFile",
"TotalPhysicalMemory",
"TotalVirtualMemory",
"URL",
"URLSegments",
"UnknownNetAddrSocketFamily",
"UptimeTS",
"User32BeforeBlocklist",
"UtilityActorsName",
"UtilityProcessStatus",
"VRProcessStatus",
"Vendor",
"Version",
"WasmLibrarySandboxMallocFailed",
"WindowsErrorReporting",
"WindowsFileDialogErrorCode",
"WindowsPackageFamilyName",
"Winsock_LSP",
"XPCOMSpinEventLoopStack",
"additional_minidumps",
"ipc_channel_error",
"useragent_locale"
};
// Type of each annotation
enum class AnnotationType : uint8_t {
String = 0, // Any type of string, const char*, nsCString, etc...
Boolean = 1, // Stored as a byte
U32 = 2, // C/C++'s uint32_t or Rust's u32
U64 = 3, // C/C++'s uint64_t or Rust's u64
USize = 4, // C/C++'s size_t or Rust's usize
};
// Type of each annotation
const AnnotationType kAnnotationTypes[] = {
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::USize,
AnnotationType::USize,
AnnotationType::USize,
AnnotationType::USize,
AnnotationType::Boolean,
AnnotationType::String,
AnnotationType::String,
AnnotationType::Boolean,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::U32,
AnnotationType::Boolean,
AnnotationType::Boolean,
AnnotationType::U32,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::Boolean,
AnnotationType::Boolean,
AnnotationType::String,
AnnotationType::U32,
AnnotationType::String,
AnnotationType::String,
AnnotationType::U32,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::Boolean,
AnnotationType::U32,
AnnotationType::String,
AnnotationType::U32,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::USize,
AnnotationType::USize,
AnnotationType::Boolean,
AnnotationType::String,
AnnotationType::Boolean,
AnnotationType::Boolean,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::U32,
AnnotationType::String,
AnnotationType::String,
AnnotationType::U32,
AnnotationType::String,
AnnotationType::U32,
AnnotationType::U32,
AnnotationType::U32,
AnnotationType::Boolean,
AnnotationType::Boolean,
AnnotationType::Boolean,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::U64,
AnnotationType::Boolean,
AnnotationType::U32,
AnnotationType::Boolean,
AnnotationType::U32,
AnnotationType::U32,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::U32,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::USize,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::U32,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::USize,
AnnotationType::String,
AnnotationType::Boolean,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::Boolean,
AnnotationType::U64,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::Boolean,
AnnotationType::Boolean,
AnnotationType::U64,
AnnotationType::String,
AnnotationType::String,
AnnotationType::U32,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::USize,
AnnotationType::Boolean,
AnnotationType::USize,
AnnotationType::USize,
AnnotationType::USize,
AnnotationType::String,
AnnotationType::String,
AnnotationType::U32,
AnnotationType::String,
AnnotationType::Boolean,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::Boolean,
AnnotationType::Boolean,
AnnotationType::U32,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String,
AnnotationType::String
};
// Allowlist of crash annotations that can be included in a crash ping
const Annotation kCrashPingAllowedList[] = {
Annotation::AsyncShutdownTimeout,
Annotation::AvailablePageFile,
Annotation::AvailablePhysicalMemory,
Annotation::AvailableSwapMemory,
Annotation::AvailableVirtualMemory,
Annotation::BackgroundTaskName,
Annotation::BlockedDllList,
Annotation::BlocklistInitFailed,
Annotation::BuildID,
Annotation::CrashTime,
Annotation::DOMFissionEnabled,
Annotation::EventLoopNestingLevel,
Annotation::ExperimentalFeatures,
Annotation::FontName,
Annotation::GPUProcessLaunchCount,
Annotation::Hang,
Annotation::HeadlessMode,
Annotation::IsGarbageCollecting,
Annotation::LastInteractionDuration,
Annotation::LowPhysicalMemoryEvents,
Annotation::MainThreadRunnableName,
Annotation::MozCrashReason,
Annotation::OOMAllocationSize,
Annotation::ProductID,
Annotation::ProductName,
Annotation::ProfilerChildShutdownPhase,
Annotation::PurgeablePhysicalMemory,
Annotation::QuotaManagerShutdownTimeout,
Annotation::ReleaseChannel,
Annotation::RemoteType,
Annotation::SecondsSinceLastCrash,
Annotation::ShutdownProgress,
Annotation::ShutdownReason,
Annotation::StartupCrash,
Annotation::SystemMemoryUsePercentage,
Annotation::TextureUsage,
Annotation::TotalPageFile,
Annotation::TotalPhysicalMemory,
Annotation::TotalVirtualMemory,
Annotation::UptimeTS,
Annotation::User32BeforeBlocklist,
Annotation::UtilityActorsName,
Annotation::WindowsErrorReporting,
Annotation::WindowsFileDialogErrorCode,
Annotation::WindowsPackageFamilyName,
Annotation::ipc_channel_error
};
// Annotations which should be skipped when they have specific values
struct AnnotationSkipValue {
Annotation annotation;
const char* value;
};
const AnnotationSkipValue kSkipIfList[] = {
{ Annotation::BlocklistInitFailed, "0" },
{ Annotation::EventLoopNestingLevel, "0" },
{ Annotation::IsGarbageCollecting, "0" },
{ Annotation::LowPhysicalMemoryEvents, "0" },
{ Annotation::OOMAllocationSize, "0" },
{ Annotation::TextureUsage, "0" },
{ Annotation::User32BeforeBlocklist, "0" }
};
/**
* Return the type of a crash annotation.
*
* @param aAnnotation a crash annotation
* @returns The type of this annotation
*/
static inline AnnotationType TypeOfAnnotation(Annotation aAnnotation) {
return kAnnotationTypes[static_cast<uint32_t>(aAnnotation)];
}
/**
* Return the string representation of a crash annotation.
*
* @param aAnnotation a crash annotation
* @returns A constant string holding the annotation name
*/
static inline const char* AnnotationToString(Annotation aAnnotation) {
return kAnnotationStrings[static_cast<uint32_t>(aAnnotation)];
}
/**
* Converts a string to its corresponding crash annotation.
*
* @param aResult a reference where the annotation will be stored
* @param aValue the string to be converted
* @return true if the string was successfully converted, false if it did not
* correspond to any known annotation
*/
bool AnnotationFromString(Annotation& aResult, const char* aValue);
/**
* Checks if the given crash annotation is allowed for inclusion in the crash
* ping.
*
* @param aAnnotation the crash annotation to be checked
* @return true if the annotation can be included in the crash ping, false
* otherwise
*/
bool IsAnnotationAllowedForPing(Annotation aAnnotation);
/**
* Checks if the annotation should be included. Some annotations are skipped if
* their value matches a specific one (like the value 0).
*
* @param aAnnotation the crash annotation to be checked
* @param aValue the contents of the annotation as a string
* @return true if the annotation should be included, false otherwise
*/
bool ShouldIncludeAnnotation(Annotation aAnnotation, const char* aValue);
/**
* Abstract annotation writer, this is needed only for code that writes out
* annotations in the exception handler.
*/
class AnnotationWriter {
public:
virtual void Write(Annotation aAnnotation, const char* aValue,
size_t aLen = 0) = 0;
virtual void Write(Annotation aAnnotation, bool aValue) = 0;
virtual void Write(Annotation aAnnotation, uint64_t aValue) = 0;
};
#ifdef XP_WIN
extern void RecordDllAnnotations(bool* aBlocklistInitFailed,
bool* aUser32BeforeBlocklist);
#endif // XP_WIN
} // namespace CrashReporter
#endif // CrashAnnotations_h