19 auto It = StreamMap.find(Type);
20 if (It != StreamMap.end())
21 return getRawStream(Streams[It->second]);
30 getDataSliceAs<support::ulittle32_t>(getData(),
Offset, 1);
32 return ExpectedSize.takeError();
33 size_t Size = (*ExpectedSize)[0];
42 getDataSliceAs<support::ulittle16_t>(getData(),
Offset,
Size);
44 return ExpectedData.takeError();
62 getDataSliceAs<minidump::MemoryInfoListHeader>(*Stream, 0, 1);
64 return ExpectedHeader.takeError();
79 auto ExpectedSize = getDataSliceAs<support::ulittle32_t>(*Stream, 0, 1);
81 return ExpectedSize.takeError();
83 size_t ListSize = ExpectedSize.get()[0];
85 size_t ListOffset = 4;
89 if (ListOffset +
sizeof(
T) * ListSize < Stream->
size())
92 return getDataSliceAs<T>(*Stream, ListOffset, ListSize);
106 return createEOFError();
113 auto ExpectedHeader = getDataSliceAs<minidump::Header>(Data, 0, 1);
115 return ExpectedHeader.takeError();
118 if (Hdr.
Signature != Header::MagicSignature)
120 if ((Hdr.
Version & 0xffff) != Header::MagicVersion)
125 if (!ExpectedStreams)
126 return ExpectedStreams.takeError();
129 for (
const auto &StreamDescriptor :
llvm::enumerate(*ExpectedStreams)) {
138 if (Type == StreamType::Unused && Loc.
DataSize == 0) {
146 return createError(
"Cannot handle one of the minidump streams");
153 return std::unique_ptr<MinidumpFile>(
154 new MinidumpFile(Source, Hdr, *ExpectedStreams, std::move(StreamMap)));
This class represents lattice values for constants.
Specifies the location (and size) of various objects in the minidump file.
ArrayRef< uint8_t > arrayRefFromStringRef(StringRef Input)
Construct a string ref from an array ref of unsigned chars.
Error takeError()
Take ownership of the stored error.
Expected< std::string > getString(size_t Offset) const
Returns the minidump string at the given offset.
StreamType
The type of a minidump stream identifies its contents.
StringRef getBuffer() const
Tagged union holding either a T or a Error.
static Error createError(const Twine &Err)
Type(LLVMContext &C, TypeID tid)
static Expected< std::unique_ptr< MinidumpFile > > create(MemoryBufferRef Source)
Construct a new MinidumpFile object from the given memory buffer.
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
size_t size() const
size - Get the array size.
ArrayRef< uint8_t > getRawStream(const minidump::Directory &Stream) const
Returns the raw contents of the stream given by the directory entry.
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&... Args)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Expected< iterator_range< MemoryInfoIterator > > getMemoryInfoList() const
Returns the list of descriptors embedded in the MemoryInfoList stream.
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array...
bool convertUTF16ToUTF8String(ArrayRef< char > SrcBytes, std::string &Out)
Converts a stream of raw bytes assumed to be UTF16 into a UTF8 std::string.
support::ulittle32_t DataSize
OutputIt copy(R &&Range, OutputIt Out)
A class providing access to the contents of a minidump file.
detail::enumerator< R > enumerate(R &&TheRange)
Given an input range, returns a new range whose values are are pair (A,B) such that A is the 0-based ...