31 size_t tell()
const {
return NextOffset; }
33 size_t allocateCallback(
size_t Size,
35 size_t Offset = NextOffset;
37 Callbacks.push_back(std::move(Callback));
42 return allocateCallback(
52 template <
typename T>
size_t allocateArray(
ArrayRef<T> Data) {
53 return allocateBytes({
reinterpret_cast<const uint8_t *
>(Data.
data()),
54 sizeof(
T) * Data.
size()});
57 template <
typename T,
typename RangeType>
58 std::pair<size_t, MutableArrayRef<T>>
61 template <
typename T>
size_t allocateObject(
const T &Data) {
65 template <
typename T,
typename... Types>
66 std::pair<size_t, T *> allocateNewObject(Types &&...
Args) {
67 T *
Object =
new (Temporaries.Allocate<
T>())
T(std::forward<Types>(
Args)...);
68 return {allocateObject(*Object), Object};
76 size_t NextOffset = 0;
79 std::vector<std::function<void(raw_ostream &)>> Callbacks;
83 template <
typename T,
typename RangeType>
84 std::pair<size_t, MutableArrayRef<T>>
86 size_t Num = std::distance(Range.
begin(), Range.
end());
88 std::uninitialized_copy(Range.
begin(), Range.
end(),
Array.begin());
89 return {allocateArray(Array),
Array};
92 size_t BlobAllocator::allocateString(
StringRef Str) {
95 assert(OK &&
"Invalid UTF8 in Str?");
102 allocateNewObject<support::ulittle32_t>(2 * (WStr.
size() - 1)).first;
107 void BlobAllocator::writeTo(
raw_ostream &OS)
const {
108 size_t BeginOffset = OS.
tell();
109 for (
const auto &Callback : Callbacks)
111 assert(OS.
tell() == BeginOffset + NextOffset &&
112 "Callbacks wrote an unexpected number of bytes.");
124 size_t DataEnd = File.tell();
139 Range.Entry.Memory =
layout(File, Range.Content);
143 M.Entry.ModuleNameRVA = File.allocateString(M.Name);
145 M.Entry.CvRecord =
layout(File, M.CvRecord);
146 M.Entry.MiscRecord =
layout(File, M.MiscRecord);
150 T.Entry.Stack.Memory =
layout(File, T.Stack);
151 T.Entry.Context =
layout(File, T.Context);
154 template <
typename EntryT>
155 static size_t layout(BlobAllocator &File,
160 File.allocateObject(
E.Entry);
162 size_t DataEnd = File.tell();
165 DataEnd = File.tell();
178 case Stream::StreamKind::Exception:
179 DataEnd =
layout(File, cast<MinidumpYAML::ExceptionStream>(S));
181 case Stream::StreamKind::MemoryInfoList: {
185 InfoList.
Infos.size());
189 case Stream::StreamKind::MemoryList:
190 DataEnd =
layout(File, cast<MemoryListStream>(S));
192 case Stream::StreamKind::ModuleList:
193 DataEnd =
layout(File, cast<ModuleListStream>(S));
195 case Stream::StreamKind::RawContent: {
198 Raw.Content.writeAsBinary(OS);
199 assert(Raw.Content.binary_size() <= Raw.Size);
200 OS << std::string(Raw.Size - Raw.Content.binary_size(),
'\0');
204 case Stream::StreamKind::SystemInfo: {
206 File.allocateObject(SystemInfo.
Info);
208 DataEnd = File.tell();
212 case Stream::StreamKind::TextContent:
215 case Stream::StreamKind::ThreadList:
216 DataEnd =
layout(File, cast<ThreadListStream>(S));
232 File.allocateObject(Obj.
Header);
234 std::vector<Directory> StreamDirectory(Obj.
Streams.size());
SystemInfo minidump stream.
This class represents lattice values for constants.
Specifies the location (and size) of various objects in the minidump file.
void push_back(const T &Elt)
constexpr T getValueOr(U &&value) const LLVM_LVALUE_FUNCTION
An efficient, type-erasing, non-owning reference to a callable.
ArrayRef< uint8_t > arrayRefFromStringRef(StringRef Input)
Construct a string ref from an array ref of unsigned chars.
minidump::Header Header
The minidump header.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
minidump::ExceptionStream MDExceptionStream
bool convertUTF8ToUTF16String(StringRef SrcUTF8, SmallVectorImpl< UTF16 > &DstUTF16)
Converts a UTF-8 string into a UTF-16 string with native endianness.
void writeAsBinary(raw_ostream &OS, uint64_t N=UINT64_MAX) const
Write the contents (regardless of whether it is binary or a hex string) as binary to the given raw_os...
yaml::BinaryRef ThreadContext
The top level structure representing a minidump object, consisting of a minidump header, and zero or more streams.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
detail::packed_endian_specific_integral< uint32_t, little, unaligned > ulittle32_t
Allocate memory in an ever growing pool, as if by bump-pointer.
Instrumentation for Order File
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
A stream representing a list of abstract entries in a minidump stream.
StringRef toStringRef(bool B)
Construct a string ref from a boolean.
ArrayRef< uint8_t >::size_type binary_size() const
The number of bytes that are represented by this BinaryRef.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
ExceptionStream minidump stream.
The base class for all minidump streams.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
This class represents a YAML stream potentially containing multiple documents.
Common declarations for yaml2obj.
std::vector< std::unique_ptr< Stream > > Streams
The list of streams in this minidump object.
A minidump stream represented as a sequence of hex bytes.
LocationDescriptor Location
bool yaml2minidump(MinidumpYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH)
A range adaptor for a pair of iterators.
minidump::SystemInfo Info
Specialized YAMLIO scalar type for representing a binary blob.
support::ulittle32_t DataSize
static LocationDescriptor layout(BlobAllocator &File, yaml::BinaryRef Data)
Specifies the location and type of a single stream in the minidump file.
std::vector< minidump::MemoryInfo > Infos
support::ulittle32_t CSDVersionRVA
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
uint64_t tell() const
tell - Return the current offset with the file.
This class implements an extremely fast bulk output stream that can only output to a stream...
print Print MemDeps of function
A structure containing the list of MemoryInfo entries comprising a MemoryInfoList stream...
StringRef - Represent a constant reference to a string, i.e.
const minidump::StreamType Type
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
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 ...
LocationDescriptor ThreadContext
support::little_t< StreamType > Type
The SystemInfo stream, containing various information about the system where this minidump was genera...
std::vector< entry_type > Entries