DebugSubsectionVisitor.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //===- DebugSubsectionVisitor.h -----------------------------*- 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. #ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGSUBSECTIONVISITOR_H
  9. #define LLVM_DEBUGINFO_CODEVIEW_DEBUGSUBSECTIONVISITOR_H
  10. #include "llvm/DebugInfo/CodeView/CodeView.h"
  11. #include "llvm/DebugInfo/CodeView/StringsAndChecksums.h"
  12. #include "llvm/Support/Error.h"
  13. namespace llvm {
  14. namespace codeview {
  15. class DebugChecksumsSubsectionRef;
  16. class DebugSubsectionRecord;
  17. class DebugInlineeLinesSubsectionRef;
  18. class DebugCrossModuleExportsSubsectionRef;
  19. class DebugCrossModuleImportsSubsectionRef;
  20. class DebugFrameDataSubsectionRef;
  21. class DebugLinesSubsectionRef;
  22. class DebugStringTableSubsectionRef;
  23. class DebugSymbolRVASubsectionRef;
  24. class DebugSymbolsSubsectionRef;
  25. class DebugUnknownSubsectionRef;
  26. class DebugSubsectionVisitor {
  27. public:
  28. virtual ~DebugSubsectionVisitor() = default;
  29. virtual Error visitUnknown(DebugUnknownSubsectionRef &Unknown) {
  30. return Error::success();
  31. }
  32. virtual Error visitLines(DebugLinesSubsectionRef &Lines,
  33. const StringsAndChecksumsRef &State) = 0;
  34. virtual Error visitFileChecksums(DebugChecksumsSubsectionRef &Checksums,
  35. const StringsAndChecksumsRef &State) = 0;
  36. virtual Error visitInlineeLines(DebugInlineeLinesSubsectionRef &Inlinees,
  37. const StringsAndChecksumsRef &State) = 0;
  38. virtual Error
  39. visitCrossModuleExports(DebugCrossModuleExportsSubsectionRef &CSE,
  40. const StringsAndChecksumsRef &State) = 0;
  41. virtual Error
  42. visitCrossModuleImports(DebugCrossModuleImportsSubsectionRef &CSE,
  43. const StringsAndChecksumsRef &State) = 0;
  44. virtual Error visitStringTable(DebugStringTableSubsectionRef &ST,
  45. const StringsAndChecksumsRef &State) = 0;
  46. virtual Error visitSymbols(DebugSymbolsSubsectionRef &CSE,
  47. const StringsAndChecksumsRef &State) = 0;
  48. virtual Error visitFrameData(DebugFrameDataSubsectionRef &FD,
  49. const StringsAndChecksumsRef &State) = 0;
  50. virtual Error visitCOFFSymbolRVAs(DebugSymbolRVASubsectionRef &RVAs,
  51. const StringsAndChecksumsRef &State) = 0;
  52. };
  53. Error visitDebugSubsection(const DebugSubsectionRecord &R,
  54. DebugSubsectionVisitor &V,
  55. const StringsAndChecksumsRef &State);
  56. namespace detail {
  57. template <typename T>
  58. Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V,
  59. StringsAndChecksumsRef &State) {
  60. State.initialize(std::forward<T>(FragmentRange));
  61. for (const DebugSubsectionRecord &L : FragmentRange) {
  62. if (auto EC = visitDebugSubsection(L, V, State))
  63. return EC;
  64. }
  65. return Error::success();
  66. }
  67. } // namespace detail
  68. template <typename T>
  69. Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V) {
  70. StringsAndChecksumsRef State;
  71. return detail::visitDebugSubsections(std::forward<T>(FragmentRange), V,
  72. State);
  73. }
  74. template <typename T>
  75. Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V,
  76. const DebugStringTableSubsectionRef &Strings) {
  77. StringsAndChecksumsRef State(Strings);
  78. return detail::visitDebugSubsections(std::forward<T>(FragmentRange), V,
  79. State);
  80. }
  81. template <typename T>
  82. Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V,
  83. const DebugStringTableSubsectionRef &Strings,
  84. const DebugChecksumsSubsectionRef &Checksums) {
  85. StringsAndChecksumsRef State(Strings, Checksums);
  86. return detail::visitDebugSubsections(std::forward<T>(FragmentRange), V,
  87. State);
  88. }
  89. } // end namespace codeview
  90. } // end namespace llvm
  91. #endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGSUBSECTIONVISITOR_H