10b57cec5SDimitry Andric //===- DebugSubsectionVisitor.cpp -------------------------------*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric
90b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h"
100b57cec5SDimitry Andric
11*81ad6265SDimitry Andric #include "llvm/DebugInfo/CodeView/CodeView.h"
120b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
130b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugCrossExSubsection.h"
140b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h"
150b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h"
160b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h"
170b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
180b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
190b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
200b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugSymbolRVASubsection.h"
210b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h"
220b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugUnknownSubsection.h"
230b57cec5SDimitry Andric #include "llvm/Support/BinaryStreamReader.h"
24*81ad6265SDimitry Andric #include "llvm/Support/SwapByteOrder.h"
250b57cec5SDimitry Andric
260b57cec5SDimitry Andric using namespace llvm;
270b57cec5SDimitry Andric using namespace llvm::codeview;
280b57cec5SDimitry Andric
visitDebugSubsection(const DebugSubsectionRecord & R,DebugSubsectionVisitor & V,const StringsAndChecksumsRef & State)290b57cec5SDimitry Andric Error llvm::codeview::visitDebugSubsection(
300b57cec5SDimitry Andric const DebugSubsectionRecord &R, DebugSubsectionVisitor &V,
310b57cec5SDimitry Andric const StringsAndChecksumsRef &State) {
320b57cec5SDimitry Andric BinaryStreamReader Reader(R.getRecordData());
330b57cec5SDimitry Andric switch (R.kind()) {
340b57cec5SDimitry Andric case DebugSubsectionKind::Lines: {
350b57cec5SDimitry Andric DebugLinesSubsectionRef Fragment;
360b57cec5SDimitry Andric if (auto EC = Fragment.initialize(Reader))
370b57cec5SDimitry Andric return EC;
380b57cec5SDimitry Andric
390b57cec5SDimitry Andric return V.visitLines(Fragment, State);
400b57cec5SDimitry Andric }
410b57cec5SDimitry Andric case DebugSubsectionKind::FileChecksums: {
420b57cec5SDimitry Andric DebugChecksumsSubsectionRef Fragment;
430b57cec5SDimitry Andric if (auto EC = Fragment.initialize(Reader))
440b57cec5SDimitry Andric return EC;
450b57cec5SDimitry Andric
460b57cec5SDimitry Andric return V.visitFileChecksums(Fragment, State);
470b57cec5SDimitry Andric }
480b57cec5SDimitry Andric case DebugSubsectionKind::InlineeLines: {
490b57cec5SDimitry Andric DebugInlineeLinesSubsectionRef Fragment;
500b57cec5SDimitry Andric if (auto EC = Fragment.initialize(Reader))
510b57cec5SDimitry Andric return EC;
520b57cec5SDimitry Andric return V.visitInlineeLines(Fragment, State);
530b57cec5SDimitry Andric }
540b57cec5SDimitry Andric case DebugSubsectionKind::CrossScopeExports: {
550b57cec5SDimitry Andric DebugCrossModuleExportsSubsectionRef Section;
560b57cec5SDimitry Andric if (auto EC = Section.initialize(Reader))
570b57cec5SDimitry Andric return EC;
580b57cec5SDimitry Andric return V.visitCrossModuleExports(Section, State);
590b57cec5SDimitry Andric }
600b57cec5SDimitry Andric case DebugSubsectionKind::CrossScopeImports: {
610b57cec5SDimitry Andric DebugCrossModuleImportsSubsectionRef Section;
620b57cec5SDimitry Andric if (auto EC = Section.initialize(Reader))
630b57cec5SDimitry Andric return EC;
640b57cec5SDimitry Andric return V.visitCrossModuleImports(Section, State);
650b57cec5SDimitry Andric }
660b57cec5SDimitry Andric case DebugSubsectionKind::Symbols: {
670b57cec5SDimitry Andric DebugSymbolsSubsectionRef Section;
680b57cec5SDimitry Andric if (auto EC = Section.initialize(Reader))
690b57cec5SDimitry Andric return EC;
700b57cec5SDimitry Andric return V.visitSymbols(Section, State);
710b57cec5SDimitry Andric }
720b57cec5SDimitry Andric case DebugSubsectionKind::StringTable: {
730b57cec5SDimitry Andric DebugStringTableSubsectionRef Section;
740b57cec5SDimitry Andric if (auto EC = Section.initialize(Reader))
750b57cec5SDimitry Andric return EC;
760b57cec5SDimitry Andric return V.visitStringTable(Section, State);
770b57cec5SDimitry Andric }
780b57cec5SDimitry Andric case DebugSubsectionKind::FrameData: {
790b57cec5SDimitry Andric DebugFrameDataSubsectionRef Section;
800b57cec5SDimitry Andric if (auto EC = Section.initialize(Reader))
810b57cec5SDimitry Andric return EC;
820b57cec5SDimitry Andric return V.visitFrameData(Section, State);
830b57cec5SDimitry Andric }
840b57cec5SDimitry Andric case DebugSubsectionKind::CoffSymbolRVA: {
850b57cec5SDimitry Andric DebugSymbolRVASubsectionRef Section;
860b57cec5SDimitry Andric if (auto EC = Section.initialize(Reader))
870b57cec5SDimitry Andric return EC;
880b57cec5SDimitry Andric return V.visitCOFFSymbolRVAs(Section, State);
890b57cec5SDimitry Andric }
900b57cec5SDimitry Andric default: {
910b57cec5SDimitry Andric DebugUnknownSubsectionRef Fragment(R.kind(), R.getRecordData());
920b57cec5SDimitry Andric return V.visitUnknown(Fragment);
930b57cec5SDimitry Andric }
940b57cec5SDimitry Andric }
950b57cec5SDimitry Andric }
96