LLVM  10.0.0svn
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;
79  MemoryInfoListHeader(uint32_t SizeOfHeader, uint32_t SizeOfEntry,
80  uint64_t NumberOfEntries)
81  : SizeOfHeader(SizeOfHeader), SizeOfEntry(SizeOfEntry),
82  NumberOfEntries(NumberOfEntries) {}
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.
128 enum class ProcessorArchitecture : uint16_t {
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 } // namespace minidump
231 
232 template <> struct DenseMapInfo<minidump::StreamType> {
234 
236  return minidump::StreamType(-2);
237  }
238 
239  static unsigned getHashValue(minidump::StreamType Val) {
240  return DenseMapInfo<uint32_t>::getHashValue(static_cast<uint32_t>(Val));
241  }
242 
244  return LHS == RHS;
245  }
246 };
247 
248 } // namespace llvm
249 
250 #endif // LLVM_BINARYFORMAT_MINIDUMP_H
static minidump::StreamType getEmptyKey()
Definition: Minidump.h:233
support::ulittle32_t FeatureInfo
Definition: Minidump.h:146
static minidump::StreamType getTombstoneKey()
Definition: Minidump.h:235
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Specifies the location (and size) of various objects in the minidump file.
Definition: Minidump.h:59
MemoryDescriptor Stack
Definition: Minidump.h:225
support::ulittle32_t NumberOfStreams
Definition: Minidump.h:40
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE()
support::ulittle32_t TimeDateStamp
Definition: Minidump.h:43
support::ulittle32_t ModuleNameRVA
Definition: Minidump.h:208
support::ulittle32_t Signature
Definition: Minidump.h:36
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:953
LocationDescriptor CvRecord
Definition: Minidump.h:210
ProcessorArchitecture
The processor architecture of the system that generated this minidump.
Definition: Minidump.h:128
static bool isEqual(minidump::StreamType LHS, minidump::StreamType RHS)
Definition: Minidump.h:243
support::little_t< MemoryType > Type
Definition: Minidump.h:112
LocationDescriptor Memory
Definition: Minidump.h:69
support::ulittle32_t SizeOfImage
Definition: Minidump.h:205
support::ulittle32_t Signature
Definition: Minidump.h:183
support::ulittle32_t ThreadId
Definition: Minidump.h:220
support::ulittle32_t Checksum
Definition: Minidump.h:206
OSPlatform
The OS Platform of the system that generated this minidump.
Definition: Minidump.h:135
support::ulittle32_t BuildNumber
Definition: Minidump.h:171
support::ulittle64_t Flags
Definition: Minidump.h:44
StreamType
The type of a minidump stream identifies its contents.
Definition: Minidump.h:50
support::ulittle32_t Checksum
Definition: Minidump.h:42
support::ulittle32_t ElfHWCaps
Definition: Minidump.h:151
support::ulittle64_t Reserved0
Definition: Minidump.h:212
support::ulittle32_t FileOS
Definition: Minidump.h:191
The minidump header is the first part of a minidump file.
Definition: Minidump.h:32
support::ulittle64_t BaseAddress
Definition: Minidump.h:105
support::ulittle32_t StreamDirectoryRVA
Definition: Minidump.h:41
support::little_t< ProcessorArchitecture > ProcessorArch
Definition: Minidump.h:162
support::ulittle32_t SizeOfEntry
Definition: Minidump.h:75
support::little_t< MemoryState > State
Definition: Minidump.h:110
support::ulittle32_t MajorVersion
Definition: Minidump.h:169
support::ulittle32_t VersionInfo
Definition: Minidump.h:145
support::ulittle64_t AllocationBase
Definition: Minidump.h:106
static constexpr uint32_t MagicSignature
Definition: Minidump.h:33
support::ulittle32_t FileSubtype
Definition: Minidump.h:193
LocationDescriptor Context
Definition: Minidump.h:226
support::ulittle16_t SuiteMask
Definition: Minidump.h:175
Detailed information about the processor of the system that generated this minidump.
Definition: Minidump.h:142
bool operator==(const VSFixedFileInfo &LHS, const VSFixedFileInfo &RHS)
Definition: Minidump.h:199
support::ulittle16_t Reserved
Definition: Minidump.h:176
support::ulittle64_t EnvironmentBlock
Definition: Minidump.h:224
support::ulittle64_t StartOfMemoryRange
Definition: Minidump.h:68
VSFixedFileInfo VersionInfo
Definition: Minidump.h:209
support::ulittle32_t AMDExtendedFeatures
Definition: Minidump.h:147
support::ulittle64_t Reserved1
Definition: Minidump.h:213
support::ulittle32_t Priority
Definition: Minidump.h:223
Describes a single memory range (both its VM address and where to find it in the file) of the process...
Definition: Minidump.h:67
MemoryInfoListHeader(uint32_t SizeOfHeader, uint32_t SizeOfEntry, uint64_t NumberOfEntries)
Definition: Minidump.h:79
static unsigned getHashValue(minidump::StreamType Val)
Definition: Minidump.h:239
support::ulittle32_t FileDateLow
Definition: Minidump.h:195
support::ulittle32_t Version
Definition: Minidump.h:39
LocationDescriptor MiscRecord
Definition: Minidump.h:211
support::ulittle16_t ProcessorRevision
Definition: Minidump.h:164
support::ulittle32_t MinorVersion
Definition: Minidump.h:170
LocationDescriptor Location
Definition: Minidump.h:122
support::ulittle32_t RVA
Definition: Minidump.h:61
support::ulittle32_t SuspendCount
Definition: Minidump.h:221
support::little_t< MemoryProtection > Protect
Definition: Minidump.h:111
support::ulittle32_t FileFlags
Definition: Minidump.h:190
support::ulittle32_t PriorityClass
Definition: Minidump.h:222
support::ulittle32_t DataSize
Definition: Minidump.h:60
support::ulittle16_t ProcessorLevel
Definition: Minidump.h:163
support::ulittle32_t FileVersionLow
Definition: Minidump.h:186
static constexpr uint16_t MagicVersion
Definition: Minidump.h:34
Merge contiguous icmps into a memcmp
Definition: MergeICmps.cpp:927
support::little_t< OSPlatform > PlatformId
Definition: Minidump.h:172
support::ulittle32_t FileVersionHigh
Definition: Minidump.h:185
support::ulittle32_t ProductVersionLow
Definition: Minidump.h:188
Specifies the location and type of a single stream in the minidump file.
Definition: Minidump.h:120
support::ulittle32_t FileDateHigh
Definition: Minidump.h:194
support::ulittle64_t NumberOfEntries
Definition: Minidump.h:76
support::ulittle32_t FileType
Definition: Minidump.h:192
support::ulittle32_t CSDVersionRVA
Definition: Minidump.h:173
support::ulittle64_t RegionSize
Definition: Minidump.h:109
support::ulittle32_t Reserved1
Definition: Minidump.h:113
support::ulittle32_t StructVersion
Definition: Minidump.h:184
support::ulittle32_t ProductVersionHigh
Definition: Minidump.h:187
support::little_t< MemoryProtection > AllocationProtect
Definition: Minidump.h:107
Describes a single thread in the minidump file.
Definition: Minidump.h:219
support::ulittle32_t Reserved0
Definition: Minidump.h:108
support::ulittle64_t BaseOfImage
Definition: Minidump.h:204
support::ulittle32_t SizeOfHeader
Definition: Minidump.h:74
support::ulittle32_t CPUID
Definition: Minidump.h:150
support::ulittle32_t FileFlagsMask
Definition: Minidump.h:189
support::little_t< StreamType > Type
Definition: Minidump.h:121
support::ulittle32_t TimeDateStamp
Definition: Minidump.h:207
The SystemInfo stream, containing various information about the system where this minidump was genera...
Definition: Minidump.h:161