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