LLVM  8.0.1
DebugFrameDataSubsection.cpp
Go to the documentation of this file.
1 //===- DebugFrameDataSubsection.cpp -----------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
12 
13 using namespace llvm;
14 using namespace llvm::codeview;
15 
17  if (Reader.bytesRemaining() % sizeof(FrameData) != 0) {
18  if (auto EC = Reader.readObject(RelocPtr))
19  return EC;
20  }
21 
22  if (Reader.bytesRemaining() % sizeof(FrameData) != 0)
23  return make_error<CodeViewError>(cv_error_code::corrupt_record,
24  "Invalid frame data record format!");
25 
26  uint32_t Count = Reader.bytesRemaining() / sizeof(FrameData);
27  if (auto EC = Reader.readArray(Frames, Count))
28  return EC;
29  return Error::success();
30 }
31 
33  BinaryStreamReader Reader(Section);
34  return initialize(Reader);
35 }
36 
38  uint32_t Size = sizeof(FrameData) * Frames.size();
39  if (IncludeRelocPtr)
40  Size += sizeof(uint32_t);
41  return Size;
42 }
43 
45  if (IncludeRelocPtr) {
46  if (auto EC = Writer.writeInteger<uint32_t>(0))
47  return EC;
48  }
49 
50  std::vector<FrameData> SortedFrames(Frames.begin(), Frames.end());
51  std::sort(SortedFrames.begin(), SortedFrames.end(),
52  [](const FrameData &LHS, const FrameData &RHS) {
53  return LHS.RvaStart < RHS.RvaStart;
54  });
55  if (auto EC = Writer.writeArray(makeArrayRef(SortedFrames)))
56  return EC;
57  return Error::success();
58 }
59 
61  Frames.push_back(Frame);
62 }
This class represents lattice values for constants.
Definition: AllocatorList.h:24
Data in the SUBSEC_FRAMEDATA subection.
Definition: CodeView.h:552
support::ulittle32_t RvaStart
Definition: CodeView.h:553
Error readObject(const T *&Dest)
Get a pointer to an object of type T from the underlying stream, as if by memcpy, and store the resul...
Error commit(BinaryStreamWriter &Writer) const override
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:451
Error writeArray(ArrayRef< T > Array)
Writes an array of objects of type T to the underlying stream, as if by using memcpy.
Provides write only access to a subclass of WritableBinaryStream.
Error writeInteger(T Value)
Write the integer Value to the underlying stream in the specified endianness.
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1116
static ErrorSuccess success()
Create a success value.
Definition: Error.h:327
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
uint32_t Size
Definition: Profile.cpp:47
uint32_t bytesRemaining() const
Lightweight error class with error context and mandatory checking.
Definition: Error.h:158
Provides read only access to a subclass of BinaryStream.
Error readArray(ArrayRef< T > &Array, uint32_t NumElements)
Get a reference to a NumElements element array of objects of type T from the underlying stream as if ...