xref: /src/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/DebugSubsectionVisitor.cpp (revision 81ad626541db97eb356e2c1d4a20eb2a26a766ab)
17ab83427SDimitry Andric //===- DebugSubsectionVisitor.cpp -------------------------------*- C++ -*-===//
2ee2f195dSDimitry Andric //
3e6d15924SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4e6d15924SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5e6d15924SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6ee2f195dSDimitry Andric //
7ee2f195dSDimitry Andric //===----------------------------------------------------------------------===//
8ee2f195dSDimitry Andric 
9ee2f195dSDimitry Andric #include "llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h"
10ee2f195dSDimitry Andric 
11145449b1SDimitry Andric #include "llvm/DebugInfo/CodeView/CodeView.h"
12ee2f195dSDimitry Andric #include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
137ab83427SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugCrossExSubsection.h"
147ab83427SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h"
157ab83427SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h"
16ee2f195dSDimitry Andric #include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h"
17ee2f195dSDimitry Andric #include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
187ab83427SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
19ee2f195dSDimitry Andric #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
207ab83427SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugSymbolRVASubsection.h"
217ab83427SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h"
22ee2f195dSDimitry Andric #include "llvm/DebugInfo/CodeView/DebugUnknownSubsection.h"
23ee2f195dSDimitry Andric #include "llvm/Support/BinaryStreamReader.h"
24145449b1SDimitry Andric #include "llvm/Support/SwapByteOrder.h"
25ee2f195dSDimitry Andric 
26ee2f195dSDimitry Andric using namespace llvm;
27ee2f195dSDimitry Andric using namespace llvm::codeview;
28ee2f195dSDimitry Andric 
visitDebugSubsection(const DebugSubsectionRecord & R,DebugSubsectionVisitor & V,const StringsAndChecksumsRef & State)297c7aba6eSDimitry Andric Error llvm::codeview::visitDebugSubsection(
307c7aba6eSDimitry Andric     const DebugSubsectionRecord &R, DebugSubsectionVisitor &V,
317c7aba6eSDimitry Andric     const StringsAndChecksumsRef &State) {
32ee2f195dSDimitry Andric   BinaryStreamReader Reader(R.getRecordData());
33ee2f195dSDimitry Andric   switch (R.kind()) {
34ee2f195dSDimitry Andric   case DebugSubsectionKind::Lines: {
35ee2f195dSDimitry Andric     DebugLinesSubsectionRef Fragment;
36ee2f195dSDimitry Andric     if (auto EC = Fragment.initialize(Reader))
37ee2f195dSDimitry Andric       return EC;
38ee2f195dSDimitry Andric 
397ab83427SDimitry Andric     return V.visitLines(Fragment, State);
40ee2f195dSDimitry Andric   }
41ee2f195dSDimitry Andric   case DebugSubsectionKind::FileChecksums: {
42ee2f195dSDimitry Andric     DebugChecksumsSubsectionRef Fragment;
43ee2f195dSDimitry Andric     if (auto EC = Fragment.initialize(Reader))
44ee2f195dSDimitry Andric       return EC;
45ee2f195dSDimitry Andric 
467ab83427SDimitry Andric     return V.visitFileChecksums(Fragment, State);
47ee2f195dSDimitry Andric   }
48ee2f195dSDimitry Andric   case DebugSubsectionKind::InlineeLines: {
49ee2f195dSDimitry Andric     DebugInlineeLinesSubsectionRef Fragment;
50ee2f195dSDimitry Andric     if (auto EC = Fragment.initialize(Reader))
51ee2f195dSDimitry Andric       return EC;
527ab83427SDimitry Andric     return V.visitInlineeLines(Fragment, State);
537ab83427SDimitry Andric   }
547ab83427SDimitry Andric   case DebugSubsectionKind::CrossScopeExports: {
557ab83427SDimitry Andric     DebugCrossModuleExportsSubsectionRef Section;
567ab83427SDimitry Andric     if (auto EC = Section.initialize(Reader))
577ab83427SDimitry Andric       return EC;
587ab83427SDimitry Andric     return V.visitCrossModuleExports(Section, State);
597ab83427SDimitry Andric   }
607ab83427SDimitry Andric   case DebugSubsectionKind::CrossScopeImports: {
617ab83427SDimitry Andric     DebugCrossModuleImportsSubsectionRef Section;
627ab83427SDimitry Andric     if (auto EC = Section.initialize(Reader))
637ab83427SDimitry Andric       return EC;
647ab83427SDimitry Andric     return V.visitCrossModuleImports(Section, State);
657ab83427SDimitry Andric   }
667ab83427SDimitry Andric   case DebugSubsectionKind::Symbols: {
677ab83427SDimitry Andric     DebugSymbolsSubsectionRef Section;
687ab83427SDimitry Andric     if (auto EC = Section.initialize(Reader))
697ab83427SDimitry Andric       return EC;
707ab83427SDimitry Andric     return V.visitSymbols(Section, State);
717ab83427SDimitry Andric   }
727ab83427SDimitry Andric   case DebugSubsectionKind::StringTable: {
737ab83427SDimitry Andric     DebugStringTableSubsectionRef Section;
747ab83427SDimitry Andric     if (auto EC = Section.initialize(Reader))
757ab83427SDimitry Andric       return EC;
767ab83427SDimitry Andric     return V.visitStringTable(Section, State);
777ab83427SDimitry Andric   }
787ab83427SDimitry Andric   case DebugSubsectionKind::FrameData: {
797ab83427SDimitry Andric     DebugFrameDataSubsectionRef Section;
807ab83427SDimitry Andric     if (auto EC = Section.initialize(Reader))
817ab83427SDimitry Andric       return EC;
827ab83427SDimitry Andric     return V.visitFrameData(Section, State);
837ab83427SDimitry Andric   }
847ab83427SDimitry Andric   case DebugSubsectionKind::CoffSymbolRVA: {
857ab83427SDimitry Andric     DebugSymbolRVASubsectionRef Section;
867ab83427SDimitry Andric     if (auto EC = Section.initialize(Reader))
877ab83427SDimitry Andric       return EC;
887ab83427SDimitry Andric     return V.visitCOFFSymbolRVAs(Section, State);
89ee2f195dSDimitry Andric   }
90ee2f195dSDimitry Andric   default: {
91ee2f195dSDimitry Andric     DebugUnknownSubsectionRef Fragment(R.kind(), R.getRecordData());
92ee2f195dSDimitry Andric     return V.visitUnknown(Fragment);
93ee2f195dSDimitry Andric   }
94ee2f195dSDimitry Andric   }
95ee2f195dSDimitry Andric }
96