16std::optional<ArrayRef<uint8_t>>
18 auto It = StreamMap.find(
Type);
19 if (It != StreamMap.end())
31 return ExpectedSize.takeError();
32 size_t Size = (*ExpectedSize)[0];
34 return createError(
"String size not even");
43 return ExpectedData.takeError();
50 return createError(
"String decoding failed");
63 std::optional<ArrayRef<uint8_t>> Stream =
66 return createError(
"No such stream");
68 getDataSliceAs<minidump::MemoryInfoListHeader>(*Stream, 0, 1);
70 return ExpectedHeader.takeError();
73 getDataSlice(*Stream,
H.SizeOfHeader,
H.SizeOfEntry *
H.NumberOfEntries);
75 return Data.takeError();
86 return createEOFError();
93 auto ExpectedHeader = getDataSliceAs<minidump::Header>(
Data, 0, 1);
95 return ExpectedHeader.takeError();
99 return createError(
"Invalid signature");
101 return createError(
"Invalid version");
105 if (!ExpectedStreams)
106 return ExpectedStreams.takeError();
109 std::vector<Directory> ExceptionStreams;
110 for (
const auto &StreamDescriptor :
llvm::enumerate(*ExpectedStreams)) {
127 if (
Type == StreamType::Exception) {
128 ExceptionStreams.push_back(StreamDescriptor.value());
134 return createError(
"Cannot handle one of the minidump streams");
137 if (!StreamMap.try_emplace(
Type, StreamDescriptor.index()).second)
138 return createError(
"Duplicate stream type");
141 return std::unique_ptr<MinidumpFile>(
142 new MinidumpFile(Source, Hdr, *ExpectedStreams, std::move(StreamMap),
143 std::move(ExceptionStreams)));
156 std::optional<ArrayRef<uint8_t>> Stream =
159 Err = createError(
"No such stream");
164 getDataSliceAs<minidump::MemoryDescriptor_64>(
166 ListHeader->NumberOfMemoryRanges);
173 if (!Descriptors->empty() &&
174 ListHeader->BaseRVA + Descriptors->front().DataSize > getData().
size()) {
175 Err = createError(
"Memory64List header RVA out of range");
181 getData().slice(ListHeader->BaseRVA), *Descriptors),
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Helper for Errors used as out-parameters.
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
The instances of the Type class are immutable: once they are created, they are never changed.
Type(LLVMContext &C, TypeID tid)
static fallible_iterator end(Memory64Iterator I)
static fallible_iterator itr(Memory64Iterator I, Error &Err)
A range adaptor for a pair of iterators.
StringRef getData() const
static Memory64Iterator begin(ArrayRef< uint8_t > Storage, ArrayRef< minidump::MemoryDescriptor_64 > Descriptors)
static Memory64Iterator end()
LLVM_ABI Expected< iterator_range< MemoryInfoIterator > > getMemoryInfoList() const
Returns the list of descriptors embedded in the MemoryInfoList stream.
Expected< minidump::Memory64ListHeader > getMemoryList64Header() const
Returns the header to the memory 64 list stream.
ArrayRef< uint8_t > getRawStream(const minidump::Directory &Stream) const
Returns the raw contents of the stream given by the directory entry.
LLVM_ABI iterator_range< ExceptionStreamsIterator > getExceptionStreams() const
Returns an iterator that reads each exception stream independently.
LLVM_ABI Expected< std::string > getString(size_t Offset) const
Returns the minidump string at the given offset.
LLVM_ABI iterator_range< FallibleMemory64Iterator > getMemory64List(Error &Err) const
Returns an iterator that pairs each descriptor with it's respective content from the Memory64List str...
static LLVM_ABI Expected< std::unique_ptr< MinidumpFile > > create(MemoryBufferRef Source)
Construct a new MinidumpFile object from the given memory buffer.
StreamType
The type of a minidump stream identifies its contents.
detail::packed_endian_specific_integral< uint32_t, llvm::endianness::little, unaligned > ulittle32_t
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
ArrayRef< CharT > arrayRefFromStringRef(StringRef Input)
Construct a string ref from an array ref of unsigned chars.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
LLVM_ABI bool convertUTF16ToUTF8String(ArrayRef< char > SrcBytes, std::string &Out)
Converts a stream of raw bytes assumed to be UTF16 into a UTF8 std::string.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
OutputIt copy(R &&Range, OutputIt Out)
An information struct used to provide DenseMap with the various necessary components for a given valu...
Specifies the location (and size) of various objects in the minidump file.