LLVM 20.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
14using namespace llvm;
15using 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(ArrayRef(SortedFrames)))
56 return EC;
57 return Error::success();
58}
59
61 Frames.push_back(Frame);
62}
uint64_t Size
Value * RHS
Value * LHS
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Provides read only access to a subclass of BinaryStream.
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...
uint64_t bytesRemaining() const
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 ...
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
Provides write only access to a subclass of WritableBinaryStream.
Error writeArray(ArrayRef< T > Array)
Writes an array of objects of type T to the underlying stream, as if by using memcpy.
Error writeInteger(T Value)
Write the integer Value to the underlying stream in the specified endianness.
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
static ErrorSuccess success()
Create a success value.
Definition: Error.h:337
Error commit(BinaryStreamWriter &Writer) const override
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1664
Data in the SUBSEC_FRAMEDATA subection.
Definition: CodeView.h:584