LLVM  9.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/DenseMapInfo.h"
22 #include "llvm/Support/Endian.h"
23 
24 namespace llvm {
25 namespace minidump {
26 
27 /// The minidump header is the first part of a minidump file. It identifies the
28 /// file as a minidump file, and gives the location of the stream directory.
29 struct Header {
30  static constexpr uint32_t MagicSignature = 0x504d444d; // PMDM
31  static constexpr uint16_t MagicVersion = 0xa793;
32 
34  // The high 16 bits of version field are implementation specific. The low 16
35  // bits should be MagicVersion.
42 };
43 static_assert(sizeof(Header) == 32, "");
44 
45 /// The type of a minidump stream identifies its contents. Streams numbers after
46 /// LastReserved are for application-defined data streams.
47 enum class StreamType : uint32_t {
48 #define HANDLE_MDMP_STREAM_TYPE(CODE, NAME) NAME = CODE,
49 #include "llvm/BinaryFormat/MinidumpConstants.def"
50  Unused = 0,
51  LastReserved = 0x0000ffff,
52 };
53 
54 /// Specifies the location (and size) of various objects in the minidump file.
55 /// The location is relative to the start of the file.
59 };
60 static_assert(sizeof(LocationDescriptor) == 8, "");
61 
62 /// Describes a single memory range (both its VM address and where to find it in
63 /// the file) of the process from which this minidump file was generated.
67 };
68 static_assert(sizeof(MemoryDescriptor) == 16, "");
69 
70 /// Specifies the location and type of a single stream in the minidump file. The
71 /// minidump stream directory is an array of entries of this type, with its size
72 /// given by Header.NumberOfStreams.
73 struct Directory {
76 };
77 static_assert(sizeof(Directory) == 12, "");
78 
79 /// The processor architecture of the system that generated this minidump. Used
80 /// in the ProcessorArch field of the SystemInfo stream.
81 enum class ProcessorArchitecture : uint16_t {
82 #define HANDLE_MDMP_ARCH(CODE, NAME) NAME = CODE,
83 #include "llvm/BinaryFormat/MinidumpConstants.def"
84 };
85 
86 /// The OS Platform of the system that generated this minidump. Used in the
87 /// PlatformId field of the SystemInfo stream.
88 enum class OSPlatform : uint32_t {
89 #define HANDLE_MDMP_PLATFORM(CODE, NAME) NAME = CODE,
90 #include "llvm/BinaryFormat/MinidumpConstants.def"
91 };
92 
93 /// Detailed information about the processor of the system that generated this
94 /// minidump. Its interpretation depends on the ProcessorArchitecture enum.
95 union CPUInfo {
96  struct X86Info {
97  char VendorID[12]; // cpuid 0: ebx, edx, ecx
100  support::ulittle32_t AMDExtendedFeatures; // cpuid 0x80000001, ebx
101  } X86;
102  struct ArmInfo {
104  support::ulittle32_t ElfHWCaps; // linux specific, 0 otherwise
105  } Arm;
106  struct OtherInfo {
107  uint8_t ProcessorFeatures[16];
108  } Other;
109 };
110 static_assert(sizeof(CPUInfo) == 24, "");
111 
112 /// The SystemInfo stream, containing various information about the system where
113 /// this minidump was generated.
114 struct SystemInfo {
118 
120  uint8_t ProductType;
121 
127 
130 
132 };
133 static_assert(sizeof(SystemInfo) == 56, "");
134 
149 };
150 static_assert(sizeof(VSFixedFileInfo) == 52, "");
151 
152 inline bool operator==(const VSFixedFileInfo &LHS, const VSFixedFileInfo &RHS) {
153  return memcmp(&LHS, &RHS, sizeof(VSFixedFileInfo)) == 0;
154 }
155 
156 struct Module {
167 };
168 static_assert(sizeof(Module) == 108, "");
169 
170 /// Describes a single thread in the minidump file. Part of the ThreadList
171 /// stream.
172 struct Thread {
180 };
181 static_assert(sizeof(Thread) == 48, "");
182 
183 } // namespace minidump
184 
185 template <> struct DenseMapInfo<minidump::StreamType> {
187 
189  return minidump::StreamType(-2);
190  }
191 
192  static unsigned getHashValue(minidump::StreamType Val) {
193  return DenseMapInfo<uint32_t>::getHashValue(static_cast<uint32_t>(Val));
194  }
195 
197  return LHS == RHS;
198  }
199 };
200 
201 } // namespace llvm
202 
203 #endif // LLVM_BINARYFORMAT_MINIDUMP_H
static minidump::StreamType getEmptyKey()
Definition: Minidump.h:186
support::ulittle32_t FeatureInfo
Definition: Minidump.h:99
static minidump::StreamType getTombstoneKey()
Definition: Minidump.h:188
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:56
MemoryDescriptor Stack
Definition: Minidump.h:178
support::ulittle32_t NumberOfStreams
Definition: Minidump.h:37
support::ulittle32_t TimeDateStamp
Definition: Minidump.h:40
support::ulittle32_t ModuleNameRVA
Definition: Minidump.h:161
support::ulittle32_t Signature
Definition: Minidump.h:33
LocationDescriptor CvRecord
Definition: Minidump.h:163
ProcessorArchitecture
The processor architecture of the system that generated this minidump.
Definition: Minidump.h:81
static bool isEqual(minidump::StreamType LHS, minidump::StreamType RHS)
Definition: Minidump.h:196
LocationDescriptor Memory
Definition: Minidump.h:66
support::ulittle32_t SizeOfImage
Definition: Minidump.h:158
support::ulittle32_t Signature
Definition: Minidump.h:136
support::ulittle32_t ThreadId
Definition: Minidump.h:173
support::ulittle32_t Checksum
Definition: Minidump.h:159
OSPlatform
The OS Platform of the system that generated this minidump.
Definition: Minidump.h:88
support::ulittle32_t BuildNumber
Definition: Minidump.h:124
support::ulittle64_t Flags
Definition: Minidump.h:41
StreamType
The type of a minidump stream identifies its contents.
Definition: Minidump.h:47
support::ulittle32_t Checksum
Definition: Minidump.h:39
support::ulittle32_t ElfHWCaps
Definition: Minidump.h:104
support::ulittle64_t Reserved0
Definition: Minidump.h:165
support::ulittle32_t FileOS
Definition: Minidump.h:144
The minidump header is the first part of a minidump file.
Definition: Minidump.h:29
ELFYAML::ELF_STO Other
Definition: ELFYAML.cpp:877
support::ulittle32_t StreamDirectoryRVA
Definition: Minidump.h:38
support::little_t< ProcessorArchitecture > ProcessorArch
Definition: Minidump.h:115
support::ulittle32_t MajorVersion
Definition: Minidump.h:122
support::ulittle32_t VersionInfo
Definition: Minidump.h:98
static constexpr uint32_t MagicSignature
Definition: Minidump.h:30
support::ulittle32_t FileSubtype
Definition: Minidump.h:146
LocationDescriptor Context
Definition: Minidump.h:179
support::ulittle16_t SuiteMask
Definition: Minidump.h:128
Detailed information about the processor of the system that generated this minidump.
Definition: Minidump.h:95
bool operator==(const VSFixedFileInfo &LHS, const VSFixedFileInfo &RHS)
Definition: Minidump.h:152
support::ulittle16_t Reserved
Definition: Minidump.h:129
support::ulittle64_t EnvironmentBlock
Definition: Minidump.h:177
support::ulittle64_t StartOfMemoryRange
Definition: Minidump.h:65
VSFixedFileInfo VersionInfo
Definition: Minidump.h:162
support::ulittle32_t AMDExtendedFeatures
Definition: Minidump.h:100
support::ulittle64_t Reserved1
Definition: Minidump.h:166
support::ulittle32_t Priority
Definition: Minidump.h:176
Describes a single memory range (both its VM address and where to find it in the file) of the process...
Definition: Minidump.h:64
static unsigned getHashValue(minidump::StreamType Val)
Definition: Minidump.h:192
support::ulittle32_t FileDateLow
Definition: Minidump.h:148
support::ulittle32_t Version
Definition: Minidump.h:36
LocationDescriptor MiscRecord
Definition: Minidump.h:164
support::ulittle16_t ProcessorRevision
Definition: Minidump.h:117
support::ulittle32_t MinorVersion
Definition: Minidump.h:123
LocationDescriptor Location
Definition: Minidump.h:75
support::ulittle32_t RVA
Definition: Minidump.h:58
support::ulittle32_t SuspendCount
Definition: Minidump.h:174
support::ulittle32_t FileFlags
Definition: Minidump.h:143
support::ulittle32_t PriorityClass
Definition: Minidump.h:175
support::ulittle32_t DataSize
Definition: Minidump.h:57
support::ulittle16_t ProcessorLevel
Definition: Minidump.h:116
support::ulittle32_t FileVersionLow
Definition: Minidump.h:139
static constexpr uint16_t MagicVersion
Definition: Minidump.h:31
Merge contiguous icmps into a memcmp
Definition: MergeICmps.cpp:927
support::little_t< OSPlatform > PlatformId
Definition: Minidump.h:125
support::ulittle32_t FileVersionHigh
Definition: Minidump.h:138
support::ulittle32_t ProductVersionLow
Definition: Minidump.h:141
Specifies the location and type of a single stream in the minidump file.
Definition: Minidump.h:73
support::ulittle32_t FileDateHigh
Definition: Minidump.h:147
support::ulittle32_t FileType
Definition: Minidump.h:145
support::ulittle32_t CSDVersionRVA
Definition: Minidump.h:126
support::ulittle32_t StructVersion
Definition: Minidump.h:137
support::ulittle32_t ProductVersionHigh
Definition: Minidump.h:140
Describes a single thread in the minidump file.
Definition: Minidump.h:172
support::ulittle64_t BaseOfImage
Definition: Minidump.h:157
support::ulittle32_t CPUID
Definition: Minidump.h:103
support::ulittle32_t FileFlagsMask
Definition: Minidump.h:142
support::little_t< StreamType > Type
Definition: Minidump.h:74
support::ulittle32_t TimeDateStamp
Definition: Minidump.h:160
The SystemInfo stream, containing various information about the system where this minidump was genera...
Definition: Minidump.h:114