CodeViewYAMLDebugSections.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. //=- CodeViewYAMLDebugSections.h - CodeView YAMLIO debug sections -*- 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. //
  9. // This file defines classes for handling the YAML representation of CodeView
  10. // Debug Info.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_OBJECTYAML_CODEVIEWYAMLDEBUGSECTIONS_H
  14. #define LLVM_OBJECTYAML_CODEVIEWYAMLDEBUGSECTIONS_H
  15. #include "llvm/ADT/ArrayRef.h"
  16. #include "llvm/ADT/StringRef.h"
  17. #include "llvm/DebugInfo/CodeView/CodeView.h"
  18. #include "llvm/DebugInfo/CodeView/DebugSubsection.h"
  19. #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
  20. #include "llvm/Support/Error.h"
  21. #include "llvm/Support/YAMLTraits.h"
  22. #include <cstdint>
  23. #include <memory>
  24. #include <vector>
  25. namespace llvm {
  26. namespace codeview {
  27. class StringsAndChecksums;
  28. class StringsAndChecksumsRef;
  29. } // end namespace codeview
  30. namespace CodeViewYAML {
  31. namespace detail {
  32. struct YAMLSubsectionBase;
  33. } // end namespace detail
  34. struct YAMLFrameData {
  35. uint32_t RvaStart;
  36. uint32_t CodeSize;
  37. uint32_t LocalSize;
  38. uint32_t ParamsSize;
  39. uint32_t MaxStackSize;
  40. StringRef FrameFunc;
  41. uint32_t PrologSize;
  42. uint32_t SavedRegsSize;
  43. uint32_t Flags;
  44. };
  45. struct YAMLCrossModuleImport {
  46. StringRef ModuleName;
  47. std::vector<uint32_t> ImportIds;
  48. };
  49. struct SourceLineEntry {
  50. uint32_t Offset;
  51. uint32_t LineStart;
  52. uint32_t EndDelta;
  53. bool IsStatement;
  54. };
  55. struct SourceColumnEntry {
  56. uint16_t StartColumn;
  57. uint16_t EndColumn;
  58. };
  59. struct SourceLineBlock {
  60. StringRef FileName;
  61. std::vector<SourceLineEntry> Lines;
  62. std::vector<SourceColumnEntry> Columns;
  63. };
  64. struct HexFormattedString {
  65. std::vector<uint8_t> Bytes;
  66. };
  67. struct SourceFileChecksumEntry {
  68. StringRef FileName;
  69. codeview::FileChecksumKind Kind;
  70. HexFormattedString ChecksumBytes;
  71. };
  72. struct SourceLineInfo {
  73. uint32_t RelocOffset;
  74. uint32_t RelocSegment;
  75. codeview::LineFlags Flags;
  76. uint32_t CodeSize;
  77. std::vector<SourceLineBlock> Blocks;
  78. };
  79. struct InlineeSite {
  80. uint32_t Inlinee;
  81. StringRef FileName;
  82. uint32_t SourceLineNum;
  83. std::vector<StringRef> ExtraFiles;
  84. };
  85. struct InlineeInfo {
  86. bool HasExtraFiles;
  87. std::vector<InlineeSite> Sites;
  88. };
  89. struct YAMLDebugSubsection {
  90. static Expected<YAMLDebugSubsection>
  91. fromCodeViewSubection(const codeview::StringsAndChecksumsRef &SC,
  92. const codeview::DebugSubsectionRecord &SS);
  93. std::shared_ptr<detail::YAMLSubsectionBase> Subsection;
  94. };
  95. struct DebugSubsectionState {};
  96. Expected<std::vector<std::shared_ptr<codeview::DebugSubsection>>>
  97. toCodeViewSubsectionList(BumpPtrAllocator &Allocator,
  98. ArrayRef<YAMLDebugSubsection> Subsections,
  99. const codeview::StringsAndChecksums &SC);
  100. std::vector<YAMLDebugSubsection>
  101. fromDebugS(ArrayRef<uint8_t> Data, const codeview::StringsAndChecksumsRef &SC);
  102. void initializeStringsAndChecksums(ArrayRef<YAMLDebugSubsection> Sections,
  103. codeview::StringsAndChecksums &SC);
  104. } // end namespace CodeViewYAML
  105. } // end namespace llvm
  106. LLVM_YAML_DECLARE_MAPPING_TRAITS(CodeViewYAML::YAMLDebugSubsection)
  107. LLVM_YAML_IS_SEQUENCE_VECTOR(CodeViewYAML::YAMLDebugSubsection)
  108. #endif // LLVM_OBJECTYAML_CODEVIEWYAMLDEBUGSECTIONS_H