32 size_t tell()
const {
return NextOffset; }
34 size_t allocateCallback(
size_t Size,
35 std::function<
void(raw_ostream &)> Callback) {
36 size_t Offset = NextOffset;
38 Callbacks.push_back(std::move(Callback));
42 size_t allocateBytes(ArrayRef<uint8_t>
Data) {
43 return allocateCallback(
44 Data.size(), [
Data](raw_ostream &OS) { OS << toStringRef(Data); });
47 size_t allocateBytes(yaml::BinaryRef
Data) {
48 return allocateCallback(
Data.binary_size(), [
Data](raw_ostream &OS) {
49 Data.writeAsBinary(OS);
53 template <
typename T>
size_t allocateArray(ArrayRef<T>
Data) {
54 return allocateBytes({
reinterpret_cast<const uint8_t *
>(
Data.data()),
55 sizeof(
T) *
Data.size()});
58 template <
typename T,
typename RangeType>
59 std::pair<size_t, MutableArrayRef<T>>
62 template <
typename T>
size_t allocateObject(
const T &
Data) {
66 template <
typename T,
typename...
Types>
67 std::pair<size_t, T *> allocateNewObject(Types &&... Args) {
68 T *
Object =
new (Temporaries.Allocate<
T>())
T(std::forward<Types>(Args)...);
69 return {allocateObject(*Object),
Object};
72 size_t allocateString(StringRef Str);
74 void writeTo(raw_ostream &OS)
const;
77 size_t NextOffset = 0;
80 std::vector<std::function<void(raw_ostream &)>> Callbacks;
84template <
typename T,
typename RangeType>
85std::pair<size_t, MutableArrayRef<T>>
87 size_t Num = std::distance(
Range.begin(),
Range.end());
90 return {allocateArray(Array),
Array};
93size_t BlobAllocator::allocateString(StringRef Str) {
96 assert(OK &&
"Invalid UTF8 in Str?");
103 allocateNewObject<support::ulittle32_t>(2 * (WStr.
size() - 1)).first;
108void BlobAllocator::writeTo(raw_ostream &OS)
const {
109 size_t BeginOffset = OS.
tell();
110 for (
const auto &Callback : Callbacks)
112 assert(OS.
tell() == BeginOffset + NextOffset &&
113 "Callbacks wrote an unexpected number of bytes.");
125 size_t DataEnd = File.tell();
144 File.allocateObject(S.
Header);
146 File.allocateObject(
E.Entry);
149 size_t DataEnd = File.tell();
151 File.allocateBytes(
E.Content);
152 if (
E.Entry.DataSize >
E.Content.binary_size()) {
153 size_t Padding =
E.Entry.DataSize -
E.Content.binary_size();
154 File.allocateCallback(Padding, [Padding](
raw_ostream &OS) {
155 OS << std::string(Padding,
'\0');
168 M.Entry.ModuleNameRVA = File.allocateString(M.Name);
170 M.Entry.CvRecord =
layout(File, M.CvRecord);
171 M.Entry.MiscRecord =
layout(File, M.MiscRecord);
175 T.Entry.Stack.Memory =
layout(File,
T.Stack);
176 T.Entry.Context =
layout(File,
T.Context);
179template <
typename EntryT>
185 File.allocateObject(
E.Entry);
187 size_t DataEnd = File.tell();
190 DataEnd = File.tell();
199 Result.Type = S.
Type;
200 Result.Location.RVA = File.tell();
201 std::optional<size_t> DataEnd;
210 InfoList.
Infos.size());
226 Raw.Content.writeAsBinary(OS);
227 assert(Raw.Content.binary_size() <= Raw.Size);
228 OS << std::string(Raw.Size - Raw.Content.binary_size(),
'\0');
236 DataEnd = File.tell();
249 Result.Location.DataSize =
250 DataEnd.value_or(File.tell()) - Result.Location.RVA;
260 File.allocateObject(Obj.
Header);
262 std::vector<Directory> StreamDirectory(Obj.
Streams.size());
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static LocationDescriptor layout(BlobAllocator &File, yaml::BinaryRef Data)
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
LLVM_ATTRIBUTE_RETURNS_NONNULL void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
void push_back(const T &Elt)
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
uint64_t tell() const
tell - Return the current offset with the file.
Specialized YAMLIO scalar type for representing a binary blob.
This class represents a YAML stream potentially containing multiple documents.
llvm::unique_function< void(llvm::Expected< T >)> Callback
A Callback<T> is a void function that accepts Expected<T>.
detail::packed_endian_specific_integral< uint32_t, llvm::endianness::little, unaligned > ulittle32_t
llvm::function_ref< void(const Twine &Msg)> ErrorHandler
LLVM_ABI bool yaml2minidump(MinidumpYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH)
This is an optimization pass for GlobalISel generic memory operations.
ArrayRef< CharT > arrayRefFromStringRef(StringRef Input)
Construct a string ref from an array ref of unsigned chars.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
auto uninitialized_copy(R &&Src, IterTy Dst)
BumpPtrAllocatorImpl BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
MutableArrayRef(T &OneElt) -> MutableArrayRef< T >
iterator_range(Container &&) -> iterator_range< llvm::detail::IterOfRange< Container > >
FunctionAddr VTableAddr uintptr_t uintptr_t Data
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool convertUTF8ToUTF16String(StringRef SrcUTF8, SmallVectorImpl< UTF16 > &DstUTF16)
Converts a UTF-8 string into a UTF-16 string with native endianness.
ExceptionStream minidump stream.
minidump::ExceptionStream MDExceptionStream
yaml::BinaryRef ThreadContext
minidump::Memory64ListHeader Header
A structure containing the list of MemoryInfo entries comprising a MemoryInfoList stream.
std::vector< minidump::MemoryInfo > Infos
The top level structure representing a minidump object, consisting of a minidump header,...
std::vector< std::unique_ptr< Stream > > Streams
The list of streams in this minidump object.
minidump::Header Header
The minidump header.
A minidump stream represented as a sequence of hex bytes.
The base class for all minidump streams.
const minidump::StreamType Type
SystemInfo minidump stream.
A stream representing a list of abstract entries in a minidump stream.
detail::ParsedMemoryDescriptor entry_type
std::vector< entry_type > Entries
Specifies the location and type of a single stream in the minidump file.
LocationDescriptor ThreadContext
Specifies the location (and size) of various objects in the minidump file.
The SystemInfo stream, containing various information about the system where this minidump was genera...
support::ulittle32_t CSDVersionRVA
Common declarations for yaml2obj.