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 14 #ifndef LLVM_OBJECTYAML_CODEVIEWYAMLDEBUGSECTIONS_H 15 #define LLVM_OBJECTYAML_CODEVIEWYAMLDEBUGSECTIONS_H 16 17 #include "llvm/ADT/ArrayRef.h" 18 #include "llvm/ADT/StringRef.h" 19 #include "llvm/DebugInfo/CodeView/CodeView.h" 20 #include "llvm/DebugInfo/CodeView/DebugSubsection.h" 21 #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h" 22 #include "llvm/Support/Compiler.h" 23 #include "llvm/Support/Error.h" 24 #include "llvm/Support/YAMLTraits.h" 25 #include <cstdint> 26 #include <memory> 27 #include <vector> 28 29 namespace llvm { 30 31 namespace codeview { 32 33 class StringsAndChecksums; 34 class StringsAndChecksumsRef; 35 36 } // end namespace codeview 37 38 namespace CodeViewYAML { 39 40 namespace detail { 41 42 struct YAMLSubsectionBase; 43 44 } // end namespace detail 45 46 struct YAMLFrameData { 47 uint32_t RvaStart; 48 uint32_t CodeSize; 49 uint32_t LocalSize; 50 uint32_t ParamsSize; 51 uint32_t MaxStackSize; 52 StringRef FrameFunc; 53 uint32_t PrologSize; 54 uint32_t SavedRegsSize; 55 uint32_t Flags; 56 }; 57 58 struct YAMLCrossModuleImport { 59 StringRef ModuleName; 60 std::vector<uint32_t> ImportIds; 61 }; 62 63 struct SourceLineEntry { 64 uint32_t Offset; 65 uint32_t LineStart; 66 uint32_t EndDelta; 67 bool IsStatement; 68 }; 69 70 struct SourceColumnEntry { 71 uint16_t StartColumn; 72 uint16_t EndColumn; 73 }; 74 75 struct SourceLineBlock { 76 StringRef FileName; 77 std::vector<SourceLineEntry> Lines; 78 std::vector<SourceColumnEntry> Columns; 79 }; 80 81 struct HexFormattedString { 82 std::vector<uint8_t> Bytes; 83 }; 84 85 struct SourceFileChecksumEntry { 86 StringRef FileName; 87 codeview::FileChecksumKind Kind; 88 HexFormattedString ChecksumBytes; 89 }; 90 91 struct SourceLineInfo { 92 uint32_t RelocOffset; 93 uint32_t RelocSegment; 94 codeview::LineFlags Flags; 95 uint32_t CodeSize; 96 std::vector<SourceLineBlock> Blocks; 97 }; 98 99 struct InlineeSite { 100 uint32_t Inlinee; 101 StringRef FileName; 102 uint32_t SourceLineNum; 103 std::vector<StringRef> ExtraFiles; 104 }; 105 106 struct InlineeInfo { 107 bool HasExtraFiles; 108 std::vector<InlineeSite> Sites; 109 }; 110 111 struct YAMLDebugSubsection { 112 LLVM_ABI static Expected<YAMLDebugSubsection> 113 fromCodeViewSubection(const codeview::StringsAndChecksumsRef &SC, 114 const codeview::DebugSubsectionRecord &SS); 115 116 std::shared_ptr<detail::YAMLSubsectionBase> Subsection; 117 }; 118 119 LLVM_ABI Expected<std::vector<std::shared_ptr<codeview::DebugSubsection>>> 120 toCodeViewSubsectionList(BumpPtrAllocator &Allocator, 121 ArrayRef<YAMLDebugSubsection> Subsections, 122 const codeview::StringsAndChecksums &SC); 123 124 LLVM_ABI std::vector<YAMLDebugSubsection> 125 fromDebugS(ArrayRef<uint8_t> Data, const codeview::StringsAndChecksumsRef &SC); 126 127 LLVM_ABI void 128 initializeStringsAndChecksums(ArrayRef<YAMLDebugSubsection> Sections, 129 codeview::StringsAndChecksums &SC); 130 131 } // end namespace CodeViewYAML 132 133 } // end namespace llvm 134 135 LLVM_YAML_DECLARE_MAPPING_TRAITS(CodeViewYAML::YAMLDebugSubsection) 136 137 LLVM_YAML_IS_SEQUENCE_VECTOR(CodeViewYAML::YAMLDebugSubsection) 138 139 #endif // LLVM_OBJECTYAML_CODEVIEWYAMLDEBUGSECTIONS_H 140