1 //===- DebugSubsectionVisitor.h -----------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTVISITOR_H
10 #define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTVISITOR_H
12 #include "llvm/DebugInfo/CodeView/CodeView.h"
13 #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
14 #include "llvm/DebugInfo/CodeView/StringsAndChecksums.h"
15 #include "llvm/Support/Error.h"
22 class DebugChecksumsSubsectionRef
;
23 class DebugSubsectionRecord
;
24 class DebugInlineeLinesSubsectionRef
;
25 class DebugCrossModuleExportsSubsectionRef
;
26 class DebugCrossModuleImportsSubsectionRef
;
27 class DebugFrameDataSubsectionRef
;
28 class DebugLinesSubsectionRef
;
29 class DebugStringTableSubsectionRef
;
30 class DebugSymbolRVASubsectionRef
;
31 class DebugSymbolsSubsectionRef
;
32 class DebugUnknownSubsectionRef
;
33 class StringsAndChecksumsRef
;
35 class DebugSubsectionVisitor
{
37 virtual ~DebugSubsectionVisitor() = default;
39 virtual Error
visitUnknown(DebugUnknownSubsectionRef
&Unknown
) {
40 return Error::success();
42 virtual Error
visitLines(DebugLinesSubsectionRef
&Lines
,
43 const StringsAndChecksumsRef
&State
) = 0;
44 virtual Error
visitFileChecksums(DebugChecksumsSubsectionRef
&Checksums
,
45 const StringsAndChecksumsRef
&State
) = 0;
46 virtual Error
visitInlineeLines(DebugInlineeLinesSubsectionRef
&Inlinees
,
47 const StringsAndChecksumsRef
&State
) = 0;
49 visitCrossModuleExports(DebugCrossModuleExportsSubsectionRef
&CSE
,
50 const StringsAndChecksumsRef
&State
) = 0;
52 visitCrossModuleImports(DebugCrossModuleImportsSubsectionRef
&CSE
,
53 const StringsAndChecksumsRef
&State
) = 0;
55 virtual Error
visitStringTable(DebugStringTableSubsectionRef
&ST
,
56 const StringsAndChecksumsRef
&State
) = 0;
58 virtual Error
visitSymbols(DebugSymbolsSubsectionRef
&CSE
,
59 const StringsAndChecksumsRef
&State
) = 0;
61 virtual Error
visitFrameData(DebugFrameDataSubsectionRef
&FD
,
62 const StringsAndChecksumsRef
&State
) = 0;
63 virtual Error
visitCOFFSymbolRVAs(DebugSymbolRVASubsectionRef
&RVAs
,
64 const StringsAndChecksumsRef
&State
) = 0;
67 Error
visitDebugSubsection(const DebugSubsectionRecord
&R
,
68 DebugSubsectionVisitor
&V
,
69 const StringsAndChecksumsRef
&State
);
73 Error
visitDebugSubsections(T
&&FragmentRange
, DebugSubsectionVisitor
&V
,
74 StringsAndChecksumsRef
&State
) {
75 State
.initialize(std::forward
<T
>(FragmentRange
));
77 for (const DebugSubsectionRecord
&L
: FragmentRange
) {
78 if (auto EC
= visitDebugSubsection(L
, V
, State
))
81 return Error::success();
86 Error
visitDebugSubsections(T
&&FragmentRange
, DebugSubsectionVisitor
&V
) {
87 StringsAndChecksumsRef State
;
88 return detail::visitDebugSubsections(std::forward
<T
>(FragmentRange
), V
,
93 Error
visitDebugSubsections(T
&&FragmentRange
, DebugSubsectionVisitor
&V
,
94 const DebugStringTableSubsectionRef
&Strings
) {
95 StringsAndChecksumsRef
State(Strings
);
96 return detail::visitDebugSubsections(std::forward
<T
>(FragmentRange
), V
,
100 template <typename T
>
101 Error
visitDebugSubsections(T
&&FragmentRange
, DebugSubsectionVisitor
&V
,
102 const DebugStringTableSubsectionRef
&Strings
,
103 const DebugChecksumsSubsectionRef
&Checksums
) {
104 StringsAndChecksumsRef
State(Strings
, Checksums
);
105 return detail::visitDebugSubsections(std::forward
<T
>(FragmentRange
), V
,
109 } // end namespace codeview
111 } // end namespace llvm
113 #endif // LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTVISITOR_H