LLVM  14.0.0git
Minidump.h
Go to the documentation of this file.
1 //===- Minidump.h - Minidump constants and structures -----------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This header constants and data structures pertaining to the Windows Minidump
10 // core file format.
11 //
12 // Reference:
13 // https://msdn.microsoft.com/en-us/library/windows/desktop/ms679293(v=vs.85).aspx
14 // https://chromium.googlesource.com/breakpad/breakpad/
15 //
16 //===----------------------------------------------------------------------===//
17 
18 #ifndef LLVM_BINARYFORMAT_MINIDUMP_H
19 #define LLVM_BINARYFORMAT_MINIDUMP_H
20 
21 #include "llvm/ADT/BitmaskEnum.h"
22 #include "llvm/ADT/DenseMapInfo.h"
23 #include "llvm/Support/Endian.h"
24 
25 namespace llvm {
26 namespace minidump {
27 
29 
30 /// The minidump header is the first part of a minidump file. It identifies the
31 /// file as a minidump file, and gives the location of the stream directory.
32 struct Header {
33  static constexpr uint32_t MagicSignature = 0x504d444d; // PMDM
34  static constexpr uint16_t MagicVersion = 0xa793;
35 
37  // The high 16 bits of version field are implementation specific. The low 16
38  // bits should be MagicVersion.
45 };
46 static_assert(sizeof(Header) == 32, "");
47 
48 /// The type of a minidump stream identifies its contents. Streams numbers after
49 /// LastReserved are for application-defined data streams.
50 enum class StreamType : uint32_t {
51 #define HANDLE_MDMP_STREAM_TYPE(CODE, NAME) NAME = CODE,
52 #include "llvm/BinaryFormat/MinidumpConstants.def"
53  Unused = 0,
54  LastReserved = 0x0000ffff,
55 };
56 
57 /// Specifies the location (and size) of various objects in the minidump file.
58 /// The location is relative to the start of the file.
62 };
63 static_assert(sizeof(LocationDescriptor) == 8, "");
64 
65 /// Describes a single memory range (both its VM address and where to find it in
66 /// the file) of the process from which this minidump file was generated.
70 };
71 static_assert(sizeof(MemoryDescriptor) == 16, "");
72 
77 
78  MemoryInfoListHeader() = default;
83 };
84 static_assert(sizeof(MemoryInfoListHeader) == 16, "");
85 
86 enum class MemoryProtection : uint32_t {
87 #define HANDLE_MDMP_PROTECT(CODE, NAME, NATIVENAME) NAME = CODE,
88 #include "llvm/BinaryFormat/MinidumpConstants.def"
89  LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/0xffffffffu),
90 };
91 
92 enum class MemoryState : uint32_t {
93 #define HANDLE_MDMP_MEMSTATE(CODE, NAME, NATIVENAME) NAME = CODE,
94 #include "llvm/BinaryFormat/MinidumpConstants.def"
95  LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/0xffffffffu),
96 };
97 
98 enum class MemoryType : uint32_t {
99 #define HANDLE_MDMP_MEMTYPE(CODE, NAME, NATIVENAME) NAME = CODE,
100 #include "llvm/BinaryFormat/MinidumpConstants.def"
101  LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/0xffffffffu),
102 };
103 
104 struct MemoryInfo {
114 };
115 static_assert(sizeof(MemoryInfo) == 48, "");
116 
117 /// Specifies the location and type of a single stream in the minidump file. The
118 /// minidump stream directory is an array of entries of this type, with its size
119 /// given by Header.NumberOfStreams.
120 struct Directory {
123 };
124 static_assert(sizeof(Directory) == 12, "");
125 
126 /// The processor architecture of the system that generated this minidump. Used
127 /// in the ProcessorArch field of the SystemInfo stream.
129 #define HANDLE_MDMP_ARCH(CODE, NAME) NAME = CODE,
130 #include "llvm/BinaryFormat/MinidumpConstants.def"
131 };
132 
133 /// The OS Platform of the system that generated this minidump. Used in the
134 /// PlatformId field of the SystemInfo stream.
135 enum class OSPlatform : uint32_t {
136 #define HANDLE_MDMP_PLATFORM(CODE, NAME) NAME = CODE,
137 #include "llvm/BinaryFormat/MinidumpConstants.def"
138 };
139 
140 /// Detailed information about the processor of the system that generated this
141 /// minidump. Its interpretation depends on the ProcessorArchitecture enum.
142 union CPUInfo {
143  struct X86Info {
144  char VendorID[12]; // cpuid 0: ebx, edx, ecx
147  support::ulittle32_t AMDExtendedFeatures; // cpuid 0x80000001, ebx
148  } X86;
149  struct ArmInfo {
151  support::ulittle32_t ElfHWCaps; // linux specific, 0 otherwise
152  } Arm;
153  struct OtherInfo {
154  uint8_t ProcessorFeatures[16];
155  } Other;
156 };
157 static_assert(sizeof(CPUInfo) == 24, "");
158 
159 /// The SystemInfo stream, containing various information about the system where
160 /// this minidump was generated.
161 struct SystemInfo {
165 
167  uint8_t ProductType;
168 
174 
177 
179 };
180 static_assert(sizeof(SystemInfo) == 56, "");
181 
196 };
197 static_assert(sizeof(VSFixedFileInfo) == 52, "");
198 
199 inline bool operator==(const VSFixedFileInfo &LHS, const VSFixedFileInfo &RHS) {
200  return memcmp(&LHS, &RHS, sizeof(VSFixedFileInfo)) == 0;
201 }
202 
203 struct Module {
214 };
215 static_assert(sizeof(Module) == 108, "");
216 
217 /// Describes a single thread in the minidump file. Part of the ThreadList
218 /// stream.
219 struct Thread {
227 };
228 static_assert(sizeof(Thread) == 48, "");
229 
230 struct Exception {
231  static constexpr size_t MaxParameters = 15;
232 
240 };
241 static_assert(sizeof(Exception) == 152, "");
242 
248 };
249 static_assert(sizeof(ExceptionStream) == 168, "");
250 
251 } // namespace minidump
252 
253 template <> struct DenseMapInfo<minidump::StreamType> {
255 
257  return minidump::StreamType(-2);
258  }
259 
260  static unsigned getHashValue(minidump::StreamType Val) {
261  return DenseMapInfo<uint32_t>::getHashValue(static_cast<uint32_t>(Val));
262  }
263 
265  return LHS == RHS;
266  }
267 };
268 
269 } // namespace llvm
270 
271 #endif // LLVM_BINARYFORMAT_MINIDUMP_H
llvm::minidump::MemoryInfoListHeader
Definition: Minidump.h:73
llvm::minidump::VSFixedFileInfo::ProductVersionLow
support::ulittle32_t ProductVersionLow
Definition: Minidump.h:188
llvm::minidump::MemoryDescriptor
Describes a single memory range (both its VM address and where to find it in the file) of the process...
Definition: Minidump.h:67
llvm::minidump::MemoryInfo::RegionSize
support::ulittle64_t RegionSize
Definition: Minidump.h:109
llvm::minidump::Header::Checksum
support::ulittle32_t Checksum
Definition: Minidump.h:42
llvm::minidump::StreamType::Unused
@ Unused
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::minidump::MemoryInfoListHeader::SizeOfEntry
support::ulittle32_t SizeOfEntry
Definition: Minidump.h:75
llvm::minidump::Module::Reserved0
support::ulittle64_t Reserved0
Definition: Minidump.h:212
llvm::minidump::Header::Flags
support::ulittle64_t Flags
Definition: Minidump.h:44
llvm::minidump::CPUInfo::ArmInfo
Definition: Minidump.h:149
llvm::minidump::Thread::Context
LocationDescriptor Context
Definition: Minidump.h:226
llvm::support::detail::packed_endian_specific_integral
Definition: Endian.h:206
llvm::DenseMapInfo< minidump::StreamType >::getTombstoneKey
static minidump::StreamType getTombstoneKey()
Definition: Minidump.h:256
llvm::minidump::CPUInfo::ArmInfo::ElfHWCaps
support::ulittle32_t ElfHWCaps
Definition: Minidump.h:151
llvm::minidump::VSFixedFileInfo::StructVersion
support::ulittle32_t StructVersion
Definition: Minidump.h:184
llvm::minidump::MemoryInfoListHeader::NumberOfEntries
support::ulittle64_t NumberOfEntries
Definition: Minidump.h:76
llvm::minidump::VSFixedFileInfo::ProductVersionHigh
support::ulittle32_t ProductVersionHigh
Definition: Minidump.h:187
llvm::minidump::Header::MagicVersion
static constexpr uint16_t MagicVersion
Definition: Minidump.h:34
llvm::minidump::ProcessorArchitecture
ProcessorArchitecture
The processor architecture of the system that generated this minidump.
Definition: Minidump.h:128
llvm::minidump::ExceptionStream
Definition: Minidump.h:243
memcmp
Merge contiguous icmps into a memcmp
Definition: MergeICmps.cpp:888
llvm::minidump::SystemInfo::MinorVersion
support::ulittle32_t MinorVersion
Definition: Minidump.h:170
llvm::minidump::SystemInfo::PlatformId
support::little_t< OSPlatform > PlatformId
Definition: Minidump.h:172
llvm::minidump::MemoryInfo::State
support::little_t< MemoryState > State
Definition: Minidump.h:110
llvm::minidump::SystemInfo::ProcessorLevel
support::ulittle16_t ProcessorLevel
Definition: Minidump.h:163
llvm::DenseMapInfo< minidump::StreamType >::getEmptyKey
static minidump::StreamType getEmptyKey()
Definition: Minidump.h:254
llvm::minidump::SystemInfo::SuiteMask
support::ulittle16_t SuiteMask
Definition: Minidump.h:175
llvm::minidump::MemoryInfo
Definition: Minidump.h:104
llvm::minidump::Header::MagicSignature
static constexpr uint32_t MagicSignature
Definition: Minidump.h:33
llvm::minidump::CPUInfo::X86Info::FeatureInfo
support::ulittle32_t FeatureInfo
Definition: Minidump.h:146
llvm::minidump::MemoryInfoListHeader::SizeOfHeader
support::ulittle32_t SizeOfHeader
Definition: Minidump.h:74
llvm::minidump::Module::TimeDateStamp
support::ulittle32_t TimeDateStamp
Definition: Minidump.h:207
llvm::minidump::Header::Signature
support::ulittle32_t Signature
Definition: Minidump.h:36
llvm::minidump::MemoryType
MemoryType
Definition: Minidump.h:98
llvm::minidump::LocationDescriptor
Specifies the location (and size) of various objects in the minidump file.
Definition: Minidump.h:59
llvm::minidump::LocationDescriptor::DataSize
support::ulittle32_t DataSize
Definition: Minidump.h:60
llvm::minidump::VSFixedFileInfo::FileFlagsMask
support::ulittle32_t FileFlagsMask
Definition: Minidump.h:189
llvm::minidump::Module::VersionInfo
VSFixedFileInfo VersionInfo
Definition: Minidump.h:209
llvm::minidump::SystemInfo::MajorVersion
support::ulittle32_t MajorVersion
Definition: Minidump.h:169
llvm::minidump::SystemInfo::NumberOfProcessors
uint8_t NumberOfProcessors
Definition: Minidump.h:166
llvm::minidump::SystemInfo
The SystemInfo stream, containing various information about the system where this minidump was genera...
Definition: Minidump.h:161
llvm::minidump::VSFixedFileInfo
Definition: Minidump.h:182
llvm::DenseMapInfo
Definition: APInt.h:34
llvm::minidump::SystemInfo::ProductType
uint8_t ProductType
Definition: Minidump.h:167
llvm::minidump::MemoryInfo::Reserved1
support::ulittle32_t Reserved1
Definition: Minidump.h:113
llvm::minidump::ExceptionStream::ExceptionRecord
Exception ExceptionRecord
Definition: Minidump.h:246
llvm::minidump::Header
The minidump header is the first part of a minidump file.
Definition: Minidump.h:32
llvm::minidump::MemoryType::LLVM_MARK_AS_BITMASK_ENUM
@ LLVM_MARK_AS_BITMASK_ENUM
llvm::minidump::MemoryProtection::LLVM_MARK_AS_BITMASK_ENUM
@ LLVM_MARK_AS_BITMASK_ENUM
llvm::minidump::VSFixedFileInfo::FileDateLow
support::ulittle32_t FileDateLow
Definition: Minidump.h:195
llvm::minidump::VSFixedFileInfo::FileOS
support::ulittle32_t FileOS
Definition: Minidump.h:191
llvm::minidump::MemoryDescriptor::Memory
LocationDescriptor Memory
Definition: Minidump.h:69
llvm::minidump::CPUInfo::X86Info::VersionInfo
support::ulittle32_t VersionInfo
Definition: Minidump.h:145
llvm::minidump::MemoryInfo::AllocationBase
support::ulittle64_t AllocationBase
Definition: Minidump.h:106
llvm::minidump::operator==
bool operator==(const VSFixedFileInfo &LHS, const VSFixedFileInfo &RHS)
Definition: Minidump.h:199
llvm::minidump::MemoryInfo::BaseAddress
support::ulittle64_t BaseAddress
Definition: Minidump.h:105
llvm::minidump::Module::MiscRecord
LocationDescriptor MiscRecord
Definition: Minidump.h:211
llvm::minidump::Directory::Location
LocationDescriptor Location
Definition: Minidump.h:122
llvm::minidump::Exception::ExceptionInformation
support::ulittle64_t ExceptionInformation[MaxParameters]
Definition: Minidump.h:239
llvm::minidump::MemoryProtection
MemoryProtection
Definition: Minidump.h:86
llvm::minidump::Exception::UnusedAlignment
support::ulittle32_t UnusedAlignment
Definition: Minidump.h:238
llvm::minidump::Module::SizeOfImage
support::ulittle32_t SizeOfImage
Definition: Minidump.h:205
llvm::minidump::CPUInfo::X86Info::VendorID
char VendorID[12]
Definition: Minidump.h:144
llvm::minidump::Header::TimeDateStamp
support::ulittle32_t TimeDateStamp
Definition: Minidump.h:43
llvm::minidump::MemoryInfoListHeader::MemoryInfoListHeader
MemoryInfoListHeader(uint32_t SizeOfHeader, uint32_t SizeOfEntry, uint64_t NumberOfEntries)
Definition: Minidump.h:79
llvm::minidump::Exception::ExceptionRecord
support::ulittle64_t ExceptionRecord
Definition: Minidump.h:235
llvm::minidump::VSFixedFileInfo::FileSubtype
support::ulittle32_t FileSubtype
Definition: Minidump.h:193
llvm::minidump::CPUInfo
Detailed information about the processor of the system that generated this minidump.
Definition: Minidump.h:142
llvm::minidump::MemoryInfo::AllocationProtect
support::little_t< MemoryProtection > AllocationProtect
Definition: Minidump.h:107
llvm::minidump::Exception::ExceptionAddress
support::ulittle64_t ExceptionAddress
Definition: Minidump.h:236
llvm::minidump::SystemInfo::CPU
CPUInfo CPU
Definition: Minidump.h:178
llvm::minidump::Module::Reserved1
support::ulittle64_t Reserved1
Definition: Minidump.h:213
llvm::minidump::Module::BaseOfImage
support::ulittle64_t BaseOfImage
Definition: Minidump.h:204
llvm::minidump::MemoryInfo::Protect
support::little_t< MemoryProtection > Protect
Definition: Minidump.h:111
llvm::minidump::StreamType
StreamType
The type of a minidump stream identifies its contents.
Definition: Minidump.h:50
uint64_t
llvm::minidump::VSFixedFileInfo::FileFlags
support::ulittle32_t FileFlags
Definition: Minidump.h:190
llvm::minidump::MemoryState
MemoryState
Definition: Minidump.h:92
llvm::DenseMapInfo< minidump::StreamType >::getHashValue
static unsigned getHashValue(minidump::StreamType Val)
Definition: Minidump.h:260
llvm::minidump::Module::CvRecord
LocationDescriptor CvRecord
Definition: Minidump.h:210
llvm::minidump::SystemInfo::ProcessorRevision
support::ulittle16_t ProcessorRevision
Definition: Minidump.h:164
llvm::minidump::Thread::ThreadId
support::ulittle32_t ThreadId
Definition: Minidump.h:220
llvm::minidump::VSFixedFileInfo::FileVersionLow
support::ulittle32_t FileVersionLow
Definition: Minidump.h:186
llvm::minidump::OSPlatform
OSPlatform
The OS Platform of the system that generated this minidump.
Definition: Minidump.h:135
llvm::minidump::Thread::Priority
support::ulittle32_t Priority
Definition: Minidump.h:223
llvm::minidump::StreamType::LastReserved
@ LastReserved
llvm::minidump::Thread::EnvironmentBlock
support::ulittle64_t EnvironmentBlock
Definition: Minidump.h:224
llvm::minidump::Exception
Definition: Minidump.h:230
llvm::minidump::LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE()
llvm::minidump::Thread::PriorityClass
support::ulittle32_t PriorityClass
Definition: Minidump.h:222
BitmaskEnum.h
llvm::minidump::ExceptionStream::ThreadId
support::ulittle32_t ThreadId
Definition: Minidump.h:244
llvm::minidump::MemoryDescriptor::StartOfMemoryRange
support::ulittle64_t StartOfMemoryRange
Definition: Minidump.h:68
uint32_t
llvm::minidump::Module::Checksum
support::ulittle32_t Checksum
Definition: Minidump.h:206
llvm::minidump::Exception::MaxParameters
static constexpr size_t MaxParameters
Definition: Minidump.h:231
llvm::minidump::CPUInfo::Arm
struct llvm::minidump::CPUInfo::ArmInfo Arm
llvm::minidump::CPUInfo::X86Info::AMDExtendedFeatures
support::ulittle32_t AMDExtendedFeatures
Definition: Minidump.h:147
llvm::minidump::ExceptionStream::ThreadContext
LocationDescriptor ThreadContext
Definition: Minidump.h:247
llvm::minidump::VSFixedFileInfo::FileDateHigh
support::ulittle32_t FileDateHigh
Definition: Minidump.h:194
uint16_t
llvm::minidump::Directory
Specifies the location and type of a single stream in the minidump file.
Definition: Minidump.h:120
llvm::minidump::MemoryState::LLVM_MARK_AS_BITMASK_ENUM
@ LLVM_MARK_AS_BITMASK_ENUM
llvm::minidump::Exception::NumberParameters
support::ulittle32_t NumberParameters
Definition: Minidump.h:237
llvm::minidump::ExceptionStream::UnusedAlignment
support::ulittle32_t UnusedAlignment
Definition: Minidump.h:245
llvm::minidump::CPUInfo::ArmInfo::CPUID
support::ulittle32_t CPUID
Definition: Minidump.h:150
llvm::minidump::Exception::ExceptionCode
support::ulittle32_t ExceptionCode
Definition: Minidump.h:233
llvm::minidump::CPUInfo::X86
struct llvm::minidump::CPUInfo::X86Info X86
llvm::minidump::Header::Version
support::ulittle32_t Version
Definition: Minidump.h:39
llvm::minidump::VSFixedFileInfo::FileType
support::ulittle32_t FileType
Definition: Minidump.h:192
llvm::minidump::Thread
Describes a single thread in the minidump file.
Definition: Minidump.h:219
llvm::minidump::SystemInfo::BuildNumber
support::ulittle32_t BuildNumber
Definition: Minidump.h:171
llvm::minidump::SystemInfo::CSDVersionRVA
support::ulittle32_t CSDVersionRVA
Definition: Minidump.h:173
llvm::minidump::CPUInfo::OtherInfo
Definition: Minidump.h:153
llvm::minidump::Module::ModuleNameRVA
support::ulittle32_t ModuleNameRVA
Definition: Minidump.h:208
llvm::minidump::MemoryInfo::Reserved0
support::ulittle32_t Reserved0
Definition: Minidump.h:108
DenseMapInfo.h
llvm::minidump::Module
Definition: Minidump.h:203
llvm::minidump::MemoryInfo::Type
support::little_t< MemoryType > Type
Definition: Minidump.h:112
llvm::minidump::Directory::Type
support::little_t< StreamType > Type
Definition: Minidump.h:121
llvm::minidump::LocationDescriptor::RVA
support::ulittle32_t RVA
Definition: Minidump.h:61
llvm::minidump::Thread::SuspendCount
support::ulittle32_t SuspendCount
Definition: Minidump.h:221
llvm::minidump::SystemInfo::Reserved
support::ulittle16_t Reserved
Definition: Minidump.h:176
llvm::minidump::CPUInfo::OtherInfo::ProcessorFeatures
uint8_t ProcessorFeatures[16]
Definition: Minidump.h:154
Endian.h
llvm::minidump::CPUInfo::Other
struct llvm::minidump::CPUInfo::OtherInfo Other
llvm::minidump::Exception::ExceptionFlags
support::ulittle32_t ExceptionFlags
Definition: Minidump.h:234
llvm::minidump::CPUInfo::X86Info
Definition: Minidump.h:143
llvm::minidump::VSFixedFileInfo::Signature
support::ulittle32_t Signature
Definition: Minidump.h:183
llvm::minidump::Thread::Stack
MemoryDescriptor Stack
Definition: Minidump.h:225
llvm::DenseMapInfo< minidump::StreamType >::isEqual
static bool isEqual(minidump::StreamType LHS, minidump::StreamType RHS)
Definition: Minidump.h:264
llvm::minidump::VSFixedFileInfo::FileVersionHigh
support::ulittle32_t FileVersionHigh
Definition: Minidump.h:185
llvm::minidump::Header::StreamDirectoryRVA
support::ulittle32_t StreamDirectoryRVA
Definition: Minidump.h:41
llvm::minidump::Header::NumberOfStreams
support::ulittle32_t NumberOfStreams
Definition: Minidump.h:40
llvm::minidump::MemoryInfoListHeader::MemoryInfoListHeader
MemoryInfoListHeader()=default
llvm::minidump::SystemInfo::ProcessorArch
support::little_t< ProcessorArchitecture > ProcessorArch
Definition: Minidump.h:162