DebugSubsectionVisitor.cpp 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. #include "llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h"
  9. #include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
  10. #include "llvm/DebugInfo/CodeView/DebugCrossExSubsection.h"
  11. #include "llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h"
  12. #include "llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h"
  13. #include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h"
  14. #include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
  15. #include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
  16. #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
  17. #include "llvm/DebugInfo/CodeView/DebugSymbolRVASubsection.h"
  18. #include "llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h"
  19. #include "llvm/DebugInfo/CodeView/DebugUnknownSubsection.h"
  20. #include "llvm/Support/BinaryStreamReader.h"
  21. #include "llvm/Support/BinaryStreamRef.h"
  22. using namespace llvm;
  23. using namespace llvm::codeview;
  24. Error llvm::codeview::visitDebugSubsection(
  25. const DebugSubsectionRecord &R, DebugSubsectionVisitor &V,
  26. const StringsAndChecksumsRef &State) {
  27. BinaryStreamReader Reader(R.getRecordData());
  28. switch (R.kind()) {
  29. case DebugSubsectionKind::Lines: {
  30. DebugLinesSubsectionRef Fragment;
  31. if (auto EC = Fragment.initialize(Reader))
  32. return EC;
  33. return V.visitLines(Fragment, State);
  34. }
  35. case DebugSubsectionKind::FileChecksums: {
  36. DebugChecksumsSubsectionRef Fragment;
  37. if (auto EC = Fragment.initialize(Reader))
  38. return EC;
  39. return V.visitFileChecksums(Fragment, State);
  40. }
  41. case DebugSubsectionKind::InlineeLines: {
  42. DebugInlineeLinesSubsectionRef Fragment;
  43. if (auto EC = Fragment.initialize(Reader))
  44. return EC;
  45. return V.visitInlineeLines(Fragment, State);
  46. }
  47. case DebugSubsectionKind::CrossScopeExports: {
  48. DebugCrossModuleExportsSubsectionRef Section;
  49. if (auto EC = Section.initialize(Reader))
  50. return EC;
  51. return V.visitCrossModuleExports(Section, State);
  52. }
  53. case DebugSubsectionKind::CrossScopeImports: {
  54. DebugCrossModuleImportsSubsectionRef Section;
  55. if (auto EC = Section.initialize(Reader))
  56. return EC;
  57. return V.visitCrossModuleImports(Section, State);
  58. }
  59. case DebugSubsectionKind::Symbols: {
  60. DebugSymbolsSubsectionRef Section;
  61. if (auto EC = Section.initialize(Reader))
  62. return EC;
  63. return V.visitSymbols(Section, State);
  64. }
  65. case DebugSubsectionKind::StringTable: {
  66. DebugStringTableSubsectionRef Section;
  67. if (auto EC = Section.initialize(Reader))
  68. return EC;
  69. return V.visitStringTable(Section, State);
  70. }
  71. case DebugSubsectionKind::FrameData: {
  72. DebugFrameDataSubsectionRef Section;
  73. if (auto EC = Section.initialize(Reader))
  74. return EC;
  75. return V.visitFrameData(Section, State);
  76. }
  77. case DebugSubsectionKind::CoffSymbolRVA: {
  78. DebugSymbolRVASubsectionRef Section;
  79. if (auto EC = Section.initialize(Reader))
  80. return EC;
  81. return V.visitCOFFSymbolRVAs(Section, State);
  82. }
  83. default: {
  84. DebugUnknownSubsectionRef Fragment(R.kind(), R.getRecordData());
  85. return V.visitUnknown(Fragment);
  86. }
  87. }
  88. }