Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 14 | pmbaty | 1 | //===- DebugCrossImpSubsection.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_DEBUGCROSSIMPSUBSECTION_H |
||
| 10 | #define LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H |
||
| 11 | |||
| 12 | #include "llvm/ADT/StringMap.h" |
||
| 13 | #include "llvm/ADT/StringRef.h" |
||
| 14 | #include "llvm/DebugInfo/CodeView/CodeView.h" |
||
| 15 | #include "llvm/DebugInfo/CodeView/DebugSubsection.h" |
||
| 16 | #include "llvm/Support/BinaryStreamArray.h" |
||
| 17 | #include "llvm/Support/BinaryStreamRef.h" |
||
| 18 | #include "llvm/Support/Endian.h" |
||
| 19 | #include "llvm/Support/Error.h" |
||
| 20 | #include <cstdint> |
||
| 21 | #include <vector> |
||
| 22 | |||
| 23 | namespace llvm { |
||
| 24 | class BinaryStreamReader; |
||
| 25 | class BinaryStreamWriter; |
||
| 26 | |||
| 27 | namespace codeview { |
||
| 28 | |||
| 29 | struct CrossModuleImportItem { |
||
| 30 | const CrossModuleImport *Header = nullptr; |
||
| 31 | FixedStreamArray<support::ulittle32_t> Imports; |
||
| 32 | }; |
||
| 33 | |||
| 34 | } // end namespace codeview |
||
| 35 | |||
| 36 | template <> struct VarStreamArrayExtractor<codeview::CrossModuleImportItem> { |
||
| 37 | public: |
||
| 38 | using ContextType = void; |
||
| 39 | |||
| 40 | Error operator()(BinaryStreamRef Stream, uint32_t &Len, |
||
| 41 | codeview::CrossModuleImportItem &Item); |
||
| 42 | }; |
||
| 43 | |||
| 44 | namespace codeview { |
||
| 45 | |||
| 46 | class DebugStringTableSubsection; |
||
| 47 | |||
| 48 | class DebugCrossModuleImportsSubsectionRef final : public DebugSubsectionRef { |
||
| 49 | using ReferenceArray = VarStreamArray<CrossModuleImportItem>; |
||
| 50 | using Iterator = ReferenceArray::Iterator; |
||
| 51 | |||
| 52 | public: |
||
| 53 | DebugCrossModuleImportsSubsectionRef() |
||
| 54 | : DebugSubsectionRef(DebugSubsectionKind::CrossScopeImports) {} |
||
| 55 | |||
| 56 | static bool classof(const DebugSubsectionRef *S) { |
||
| 57 | return S->kind() == DebugSubsectionKind::CrossScopeImports; |
||
| 58 | } |
||
| 59 | |||
| 60 | Error initialize(BinaryStreamReader Reader); |
||
| 61 | Error initialize(BinaryStreamRef Stream); |
||
| 62 | |||
| 63 | Iterator begin() const { return References.begin(); } |
||
| 64 | Iterator end() const { return References.end(); } |
||
| 65 | |||
| 66 | private: |
||
| 67 | ReferenceArray References; |
||
| 68 | }; |
||
| 69 | |||
| 70 | class DebugCrossModuleImportsSubsection final : public DebugSubsection { |
||
| 71 | public: |
||
| 72 | explicit DebugCrossModuleImportsSubsection( |
||
| 73 | DebugStringTableSubsection &Strings) |
||
| 74 | : DebugSubsection(DebugSubsectionKind::CrossScopeImports), |
||
| 75 | Strings(Strings) {} |
||
| 76 | |||
| 77 | static bool classof(const DebugSubsection *S) { |
||
| 78 | return S->kind() == DebugSubsectionKind::CrossScopeImports; |
||
| 79 | } |
||
| 80 | |||
| 81 | void addImport(StringRef Module, uint32_t ImportId); |
||
| 82 | |||
| 83 | uint32_t calculateSerializedSize() const override; |
||
| 84 | Error commit(BinaryStreamWriter &Writer) const override; |
||
| 85 | |||
| 86 | private: |
||
| 87 | DebugStringTableSubsection &Strings; |
||
| 88 | StringMap<std::vector<support::ulittle32_t>> Mappings; |
||
| 89 | }; |
||
| 90 | |||
| 91 | } // end namespace codeview |
||
| 92 | |||
| 93 | } // end namespace llvm |
||
| 94 | |||
| 95 | #endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H |