DebugSubsectionVisitor.h 4.3 KB

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