1deb39130SZachary Turner //===- DebugSubsectionVisitor.cpp -------------------------------*- C++ -*-===// 28c099fe0SZachary Turner // 3*2946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*2946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 5*2946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 68c099fe0SZachary Turner // 78c099fe0SZachary Turner //===----------------------------------------------------------------------===// 88c099fe0SZachary Turner 98c099fe0SZachary Turner #include "llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h" 108c099fe0SZachary Turner 118c099fe0SZachary Turner #include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h" 12349c18f8SZachary Turner #include "llvm/DebugInfo/CodeView/DebugCrossExSubsection.h" 13349c18f8SZachary Turner #include "llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h" 14deb39130SZachary Turner #include "llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h" 158c099fe0SZachary Turner #include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h" 168c099fe0SZachary Turner #include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h" 171bf77620SZachary Turner #include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h" 188c099fe0SZachary Turner #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h" 193226fe95SZachary Turner #include "llvm/DebugInfo/CodeView/DebugSymbolRVASubsection.h" 20deb39130SZachary Turner #include "llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h" 218c099fe0SZachary Turner #include "llvm/DebugInfo/CodeView/DebugUnknownSubsection.h" 228c099fe0SZachary Turner #include "llvm/Support/BinaryStreamReader.h" 238c099fe0SZachary Turner #include "llvm/Support/BinaryStreamRef.h" 248c099fe0SZachary Turner 258c099fe0SZachary Turner using namespace llvm; 268c099fe0SZachary Turner using namespace llvm::codeview; 278c099fe0SZachary Turner 28a8cfc29cSZachary Turner Error llvm::codeview::visitDebugSubsection( 29a8cfc29cSZachary Turner const DebugSubsectionRecord &R, DebugSubsectionVisitor &V, 30a8cfc29cSZachary Turner const StringsAndChecksumsRef &State) { 318c099fe0SZachary Turner BinaryStreamReader Reader(R.getRecordData()); 328c099fe0SZachary Turner switch (R.kind()) { 338c099fe0SZachary Turner case DebugSubsectionKind::Lines: { 348c099fe0SZachary Turner DebugLinesSubsectionRef Fragment; 358c099fe0SZachary Turner if (auto EC = Fragment.initialize(Reader)) 368c099fe0SZachary Turner return EC; 378c099fe0SZachary Turner 381bf77620SZachary Turner return V.visitLines(Fragment, State); 398c099fe0SZachary Turner } 408c099fe0SZachary Turner case DebugSubsectionKind::FileChecksums: { 418c099fe0SZachary Turner DebugChecksumsSubsectionRef Fragment; 428c099fe0SZachary Turner if (auto EC = Fragment.initialize(Reader)) 438c099fe0SZachary Turner return EC; 448c099fe0SZachary Turner 451bf77620SZachary Turner return V.visitFileChecksums(Fragment, State); 468c099fe0SZachary Turner } 478c099fe0SZachary Turner case DebugSubsectionKind::InlineeLines: { 488c099fe0SZachary Turner DebugInlineeLinesSubsectionRef Fragment; 498c099fe0SZachary Turner if (auto EC = Fragment.initialize(Reader)) 508c099fe0SZachary Turner return EC; 511bf77620SZachary Turner return V.visitInlineeLines(Fragment, State); 528c099fe0SZachary Turner } 53349c18f8SZachary Turner case DebugSubsectionKind::CrossScopeExports: { 54349c18f8SZachary Turner DebugCrossModuleExportsSubsectionRef Section; 55349c18f8SZachary Turner if (auto EC = Section.initialize(Reader)) 56349c18f8SZachary Turner return EC; 571bf77620SZachary Turner return V.visitCrossModuleExports(Section, State); 58349c18f8SZachary Turner } 59349c18f8SZachary Turner case DebugSubsectionKind::CrossScopeImports: { 60349c18f8SZachary Turner DebugCrossModuleImportsSubsectionRef Section; 61349c18f8SZachary Turner if (auto EC = Section.initialize(Reader)) 62349c18f8SZachary Turner return EC; 631bf77620SZachary Turner return V.visitCrossModuleImports(Section, State); 64349c18f8SZachary Turner } 65deb39130SZachary Turner case DebugSubsectionKind::Symbols: { 66deb39130SZachary Turner DebugSymbolsSubsectionRef Section; 67deb39130SZachary Turner if (auto EC = Section.initialize(Reader)) 68deb39130SZachary Turner return EC; 69deb39130SZachary Turner return V.visitSymbols(Section, State); 70deb39130SZachary Turner } 71deb39130SZachary Turner case DebugSubsectionKind::StringTable: { 72deb39130SZachary Turner DebugStringTableSubsectionRef Section; 73deb39130SZachary Turner if (auto EC = Section.initialize(Reader)) 74deb39130SZachary Turner return EC; 75deb39130SZachary Turner return V.visitStringTable(Section, State); 76deb39130SZachary Turner } 77deb39130SZachary Turner case DebugSubsectionKind::FrameData: { 78deb39130SZachary Turner DebugFrameDataSubsectionRef Section; 79deb39130SZachary Turner if (auto EC = Section.initialize(Reader)) 80deb39130SZachary Turner return EC; 81deb39130SZachary Turner return V.visitFrameData(Section, State); 82deb39130SZachary Turner } 833226fe95SZachary Turner case DebugSubsectionKind::CoffSymbolRVA: { 843226fe95SZachary Turner DebugSymbolRVASubsectionRef Section; 853226fe95SZachary Turner if (auto EC = Section.initialize(Reader)) 863226fe95SZachary Turner return EC; 873226fe95SZachary Turner return V.visitCOFFSymbolRVAs(Section, State); 883226fe95SZachary Turner } 898c099fe0SZachary Turner default: { 908c099fe0SZachary Turner DebugUnknownSubsectionRef Fragment(R.kind(), R.getRecordData()); 918c099fe0SZachary Turner return V.visitUnknown(Fragment); 928c099fe0SZachary Turner } 938c099fe0SZachary Turner } 948c099fe0SZachary Turner } 95