9#ifndef LLVM_OBJECT_MINIDUMP_H 
   10#define LLVM_OBJECT_MINIDUMP_H 
   48  LLVM_ABI std::optional<ArrayRef<uint8_t>>
 
   67    return getStream<minidump::SystemInfo>(minidump::StreamType::SystemInfo);
 
 
   76    return getListStream<minidump::Module>(minidump::StreamType::ModuleList);
 
 
   85    return getListStream<minidump::Thread>(minidump::StreamType::ThreadList);
 
 
   93    if (Directory.
Type != minidump::StreamType::Exception) {
 
   94      return createError(
"Not an exception stream");
 
   97    return getStreamFromDirectory<minidump::ExceptionStream>(Directory);
 
 
  105    if (it.begin() == it.end())
 
  106      return createError(
"No exception streams");
 
 
  118    return getListStream<minidump::MemoryDescriptor>(
 
  119        minidump::StreamType::MemoryList);
 
 
  125    return getStream<minidump::Memory64ListHeader>(
 
  126        minidump::StreamType::Memory64List);
 
 
  131                                    std::forward_iterator_tag,
 
  132                                    minidump::MemoryInfo> {
 
  135        : Storage(Storage), Stride(Stride) {
 
  136      assert(Storage.size() % Stride == 0);
 
 
  140      return Storage.size() == R.Storage.size();
 
 
  149      Storage = Storage.drop_front(Stride);
 
 
 
  160  class Memory64Iterator {
 
  162    static Memory64Iterator
 
  165      return Memory64Iterator(Storage, Descriptors);
 
 
  168    static Memory64Iterator 
end() { 
return Memory64Iterator(); }
 
  171      return IsEnd == R.IsEnd;
 
 
  174    bool operator!=(
const Memory64Iterator &R)
 const { 
return !(*
this == R); }
 
  176    const std::pair<minidump::MemoryDescriptor_64, ArrayRef<uint8_t>> &
 
  181    const std::pair<minidump::MemoryDescriptor_64, ArrayRef<uint8_t>> *
 
  187      if (Descriptors.empty()) {
 
  194      if (Descriptor.
DataSize > Storage.size()) {
 
  197            "Memory64 Descriptor exceeds end of file.",
 
  202      Current = std::make_pair(Descriptor, Content);
 
  204      Storage = Storage.drop_front(Descriptor.
DataSize);
 
  205      Descriptors = Descriptors.drop_front();
 
 
  214        : Storage(Storage), Descriptors(Descriptors), IsEnd(
false) {
 
  216             Storage.
size() >= Descriptors.
front().DataSize);
 
  219      Current = std::make_pair(Descriptor, Content);
 
  228    std::pair<minidump::MemoryDescriptor_64, ArrayRef<uint8_t>> Current;
 
 
  237                             const MinidumpFile *File)
 
  238        : Streams(Streams), File(File) {}
 
 
  241      return Streams.size() == R.Streams.size();
 
 
  245      return !(*
this == R);
 
 
  249      return File->getExceptionStream(Streams.front());
 
 
  253      if (!Streams.empty())
 
  254        Streams = Streams.drop_front();
 
 
  261    const MinidumpFile *File;
 
 
  294  static Error createEOFError() {
 
  306  template <
typename T>
 
  313               std::vector<minidump::Directory> ExceptionStreams)
 
  315        StreamMap(
std::
move(StreamMap)),
 
  316        ExceptionStreams(
std::
move(ExceptionStreams)) {}
 
  318  ArrayRef<uint8_t> 
getData()
 const {
 
  324  template <
typename T>
 
  326  getStreamFromDirectory(minidump::Directory Directory) 
const;
 
  330  template <
typename T>
 
  335  template <
typename T>
 
  338  const minidump::Header &Header;
 
  340  DenseMap<minidump::StreamType, std::size_t> StreamMap;
 
  341  std::vector<minidump::Directory> ExceptionStreams;
 
 
  346MinidumpFile::getStreamFromDirectory(minidump::Directory Directory)
 const {
 
  348  if (Stream.size() >= 
sizeof(
T))
 
  349    return *
reinterpret_cast<const T *
>(Stream.data());
 
  350  return createEOFError();
 
  356    if (Stream->size() >= 
sizeof(
T))
 
  357      return *
reinterpret_cast<const T *
>(Stream->data());
 
  358    return createEOFError();
 
  360  return createError(
"No such stream");
 
  364Expected<ArrayRef<T>> MinidumpFile::getDataSliceAs(ArrayRef<uint8_t> 
Data,
 
  368  if (
Count > std::numeric_limits<uint64_t>::max() / 
sizeof(
T))
 
  369    return createEOFError();
 
  370  Expected<ArrayRef<uint8_t>> Slice =
 
  373    return Slice.takeError();
 
  375  return ArrayRef<T>(
reinterpret_cast<const T *
>(Slice->data()), 
Count);
 
  383    return createError(
"No such stream");
 
  384  auto ExpectedSize = getDataSliceAs<support::ulittle32_t>(*Stream, 0, 1);
 
  386    return ExpectedSize.takeError();
 
  388  size_t ListSize = ExpectedSize.get()[0];
 
  390  size_t ListOffset = 4;
 
  394  if (ListOffset + 
sizeof(
T) * ListSize < Stream->
size())
 
  397  return getDataSliceAs<T>(*Stream, ListOffset, ListSize);
 
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
 
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
 
This file defines the DenseMap class.
 
static Expected< const T & > getDataSliceAs(ArrayRef< uint8_t > Data, uint64_t Offset)
 
static Expected< ArrayRef< uint8_t > > getDataSlice(ArrayRef< uint8_t > Data, uint64_t Offset, uint64_t Size)
 
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.
 
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.
 
StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
 
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.
 
StringRef getData() const
 
Binary(unsigned int Type, MemoryBufferRef Source)
 
bool operator!=(const ExceptionStreamsIterator &R) const
 
Expected< const minidump::ExceptionStream & > operator*()
 
ExceptionStreamsIterator & operator++()
 
bool operator==(const ExceptionStreamsIterator &R) const
 
ExceptionStreamsIterator(ArrayRef< minidump::Directory > Streams, const MinidumpFile *File)
 
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
 
LLVM_ABI Expected< iterator_range< MemoryInfoIterator > > getMemoryInfoList() const
Returns the list of descriptors embedded in the MemoryInfoList stream.
 
Expected< const minidump::ExceptionStream & > getExceptionStream(minidump::Directory Directory) const
Returns the contents of the Exception 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 first exception stream in the file.
 
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.
 
LLVM_ABI iterator_range< ExceptionStreamsIterator > getExceptionStreams() const
Returns an iterator that reads each exception stream independently.
 
static bool classof(const Binary *B)
 
LLVM_ABI 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.
 
llvm::fallible_iterator< Memory64Iterator > FallibleMemory64Iterator
 
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.
 
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.
 
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.
 
FunctionAddr VTableAddr Count
 
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
 
FunctionAddr VTableAddr uintptr_t uintptr_t Data
 
ArrayRef(const T &OneElt) -> ArrayRef< T >
 
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.
 
Specifies the location and type of a single stream in the minidump file.
 
LocationDescriptor Location
 
support::little_t< StreamType > Type
 
Specifies the location (and size) of various objects in the minidump file.
 
support::ulittle32_t DataSize
 
support::ulittle64_t DataSize