1//=- CodeViewYAMLDebugSections.h - CodeView YAMLIO debug sections -*- C++ -*-=//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines classes for handling the YAML representation of CodeView
11// Debug Info.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_OBJECTYAML_CODEVIEWYAMLDEBUGSECTIONS_H
16#define LLVM_OBJECTYAML_CODEVIEWYAMLDEBUGSECTIONS_H
17
18#include "llvm/ADT/ArrayRef.h"
19#include "llvm/ADT/StringRef.h"
20#include "llvm/DebugInfo/CodeView/CodeView.h"
21#include "llvm/DebugInfo/CodeView/DebugSubsection.h"
22#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
23#include "llvm/Support/Error.h"
24#include "llvm/Support/YAMLTraits.h"
25#include <cstdint>
26#include <memory>
27#include <vector>
28
29namespace llvm {
30
31namespace codeview {
32
33class StringsAndChecksums;
34class StringsAndChecksumsRef;
35
36} // end namespace codeview
37
38namespace CodeViewYAML {
39
40namespace detail {
41
42struct YAMLSubsectionBase;
43
44} // end namespace detail
45
46struct 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
58struct YAMLCrossModuleImport {
59  StringRef ModuleName;
60  std::vector<uint32_t> ImportIds;
61};
62
63struct SourceLineEntry {
64  uint32_t Offset;
65  uint32_t LineStart;
66  uint32_t EndDelta;
67  bool IsStatement;
68};
69
70struct SourceColumnEntry {
71  uint16_t StartColumn;
72  uint16_t EndColumn;
73};
74
75struct SourceLineBlock {
76  StringRef FileName;
77  std::vector<SourceLineEntry> Lines;
78  std::vector<SourceColumnEntry> Columns;
79};
80
81struct HexFormattedString {
82  std::vector<uint8_t> Bytes;
83};
84
85struct SourceFileChecksumEntry {
86  StringRef FileName;
87  codeview::FileChecksumKind Kind;
88  HexFormattedString ChecksumBytes;
89};
90
91struct SourceLineInfo {
92  uint32_t RelocOffset;
93  uint32_t RelocSegment;
94  codeview::LineFlags Flags;
95  uint32_t CodeSize;
96  std::vector<SourceLineBlock> Blocks;
97};
98
99struct InlineeSite {
100  uint32_t Inlinee;
101  StringRef FileName;
102  uint32_t SourceLineNum;
103  std::vector<StringRef> ExtraFiles;
104};
105
106struct InlineeInfo {
107  bool HasExtraFiles;
108  std::vector<InlineeSite> Sites;
109};
110
111struct YAMLDebugSubsection {
112  static Expected<YAMLDebugSubsection>
113  fromCodeViewSubection(const codeview::StringsAndChecksumsRef &SC,
114                        const codeview::DebugSubsectionRecord &SS);
115
116  std::shared_ptr<detail::YAMLSubsectionBase> Subsection;
117};
118
119struct DebugSubsectionState {};
120
121Expected<std::vector<std::shared_ptr<codeview::DebugSubsection>>>
122toCodeViewSubsectionList(BumpPtrAllocator &Allocator,
123                         ArrayRef<YAMLDebugSubsection> Subsections,
124                         const codeview::StringsAndChecksums &SC);
125
126std::vector<YAMLDebugSubsection>
127fromDebugS(ArrayRef<uint8_t> Data, const codeview::StringsAndChecksumsRef &SC);
128
129void initializeStringsAndChecksums(ArrayRef<YAMLDebugSubsection> Sections,
130                                   codeview::StringsAndChecksums &SC);
131
132} // end namespace CodeViewYAML
133
134} // end namespace llvm
135
136LLVM_YAML_DECLARE_MAPPING_TRAITS(CodeViewYAML::YAMLDebugSubsection)
137
138LLVM_YAML_IS_SEQUENCE_VECTOR(CodeViewYAML::YAMLDebugSubsection)
139
140#endif // LLVM_OBJECTYAML_CODEVIEWYAMLDEBUGSECTIONS_H
141