LLVM 20.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
23#include "llvm/Support/Endian.h"
24
25namespace llvm {
26namespace 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.
32struct 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};
46static_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.
50enum 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};
63static_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};
71static_assert(sizeof(MemoryDescriptor) == 16);
72
76};
77static_assert(sizeof(MemoryDescriptor_64) == 16);
78
81};
82static_assert(sizeof(MemoryListHeader) == 4);
83
87};
88static_assert(sizeof(Memory64ListHeader) == 16);
89
94
100};
101static_assert(sizeof(MemoryInfoListHeader) == 16);
102
104#define HANDLE_MDMP_PROTECT(CODE, NAME, NATIVENAME) NAME = CODE,
105#include "llvm/BinaryFormat/MinidumpConstants.def"
106 LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/0xffffffffu),
107};
108
109enum class MemoryState : uint32_t {
110#define HANDLE_MDMP_MEMSTATE(CODE, NAME, NATIVENAME) NAME = CODE,
111#include "llvm/BinaryFormat/MinidumpConstants.def"
112 LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/0xffffffffu),
113};
114
115enum class MemoryType : uint32_t {
116#define HANDLE_MDMP_MEMTYPE(CODE, NAME, NATIVENAME) NAME = CODE,
117#include "llvm/BinaryFormat/MinidumpConstants.def"
118 LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/0xffffffffu),
119};
120
131};
132static_assert(sizeof(MemoryInfo) == 48);
133
134/// Specifies the location and type of a single stream in the minidump file. The
135/// minidump stream directory is an array of entries of this type, with its size
136/// given by Header.NumberOfStreams.
137struct Directory {
140};
141static_assert(sizeof(Directory) == 12);
142
143/// The processor architecture of the system that generated this minidump. Used
144/// in the ProcessorArch field of the SystemInfo stream.
146#define HANDLE_MDMP_ARCH(CODE, NAME) NAME = CODE,
147#include "llvm/BinaryFormat/MinidumpConstants.def"
148};
149
150/// The OS Platform of the system that generated this minidump. Used in the
151/// PlatformId field of the SystemInfo stream.
152enum class OSPlatform : uint32_t {
153#define HANDLE_MDMP_PLATFORM(CODE, NAME) NAME = CODE,
154#include "llvm/BinaryFormat/MinidumpConstants.def"
155};
156
157/// Detailed information about the processor of the system that generated this
158/// minidump. Its interpretation depends on the ProcessorArchitecture enum.
159union CPUInfo {
160 struct X86Info {
161 char VendorID[12]; // cpuid 0: ebx, edx, ecx
166 struct ArmInfo {
168 support::ulittle32_t ElfHWCaps; // linux specific, 0 otherwise
170 struct OtherInfo {
173};
174static_assert(sizeof(CPUInfo) == 24);
175
176/// The SystemInfo stream, containing various information about the system where
177/// this minidump was generated.
182
185
191
194
196};
197static_assert(sizeof(SystemInfo) == 56);
198
213};
214static_assert(sizeof(VSFixedFileInfo) == 52);
215
216inline bool operator==(const VSFixedFileInfo &LHS, const VSFixedFileInfo &RHS) {
217 return memcmp(&LHS, &RHS, sizeof(VSFixedFileInfo)) == 0;
218}
219
220struct Module {
231};
232static_assert(sizeof(Module) == 108);
233
234/// Describes a single thread in the minidump file. Part of the ThreadList
235/// stream.
236struct Thread {
244};
245static_assert(sizeof(Thread) == 48);
246
247struct Exception {
248 static constexpr size_t MaxParameters = 15;
249 static constexpr size_t MaxParameterBytes = MaxParameters * sizeof(uint64_t);
250 static const uint32_t LLDB_FLAG = 0x4C4C4442; // ASCII for 'LLDB'
251
259};
260static_assert(sizeof(Exception) == 152);
261
267};
268static_assert(sizeof(ExceptionStream) == 168);
269
270} // namespace minidump
271
272template <> struct DenseMapInfo<minidump::StreamType> {
274
276 return minidump::StreamType(-2);
277 }
278
279 static unsigned getHashValue(minidump::StreamType Val) {
280 return DenseMapInfo<uint32_t>::getHashValue(static_cast<uint32_t>(Val));
281 }
282
284 return LHS == RHS;
285 }
286};
287
288} // namespace llvm
289
290#endif // LLVM_BINARYFORMAT_MINIDUMP_H
This file defines DenseMapInfo traits for DenseMap.
Merge contiguous icmps into a memcmp
Definition: MergeICmps.cpp:911
Value * RHS
Value * LHS
ProcessorArchitecture
The processor architecture of the system that generated this minidump.
Definition: Minidump.h:145
StreamType
The type of a minidump stream identifies its contents.
Definition: Minidump.h:50
OSPlatform
The OS Platform of the system that generated this minidump.
Definition: Minidump.h:152
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE()
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
static unsigned getHashValue(minidump::StreamType Val)
Definition: Minidump.h:279
static minidump::StreamType getTombstoneKey()
Definition: Minidump.h:275
static bool isEqual(minidump::StreamType LHS, minidump::StreamType RHS)
Definition: Minidump.h:283
static minidump::StreamType getEmptyKey()
Definition: Minidump.h:273
An information struct used to provide DenseMap with the various necessary components for a given valu...
Definition: DenseMapInfo.h:52
support::ulittle32_t CPUID
Definition: Minidump.h:167
support::ulittle32_t ElfHWCaps
Definition: Minidump.h:168
support::ulittle32_t AMDExtendedFeatures
Definition: Minidump.h:164
support::ulittle32_t VersionInfo
Definition: Minidump.h:162
support::ulittle32_t FeatureInfo
Definition: Minidump.h:163
Specifies the location and type of a single stream in the minidump file.
Definition: Minidump.h:137
LocationDescriptor Location
Definition: Minidump.h:139
support::little_t< StreamType > Type
Definition: Minidump.h:138
support::ulittle32_t UnusedAlignment
Definition: Minidump.h:264
LocationDescriptor ThreadContext
Definition: Minidump.h:266
support::ulittle32_t ThreadId
Definition: Minidump.h:263
static constexpr size_t MaxParameters
Definition: Minidump.h:248
support::ulittle32_t ExceptionFlags
Definition: Minidump.h:253
support::ulittle32_t NumberParameters
Definition: Minidump.h:256
support::ulittle64_t ExceptionInformation[MaxParameters]
Definition: Minidump.h:258
support::ulittle64_t ExceptionRecord
Definition: Minidump.h:254
static constexpr size_t MaxParameterBytes
Definition: Minidump.h:249
static const uint32_t LLDB_FLAG
Definition: Minidump.h:250
support::ulittle64_t ExceptionAddress
Definition: Minidump.h:255
support::ulittle32_t UnusedAlignment
Definition: Minidump.h:257
support::ulittle32_t ExceptionCode
Definition: Minidump.h:252
The minidump header is the first part of a minidump file.
Definition: Minidump.h:32
support::ulittle64_t Flags
Definition: Minidump.h:44
support::ulittle32_t NumberOfStreams
Definition: Minidump.h:40
support::ulittle32_t Version
Definition: Minidump.h:39
support::ulittle32_t TimeDateStamp
Definition: Minidump.h:43
static constexpr uint32_t MagicSignature
Definition: Minidump.h:33
static constexpr uint16_t MagicVersion
Definition: Minidump.h:34
support::ulittle32_t Signature
Definition: Minidump.h:36
support::ulittle32_t Checksum
Definition: Minidump.h:42
support::ulittle32_t StreamDirectoryRVA
Definition: Minidump.h:41
Specifies the location (and size) of various objects in the minidump file.
Definition: Minidump.h:59
support::ulittle32_t RVA
Definition: Minidump.h:61
support::ulittle32_t DataSize
Definition: Minidump.h:60
support::ulittle64_t NumberOfMemoryRanges
Definition: Minidump.h:85
support::ulittle64_t BaseRVA
Definition: Minidump.h:86
support::ulittle64_t DataSize
Definition: Minidump.h:75
support::ulittle64_t StartOfMemoryRange
Definition: Minidump.h:74
Describes a single memory range (both its VM address and where to find it in the file) of the process...
Definition: Minidump.h:67
support::ulittle64_t StartOfMemoryRange
Definition: Minidump.h:68
LocationDescriptor Memory
Definition: Minidump.h:69
support::ulittle32_t SizeOfHeader
Definition: Minidump.h:91
support::ulittle32_t SizeOfEntry
Definition: Minidump.h:92
support::ulittle64_t NumberOfEntries
Definition: Minidump.h:93
MemoryInfoListHeader(uint32_t SizeOfHeader, uint32_t SizeOfEntry, uint64_t NumberOfEntries)
Definition: Minidump.h:96
support::little_t< MemoryState > State
Definition: Minidump.h:127
support::ulittle64_t BaseAddress
Definition: Minidump.h:122
support::little_t< MemoryProtection > AllocationProtect
Definition: Minidump.h:124
support::little_t< MemoryType > Type
Definition: Minidump.h:129
support::little_t< MemoryProtection > Protect
Definition: Minidump.h:128
support::ulittle32_t Reserved1
Definition: Minidump.h:130
support::ulittle64_t AllocationBase
Definition: Minidump.h:123
support::ulittle32_t Reserved0
Definition: Minidump.h:125
support::ulittle64_t RegionSize
Definition: Minidump.h:126
support::ulittle32_t NumberOfMemoryRanges
Definition: Minidump.h:80
LocationDescriptor CvRecord
Definition: Minidump.h:227
support::ulittle64_t Reserved0
Definition: Minidump.h:229
support::ulittle32_t TimeDateStamp
Definition: Minidump.h:224
support::ulittle64_t Reserved1
Definition: Minidump.h:230
support::ulittle32_t Checksum
Definition: Minidump.h:223
LocationDescriptor MiscRecord
Definition: Minidump.h:228
VSFixedFileInfo VersionInfo
Definition: Minidump.h:226
support::ulittle32_t SizeOfImage
Definition: Minidump.h:222
support::ulittle64_t BaseOfImage
Definition: Minidump.h:221
support::ulittle32_t ModuleNameRVA
Definition: Minidump.h:225
The SystemInfo stream, containing various information about the system where this minidump was genera...
Definition: Minidump.h:178
support::ulittle16_t ProcessorRevision
Definition: Minidump.h:181
support::little_t< ProcessorArchitecture > ProcessorArch
Definition: Minidump.h:179
support::ulittle32_t BuildNumber
Definition: Minidump.h:188
support::ulittle16_t SuiteMask
Definition: Minidump.h:192
support::ulittle32_t MajorVersion
Definition: Minidump.h:186
support::little_t< OSPlatform > PlatformId
Definition: Minidump.h:189
support::ulittle32_t CSDVersionRVA
Definition: Minidump.h:190
support::ulittle32_t MinorVersion
Definition: Minidump.h:187
support::ulittle16_t Reserved
Definition: Minidump.h:193
support::ulittle16_t ProcessorLevel
Definition: Minidump.h:180
Describes a single thread in the minidump file.
Definition: Minidump.h:236
support::ulittle32_t Priority
Definition: Minidump.h:240
support::ulittle64_t EnvironmentBlock
Definition: Minidump.h:241
support::ulittle32_t PriorityClass
Definition: Minidump.h:239
MemoryDescriptor Stack
Definition: Minidump.h:242
LocationDescriptor Context
Definition: Minidump.h:243
support::ulittle32_t SuspendCount
Definition: Minidump.h:238
support::ulittle32_t ThreadId
Definition: Minidump.h:237
support::ulittle32_t Signature
Definition: Minidump.h:200
support::ulittle32_t StructVersion
Definition: Minidump.h:201
support::ulittle32_t FileDateLow
Definition: Minidump.h:212
support::ulittle32_t FileVersionLow
Definition: Minidump.h:203
support::ulittle32_t FileDateHigh
Definition: Minidump.h:211
support::ulittle32_t FileFlagsMask
Definition: Minidump.h:206
support::ulittle32_t ProductVersionLow
Definition: Minidump.h:205
support::ulittle32_t FileFlags
Definition: Minidump.h:207
support::ulittle32_t FileSubtype
Definition: Minidump.h:210
support::ulittle32_t FileOS
Definition: Minidump.h:208
support::ulittle32_t FileType
Definition: Minidump.h:209
support::ulittle32_t FileVersionHigh
Definition: Minidump.h:202
support::ulittle32_t ProductVersionHigh
Definition: Minidump.h:204
Detailed information about the processor of the system that generated this minidump.
Definition: Minidump.h:159
struct llvm::minidump::CPUInfo::ArmInfo Arm
struct llvm::minidump::CPUInfo::OtherInfo Other
struct llvm::minidump::CPUInfo::X86Info X86