DebugSubsectionVisitor.cpp 3.4 KB

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