1 //===- DebugInlineeLinesSubsection.h ----------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef LLVM_DEBUGINFO_CODEVIEW_BUGINLINEELINESSUBSECTION_H 11 #define LLVM_DEBUGINFO_CODEVIEW_BUGINLINEELINESSUBSECTION_H 12 13 #include "llvm/DebugInfo/CodeView/DebugSubsection.h" 14 #include "llvm/DebugInfo/CodeView/Line.h" 15 #include "llvm/Support/BinaryStreamArray.h" 16 #include "llvm/Support/BinaryStreamReader.h" 17 #include "llvm/Support/Error.h" 18 19 namespace llvm { 20 namespace codeview { 21 22 class DebugInlineeLinesSubsectionRef; 23 class DebugChecksumsSubsection; 24 25 enum class InlineeLinesSignature : uint32_t { 26 Normal, // CV_INLINEE_SOURCE_LINE_SIGNATURE 27 ExtraFiles // CV_INLINEE_SOURCE_LINE_SIGNATURE_EX 28 }; 29 30 struct InlineeSourceLineHeader { 31 TypeIndex Inlinee; // ID of the function that was inlined. 32 support::ulittle32_t FileID; // Offset into FileChecksums subsection. 33 support::ulittle32_t SourceLineNum; // First line of inlined code. 34 // If extra files present: 35 // ulittle32_t ExtraFileCount; 36 // ulittle32_t Files[]; 37 }; 38 39 struct InlineeSourceLine { 40 const InlineeSourceLineHeader *Header; 41 FixedStreamArray<support::ulittle32_t> ExtraFiles; 42 }; 43 } 44 45 template <> struct VarStreamArrayExtractor<codeview::InlineeSourceLine> { 46 Error operator()(BinaryStreamRef Stream, uint32_t &Len, 47 codeview::InlineeSourceLine &Item); 48 bool HasExtraFiles = false; 49 }; 50 51 namespace codeview { 52 class DebugInlineeLinesSubsectionRef final : public DebugSubsectionRef { 53 typedef VarStreamArray<InlineeSourceLine> LinesArray; 54 typedef LinesArray::Iterator Iterator; 55 56 public: 57 DebugInlineeLinesSubsectionRef(); 58 59 static bool classof(const DebugSubsectionRef *S) { 60 return S->kind() == DebugSubsectionKind::InlineeLines; 61 } 62 63 Error initialize(BinaryStreamReader Reader); 64 bool hasExtraFiles() const; 65 66 Iterator begin() const { return Lines.begin(); } 67 Iterator end() const { return Lines.end(); } 68 69 private: 70 InlineeLinesSignature Signature; 71 VarStreamArray<InlineeSourceLine> Lines; 72 }; 73 74 class DebugInlineeLinesSubsection final : public DebugSubsection { 75 public: 76 struct Entry { 77 std::vector<support::ulittle32_t> ExtraFiles; 78 InlineeSourceLineHeader Header; 79 }; 80 81 DebugInlineeLinesSubsection(DebugChecksumsSubsection &Checksums, 82 bool HasExtraFiles = false); 83 84 static bool classof(const DebugSubsection *S) { 85 return S->kind() == DebugSubsectionKind::InlineeLines; 86 } 87 88 Error commit(BinaryStreamWriter &Writer) const override; 89 uint32_t calculateSerializedSize() const override; 90 91 void addInlineSite(TypeIndex FuncId, StringRef FileName, uint32_t SourceLine); 92 void addExtraFile(StringRef FileName); 93 94 bool hasExtraFiles() const { return HasExtraFiles; } 95 void setHasExtraFiles(bool Has) { HasExtraFiles = Has; } 96 97 std::vector<Entry>::const_iterator begin() const { return Entries.begin(); } 98 std::vector<Entry>::const_iterator end() const { return Entries.end(); } 99 100 private: 101 DebugChecksumsSubsection &Checksums; 102 103 bool HasExtraFiles = false; 104 uint32_t ExtraFileCount = 0; 105 106 std::vector<Entry> Entries; 107 }; 108 } 109 } 110 111 #endif 112