LLVM  16.0.0git
DebugFrameDataSubsection.cpp
Go to the documentation of this file.
1 //===- DebugFrameDataSubsection.cpp -----------------------------*- C++ -*-===//
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 
13 
14 using namespace llvm;
15 using namespace llvm::codeview;
16 
18  if (Reader.bytesRemaining() % sizeof(FrameData) != 0) {
19  if (auto EC = Reader.readObject(RelocPtr))
20  return EC;
21  }
22 
23  if (Reader.bytesRemaining() % sizeof(FrameData) != 0)
24  return make_error<CodeViewError>(cv_error_code::corrupt_record,
25  "Invalid frame data record format!");
26 
27  uint32_t Count = Reader.bytesRemaining() / sizeof(FrameData);
28  if (auto EC = Reader.readArray(Frames, Count))
29  return EC;
30  return Error::success();
31 }
32 
34  BinaryStreamReader Reader(Section);
35  return initialize(Reader);
36 }
37 
39  uint32_t Size = sizeof(FrameData) * Frames.size();
40  if (IncludeRelocPtr)
41  Size += sizeof(uint32_t);
42  return Size;
43 }
44 
46  if (IncludeRelocPtr) {
47  if (auto EC = Writer.writeInteger<uint32_t>(0))
48  return EC;
49  }
50 
51  std::vector<FrameData> SortedFrames(Frames.begin(), Frames.end());
52  llvm::sort(SortedFrames, [](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 }
BinaryStreamReader.h
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::BinaryStreamWriter::writeInteger
Error writeInteger(T Value)
Write the integer Value to the underlying stream in the specified endianness.
Definition: BinaryStreamWriter.h:58
llvm::BinaryStreamWriter
Provides write only access to a subclass of WritableBinaryStream.
Definition: BinaryStreamWriter.h:30
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:329
llvm::codeview::FrameData
Data in the SUBSEC_FRAMEDATA subection.
Definition: CodeView.h:574
llvm::BinaryStreamReader::bytesRemaining
uint64_t bytesRemaining() const
Definition: BinaryStreamReader.h:250
llvm::BinaryStreamWriter::writeArray
Error writeArray(ArrayRef< T > Array)
Writes an array of objects of type T to the underlying stream, as if by using memcpy.
Definition: BinaryStreamWriter.h:145
RHS
Value * RHS
Definition: X86PartialReduction.cpp:76
LHS
Value * LHS
Definition: X86PartialReduction.cpp:75
llvm::codeview::DebugFrameDataSubsection::commit
Error commit(BinaryStreamWriter &Writer) const override
Definition: DebugFrameDataSubsection.cpp:45
llvm::BinaryStreamReader
Provides read only access to a subclass of BinaryStream.
Definition: BinaryStreamReader.h:29
llvm::sort
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1538
llvm::codeview::CompileSym2Flags::EC
@ EC
llvm::BinaryStreamReader::readObject
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...
Definition: BinaryStreamReader.h:162
llvm::codeview::DebugFrameDataSubsectionRef::initialize
Error initialize(BinaryStreamReader Reader)
Definition: DebugFrameDataSubsection.cpp:17
llvm::codeview::DebugFrameDataSubsection::calculateSerializedSize
uint32_t calculateSerializedSize() const override
Definition: DebugFrameDataSubsection.cpp:38
uint32_t
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
llvm::codeview::cv_error_code::corrupt_record
@ corrupt_record
llvm::codeview::DebugFrameDataSubsection::addFrameData
void addFrameData(const FrameData &Frame)
Definition: DebugFrameDataSubsection.cpp:60
llvm::codeview
Definition: AppendingTypeTableBuilder.h:22
llvm::makeArrayRef
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:475
DebugFrameDataSubsection.h
BinaryStreamWriter.h
CodeViewError.h
llvm::BinaryStreamReader::readArray
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 ...
Definition: BinaryStreamReader.h:180
llvm::BinaryStreamRef
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
Definition: BinaryStreamRef.h:155