DebugSubsectionVisitor.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- DebugSubsectionVisitor.h -----------------------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGSUBSECTIONVISITOR_H
  14. #define LLVM_DEBUGINFO_CODEVIEW_DEBUGSUBSECTIONVISITOR_H
  15. #include "llvm/DebugInfo/CodeView/StringsAndChecksums.h"
  16. #include "llvm/Support/Error.h"
  17. namespace llvm {
  18. namespace codeview {
  19. class DebugChecksumsSubsectionRef;
  20. class DebugSubsectionRecord;
  21. class DebugInlineeLinesSubsectionRef;
  22. class DebugCrossModuleExportsSubsectionRef;
  23. class DebugCrossModuleImportsSubsectionRef;
  24. class DebugFrameDataSubsectionRef;
  25. class DebugLinesSubsectionRef;
  26. class DebugStringTableSubsectionRef;
  27. class DebugSymbolRVASubsectionRef;
  28. class DebugSymbolsSubsectionRef;
  29. class DebugUnknownSubsectionRef;
  30. class DebugSubsectionVisitor {
  31. public:
  32. virtual ~DebugSubsectionVisitor() = default;
  33. virtual Error visitUnknown(DebugUnknownSubsectionRef &Unknown) {
  34. return Error::success();
  35. }
  36. virtual Error visitLines(DebugLinesSubsectionRef &Lines,
  37. const StringsAndChecksumsRef &State) = 0;
  38. virtual Error visitFileChecksums(DebugChecksumsSubsectionRef &Checksums,
  39. const StringsAndChecksumsRef &State) = 0;
  40. virtual Error visitInlineeLines(DebugInlineeLinesSubsectionRef &Inlinees,
  41. const StringsAndChecksumsRef &State) = 0;
  42. virtual Error
  43. visitCrossModuleExports(DebugCrossModuleExportsSubsectionRef &CSE,
  44. const StringsAndChecksumsRef &State) = 0;
  45. virtual Error
  46. visitCrossModuleImports(DebugCrossModuleImportsSubsectionRef &CSE,
  47. const StringsAndChecksumsRef &State) = 0;
  48. virtual Error visitStringTable(DebugStringTableSubsectionRef &ST,
  49. const StringsAndChecksumsRef &State) = 0;
  50. virtual Error visitSymbols(DebugSymbolsSubsectionRef &CSE,
  51. const StringsAndChecksumsRef &State) = 0;
  52. virtual Error visitFrameData(DebugFrameDataSubsectionRef &FD,
  53. const StringsAndChecksumsRef &State) = 0;
  54. virtual Error visitCOFFSymbolRVAs(DebugSymbolRVASubsectionRef &RVAs,
  55. const StringsAndChecksumsRef &State) = 0;
  56. };
  57. Error visitDebugSubsection(const DebugSubsectionRecord &R,
  58. DebugSubsectionVisitor &V,
  59. const StringsAndChecksumsRef &State);
  60. namespace detail {
  61. template <typename T>
  62. Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V,
  63. StringsAndChecksumsRef &State) {
  64. State.initialize(std::forward<T>(FragmentRange));
  65. for (const DebugSubsectionRecord &L : FragmentRange) {
  66. if (auto EC = visitDebugSubsection(L, V, State))
  67. return EC;
  68. }
  69. return Error::success();
  70. }
  71. } // namespace detail
  72. template <typename T>
  73. Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V) {
  74. StringsAndChecksumsRef State;
  75. return detail::visitDebugSubsections(std::forward<T>(FragmentRange), V,
  76. State);
  77. }
  78. template <typename T>
  79. Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V,
  80. const DebugStringTableSubsectionRef &Strings) {
  81. StringsAndChecksumsRef State(Strings);
  82. return detail::visitDebugSubsections(std::forward<T>(FragmentRange), V,
  83. State);
  84. }
  85. template <typename T>
  86. Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V,
  87. const DebugStringTableSubsectionRef &Strings,
  88. const DebugChecksumsSubsectionRef &Checksums) {
  89. StringsAndChecksumsRef State(Strings, Checksums);
  90. return detail::visitDebugSubsections(std::forward<T>(FragmentRange), V,
  91. State);
  92. }
  93. } // end namespace codeview
  94. } // end namespace llvm
  95. #endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGSUBSECTIONVISITOR_H
  96. #ifdef __GNUC__
  97. #pragma GCC diagnostic pop
  98. #endif