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