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