19 template <
typename EndianType>
20 static inline void mapOptional(yaml::IO &IO,
const char *
Key, EndianType &Val,
21 typename EndianType::value_type Default) {
22 IO.mapOptional(Key, Val, EndianType(Default));
26 template <
typename MapType,
typename EndianType>
29 MapType Mapped =
static_cast<typename EndianType::value_type
>(Val);
30 IO.mapRequired(Key, Mapped);
31 Val =
static_cast<typename EndianType::value_type
>(Mapped);
36 template <
typename MapType,
typename EndianType>
39 MapType Mapped =
static_cast<typename EndianType::value_type
>(Val);
40 IO.mapOptional(Key, Mapped, Default);
41 Val =
static_cast<typename EndianType::value_type
>(Mapped);
46 template <
typename EndianType>
struct HexType;
47 template <>
struct HexType<support::
ulittle16_t> {
using type = yaml::Hex16; };
48 template <>
struct HexType<support::
ulittle32_t> {
using type = yaml::Hex32; };
49 template <>
struct HexType<support::
ulittle64_t> {
using type = yaml::Hex64; };
53 template <
typename EndianType>
56 mapRequiredAs<typename HexType<EndianType>::type>(IO,
Key, Val);
61 template <
typename EndianType>
64 typename EndianType::value_type Default) {
65 mapOptionalAs<typename HexType<EndianType>::type>(IO,
Key, Val, Default);
72 case StreamType::Exception:
73 return StreamKind::Exception;
74 case StreamType::MemoryInfoList:
75 return StreamKind::MemoryInfoList;
76 case StreamType::MemoryList:
77 return StreamKind::MemoryList;
78 case StreamType::ModuleList:
79 return StreamKind::ModuleList;
80 case StreamType::SystemInfo:
81 return StreamKind::SystemInfo;
82 case StreamType::LinuxCPUInfo:
83 case StreamType::LinuxProcStatus:
84 case StreamType::LinuxLSBRelease:
85 case StreamType::LinuxCMDLine:
86 case StreamType::LinuxMaps:
87 case StreamType::LinuxProcStat:
88 case StreamType::LinuxProcUptime:
89 return StreamKind::TextContent;
90 case StreamType::ThreadList:
91 return StreamKind::ThreadList;
93 return StreamKind::RawContent;
100 case StreamKind::Exception:
101 return std::make_unique<ExceptionStream>();
102 case StreamKind::MemoryInfoList:
103 return std::make_unique<MemoryInfoListStream>();
104 case StreamKind::MemoryList:
105 return std::make_unique<MemoryListStream>();
106 case StreamKind::ModuleList:
107 return std::make_unique<ModuleListStream>();
108 case StreamKind::RawContent:
109 return std::make_unique<RawContentStream>(Type);
110 case StreamKind::SystemInfo:
111 return std::make_unique<SystemInfoStream>();
112 case StreamKind::TextContent:
113 return std::make_unique<TextContentStream>(Type);
114 case StreamKind::ThreadList:
115 return std::make_unique<ThreadListStream>();
120 void yaml::ScalarBitSetTraits<MemoryProtection>::bitset(
122 #define HANDLE_MDMP_PROTECT(CODE, NAME, NATIVENAME) \ 123 IO.bitSetCase(Protect, #NATIVENAME, MemoryProtection::NAME); 124 #include "llvm/BinaryFormat/MinidumpConstants.def" 127 void yaml::ScalarBitSetTraits<MemoryState>::bitset(IO &IO,
MemoryState &State) {
128 #define HANDLE_MDMP_MEMSTATE(CODE, NAME, NATIVENAME) \ 129 IO.bitSetCase(State, #NATIVENAME, MemoryState::NAME); 130 #include "llvm/BinaryFormat/MinidumpConstants.def" 133 void yaml::ScalarBitSetTraits<MemoryType>::bitset(IO &IO,
MemoryType &
Type) {
134 #define HANDLE_MDMP_MEMTYPE(CODE, NAME, NATIVENAME) \ 135 IO.bitSetCase(Type, #NATIVENAME, MemoryType::NAME); 136 #include "llvm/BinaryFormat/MinidumpConstants.def" 139 void yaml::ScalarEnumerationTraits<ProcessorArchitecture>::enumeration(
141 #define HANDLE_MDMP_ARCH(CODE, NAME) \ 142 IO.enumCase(Arch, #NAME, ProcessorArchitecture::NAME); 143 #include "llvm/BinaryFormat/MinidumpConstants.def" 144 IO.enumFallback<Hex16>(Arch);
147 void yaml::ScalarEnumerationTraits<OSPlatform>::enumeration(IO &IO,
149 #define HANDLE_MDMP_PLATFORM(CODE, NAME) \ 150 IO.enumCase(Plat, #NAME, OSPlatform::NAME); 151 #include "llvm/BinaryFormat/MinidumpConstants.def" 152 IO.enumFallback<Hex32>(Plat);
155 void yaml::ScalarEnumerationTraits<StreamType>::enumeration(IO &IO,
157 #define HANDLE_MDMP_STREAM_TYPE(CODE, NAME) \ 158 IO.enumCase(Type, #NAME, StreamType::NAME); 159 #include "llvm/BinaryFormat/MinidumpConstants.def" 160 IO.enumFallback<Hex32>(Type);
170 template <std::
size_t N>
struct FixedSizeHex {
171 FixedSizeHex(uint8_t (&Storage)[
N]) : Storage(Storage) {}
173 uint8_t (&Storage)[
N];
179 template <std::
size_t N>
struct ScalarTraits<FixedSizeHex<
N>> {
186 return "Invalid hex digit in input";
187 if (Scalar.
size() < 2 *
N)
188 return "String too short";
189 if (Scalar.
size() > 2 *
N)
190 return "String too long";
202 IO.mapRequired(
"Features", Features);
207 template <std::
size_t N>
struct FixedSizeString {
208 FixedSizeString(
char (&Storage)[
N]) : Storage(Storage) {}
216 template <std::
size_t N>
struct ScalarTraits<FixedSizeString<
N>> {
222 if (Scalar.
size() <
N)
223 return "String too short";
224 if (Scalar.
size() >
N)
225 return "String too long";
226 copy(Scalar, Fixed.Storage);
238 IO.mapRequired(
"Vendor ID", VendorID);
248 mapRequiredAs<MemoryProtection>(IO,
"Allocation Protect",
252 mapRequiredAs<MemoryState>(IO,
"State", Info.
State);
253 mapOptionalAs<MemoryProtection>(IO,
"Protect", Info.
Protect,
255 mapRequiredAs<MemoryType>(IO,
"Type", Info.
Type);
281 mapOptional(IO,
"Time Date Stamp", M.Entry.TimeDateStamp, 0);
282 IO.mapRequired(
"Module Name", M.Name);
283 IO.mapOptional(
"Version Info", M.Entry.VersionInfo,
VSFixedFileInfo());
284 IO.mapRequired(
"CodeView Record", M.CvRecord);
291 IO.mapOptional(
"Content", Stream.
Content);
297 return "Stream size must be greater or equal to the content size";
303 MappingContextTraits<MemoryDescriptor, yaml::BinaryRef>::mapping(
304 IO, Range.Entry, Range.Content);
308 IO.mapRequired(
"Memory Ranges", Stream.
Infos);
312 IO.mapRequired(
"Memory Ranges", Stream.
Entries);
316 IO.mapRequired(
"Modules", Stream.
Entries);
325 IO.mapOptional(
"Product type", Info.
ProductType, 0);
329 IO.mapRequired(
"Platform ID", Info.
PlatformId);
330 IO.mapOptional(
"CSD Version", Stream.
CSDVersion,
"");
333 switch (static_cast<ProcessorArchitecture>(Info.
ProcessorArch)) {
334 case ProcessorArchitecture::X86:
335 case ProcessorArchitecture::AMD64:
336 IO.mapOptional(
"CPU", Info.
CPU.
X86);
339 case ProcessorArchitecture::ARM64:
340 case ProcessorArchitecture::BP_ARM64:
341 IO.mapOptional(
"CPU", Info.
CPU.
Arm);
344 IO.mapOptional(
"CPU", Info.
CPU.
Other);
350 IO.mapOptional(
"Text", Stream.
Text);
353 void yaml::MappingContextTraits<MemoryDescriptor, yaml::BinaryRef>::mapping(
356 IO.mapRequired(
"Content", Content);
365 mapOptionalHex(IO,
"Environment Block", T.Entry.EnvironmentBlock, 0);
366 IO.mapRequired(
"Context", T.Context);
367 IO.mapRequired(
"Stack", T.Entry.Stack, T.Stack);
371 IO.mapRequired(
"Threads", Stream.
Entries);
401 yaml::IO &IO, std::unique_ptr<MinidumpYAML::Stream> &S) {
405 IO.mapRequired(
"Type", Type);
407 if (!IO.outputting())
411 streamMapping(IO, llvm::cast<MinidumpYAML::ExceptionStream>(*S));
438 yaml::IO &IO, std::unique_ptr<MinidumpYAML::Stream> &S) {
455 IO.mapTag(
"!minidump",
true);
459 IO.mapRequired(
"Streams", O.
Streams);
466 case StreamKind::Exception: {
469 if (!ExpectedExceptionStream)
470 return ExpectedExceptionStream.
takeError();
472 File.
getRawData(ExpectedExceptionStream->ThreadContext);
473 if (!ExpectedThreadContext)
474 return ExpectedThreadContext.
takeError();
475 return std::make_unique<ExceptionStream>(*ExpectedExceptionStream,
476 *ExpectedThreadContext);
478 case StreamKind::MemoryInfoList: {
480 return std::make_unique<MemoryInfoListStream>(*ExpectedList);
482 return ExpectedList.takeError();
484 case StreamKind::MemoryList: {
487 return ExpectedList.takeError();
488 std::vector<MemoryListStream::entry_type> Ranges;
490 auto ExpectedContent = File.
getRawData(MD.Memory);
491 if (!ExpectedContent)
492 return ExpectedContent.takeError();
493 Ranges.push_back({MD, *ExpectedContent});
495 return std::make_unique<MemoryListStream>(std::move(Ranges));
497 case StreamKind::ModuleList: {
500 return ExpectedList.takeError();
501 std::vector<ModuleListStream::entry_type> Modules;
502 for (
const Module &M : *ExpectedList) {
503 auto ExpectedName = File.
getString(M.ModuleNameRVA);
505 return ExpectedName.takeError();
506 auto ExpectedCv = File.
getRawData(M.CvRecord);
508 return ExpectedCv.takeError();
509 auto ExpectedMisc = File.
getRawData(M.MiscRecord);
511 return ExpectedMisc.takeError();
513 {M, std::move(*ExpectedName), *ExpectedCv, *ExpectedMisc});
515 return std::make_unique<ModuleListStream>(std::move(Modules));
517 case StreamKind::RawContent:
518 return std::make_unique<RawContentStream>(StreamDesc.
Type,
520 case StreamKind::SystemInfo: {
523 return ExpectedInfo.takeError();
524 auto ExpectedCSDVersion = File.
getString(ExpectedInfo->CSDVersionRVA);
525 if (!ExpectedCSDVersion)
526 return ExpectedInfo.takeError();
527 return std::make_unique<SystemInfoStream>(*ExpectedInfo,
528 std::move(*ExpectedCSDVersion));
530 case StreamKind::TextContent:
531 return std::make_unique<TextContentStream>(
533 case StreamKind::ThreadList: {
536 return ExpectedList.takeError();
537 std::vector<ThreadListStream::entry_type> Threads;
538 for (
const Thread &
T : *ExpectedList) {
539 auto ExpectedStack = File.
getRawData(
T.Stack.Memory);
541 return ExpectedStack.takeError();
543 if (!ExpectedContext)
544 return ExpectedContext.takeError();
545 Threads.push_back({
T, *ExpectedStack, *ExpectedContext});
547 return std::make_unique<ThreadListStream>(std::move(Threads));
554 std::vector<std::unique_ptr<Stream>> Streams;
555 Streams.reserve(File.
streams().size());
559 return ExpectedStream.takeError();
560 Streams.push_back(std::move(*ExpectedStream));
support::ulittle32_t FeatureInfo
static void output(const FixedSizeString< N > &Fixed, void *, raw_ostream &OS)
SystemInfo minidump stream.
Expected< const minidump::ExceptionStream & > getExceptionStream() const
Returns the contents of the Exception stream.
support::ulittle64_t ExceptionInformation[MaxParameters]
static Expected< Object > create(const object::MinidumpFile &File)
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
static void mapRequiredHex(yaml::IO &IO, const char *Key, EndianType &Val)
Yaml-map an endian-aware type as an appropriately-sized hex value.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
static StringRef input(StringRef Scalar, void *, FixedSizeHex< N > &Fixed)
This class provides various memory handling functions that manipulate MemoryBlock instances...
struct llvm::minidump::CPUInfo::X86Info X86
ProcessorArchitecture
The processor architecture of the system that generated this minidump.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
struct llvm::minidump::CPUInfo::OtherInfo Other
support::ulittle32_t NumberParameters
uint8_t NumberOfProcessors
Error takeError()
Take ownership of the stored error.
detail::packed_endian_specific_integral< uint16_t, little, unaligned > ulittle16_t
static StringRef input(StringRef Scalar, void *, FixedSizeString< N > &Fixed)
ArrayRef< minidump::Directory > streams() const
Returns the list of streams (stream directory entries) in this file.
support::little_t< MemoryType > Type
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
std::string fromHex(StringRef Input)
Convert hexadecimal string Input to its binary representation.
Expected< std::string > getString(size_t Offset) const
Returns the minidump string at the given offset.
detail::packed_endian_specific_integral< uint64_t, little, unaligned > ulittle64_t
support::ulittle32_t Signature
minidump::Header Header
The minidump header.
OSPlatform
The OS Platform of the system that generated this minidump.
support::ulittle32_t BuildNumber
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
StreamType
The type of a minidump stream identifies its contents.
support::ulittle32_t ElfHWCaps
const minidump::Header & header() const
Returns the contents of the minidump header.
support::ulittle32_t FileOS
Tagged union holding either a T or a Error.
support::ulittle64_t BaseAddress
support::little_t< ProcessorArchitecture > ProcessorArch
support::little_t< MemoryState > State
support::ulittle32_t MajorVersion
static constexpr size_t MaxParameters
Exception ExceptionRecord
support::ulittle32_t VersionInfo
Expected< const minidump::SystemInfo & > getSystemInfo() const
Returns the contents of the SystemInfo stream, cast to the appropriate type.
support::ulittle64_t AllocationBase
Expected< ArrayRef< minidump::Module > > getModuleList() const
Returns the module list embedded in the ModuleList stream.
minidump::ExceptionStream MDExceptionStream
LLVM_NODISCARD size_t size() const
size - Get the string size.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
static void streamMapping(yaml::IO &IO, RawContentStream &Stream)
Type(LLVMContext &C, TypeID tid)
support::ulittle32_t FileSubtype
Analysis containing CSE Info
support::ulittle16_t SuiteMask
support::ulittle32_t ExceptionCode
yaml::BinaryRef ThreadContext
static void output(const FixedSizeHex< N > &Fixed, void *, raw_ostream &OS)
The top level structure representing a minidump object, consisting of a minidump header, and zero or more streams.
support::ulittle16_t Reserved
The instances of the Type class are immutable: once they are created, they are never changed...
detail::packed_endian_specific_integral< uint32_t, little, unaligned > ulittle32_t
support::ulittle64_t StartOfMemoryRange
support::ulittle32_t AMDExtendedFeatures
Instrumentation for Order File
static void mapRequiredAs(yaml::IO &IO, const char *Key, EndianType &Val)
Yaml-map an endian-aware type EndianType as some other type MapType.
static StreamKind getKind(minidump::StreamType Type)
Get the stream Kind used for representing streams of a given Type.
bool isHexDigit(char C)
Checks if character C is a hexadecimal numeric character.
Expected< ArrayRef< minidump::MemoryDescriptor > > getMemoryList() const
Returns the list of descriptors embedded in the MemoryList stream.
Expected< ArrayRef< uint8_t > > getRawData(minidump::LocationDescriptor Desc) const
Returns the raw contents of an object given by the LocationDescriptor.
static QuotingType mustQuote(StringRef S)
static void mapOptionalAs(yaml::IO &IO, const char *Key, EndianType &Val, MapType Default)
Perform an optional yaml-mapping of an endian-aware type EndianType as some other type MapType...
Expected< ArrayRef< minidump::Thread > > getThreadList() const
Returns the thread list embedded in the ThreadList stream.
A stream representing a list of abstract entries in a minidump stream.
void toVector(SmallVectorImpl< char > &Out) const
Append the concatenated string into the given SmallString or SmallVector.
StringRef toStringRef(bool B)
Construct a string ref from a boolean.
support::ulittle32_t ExceptionFlags
ArrayRef< uint8_t > getRawStream(const minidump::Directory &Stream) const
Returns the raw contents of the stream given by the directory entry.
Describes a single memory range (both its VM address and where to find it in the file) of the process...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
struct llvm::minidump::CPUInfo::ArmInfo Arm
support::ulittle32_t FileDateLow
support::ulittle32_t ThreadId
ArrayRef< uint8_t >::size_type binary_size() const
The number of bytes that are represented by this BinaryRef.
ExceptionStream minidump stream.
The base class for all minidump streams.
support::ulittle16_t ProcessorRevision
support::ulittle32_t MinorVersion
std::vector< std::unique_ptr< Stream > > Streams
The list of streams in this minidump object.
A minidump stream represented as a sequence of hex bytes.
static void mapOptionalHex(yaml::IO &IO, const char *Key, EndianType &Val, typename EndianType::value_type Default)
Perform an optional yaml-mapping of an endian-aware type as an appropriately-sized hex value...
Expected< iterator_range< MemoryInfoIterator > > getMemoryInfoList() const
Returns the list of descriptors embedded in the MemoryInfoList stream.
static StringRef streamValidate(RawContentStream &Stream)
minidump::SystemInfo Info
support::little_t< MemoryProtection > Protect
Specialized YAMLIO scalar type for representing a binary blob.
A StringRef, which is printed using YAML block notation.
support::ulittle32_t FileFlags
support::ulittle16_t ProcessorLevel
support::ulittle32_t FileVersionLow
support::little_t< OSPlatform > PlatformId
support::ulittle32_t FileVersionHigh
uint8_t ProcessorFeatures[16]
support::ulittle32_t ProductVersionLow
Specifies the location and type of a single stream in the minidump file.
support::ulittle32_t FileDateHigh
support::ulittle32_t FileType
std::vector< minidump::MemoryInfo > Infos
support::ulittle64_t RegionSize
support::ulittle32_t Reserved1
support::ulittle32_t StructVersion
support::ulittle32_t ProductVersionHigh
support::ulittle64_t ExceptionRecord
support::little_t< MemoryProtection > AllocationProtect
support::ulittle64_t ExceptionAddress
Describes a single thread in the minidump file.
support::ulittle32_t Reserved0
This class implements an extremely fast bulk output stream that can only output to a stream...
A structure containing the list of MemoryInfo entries comprising a MemoryInfoList stream...
StringRef - Represent a constant reference to a string, i.e.
std::string toHex(StringRef Input, bool LowerCase=false)
Convert buffer Input to its hexadecimal representation.
static QuotingType mustQuote(StringRef S)
OutputIt copy(R &&Range, OutputIt Out)
static std::unique_ptr< Stream > create(minidump::StreamType Type)
Create an empty stream of the given Type.
A class providing access to the contents of a minidump file.
support::ulittle32_t CPUID
void validate(const Triple &TT, const FeatureBitset &FeatureBits)
static void mapOptional(yaml::IO &IO, const char *Key, EndianType &Val, typename EndianType::value_type Default)
Perform an optional yaml-mapping of an endian-aware type EndianType.
support::ulittle32_t FileFlagsMask
support::little_t< StreamType > Type
The SystemInfo stream, containing various information about the system where this minidump was genera...
std::vector< entry_type > Entries