LLVM  9.0.0svn
MinidumpYAML.cpp
Go to the documentation of this file.
1 //===- MinidumpYAML.cpp - Minidump YAMLIO implementation ------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 #include "llvm/Support/Allocator.h"
12 
13 using namespace llvm;
14 using namespace llvm::MinidumpYAML;
15 using namespace llvm::minidump;
16 
17 namespace {
18 /// A helper class to manage the placement of various structures into the final
19 /// minidump binary. Space for objects can be allocated via various allocate***
20 /// methods, while the final minidump file is written by calling the writeTo
21 /// method. The plain versions of allocation functions take a reference to the
22 /// data which is to be written (and hence the data must be available until
23 /// writeTo is called), while the "New" versions allocate the data in an
24 /// allocator-managed buffer, which is available until the allocator object is
25 /// destroyed. For both kinds of functions, it is possible to modify the
26 /// data for which the space has been "allocated" until the final writeTo call.
27 /// This is useful for "linking" the allocated structures via their offsets.
28 class BlobAllocator {
29 public:
30  size_t tell() const { return NextOffset; }
31 
32  size_t allocateCallback(size_t Size,
33  std::function<void(raw_ostream &)> Callback) {
34  size_t Offset = NextOffset;
35  NextOffset += Size;
36  Callbacks.push_back(std::move(Callback));
37  return Offset;
38  }
39 
40  size_t allocateBytes(ArrayRef<uint8_t> Data) {
41  return allocateCallback(
42  Data.size(), [Data](raw_ostream &OS) { OS << toStringRef(Data); });
43  }
44 
45  size_t allocateBytes(yaml::BinaryRef Data) {
46  return allocateCallback(Data.binary_size(), [Data](raw_ostream &OS) {
47  Data.writeAsBinary(OS);
48  });
49  }
50 
51  template <typename T> size_t allocateArray(ArrayRef<T> Data) {
52  return allocateBytes({reinterpret_cast<const uint8_t *>(Data.data()),
53  sizeof(T) * Data.size()});
54  }
55 
56  template <typename T, typename RangeType>
57  std::pair<size_t, MutableArrayRef<T>>
58  allocateNewArray(const iterator_range<RangeType> &Range);
59 
60  template <typename T> size_t allocateObject(const T &Data) {
61  return allocateArray(makeArrayRef(Data));
62  }
63 
64  template <typename T, typename... Types>
65  std::pair<size_t, T *> allocateNewObject(Types &&... Args) {
66  T *Object = new (Temporaries.Allocate<T>()) T(std::forward<Types>(Args)...);
67  return {allocateObject(*Object), Object};
68  }
69 
70  size_t allocateString(StringRef Str);
71 
72  void writeTo(raw_ostream &OS) const;
73 
74 private:
75  size_t NextOffset = 0;
76 
77  BumpPtrAllocator Temporaries;
78  std::vector<std::function<void(raw_ostream &)>> Callbacks;
79 };
80 } // namespace
81 
82 template <typename T, typename RangeType>
83 std::pair<size_t, MutableArrayRef<T>>
84 BlobAllocator::allocateNewArray(const iterator_range<RangeType> &Range) {
85  size_t Num = std::distance(Range.begin(), Range.end());
86  MutableArrayRef<T> Array(Temporaries.Allocate<T>(Num), Num);
87  std::uninitialized_copy(Range.begin(), Range.end(), Array.begin());
88  return {allocateArray(Array), Array};
89 }
90 
91 size_t BlobAllocator::allocateString(StringRef Str) {
93  bool OK = convertUTF8ToUTF16String(Str, WStr);
94  assert(OK && "Invalid UTF8 in Str?");
95  (void)OK;
96 
97  // The utf16 string is null-terminated, but the terminator is not counted in
98  // the string size.
99  WStr.push_back(0);
100  size_t Result =
101  allocateNewObject<support::ulittle32_t>(2 * (WStr.size() - 1)).first;
102  allocateNewArray<support::ulittle16_t>(make_range(WStr.begin(), WStr.end()));
103  return Result;
104 }
105 
106 void BlobAllocator::writeTo(raw_ostream &OS) const {
107  size_t BeginOffset = OS.tell();
108  for (const auto &Callback : Callbacks)
109  Callback(OS);
110  assert(OS.tell() == BeginOffset + NextOffset &&
111  "Callbacks wrote an unexpected number of bytes.");
112  (void)BeginOffset;
113 }
114 
115 /// Perform an optional yaml-mapping of an endian-aware type EndianType. The
116 /// only purpose of this function is to avoid casting the Default value to the
117 /// endian type;
118 template <typename EndianType>
119 static inline void mapOptional(yaml::IO &IO, const char *Key, EndianType &Val,
120  typename EndianType::value_type Default) {
121  IO.mapOptional(Key, Val, EndianType(Default));
122 }
123 
124 /// Yaml-map an endian-aware type EndianType as some other type MapType.
125 template <typename MapType, typename EndianType>
126 static inline void mapRequiredAs(yaml::IO &IO, const char *Key,
127  EndianType &Val) {
128  MapType Mapped = static_cast<typename EndianType::value_type>(Val);
129  IO.mapRequired(Key, Mapped);
130  Val = static_cast<typename EndianType::value_type>(Mapped);
131 }
132 
133 /// Perform an optional yaml-mapping of an endian-aware type EndianType as some
134 /// other type MapType.
135 template <typename MapType, typename EndianType>
136 static inline void mapOptionalAs(yaml::IO &IO, const char *Key, EndianType &Val,
137  MapType Default) {
138  MapType Mapped = static_cast<typename EndianType::value_type>(Val);
139  IO.mapOptional(Key, Mapped, Default);
140  Val = static_cast<typename EndianType::value_type>(Mapped);
141 }
142 
143 namespace {
144 /// Return the appropriate yaml Hex type for a given endian-aware type.
145 template <typename EndianType> struct HexType;
146 template <> struct HexType<support::ulittle16_t> { using type = yaml::Hex16; };
147 template <> struct HexType<support::ulittle32_t> { using type = yaml::Hex32; };
148 template <> struct HexType<support::ulittle64_t> { using type = yaml::Hex64; };
149 } // namespace
150 
151 /// Yaml-map an endian-aware type as an appropriately-sized hex value.
152 template <typename EndianType>
153 static inline void mapRequiredHex(yaml::IO &IO, const char *Key,
154  EndianType &Val) {
155  mapRequiredAs<typename HexType<EndianType>::type>(IO, Key, Val);
156 }
157 
158 /// Perform an optional yaml-mapping of an endian-aware type as an
159 /// appropriately-sized hex value.
160 template <typename EndianType>
161 static inline void mapOptionalHex(yaml::IO &IO, const char *Key,
162  EndianType &Val,
163  typename EndianType::value_type Default) {
164  mapOptionalAs<typename HexType<EndianType>::type>(IO, Key, Val, Default);
165 }
166 
167 Stream::~Stream() = default;
168 
170  switch (Type) {
171  case StreamType::ModuleList:
172  return StreamKind::ModuleList;
173  case StreamType::SystemInfo:
174  return StreamKind::SystemInfo;
175  case StreamType::LinuxCPUInfo:
176  case StreamType::LinuxProcStatus:
177  case StreamType::LinuxLSBRelease:
178  case StreamType::LinuxCMDLine:
179  case StreamType::LinuxMaps:
180  case StreamType::LinuxProcStat:
181  case StreamType::LinuxProcUptime:
182  return StreamKind::TextContent;
183  default:
184  return StreamKind::RawContent;
185  }
186 }
187 
188 std::unique_ptr<Stream> Stream::create(StreamType Type) {
189  StreamKind Kind = getKind(Type);
190  switch (Kind) {
191  case StreamKind::ModuleList:
192  return llvm::make_unique<ModuleListStream>();
193  case StreamKind::RawContent:
194  return llvm::make_unique<RawContentStream>(Type);
195  case StreamKind::SystemInfo:
196  return llvm::make_unique<SystemInfoStream>();
197  case StreamKind::TextContent:
198  return llvm::make_unique<TextContentStream>(Type);
199  }
200  llvm_unreachable("Unhandled stream kind!");
201 }
202 
203 void yaml::ScalarEnumerationTraits<ProcessorArchitecture>::enumeration(
204  IO &IO, ProcessorArchitecture &Arch) {
205 #define HANDLE_MDMP_ARCH(CODE, NAME) \
206  IO.enumCase(Arch, #NAME, ProcessorArchitecture::NAME);
207 #include "llvm/BinaryFormat/MinidumpConstants.def"
208  IO.enumFallback<Hex16>(Arch);
209 }
210 
211 void yaml::ScalarEnumerationTraits<OSPlatform>::enumeration(IO &IO,
212  OSPlatform &Plat) {
213 #define HANDLE_MDMP_PLATFORM(CODE, NAME) \
214  IO.enumCase(Plat, #NAME, OSPlatform::NAME);
215 #include "llvm/BinaryFormat/MinidumpConstants.def"
216  IO.enumFallback<Hex32>(Plat);
217 }
218 
219 void yaml::ScalarEnumerationTraits<StreamType>::enumeration(IO &IO,
220  StreamType &Type) {
221 #define HANDLE_MDMP_STREAM_TYPE(CODE, NAME) \
222  IO.enumCase(Type, #NAME, StreamType::NAME);
223 #include "llvm/BinaryFormat/MinidumpConstants.def"
224  IO.enumFallback<Hex32>(Type);
225 }
226 
229  mapRequiredHex(IO, "CPUID", Info.CPUID);
230  mapOptionalHex(IO, "ELF hwcaps", Info.ElfHWCaps, 0);
231 }
232 
233 namespace {
234 template <std::size_t N> struct FixedSizeHex {
235  FixedSizeHex(uint8_t (&Storage)[N]) : Storage(Storage) {}
236 
237  uint8_t (&Storage)[N];
238 };
239 } // namespace
240 
241 namespace llvm {
242 namespace yaml {
243 template <std::size_t N> struct ScalarTraits<FixedSizeHex<N>> {
244  static void output(const FixedSizeHex<N> &Fixed, void *, raw_ostream &OS) {
245  OS << toHex(makeArrayRef(Fixed.Storage));
246  }
247 
248  static StringRef input(StringRef Scalar, void *, FixedSizeHex<N> &Fixed) {
249  if (!all_of(Scalar, isHexDigit))
250  return "Invalid hex digit in input";
251  if (Scalar.size() < 2 * N)
252  return "String too short";
253  if (Scalar.size() > 2 * N)
254  return "String too long";
255  copy(fromHex(Scalar), Fixed.Storage);
256  return "";
257  }
258 
259  static QuotingType mustQuote(StringRef S) { return QuotingType::None; }
260 };
261 } // namespace yaml
262 } // namespace llvm
264  IO &IO, CPUInfo::OtherInfo &Info) {
265  FixedSizeHex<sizeof(Info.ProcessorFeatures)> Features(Info.ProcessorFeatures);
266  IO.mapRequired("Features", Features);
267 }
268 
269 namespace {
270 /// A type which only accepts strings of a fixed size for yaml conversion.
271 template <std::size_t N> struct FixedSizeString {
272  FixedSizeString(char (&Storage)[N]) : Storage(Storage) {}
273 
274  char (&Storage)[N];
275 };
276 } // namespace
277 
278 namespace llvm {
279 namespace yaml {
280 template <std::size_t N> struct ScalarTraits<FixedSizeString<N>> {
281  static void output(const FixedSizeString<N> &Fixed, void *, raw_ostream &OS) {
282  OS << StringRef(Fixed.Storage, N);
283  }
284 
285  static StringRef input(StringRef Scalar, void *, FixedSizeString<N> &Fixed) {
286  if (Scalar.size() < N)
287  return "String too short";
288  if (Scalar.size() > N)
289  return "String too long";
290  copy(Scalar, Fixed.Storage);
291  return "";
292  }
293 
294  static QuotingType mustQuote(StringRef S) { return needsQuotes(S); }
295 };
296 } // namespace yaml
297 } // namespace llvm
298 
300  CPUInfo::X86Info &Info) {
301  FixedSizeString<sizeof(Info.VendorID)> VendorID(Info.VendorID);
302  IO.mapRequired("Vendor ID", VendorID);
303 
304  mapRequiredHex(IO, "Version Info", Info.VersionInfo);
305  mapRequiredHex(IO, "Feature Info", Info.FeatureInfo);
306  mapOptionalHex(IO, "AMD Extended Features", Info.AMDExtendedFeatures, 0);
307 }
308 
310  VSFixedFileInfo &Info) {
311  mapOptionalHex(IO, "Signature", Info.Signature, 0);
312  mapOptionalHex(IO, "Struct Version", Info.StructVersion, 0);
313  mapOptionalHex(IO, "File Version High", Info.FileVersionHigh, 0);
314  mapOptionalHex(IO, "File Version Low", Info.FileVersionLow, 0);
315  mapOptionalHex(IO, "Product Version High", Info.ProductVersionHigh, 0);
316  mapOptionalHex(IO, "Product Version Low", Info.ProductVersionLow, 0);
317  mapOptionalHex(IO, "File Flags Mask", Info.FileFlagsMask, 0);
318  mapOptionalHex(IO, "File Flags", Info.FileFlags, 0);
319  mapOptionalHex(IO, "File OS", Info.FileOS, 0);
320  mapOptionalHex(IO, "File Type", Info.FileType, 0);
321  mapOptionalHex(IO, "File Subtype", Info.FileSubtype, 0);
322  mapOptionalHex(IO, "File Date High", Info.FileDateHigh, 0);
323  mapOptionalHex(IO, "File Date Low", Info.FileDateLow, 0);
324 }
325 
327  IO &IO, ModuleListStream::ParsedModule &M) {
328  mapRequiredHex(IO, "Base of Image", M.Module.BaseOfImage);
329  mapRequiredHex(IO, "Size of Image", M.Module.SizeOfImage);
330  mapOptionalHex(IO, "Checksum", M.Module.Checksum, 0);
331  IO.mapOptional("Time Date Stamp", M.Module.TimeDateStamp,
333  IO.mapRequired("Module Name", M.Name);
334  IO.mapOptional("Version Info", M.Module.VersionInfo, VSFixedFileInfo());
335  IO.mapRequired("CodeView Record", M.CvRecord);
336  IO.mapOptional("Misc Record", M.MiscRecord, yaml::BinaryRef());
337  mapOptionalHex(IO, "Reserved0", M.Module.Reserved0, 0);
338  mapOptionalHex(IO, "Reserved1", M.Module.Reserved1, 0);
339 }
340 
341 static void streamMapping(yaml::IO &IO, RawContentStream &Stream) {
342  IO.mapOptional("Content", Stream.Content);
343  IO.mapOptional("Size", Stream.Size, Stream.Content.binary_size());
344 }
345 
347  if (Stream.Size.value < Stream.Content.binary_size())
348  return "Stream size must be greater or equal to the content size";
349  return "";
350 }
351 
352 static void streamMapping(yaml::IO &IO, ModuleListStream &Stream) {
353  IO.mapRequired("Modules", Stream.Modules);
354 }
355 
356 static void streamMapping(yaml::IO &IO, SystemInfoStream &Stream) {
357  SystemInfo &Info = Stream.Info;
358  IO.mapRequired("Processor Arch", Info.ProcessorArch);
359  mapOptional(IO, "Processor Level", Info.ProcessorLevel, 0);
360  mapOptional(IO, "Processor Revision", Info.ProcessorRevision, 0);
361  IO.mapOptional("Number of Processors", Info.NumberOfProcessors, 0);
362  IO.mapOptional("Product type", Info.ProductType, 0);
363  mapOptional(IO, "Major Version", Info.MajorVersion, 0);
364  mapOptional(IO, "Minor Version", Info.MinorVersion, 0);
365  mapOptional(IO, "Build Number", Info.BuildNumber, 0);
366  IO.mapRequired("Platform ID", Info.PlatformId);
367  IO.mapOptional("CSD Version", Stream.CSDVersion, "");
368  mapOptionalHex(IO, "Suite Mask", Info.SuiteMask, 0);
369  mapOptionalHex(IO, "Reserved", Info.Reserved, 0);
370  switch (static_cast<ProcessorArchitecture>(Info.ProcessorArch)) {
371  case ProcessorArchitecture::X86:
372  case ProcessorArchitecture::AMD64:
373  IO.mapOptional("CPU", Info.CPU.X86);
374  break;
376  case ProcessorArchitecture::ARM64:
377  IO.mapOptional("CPU", Info.CPU.Arm);
378  break;
379  default:
380  IO.mapOptional("CPU", Info.CPU.Other);
381  break;
382  }
383 }
384 
385 static void streamMapping(yaml::IO &IO, TextContentStream &Stream) {
386  IO.mapOptional("Text", Stream.Text);
387 }
388 
390  yaml::IO &IO, std::unique_ptr<MinidumpYAML::Stream> &S) {
391  StreamType Type;
392  if (IO.outputting())
393  Type = S->Type;
394  IO.mapRequired("Type", Type);
395 
396  if (!IO.outputting())
398  switch (S->Kind) {
400  streamMapping(IO, llvm::cast<ModuleListStream>(*S));
401  break;
403  streamMapping(IO, llvm::cast<RawContentStream>(*S));
404  break;
406  streamMapping(IO, llvm::cast<SystemInfoStream>(*S));
407  break;
409  streamMapping(IO, llvm::cast<TextContentStream>(*S));
410  break;
411  }
412 }
413 
415  yaml::IO &IO, std::unique_ptr<MinidumpYAML::Stream> &S) {
416  switch (S->Kind) {
418  return streamValidate(cast<RawContentStream>(*S));
422  return "";
423  }
424  llvm_unreachable("Fully covered switch above!");
425 }
426 
428  IO.mapTag("!minidump", true);
429  mapOptionalHex(IO, "Signature", O.Header.Signature, Header::MagicSignature);
430  mapOptionalHex(IO, "Version", O.Header.Version, Header::MagicVersion);
431  mapOptionalHex(IO, "Flags", O.Header.Flags, 0);
432  IO.mapRequired("Streams", O.Streams);
433 }
434 
435 static Directory layout(BlobAllocator &File, Stream &S) {
436  Directory Result;
437  Result.Type = S.Type;
438  Result.Location.RVA = File.tell();
439  Optional<size_t> DataEnd;
440  switch (S.Kind) {
442  ModuleListStream &List = cast<ModuleListStream>(S);
443 
444  File.allocateNewObject<support::ulittle32_t>(List.Modules.size());
446  File.allocateObject(M.Module);
447 
448  // Module names and CodeView/Misc records are not a part of the stream.
449  DataEnd = File.tell();
450  for (ModuleListStream::ParsedModule &M : List.Modules) {
451  M.Module.ModuleNameRVA = File.allocateString(M.Name);
452 
453  M.Module.CvRecord.RVA = File.allocateBytes(M.CvRecord);
455 
456  M.Module.MiscRecord.RVA = File.allocateBytes(M.MiscRecord);
458  }
459  break;
460  }
462  RawContentStream &Raw = cast<RawContentStream>(S);
463  File.allocateCallback(Raw.Size, [&Raw](raw_ostream &OS) {
464  Raw.Content.writeAsBinary(OS);
465  assert(Raw.Content.binary_size() <= Raw.Size);
466  OS << std::string(Raw.Size - Raw.Content.binary_size(), '\0');
467  });
468  break;
469  }
471  SystemInfoStream &SystemInfo = cast<SystemInfoStream>(S);
472  File.allocateObject(SystemInfo.Info);
473  // The CSD string is not a part of the stream.
474  DataEnd = File.tell();
475  SystemInfo.Info.CSDVersionRVA = File.allocateString(SystemInfo.CSDVersion);
476  break;
477  }
479  File.allocateArray(arrayRefFromStringRef(cast<TextContentStream>(S).Text));
480  break;
481  }
482  // If DataEnd is not set, we assume everything we generated is a part of the
483  // stream.
484  Result.Location.DataSize =
485  DataEnd.getValueOr(File.tell()) - Result.Location.RVA;
486  return Result;
487 }
488 
490  BlobAllocator File;
491  File.allocateObject(Obj.Header);
492 
493  std::vector<Directory> StreamDirectory(Obj.Streams.size());
495  File.allocateArray(makeArrayRef(StreamDirectory));
496  Obj.Header.NumberOfStreams = StreamDirectory.size();
497 
498  for (auto &Stream : enumerate(Obj.Streams))
499  StreamDirectory[Stream.index()] = layout(File, *Stream.value());
500 
501  File.writeTo(OS);
502 }
503 
505  yaml::Input Input(Yaml);
506  Object Obj;
507  Input >> Obj;
508  if (std::error_code EC = Input.error())
509  return errorCodeToError(EC);
510 
511  writeAsBinary(Obj, OS);
512  return Error::success();
513 }
514 
516 Stream::create(const Directory &StreamDesc, const object::MinidumpFile &File) {
517  StreamKind Kind = getKind(StreamDesc.Type);
518  switch (Kind) {
519  case StreamKind::ModuleList: {
520  auto ExpectedList = File.getModuleList();
521  if (!ExpectedList)
522  return ExpectedList.takeError();
523  std::vector<ModuleListStream::ParsedModule> Modules;
524  for (const Module &M : *ExpectedList) {
525  auto ExpectedName = File.getString(M.ModuleNameRVA);
526  if (!ExpectedName)
527  return ExpectedName.takeError();
528  auto ExpectedCv = File.getRawData(M.CvRecord);
529  if (!ExpectedCv)
530  return ExpectedCv.takeError();
531  auto ExpectedMisc = File.getRawData(M.MiscRecord);
532  if (!ExpectedMisc)
533  return ExpectedMisc.takeError();
534  Modules.push_back(
535  {M, std::move(*ExpectedName), *ExpectedCv, *ExpectedMisc});
536  }
537  return llvm::make_unique<ModuleListStream>(std::move(Modules));
538  }
539  case StreamKind::RawContent:
540  return llvm::make_unique<RawContentStream>(StreamDesc.Type,
541  File.getRawStream(StreamDesc));
542  case StreamKind::SystemInfo: {
543  auto ExpectedInfo = File.getSystemInfo();
544  if (!ExpectedInfo)
545  return ExpectedInfo.takeError();
546  auto ExpectedCSDVersion = File.getString(ExpectedInfo->CSDVersionRVA);
547  if (!ExpectedCSDVersion)
548  return ExpectedInfo.takeError();
549  return llvm::make_unique<SystemInfoStream>(*ExpectedInfo,
550  std::move(*ExpectedCSDVersion));
551  }
552  case StreamKind::TextContent:
553  return llvm::make_unique<TextContentStream>(
554  StreamDesc.Type, toStringRef(File.getRawStream(StreamDesc)));
555  }
556  llvm_unreachable("Unhandled stream kind!");
557 }
558 
560  std::vector<std::unique_ptr<Stream>> Streams;
561  Streams.reserve(File.streams().size());
562  for (const Directory &StreamDesc : File.streams()) {
563  auto ExpectedStream = Stream::create(StreamDesc, File);
564  if (!ExpectedStream)
565  return ExpectedStream.takeError();
566  Streams.push_back(std::move(*ExpectedStream));
567  }
568  return Object(File.header(), std::move(Streams));
569 }
Expected< ArrayRef< minidump::Module > > getModuleList() const
Returns the module list embedded in the ModuleList stream.
Definition: Minidump.cpp:56
support::ulittle32_t FeatureInfo
Definition: Minidump.h:91
static void output(const FixedSizeString< N > &Fixed, void *, raw_ostream &OS)
SystemInfo minidump stream.
Definition: MinidumpYAML.h:93
static Expected< Object > create(const object::MinidumpFile &File)
This class represents lattice values for constants.
Definition: AllocatorList.h:23
A stream representing the list of modules loaded in the process.
Definition: MinidumpYAML.h:59
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
static void mapRequiredHex(yaml::IO &IO, const char *Key, EndianType &Val)
Yaml-map an endian-aware type as an appropriately-sized hex value.
support::ulittle32_t NumberOfStreams
Definition: Minidump.h:37
static StringRef input(StringRef Scalar, void *, FixedSizeHex< N > &Fixed)
struct llvm::minidump::CPUInfo::X86Info X86
constexpr T getValueOr(U &&value) const LLVM_LVALUE_FUNCTION
Definition: Optional.h:266
support::ulittle32_t ModuleNameRVA
Definition: Minidump.h:153
support::ulittle32_t Signature
Definition: Minidump.h:33
LocationDescriptor CvRecord
Definition: Minidump.h:155
ProcessorArchitecture
The processor architecture of the system that generated this minidump.
Definition: Minidump.h:73
ArrayRef< uint8_t > arrayRefFromStringRef(StringRef Input)
Construct a string ref from an array ref of unsigned chars.
Definition: StringExtras.h:60
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:1185
struct llvm::minidump::CPUInfo::OtherInfo Other
detail::packed_endian_specific_integral< uint16_t, little, unaligned > ulittle16_t
Definition: Endian.h:272
static StringRef input(StringRef Scalar, void *, FixedSizeString< N > &Fixed)
ArrayRef< minidump::Directory > streams() const
Returns the list of streams (stream directory entries) in this file.
Definition: Minidump.h:35
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
std::string fromHex(StringRef Input)
Convert hexadecimal string Input to its binary representation.
Definition: StringExtras.h:170
Expected< std::string > getString(size_t Offset) const
Returns the minidump string at the given offset.
Definition: Minidump.cpp:25
detail::packed_endian_specific_integral< uint64_t, little, unaligned > ulittle64_t
Definition: Endian.h:276
support::ulittle32_t SizeOfImage
Definition: Minidump.h:150
support::ulittle32_t Signature
Definition: Minidump.h:128
minidump::Header Header
The minidump header.
Definition: MinidumpYAML.h:144
support::ulittle32_t Checksum
Definition: Minidump.h:151
OSPlatform
The OS Platform of the system that generated this minidump.
Definition: Minidump.h:80
support::ulittle32_t BuildNumber
Definition: Minidump.h:116
support::ulittle64_t Flags
Definition: Minidump.h:41
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:450
StreamType
The type of a minidump stream identifies its contents.
Definition: Minidump.h:47
support::ulittle32_t ElfHWCaps
Definition: Minidump.h:96
const minidump::Header & header() const
Returns the contents of the minidump header.
Definition: Minidump.h:32
support::ulittle64_t Reserved0
Definition: Minidump.h:157
support::ulittle32_t FileOS
Definition: Minidump.h:136
Tagged union holding either a T or a Error.
Definition: CachePruning.h:22
support::ulittle32_t StreamDirectoryRVA
Definition: Minidump.h:38
support::little_t< ProcessorArchitecture > ProcessorArch
Definition: Minidump.h:107
Key
PAL metadata keys.
support::ulittle32_t MajorVersion
Definition: Minidump.h:114
support::ulittle32_t VersionInfo
Definition: Minidump.h:90
Expected< const minidump::SystemInfo & > getSystemInfo() const
Returns the contents of the SystemInfo stream, cast to the appropriate type.
Definition: Minidump.h:61
#define T
LLVM_NODISCARD size_t size() const
size - Get the string size.
Definition: StringRef.h:130
void writeAsBinary(Object &Obj, raw_ostream &OS)
Serialize the minidump file represented by Obj to OS in binary form.
bool convertUTF8ToUTF16String(StringRef SrcUTF8, SmallVectorImpl< UTF16 > &DstUTF16)
Converts a UTF-8 string into a UTF-16 string with native endianness.
static void streamMapping(yaml::IO &IO, RawContentStream &Stream)
support::ulittle32_t FileSubtype
Definition: Minidump.h:138
Analysis containing CSE Info
Definition: CSEInfo.cpp:20
support::ulittle16_t SuiteMask
Definition: Minidump.h:120
static void output(const FixedSizeHex< N > &Fixed, void *, raw_ostream &OS)
The top level structure representing a minidump object, consisting of a minidump header, and zero or more streams.
Definition: MinidumpYAML.h:132
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:290
support::ulittle16_t Reserved
Definition: Minidump.h:121
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
detail::packed_endian_specific_integral< uint32_t, little, unaligned > ulittle32_t
Definition: Endian.h:274
VSFixedFileInfo VersionInfo
Definition: Minidump.h:154
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:140
support::ulittle32_t AMDExtendedFeatures
Definition: Minidump.h:92
Instrumentation for Order File
static void mapRequiredAs(yaml::IO &IO, const char *Key, EndianType &Val)
Yaml-map an endian-aware type EndianType as some other type MapType.
static StreamKind getKind(minidump::StreamType Type)
Get the stream Kind used for representing streams of a given Type.
support::ulittle64_t Reserved1
Definition: Minidump.h:158
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:148
bool isHexDigit(char C)
Checks if character C is a hexadecimal numeric character.
Definition: StringExtras.h:79
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
Definition: Error.cpp:87
void writeAsBinary(raw_ostream &OS) const
Write the contents (regardless of whether it is binary or a hex string) as binary to the given raw_os...
Definition: YAML.cpp:40
Expected< ArrayRef< uint8_t > > getRawData(minidump::LocationDescriptor Desc) const
Returns the raw contents of an object given by the LocationDescriptor.
Definition: Minidump.h:49
static QuotingType mustQuote(StringRef S)
static void mapOptionalAs(yaml::IO &IO, const char *Key, EndianType &Val, MapType Default)
Perform an optional yaml-mapping of an endian-aware type EndianType as some other type MapType...
std::vector< ParsedModule > Modules
Definition: MinidumpYAML.h:66
StringRef toStringRef(bool B)
Construct a string ref from a boolean.
Definition: StringExtras.h:52
size_t size() const
Definition: SmallVector.h:52
ArrayRef< uint8_t > getRawStream(const minidump::Directory &Stream) const
Returns the raw contents of the stream given by the directory entry.
Definition: Minidump.h:38
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const T * data() const
Definition: ArrayRef.h:145
struct llvm::minidump::CPUInfo::ArmInfo Arm
support::ulittle32_t FileDateLow
Definition: Minidump.h:140
ArrayRef< uint8_t >::size_type binary_size() const
The number of bytes that are represented by this BinaryRef.
Definition: YAML.h:80
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
static ErrorSuccess success()
Create a success value.
Definition: Error.h:326
support::ulittle32_t Version
Definition: Minidump.h:36
LocationDescriptor MiscRecord
Definition: Minidump.h:156
The base class for all minidump streams.
Definition: MinidumpYAML.h:27
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:841
support::ulittle16_t ProcessorRevision
Definition: Minidump.h:109
support::ulittle32_t MinorVersion
Definition: Minidump.h:115
std::vector< std::unique_ptr< Stream > > Streams
The list of streams in this minidump object.
Definition: MinidumpYAML.h:147
A minidump stream represented as a sequence of hex bytes.
Definition: MinidumpYAML.h:79
LocationDescriptor Location
Definition: Minidump.h:67
A range adaptor for a pair of iterators.
static void mapOptionalHex(yaml::IO &IO, const char *Key, EndianType &Val, typename EndianType::value_type Default)
Perform an optional yaml-mapping of an endian-aware type as an appropriately-sized hex value...
support::ulittle32_t RVA
Definition: Minidump.h:58
static StringRef streamValidate(RawContentStream &Stream)
Specialized YAMLIO scalar type for representing a binary blob.
Definition: YAML.h:63
A StringRef, which is printed using YAML block notation.
Definition: MinidumpYAML.h:117
support::ulittle32_t FileFlags
Definition: Minidump.h:135
support::ulittle32_t DataSize
Definition: Minidump.h:57
support::ulittle16_t ProcessorLevel
Definition: Minidump.h:108
support::ulittle32_t FileVersionLow
Definition: Minidump.h:131
support::little_t< OSPlatform > PlatformId
Definition: Minidump.h:117
support::ulittle32_t FileVersionHigh
Definition: Minidump.h:130
support::ulittle32_t ProductVersionLow
Definition: Minidump.h:133
const NodeList & List
Definition: RDFGraph.cpp:201
#define N
Specifies the location and type of a single stream in the minidump file.
Definition: Minidump.h:65
support::ulittle32_t FileDateHigh
Definition: Minidump.h:139
support::ulittle32_t FileType
Definition: Minidump.h:137
uint32_t Size
Definition: Profile.cpp:46
support::ulittle32_t CSDVersionRVA
Definition: Minidump.h:118
support::ulittle32_t StructVersion
Definition: Minidump.h:129
support::ulittle32_t ProductVersionHigh
Definition: Minidump.h:132
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
IteratorT begin() const
uint64_t tell() const
tell - Return the current offset with the file.
Definition: raw_ostream.h:99
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
support::ulittle64_t BaseOfImage
Definition: Minidump.h:149
print Print MemDeps of function
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
const StreamKind Kind
Definition: MinidumpYAML.h:38
static Directory layout(BlobAllocator &File, Stream &S)
std::string toHex(StringRef Input, bool LowerCase=false)
Convert buffer Input to its hexadecimal representation.
Definition: StringExtras.h:141
static QuotingType mustQuote(StringRef S)
OutputIt copy(R &&Range, OutputIt Out)
Definition: STLExtras.h:1237
IteratorT end() const
static std::unique_ptr< Stream > create(minidump::StreamType Type)
Create an empty stream of the given Type.
const minidump::StreamType Type
Definition: MinidumpYAML.h:39
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
A class providing access to the contents of a minidump file.
Definition: Minidump.h:22
support::ulittle32_t CPUID
Definition: Minidump.h:95
void validate(const Triple &TT, const FeatureBitset &FeatureBits)
static void mapOptional(yaml::IO &IO, const char *Key, EndianType &Val, typename EndianType::value_type Default)
Perform an optional yaml-mapping of an endian-aware type EndianType.
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 ...
Definition: STLExtras.h:1571
support::ulittle32_t FileFlagsMask
Definition: Minidump.h:134
support::little_t< StreamType > Type
Definition: Minidump.h:66
The SystemInfo stream, containing various information about the system where this minidump was genera...
Definition: Minidump.h:106
support::ulittle32_t TimeDateStamp
Definition: Minidump.h:152