1 //===- DebugFrameDataSubsection.h ------------------------------*- 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 
9 #ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGFRAMEDATASUBSECTION_H
10 #define LLVM_DEBUGINFO_CODEVIEW_DEBUGFRAMEDATASUBSECTION_H
11 
12 #include "llvm/DebugInfo/CodeView/CodeView.h"
13 #include "llvm/DebugInfo/CodeView/DebugSubsection.h"
14 #include "llvm/Support/BinaryStreamArray.h"
15 #include "llvm/Support/BinaryStreamRef.h"
16 #include "llvm/Support/Endian.h"
17 #include "llvm/Support/Error.h"
18 
19 namespace llvm {
20 class BinaryStreamReader;
21 class BinaryStreamWriter;
22 
23 namespace codeview {
24 class DebugFrameDataSubsectionRef final : public DebugSubsectionRef {
25 public:
DebugFrameDataSubsectionRef()26   DebugFrameDataSubsectionRef()
27       : DebugSubsectionRef(DebugSubsectionKind::FrameData) {}
classof(const DebugSubsection * S)28   static bool classof(const DebugSubsection *S) {
29     return S->kind() == DebugSubsectionKind::FrameData;
30   }
31 
32   Error initialize(BinaryStreamReader Reader);
33   Error initialize(BinaryStreamRef Stream);
34 
begin()35   FixedStreamArray<FrameData>::Iterator begin() const { return Frames.begin(); }
end()36   FixedStreamArray<FrameData>::Iterator end() const { return Frames.end(); }
37 
getRelocPtr()38   const support::ulittle32_t *getRelocPtr() const { return RelocPtr; }
39 
40 private:
41   const support::ulittle32_t *RelocPtr = nullptr;
42   FixedStreamArray<FrameData> Frames;
43 };
44 
45 class DebugFrameDataSubsection final : public DebugSubsection {
46 public:
DebugFrameDataSubsection(bool IncludeRelocPtr)47   DebugFrameDataSubsection(bool IncludeRelocPtr)
48       : DebugSubsection(DebugSubsectionKind::FrameData),
49         IncludeRelocPtr(IncludeRelocPtr) {}
classof(const DebugSubsection * S)50   static bool classof(const DebugSubsection *S) {
51     return S->kind() == DebugSubsectionKind::FrameData;
52   }
53 
54   uint32_t calculateSerializedSize() const override;
55   Error commit(BinaryStreamWriter &Writer) const override;
56 
57   void addFrameData(const FrameData &Frame);
58   void setFrames(ArrayRef<FrameData> Frames);
59 
60 private:
61   bool IncludeRelocPtr = false;
62   std::vector<FrameData> Frames;
63 };
64 }
65 }
66 
67 #endif
68