DebugCrossImpSubsection.h 2.9 KB

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