9#ifndef LLVM_OBJECT_MINIDUMP_H
10#define LLVM_OBJECT_MINIDUMP_H
45 std::optional<ArrayRef<uint8_t>>
52 return getDataSlice(getData(), Desc.
RVA, Desc.
DataSize);
64 return getStream<minidump::SystemInfo>(minidump::StreamType::SystemInfo);
73 return getListStream<minidump::Module>(minidump::StreamType::ModuleList);
82 return getListStream<minidump::Thread>(minidump::StreamType::ThreadList);
90 return getStream<minidump::ExceptionStream>(
91 minidump::StreamType::Exception);
102 return getListStream<minidump::MemoryDescriptor>(
103 minidump::StreamType::MemoryList);
108 std::forward_iterator_tag,
109 minidump::MemoryInfo> {
112 : Storage(Storage), Stride(Stride) {
117 return Storage.
size() == R.Storage.size();
149 static Error createEOFError() {
150 return make_error<GenericBinaryError>(
"Unexpected EOF",
155 static Expected<ArrayRef<uint8_t>> getDataSlice(ArrayRef<uint8_t>
Data,
161 template <
typename T>
162 static Expected<ArrayRef<T>> getDataSliceAs(ArrayRef<uint8_t>
Data,
163 size_t Offset,
size_t Count);
165 MinidumpFile(MemoryBufferRef Source,
const minidump::Header &Header,
166 ArrayRef<minidump::Directory> Streams,
167 DenseMap<minidump::StreamType, std::size_t> StreamMap)
169 StreamMap(
std::
move(StreamMap)) {}
171 ArrayRef<uint8_t> getData()
const {
177 template <
typename T>
182 template <
typename T>
185 const minidump::Header &Header;
186 ArrayRef<minidump::Directory> Streams;
187 DenseMap<minidump::StreamType, std::size_t> StreamMap;
192 if (std::optional<ArrayRef<uint8_t>> Stream =
getRawStream(Type)) {
193 if (Stream->size() >=
sizeof(
T))
194 return *
reinterpret_cast<const T *
>(Stream->data());
195 return createEOFError();
197 return createError(
"No such stream");
201Expected<ArrayRef<T>> MinidumpFile::getDataSliceAs(ArrayRef<uint8_t>
Data,
205 if (Count > std::numeric_limits<size_t>::max() /
sizeof(
T))
206 return createEOFError();
207 Expected<ArrayRef<uint8_t>> Slice =
210 return Slice.takeError();
211 return ArrayRef<T>(
reinterpret_cast<const T *
>(Slice->data()), Count);
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file defines the DenseMap class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
size_t size() const
size - Get the array size.
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.
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
StringRef getBuffer() const
StringRef - Represent a constant reference to a string, i.e.
The instances of the Type class are immutable: once they are created, they are never changed.
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
bool operator==(const MemoryInfoIterator &R) const
MemoryInfoIterator & operator++()
MemoryInfoIterator(ArrayRef< uint8_t > Storage, size_t Stride)
const minidump::MemoryInfo & operator*() const
A class providing access to the contents of a minidump file.
Expected< iterator_range< MemoryInfoIterator > > getMemoryInfoList() const
Returns the list of descriptors embedded in the MemoryInfoList stream.
ArrayRef< uint8_t > getRawStream(const minidump::Directory &Stream) const
Returns the raw contents of the stream given by the directory entry.
Expected< const minidump::ExceptionStream & > getExceptionStream() const
Returns the contents of the Exception stream.
const minidump::Header & header() const
Returns the contents of the minidump header.
Expected< const minidump::SystemInfo & > getSystemInfo() const
Returns the contents of the SystemInfo stream, cast to the appropriate type.
Expected< ArrayRef< uint8_t > > getRawData(minidump::LocationDescriptor Desc) const
Returns the raw contents of an object given by the LocationDescriptor.
static bool classof(const Binary *B)
Expected< std::string > getString(size_t Offset) const
Returns the minidump string at the given offset.
Expected< ArrayRef< minidump::MemoryDescriptor > > getMemoryList() const
Returns the list of descriptors embedded in the MemoryList stream.
Expected< ArrayRef< minidump::Module > > getModuleList() const
Returns the module list embedded in the ModuleList stream.
Expected< ArrayRef< minidump::Thread > > getThreadList() const
Returns the thread list embedded in the ThreadList stream.
ArrayRef< minidump::Directory > streams() const
Returns the list of streams (stream directory entries) in this file.
static 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.
This is an optimization pass for GlobalISel generic memory operations.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Specifies the location and type of a single stream in the minidump file.
LocationDescriptor Location
Specifies the location (and size) of various objects in the minidump file.
support::ulittle32_t DataSize