9#ifndef LLVM_OBJECT_MINIDUMP_H
10#define LLVM_OBJECT_MINIDUMP_H
46 std::optional<ArrayRef<uint8_t>>
53 return getDataSlice(getData(),
Desc.RVA,
Desc.DataSize);
65 return getStream<minidump::SystemInfo>(minidump::StreamType::SystemInfo);
74 return getListStream<minidump::Module>(minidump::StreamType::ModuleList);
83 return getListStream<minidump::Thread>(minidump::StreamType::ThreadList);
91 return getStream<minidump::ExceptionStream>(
92 minidump::StreamType::Exception);
103 return getListStream<minidump::MemoryDescriptor>(
104 minidump::StreamType::MemoryList);
110 return getStream<minidump::Memory64ListHeader>(
111 minidump::StreamType::Memory64List);
116 std::forward_iterator_tag,
117 minidump::MemoryInfo> {
120 : Storage(Storage), Stride(Stride) {
125 return Storage.
size() == R.Storage.size();
156 return IsEnd == R.IsEnd;
161 const std::pair<minidump::MemoryDescriptor_64, ArrayRef<uint8_t>> &
166 const std::pair<minidump::MemoryDescriptor_64, ArrayRef<uint8_t>> *
172 if (Descriptors.empty()) {
181 return make_error<GenericBinaryError>(
182 "Memory64 Descriptor exceeds end of file.",
187 Current = std::make_pair(Descriptor,
Content);
190 Descriptors = Descriptors.drop_front();
199 : Storage(Storage), Descriptors(Descriptors), IsEnd(
false) {
201 Storage.
size() >= Descriptors.
front().DataSize);
204 Current = std::make_pair(Descriptor,
Content);
211 Descriptors(
ArrayRef<minidump::MemoryDescriptor_64>()), IsEnd(
true) {}
213 std::pair<minidump::MemoryDescriptor_64, ArrayRef<uint8_t>> Current;
241 static Error createEOFError() {
242 return make_error<GenericBinaryError>(
"Unexpected EOF",
253 template <
typename T>
261 StreamMap(
std::
move(StreamMap)) {}
263 ArrayRef<uint8_t> getData()
const {
269 template <
typename T>
274 template <
typename T>
277 const minidump::Header &Header;
278 ArrayRef<minidump::Directory> Streams;
279 DenseMap<minidump::StreamType, std::size_t> StreamMap;
284 if (std::optional<ArrayRef<uint8_t>> Stream =
getRawStream(Type)) {
285 if (Stream->size() >=
sizeof(
T))
286 return *
reinterpret_cast<const T *
>(Stream->data());
287 return createEOFError();
289 return createError(
"No such stream");
293Expected<ArrayRef<T>> MinidumpFile::getDataSliceAs(ArrayRef<uint8_t>
Data,
297 if (Count > std::numeric_limits<uint64_t>::max() /
sizeof(
T))
298 return createEOFError();
299 Expected<ArrayRef<uint8_t>> Slice =
302 return Slice.takeError();
304 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 > take_front(size_t N=1) const
Return a copy of *this with only the first N elements.
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
const T & front() const
front - Get the first element.
size_t size() const
size - Get the array size.
bool empty() const
empty - Check if the array is empty.
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.
static ErrorSuccess success()
Create a success value.
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.
A wrapper class for fallible iterators.
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
A range adaptor for a pair of iterators.
Class the provides an iterator over the memory64 memory ranges.
bool operator==(const Memory64Iterator &R) const
static Memory64Iterator begin(ArrayRef< uint8_t > Storage, ArrayRef< minidump::MemoryDescriptor_64 > Descriptors)
bool operator!=(const Memory64Iterator &R) const
const std::pair< minidump::MemoryDescriptor_64, ArrayRef< uint8_t > > & operator*()
const std::pair< minidump::MemoryDescriptor_64, ArrayRef< uint8_t > > * operator->()
static Memory64Iterator end()
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.
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.
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.
iterator_range< FallibleMemory64Iterator > getMemory64List(Error &Err) const
Returns an iterator that pairs each descriptor with it's respective content from the Memory64List str...
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.
Implement std::hash so that hash_code can be used in STL containers.
Description of the encoding of one expression Op.
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
support::ulittle64_t DataSize