DebugCrossImpSubsection.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- DebugCrossImpSubsection.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_DEBUGCROSSIMPSUBSECTION_H
  14. #define LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H
  15. #include "llvm/ADT/StringMap.h"
  16. #include "llvm/ADT/StringRef.h"
  17. #include "llvm/DebugInfo/CodeView/CodeView.h"
  18. #include "llvm/DebugInfo/CodeView/DebugSubsection.h"
  19. #include "llvm/Support/BinaryStreamArray.h"
  20. #include "llvm/Support/BinaryStreamRef.h"
  21. #include "llvm/Support/Endian.h"
  22. #include "llvm/Support/Error.h"
  23. #include <cstdint>
  24. #include <vector>
  25. namespace llvm {
  26. class BinaryStreamReader;
  27. class BinaryStreamWriter;
  28. namespace codeview {
  29. struct CrossModuleImportItem {
  30. const CrossModuleImport *Header = nullptr;
  31. FixedStreamArray<support::ulittle32_t> Imports;
  32. };
  33. } // end namespace codeview
  34. template <> struct VarStreamArrayExtractor<codeview::CrossModuleImportItem> {
  35. public:
  36. using ContextType = void;
  37. Error operator()(BinaryStreamRef Stream, uint32_t &Len,
  38. codeview::CrossModuleImportItem &Item);
  39. };
  40. namespace codeview {
  41. class DebugStringTableSubsection;
  42. class DebugCrossModuleImportsSubsectionRef final : public DebugSubsectionRef {
  43. using ReferenceArray = VarStreamArray<CrossModuleImportItem>;
  44. using Iterator = ReferenceArray::Iterator;
  45. public:
  46. DebugCrossModuleImportsSubsectionRef()
  47. : DebugSubsectionRef(DebugSubsectionKind::CrossScopeImports) {}
  48. static bool classof(const DebugSubsectionRef *S) {
  49. return S->kind() == DebugSubsectionKind::CrossScopeImports;
  50. }
  51. Error initialize(BinaryStreamReader Reader);
  52. Error initialize(BinaryStreamRef Stream);
  53. Iterator begin() const { return References.begin(); }
  54. Iterator end() const { return References.end(); }
  55. private:
  56. ReferenceArray References;
  57. };
  58. class DebugCrossModuleImportsSubsection final : public DebugSubsection {
  59. public:
  60. explicit DebugCrossModuleImportsSubsection(
  61. DebugStringTableSubsection &Strings)
  62. : DebugSubsection(DebugSubsectionKind::CrossScopeImports),
  63. Strings(Strings) {}
  64. static bool classof(const DebugSubsection *S) {
  65. return S->kind() == DebugSubsectionKind::CrossScopeImports;
  66. }
  67. void addImport(StringRef Module, uint32_t ImportId);
  68. uint32_t calculateSerializedSize() const override;
  69. Error commit(BinaryStreamWriter &Writer) const override;
  70. private:
  71. DebugStringTableSubsection &Strings;
  72. StringMap<std::vector<support::ulittle32_t>> Mappings;
  73. };
  74. } // end namespace codeview
  75. } // end namespace llvm
  76. #endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H
  77. #ifdef __GNUC__
  78. #pragma GCC diagnostic pop
  79. #endif