1db17bf38SDimitry Andric //===- DebugSubsectionVisitor.cpp -------------------------------*- C++ -*-===//
289cb50c9SDimitry Andric //
389cb50c9SDimitry Andric //                     The LLVM Compiler Infrastructure
489cb50c9SDimitry Andric //
589cb50c9SDimitry Andric // This file is distributed under the University of Illinois Open Source
689cb50c9SDimitry Andric // License. See LICENSE.TXT for details.
789cb50c9SDimitry Andric //
889cb50c9SDimitry Andric //===----------------------------------------------------------------------===//
989cb50c9SDimitry Andric 
1089cb50c9SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h"
1189cb50c9SDimitry Andric 
1289cb50c9SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
13db17bf38SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugCrossExSubsection.h"
14db17bf38SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h"
15db17bf38SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h"
1689cb50c9SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h"
1789cb50c9SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
18db17bf38SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
1989cb50c9SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
20db17bf38SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugSymbolRVASubsection.h"
21db17bf38SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h"
2289cb50c9SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugUnknownSubsection.h"
2389cb50c9SDimitry Andric #include "llvm/Support/BinaryStreamReader.h"
2489cb50c9SDimitry Andric #include "llvm/Support/BinaryStreamRef.h"
2589cb50c9SDimitry Andric 
2689cb50c9SDimitry Andric using namespace llvm;
2789cb50c9SDimitry Andric using namespace llvm::codeview;
2889cb50c9SDimitry Andric 
visitDebugSubsection(const DebugSubsectionRecord & R,DebugSubsectionVisitor & V,const StringsAndChecksumsRef & State)29*24d58133SDimitry Andric Error llvm::codeview::visitDebugSubsection(
30*24d58133SDimitry Andric     const DebugSubsectionRecord &R, DebugSubsectionVisitor &V,
31*24d58133SDimitry Andric     const StringsAndChecksumsRef &State) {
3289cb50c9SDimitry Andric   BinaryStreamReader Reader(R.getRecordData());
3389cb50c9SDimitry Andric   switch (R.kind()) {
3489cb50c9SDimitry Andric   case DebugSubsectionKind::Lines: {
3589cb50c9SDimitry Andric     DebugLinesSubsectionRef Fragment;
3689cb50c9SDimitry Andric     if (auto EC = Fragment.initialize(Reader))
3789cb50c9SDimitry Andric       return EC;
3889cb50c9SDimitry Andric 
39db17bf38SDimitry Andric     return V.visitLines(Fragment, State);
4089cb50c9SDimitry Andric   }
4189cb50c9SDimitry Andric   case DebugSubsectionKind::FileChecksums: {
4289cb50c9SDimitry Andric     DebugChecksumsSubsectionRef Fragment;
4389cb50c9SDimitry Andric     if (auto EC = Fragment.initialize(Reader))
4489cb50c9SDimitry Andric       return EC;
4589cb50c9SDimitry Andric 
46db17bf38SDimitry Andric     return V.visitFileChecksums(Fragment, State);
4789cb50c9SDimitry Andric   }
4889cb50c9SDimitry Andric   case DebugSubsectionKind::InlineeLines: {
4989cb50c9SDimitry Andric     DebugInlineeLinesSubsectionRef Fragment;
5089cb50c9SDimitry Andric     if (auto EC = Fragment.initialize(Reader))
5189cb50c9SDimitry Andric       return EC;
52db17bf38SDimitry Andric     return V.visitInlineeLines(Fragment, State);
53db17bf38SDimitry Andric   }
54db17bf38SDimitry Andric   case DebugSubsectionKind::CrossScopeExports: {
55db17bf38SDimitry Andric     DebugCrossModuleExportsSubsectionRef Section;
56db17bf38SDimitry Andric     if (auto EC = Section.initialize(Reader))
57db17bf38SDimitry Andric       return EC;
58db17bf38SDimitry Andric     return V.visitCrossModuleExports(Section, State);
59db17bf38SDimitry Andric   }
60db17bf38SDimitry Andric   case DebugSubsectionKind::CrossScopeImports: {
61db17bf38SDimitry Andric     DebugCrossModuleImportsSubsectionRef Section;
62db17bf38SDimitry Andric     if (auto EC = Section.initialize(Reader))
63db17bf38SDimitry Andric       return EC;
64db17bf38SDimitry Andric     return V.visitCrossModuleImports(Section, State);
65db17bf38SDimitry Andric   }
66db17bf38SDimitry Andric   case DebugSubsectionKind::Symbols: {
67db17bf38SDimitry Andric     DebugSymbolsSubsectionRef Section;
68db17bf38SDimitry Andric     if (auto EC = Section.initialize(Reader))
69db17bf38SDimitry Andric       return EC;
70db17bf38SDimitry Andric     return V.visitSymbols(Section, State);
71db17bf38SDimitry Andric   }
72db17bf38SDimitry Andric   case DebugSubsectionKind::StringTable: {
73db17bf38SDimitry Andric     DebugStringTableSubsectionRef Section;
74db17bf38SDimitry Andric     if (auto EC = Section.initialize(Reader))
75db17bf38SDimitry Andric       return EC;
76db17bf38SDimitry Andric     return V.visitStringTable(Section, State);
77db17bf38SDimitry Andric   }
78db17bf38SDimitry Andric   case DebugSubsectionKind::FrameData: {
79db17bf38SDimitry Andric     DebugFrameDataSubsectionRef Section;
80db17bf38SDimitry Andric     if (auto EC = Section.initialize(Reader))
81db17bf38SDimitry Andric       return EC;
82db17bf38SDimitry Andric     return V.visitFrameData(Section, State);
83db17bf38SDimitry Andric   }
84db17bf38SDimitry Andric   case DebugSubsectionKind::CoffSymbolRVA: {
85db17bf38SDimitry Andric     DebugSymbolRVASubsectionRef Section;
86db17bf38SDimitry Andric     if (auto EC = Section.initialize(Reader))
87db17bf38SDimitry Andric       return EC;
88db17bf38SDimitry Andric     return V.visitCOFFSymbolRVAs(Section, State);
8989cb50c9SDimitry Andric   }
9089cb50c9SDimitry Andric   default: {
9189cb50c9SDimitry Andric     DebugUnknownSubsectionRef Fragment(R.kind(), R.getRecordData());
9289cb50c9SDimitry Andric     return V.visitUnknown(Fragment);
9389cb50c9SDimitry Andric   }
9489cb50c9SDimitry Andric   }
9589cb50c9SDimitry Andric }
96