1*0b57cec5SDimitry Andric //===- DebugSubsectionVisitor.cpp -------------------------------*- C++ -*-===//
2*0b57cec5SDimitry Andric //
3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*0b57cec5SDimitry Andric //
7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
8*0b57cec5SDimitry Andric
9*0b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h"
10*0b57cec5SDimitry Andric
11*0b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/CodeView.h"
12*0b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
13*0b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugCrossExSubsection.h"
14*0b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h"
15*0b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h"
16*0b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h"
17*0b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
18*0b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
19*0b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
20*0b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugSymbolRVASubsection.h"
21*0b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h"
22*0b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugUnknownSubsection.h"
23*0b57cec5SDimitry Andric #include "llvm/Support/BinaryStreamReader.h"
24*0b57cec5SDimitry Andric #include "llvm/Support/SwapByteOrder.h"
25*0b57cec5SDimitry Andric
26*0b57cec5SDimitry Andric using namespace llvm;
27*0b57cec5SDimitry Andric using namespace llvm::codeview;
28*0b57cec5SDimitry Andric
visitDebugSubsection(const DebugSubsectionRecord & R,DebugSubsectionVisitor & V,const StringsAndChecksumsRef & State)29*0b57cec5SDimitry Andric Error llvm::codeview::visitDebugSubsection(
30*0b57cec5SDimitry Andric const DebugSubsectionRecord &R, DebugSubsectionVisitor &V,
31*0b57cec5SDimitry Andric const StringsAndChecksumsRef &State) {
32*0b57cec5SDimitry Andric BinaryStreamReader Reader(R.getRecordData());
33*0b57cec5SDimitry Andric switch (R.kind()) {
34*0b57cec5SDimitry Andric case DebugSubsectionKind::Lines: {
35*0b57cec5SDimitry Andric DebugLinesSubsectionRef Fragment;
36*0b57cec5SDimitry Andric if (auto EC = Fragment.initialize(Reader))
37*0b57cec5SDimitry Andric return EC;
38*0b57cec5SDimitry Andric
39*0b57cec5SDimitry Andric return V.visitLines(Fragment, State);
40*0b57cec5SDimitry Andric }
41*0b57cec5SDimitry Andric case DebugSubsectionKind::FileChecksums: {
42*0b57cec5SDimitry Andric DebugChecksumsSubsectionRef Fragment;
43*0b57cec5SDimitry Andric if (auto EC = Fragment.initialize(Reader))
44*0b57cec5SDimitry Andric return EC;
45*0b57cec5SDimitry Andric
46*0b57cec5SDimitry Andric return V.visitFileChecksums(Fragment, State);
47*0b57cec5SDimitry Andric }
48*0b57cec5SDimitry Andric case DebugSubsectionKind::InlineeLines: {
49*0b57cec5SDimitry Andric DebugInlineeLinesSubsectionRef Fragment;
50*0b57cec5SDimitry Andric if (auto EC = Fragment.initialize(Reader))
51*0b57cec5SDimitry Andric return EC;
52*0b57cec5SDimitry Andric return V.visitInlineeLines(Fragment, State);
53*0b57cec5SDimitry Andric }
54*0b57cec5SDimitry Andric case DebugSubsectionKind::CrossScopeExports: {
55*0b57cec5SDimitry Andric DebugCrossModuleExportsSubsectionRef Section;
56*0b57cec5SDimitry Andric if (auto EC = Section.initialize(Reader))
57*0b57cec5SDimitry Andric return EC;
58*0b57cec5SDimitry Andric return V.visitCrossModuleExports(Section, State);
59*0b57cec5SDimitry Andric }
60*0b57cec5SDimitry Andric case DebugSubsectionKind::CrossScopeImports: {
61*0b57cec5SDimitry Andric DebugCrossModuleImportsSubsectionRef Section;
62*0b57cec5SDimitry Andric if (auto EC = Section.initialize(Reader))
63*0b57cec5SDimitry Andric return EC;
64*0b57cec5SDimitry Andric return V.visitCrossModuleImports(Section, State);
65*0b57cec5SDimitry Andric }
66*0b57cec5SDimitry Andric case DebugSubsectionKind::Symbols: {
67*0b57cec5SDimitry Andric DebugSymbolsSubsectionRef Section;
68*0b57cec5SDimitry Andric if (auto EC = Section.initialize(Reader))
69*0b57cec5SDimitry Andric return EC;
70*0b57cec5SDimitry Andric return V.visitSymbols(Section, State);
71*0b57cec5SDimitry Andric }
72*0b57cec5SDimitry Andric case DebugSubsectionKind::StringTable: {
73*0b57cec5SDimitry Andric DebugStringTableSubsectionRef Section;
74*0b57cec5SDimitry Andric if (auto EC = Section.initialize(Reader))
75*0b57cec5SDimitry Andric return EC;
76*0b57cec5SDimitry Andric return V.visitStringTable(Section, State);
77*0b57cec5SDimitry Andric }
78*0b57cec5SDimitry Andric case DebugSubsectionKind::FrameData: {
79*0b57cec5SDimitry Andric DebugFrameDataSubsectionRef Section;
80*0b57cec5SDimitry Andric if (auto EC = Section.initialize(Reader))
81*0b57cec5SDimitry Andric return EC;
82*0b57cec5SDimitry Andric return V.visitFrameData(Section, State);
83*0b57cec5SDimitry Andric }
84*0b57cec5SDimitry Andric case DebugSubsectionKind::CoffSymbolRVA: {
85*0b57cec5SDimitry Andric DebugSymbolRVASubsectionRef Section;
86*0b57cec5SDimitry Andric if (auto EC = Section.initialize(Reader))
87*0b57cec5SDimitry Andric return EC;
88*0b57cec5SDimitry Andric return V.visitCOFFSymbolRVAs(Section, State);
89*0b57cec5SDimitry Andric }
90*0b57cec5SDimitry Andric default: {
91*0b57cec5SDimitry Andric DebugUnknownSubsectionRef Fragment(R.kind(), R.getRecordData());
92*0b57cec5SDimitry Andric return V.visitUnknown(Fragment);
93*0b57cec5SDimitry Andric }
94*0b57cec5SDimitry Andric }
95 }
96