Line data Source code
1 : //===- DebugSubsectionVisitor.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_MODULEDEBUGFRAGMENTVISITOR_H
11 : #define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTVISITOR_H
12 :
13 : #include "llvm/DebugInfo/CodeView/CodeView.h"
14 : #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
15 : #include "llvm/DebugInfo/CodeView/StringsAndChecksums.h"
16 : #include "llvm/Support/Error.h"
17 : #include <cstdint>
18 :
19 : namespace llvm {
20 :
21 : namespace codeview {
22 :
23 : class DebugChecksumsSubsectionRef;
24 : class DebugSubsectionRecord;
25 : class DebugInlineeLinesSubsectionRef;
26 : class DebugCrossModuleExportsSubsectionRef;
27 : class DebugCrossModuleImportsSubsectionRef;
28 : class DebugFrameDataSubsectionRef;
29 : class DebugLinesSubsectionRef;
30 : class DebugStringTableSubsectionRef;
31 : class DebugSymbolRVASubsectionRef;
32 : class DebugSymbolsSubsectionRef;
33 : class DebugUnknownSubsectionRef;
34 : class StringsAndChecksumsRef;
35 :
36 : class DebugSubsectionVisitor {
37 : public:
38 0 : virtual ~DebugSubsectionVisitor() = default;
39 :
40 0 : virtual Error visitUnknown(DebugUnknownSubsectionRef &Unknown) {
41 0 : return Error::success();
42 : }
43 : virtual Error visitLines(DebugLinesSubsectionRef &Lines,
44 : const StringsAndChecksumsRef &State) = 0;
45 : virtual Error visitFileChecksums(DebugChecksumsSubsectionRef &Checksums,
46 : const StringsAndChecksumsRef &State) = 0;
47 : virtual Error visitInlineeLines(DebugInlineeLinesSubsectionRef &Inlinees,
48 : const StringsAndChecksumsRef &State) = 0;
49 : virtual Error
50 : visitCrossModuleExports(DebugCrossModuleExportsSubsectionRef &CSE,
51 : const StringsAndChecksumsRef &State) = 0;
52 : virtual Error
53 : visitCrossModuleImports(DebugCrossModuleImportsSubsectionRef &CSE,
54 : const StringsAndChecksumsRef &State) = 0;
55 :
56 : virtual Error visitStringTable(DebugStringTableSubsectionRef &ST,
57 : const StringsAndChecksumsRef &State) = 0;
58 :
59 : virtual Error visitSymbols(DebugSymbolsSubsectionRef &CSE,
60 : const StringsAndChecksumsRef &State) = 0;
61 :
62 : virtual Error visitFrameData(DebugFrameDataSubsectionRef &FD,
63 : const StringsAndChecksumsRef &State) = 0;
64 : virtual Error visitCOFFSymbolRVAs(DebugSymbolRVASubsectionRef &RVAs,
65 : const StringsAndChecksumsRef &State) = 0;
66 : };
67 :
68 : Error visitDebugSubsection(const DebugSubsectionRecord &R,
69 : DebugSubsectionVisitor &V,
70 : const StringsAndChecksumsRef &State);
71 :
72 : namespace detail {
73 : template <typename T>
74 : Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V,
75 : StringsAndChecksumsRef &State) {
76 : State.initialize(std::forward<T>(FragmentRange));
77 :
78 : for (const DebugSubsectionRecord &L : FragmentRange) {
79 : if (auto EC = visitDebugSubsection(L, V, State))
80 : return EC;
81 : }
82 : return Error::success();
83 : }
84 : } // namespace detail
85 :
86 : template <typename T>
87 : Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V) {
88 : StringsAndChecksumsRef State;
89 : return detail::visitDebugSubsections(std::forward<T>(FragmentRange), V,
90 : State);
91 : }
92 :
93 : template <typename T>
94 : Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V,
95 : const DebugStringTableSubsectionRef &Strings) {
96 : StringsAndChecksumsRef State(Strings);
97 : return detail::visitDebugSubsections(std::forward<T>(FragmentRange), V,
98 : State);
99 : }
100 :
101 : template <typename T>
102 : Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V,
103 : const DebugStringTableSubsectionRef &Strings,
104 : const DebugChecksumsSubsectionRef &Checksums) {
105 : StringsAndChecksumsRef State(Strings, Checksums);
106 : return detail::visitDebugSubsections(std::forward<T>(FragmentRange), V,
107 : State);
108 : }
109 :
110 : } // end namespace codeview
111 :
112 : } // end namespace llvm
113 :
114 : #endif // LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTVISITOR_H
|