LLVM  14.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 
11 
12 using namespace llvm;
13 using namespace llvm::codeview;
14 
16  if (Reader.bytesRemaining() % sizeof(FrameData) != 0) {
17  if (auto EC = Reader.readObject(RelocPtr))
18  return EC;
19  }
20 
21  if (Reader.bytesRemaining() % sizeof(FrameData) != 0)
22  return make_error<CodeViewError>(cv_error_code::corrupt_record,
23  "Invalid frame data record format!");
24 
25  uint32_t Count = Reader.bytesRemaining() / sizeof(FrameData);
26  if (auto EC = Reader.readArray(Frames, Count))
27  return EC;
28  return Error::success();
29 }
30 
33  return initialize(Reader);
34 }
35 
37  uint32_t Size = sizeof(FrameData) * Frames.size();
38  if (IncludeRelocPtr)
39  Size += sizeof(uint32_t);
40  return Size;
41 }
42 
44  if (IncludeRelocPtr) {
45  if (auto EC = Writer.writeInteger<uint32_t>(0))
46  return EC;
47  }
48 
49  std::vector<FrameData> SortedFrames(Frames.begin(), Frames.end());
50  llvm::sort(SortedFrames, [](const FrameData &LHS, const FrameData &RHS) {
51  return LHS.RvaStart < RHS.RvaStart;
52  });
53  if (auto EC = Writer.writeArray(makeArrayRef(SortedFrames)))
54  return EC;
55  return Error::success();
56 }
57 
59  Frames.push_back(Frame);
60 }
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::BinaryStreamWriter::writeInteger
Error writeInteger(T Value)
Write the integer Value to the underlying stream in the specified endianness.
Definition: BinaryStreamWriter.h:64
llvm::BinaryStreamWriter
Provides write only access to a subclass of WritableBinaryStream.
Definition: BinaryStreamWriter.h:31
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:331
llvm::codeview::FrameData
Data in the SUBSEC_FRAMEDATA subection.
Definition: CodeView.h:572
llvm::BinaryStreamReader::bytesRemaining
uint64_t bytesRemaining() const
Definition: BinaryStreamReader.h:257
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:151
llvm::ARMBuildAttrs::Section
@ Section
Legacy Tags.
Definition: ARMBuildAttributes.h:78
llvm::codeview::DebugFrameDataSubsection::commit
Error commit(BinaryStreamWriter &Writer) const override
Definition: DebugFrameDataSubsection.cpp:43
llvm::codeview::FrameData::RvaStart
support::ulittle32_t RvaStart
Definition: CodeView.h:573
llvm::BinaryStreamReader
Provides read only access to a subclass of BinaryStream.
Definition: BinaryStreamReader.h:31
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:169
llvm::codeview::DebugFrameDataSubsectionRef::initialize
Error initialize(BinaryStreamReader Reader)
Definition: DebugFrameDataSubsection.cpp:15
llvm::codeview::DebugFrameDataSubsection::calculateSerializedSize
uint32_t calculateSerializedSize() const override
Definition: DebugFrameDataSubsection.cpp:36
uint32_t
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::sort
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1488
llvm::codeview::cv_error_code::corrupt_record
@ corrupt_record
llvm::codeview::DebugFrameDataSubsection::addFrameData
void addFrameData(const FrameData &Frame)
Definition: DebugFrameDataSubsection.cpp:58
llvm::codeview
Definition: AppendingTypeTableBuilder.h:22
llvm::makeArrayRef
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:476
DebugFrameDataSubsection.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:187
llvm::BinaryStreamRef
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
Definition: BinaryStreamRef.h:156