1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
| //===- DWARFYAML.cpp - DWARF YAMLIO implementation ------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file defines classes for handling the YAML representation of DWARF Debug
// Info.
//
//===----------------------------------------------------------------------===//
#include "llvm/ObjectYAML/DWARFYAML.h"
namespace llvm {
bool DWARFYAML::Data::isEmpty() const {
return 0 == DebugStrings.size() + AbbrevDecls.size();
}
namespace yaml {
void MappingTraits<DWARFYAML::Data>::mapping(IO &IO, DWARFYAML::Data &DWARF) {
auto oldContext = IO.getContext();
IO.setContext(&DWARF);
IO.mapOptional("debug_str", DWARF.DebugStrings);
IO.mapOptional("debug_abbrev", DWARF.AbbrevDecls);
if (!DWARF.ARanges.empty() || !IO.outputting())
IO.mapOptional("debug_aranges", DWARF.ARanges);
if (!DWARF.PubNames.Entries.empty() || !IO.outputting())
IO.mapOptional("debug_pubnames", DWARF.PubNames);
if (!DWARF.PubTypes.Entries.empty() || !IO.outputting())
IO.mapOptional("debug_pubtypes", DWARF.PubTypes);
if (!DWARF.GNUPubNames.Entries.empty() || !IO.outputting())
IO.mapOptional("debug_gnu_pubnames", DWARF.GNUPubNames);
if (!DWARF.GNUPubTypes.Entries.empty() || !IO.outputting())
IO.mapOptional("debug_gnu_pubtypes", DWARF.GNUPubTypes);
IO.mapOptional("debug_info", DWARF.CompileUnits);
IO.mapOptional("debug_line", DWARF.DebugLines);
IO.setContext(&oldContext);
}
void MappingTraits<DWARFYAML::Abbrev>::mapping(IO &IO,
DWARFYAML::Abbrev &Abbrev) {
IO.mapRequired("Code", Abbrev.Code);
IO.mapRequired("Tag", Abbrev.Tag);
IO.mapRequired("Children", Abbrev.Children);
IO.mapRequired("Attributes", Abbrev.Attributes);
}
void MappingTraits<DWARFYAML::AttributeAbbrev>::mapping(
IO &IO, DWARFYAML::AttributeAbbrev &AttAbbrev) {
IO.mapRequired("Attribute", AttAbbrev.Attribute);
IO.mapRequired("Form", AttAbbrev.Form);
if(AttAbbrev.Form == dwarf::DW_FORM_implicit_const)
IO.mapRequired("Value", AttAbbrev.Value);
}
void MappingTraits<DWARFYAML::ARangeDescriptor>::mapping(
IO &IO, DWARFYAML::ARangeDescriptor &Descriptor) {
IO.mapRequired("Address", Descriptor.Address);
IO.mapRequired("Length", Descriptor.Length);
}
void MappingTraits<DWARFYAML::ARange>::mapping(IO &IO,
DWARFYAML::ARange &Range) {
IO.mapRequired("Length", Range.Length);
IO.mapRequired("Version", Range.Version);
IO.mapRequired("CuOffset", Range.CuOffset);
IO.mapRequired("AddrSize", Range.AddrSize);
IO.mapRequired("SegSize", Range.SegSize);
IO.mapRequired("Descriptors", Range.Descriptors);
}
void MappingTraits<DWARFYAML::PubEntry>::mapping(IO &IO,
DWARFYAML::PubEntry &Entry) {
IO.mapRequired("DieOffset", Entry.DieOffset);
if (reinterpret_cast<DWARFYAML::PubSection *>(IO.getContext())->IsGNUStyle)
IO.mapRequired("Descriptor", Entry.Descriptor);
IO.mapRequired("Name", Entry.Name);
}
void MappingTraits<DWARFYAML::PubSection>::mapping(
IO &IO, DWARFYAML::PubSection &Section) {
auto OldContext = IO.getContext();
IO.setContext(&Section);
IO.mapRequired("Length", Section.Length);
IO.mapRequired("Version", Section.Version);
IO.mapRequired("UnitOffset", Section.UnitOffset);
IO.mapRequired("UnitSize", Section.UnitSize);
IO.mapRequired("Entries", Section.Entries);
IO.setContext(OldContext);
}
void MappingTraits<DWARFYAML::Unit>::mapping(IO &IO, DWARFYAML::Unit &Unit) {
IO.mapRequired("Length", Unit.Length);
IO.mapRequired("Version", Unit.Version);
if (Unit.Version >= 5)
IO.mapRequired("UnitType", Unit.Type);
IO.mapRequired("AbbrOffset", Unit.AbbrOffset);
IO.mapRequired("AddrSize", Unit.AddrSize);
IO.mapOptional("Entries", Unit.Entries);
}
void MappingTraits<DWARFYAML::Entry>::mapping(IO &IO, DWARFYAML::Entry &Entry) {
IO.mapRequired("AbbrCode", Entry.AbbrCode);
IO.mapRequired("Values", Entry.Values);
}
void MappingTraits<DWARFYAML::FormValue>::mapping(
IO &IO, DWARFYAML::FormValue &FormValue) {
IO.mapOptional("Value", FormValue.Value);
if (!FormValue.CStr.empty() || !IO.outputting())
IO.mapOptional("CStr", FormValue.CStr);
if (!FormValue.BlockData.empty() || !IO.outputting())
IO.mapOptional("BlockData", FormValue.BlockData);
}
void MappingTraits<DWARFYAML::File>::mapping(IO &IO, DWARFYAML::File &File) {
IO.mapRequired("Name", File.Name);
IO.mapRequired("DirIdx", File.DirIdx);
IO.mapRequired("ModTime", File.ModTime);
IO.mapRequired("Length", File.Length);
}
void MappingTraits<DWARFYAML::LineTableOpcode>::mapping(
IO &IO, DWARFYAML::LineTableOpcode &LineTableOpcode) {
IO.mapRequired("Opcode", LineTableOpcode.Opcode);
if (LineTableOpcode.Opcode == dwarf::DW_LNS_extended_op) {
IO.mapRequired("ExtLen", LineTableOpcode.ExtLen);
IO.mapRequired("SubOpcode", LineTableOpcode.SubOpcode);
}
if (!LineTableOpcode.UnknownOpcodeData.empty() || !IO.outputting())
IO.mapOptional("UnknownOpcodeData", LineTableOpcode.UnknownOpcodeData);
if (!LineTableOpcode.UnknownOpcodeData.empty() || !IO.outputting())
IO.mapOptional("StandardOpcodeData", LineTableOpcode.StandardOpcodeData);
if (!LineTableOpcode.FileEntry.Name.empty() || !IO.outputting())
IO.mapOptional("FileEntry", LineTableOpcode.FileEntry);
if (LineTableOpcode.Opcode == dwarf::DW_LNS_advance_line || !IO.outputting())
IO.mapOptional("SData", LineTableOpcode.SData);
IO.mapOptional("Data", LineTableOpcode.Data);
}
void MappingTraits<DWARFYAML::LineTable>::mapping(
IO &IO, DWARFYAML::LineTable &LineTable) {
IO.mapRequired("Length", LineTable.Length);
IO.mapRequired("Version", LineTable.Version);
IO.mapRequired("PrologueLength", LineTable.PrologueLength);
IO.mapRequired("MinInstLength", LineTable.MinInstLength);
if(LineTable.Version >= 4)
IO.mapRequired("MaxOpsPerInst", LineTable.MaxOpsPerInst);
IO.mapRequired("DefaultIsStmt", LineTable.DefaultIsStmt);
IO.mapRequired("LineBase", LineTable.LineBase);
IO.mapRequired("LineRange", LineTable.LineRange);
IO.mapRequired("OpcodeBase", LineTable.OpcodeBase);
IO.mapRequired("StandardOpcodeLengths", LineTable.StandardOpcodeLengths);
IO.mapRequired("IncludeDirs", LineTable.IncludeDirs);
IO.mapRequired("Files", LineTable.Files);
IO.mapRequired("Opcodes", LineTable.Opcodes);
}
void MappingTraits<DWARFYAML::InitialLength>::mapping(
IO &IO, DWARFYAML::InitialLength &InitialLength) {
IO.mapRequired("TotalLength", InitialLength.TotalLength);
if (InitialLength.isDWARF64())
IO.mapRequired("TotalLength64", InitialLength.TotalLength64);
}
} // end namespace yaml
} // end namespace llvm
|