LLVM  10.0.0svn
DWARFYAML.cpp
Go to the documentation of this file.
1 //===- DWARFYAML.cpp - DWARF YAMLIO implementation ------------------------===//
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 DWARF Debug
10 // Info.
11 //
12 //===----------------------------------------------------------------------===//
13 
15 
16 namespace llvm {
17 
19  return 0 == DebugStrings.size() + AbbrevDecls.size();
20 }
21 
22 namespace yaml {
23 
25  auto oldContext = IO.getContext();
26  IO.setContext(&DWARF);
27  IO.mapOptional("debug_str", DWARF.DebugStrings);
28  IO.mapOptional("debug_abbrev", DWARF.AbbrevDecls);
29  if (!DWARF.ARanges.empty() || !IO.outputting())
30  IO.mapOptional("debug_aranges", DWARF.ARanges);
31  if (!DWARF.PubNames.Entries.empty() || !IO.outputting())
32  IO.mapOptional("debug_pubnames", DWARF.PubNames);
33  if (!DWARF.PubTypes.Entries.empty() || !IO.outputting())
34  IO.mapOptional("debug_pubtypes", DWARF.PubTypes);
35  if (!DWARF.GNUPubNames.Entries.empty() || !IO.outputting())
36  IO.mapOptional("debug_gnu_pubnames", DWARF.GNUPubNames);
37  if (!DWARF.GNUPubTypes.Entries.empty() || !IO.outputting())
38  IO.mapOptional("debug_gnu_pubtypes", DWARF.GNUPubTypes);
39  IO.mapOptional("debug_info", DWARF.CompileUnits);
40  IO.mapOptional("debug_line", DWARF.DebugLines);
41  IO.setContext(&oldContext);
42 }
43 
45  DWARFYAML::Abbrev &Abbrev) {
46  IO.mapRequired("Code", Abbrev.Code);
47  IO.mapRequired("Tag", Abbrev.Tag);
48  IO.mapRequired("Children", Abbrev.Children);
49  IO.mapRequired("Attributes", Abbrev.Attributes);
50 }
51 
53  IO &IO, DWARFYAML::AttributeAbbrev &AttAbbrev) {
54  IO.mapRequired("Attribute", AttAbbrev.Attribute);
55  IO.mapRequired("Form", AttAbbrev.Form);
56  if(AttAbbrev.Form == dwarf::DW_FORM_implicit_const)
57  IO.mapRequired("Value", AttAbbrev.Value);
58 }
59 
61  IO &IO, DWARFYAML::ARangeDescriptor &Descriptor) {
62  IO.mapRequired("Address", Descriptor.Address);
63  IO.mapRequired("Length", Descriptor.Length);
64 }
65 
67  DWARFYAML::ARange &Range) {
68  IO.mapRequired("Length", Range.Length);
69  IO.mapRequired("Version", Range.Version);
70  IO.mapRequired("CuOffset", Range.CuOffset);
71  IO.mapRequired("AddrSize", Range.AddrSize);
72  IO.mapRequired("SegSize", Range.SegSize);
73  IO.mapRequired("Descriptors", Range.Descriptors);
74 }
75 
78  IO.mapRequired("DieOffset", Entry.DieOffset);
79  if (reinterpret_cast<DWARFYAML::PubSection *>(IO.getContext())->IsGNUStyle)
80  IO.mapRequired("Descriptor", Entry.Descriptor);
81  IO.mapRequired("Name", Entry.Name);
82 }
83 
85  IO &IO, DWARFYAML::PubSection &Section) {
86  auto OldContext = IO.getContext();
87  IO.setContext(&Section);
88 
89  IO.mapRequired("Length", Section.Length);
90  IO.mapRequired("Version", Section.Version);
91  IO.mapRequired("UnitOffset", Section.UnitOffset);
92  IO.mapRequired("UnitSize", Section.UnitSize);
93  IO.mapRequired("Entries", Section.Entries);
94 
95  IO.setContext(OldContext);
96 }
97 
99  IO.mapRequired("Length", Unit.Length);
100  IO.mapRequired("Version", Unit.Version);
101  if (Unit.Version >= 5)
102  IO.mapRequired("UnitType", Unit.Type);
103  IO.mapRequired("AbbrOffset", Unit.AbbrOffset);
104  IO.mapRequired("AddrSize", Unit.AddrSize);
105  IO.mapOptional("Entries", Unit.Entries);
106 }
107 
109  IO.mapRequired("AbbrCode", Entry.AbbrCode);
110  IO.mapRequired("Values", Entry.Values);
111 }
112 
114  IO &IO, DWARFYAML::FormValue &FormValue) {
115  IO.mapOptional("Value", FormValue.Value);
116  if (!FormValue.CStr.empty() || !IO.outputting())
117  IO.mapOptional("CStr", FormValue.CStr);
118  if (!FormValue.BlockData.empty() || !IO.outputting())
119  IO.mapOptional("BlockData", FormValue.BlockData);
120 }
121 
123  IO.mapRequired("Name", File.Name);
124  IO.mapRequired("DirIdx", File.DirIdx);
125  IO.mapRequired("ModTime", File.ModTime);
126  IO.mapRequired("Length", File.Length);
127 }
128 
130  IO &IO, DWARFYAML::LineTableOpcode &LineTableOpcode) {
131  IO.mapRequired("Opcode", LineTableOpcode.Opcode);
132  if (LineTableOpcode.Opcode == dwarf::DW_LNS_extended_op) {
133  IO.mapRequired("ExtLen", LineTableOpcode.ExtLen);
134  IO.mapRequired("SubOpcode", LineTableOpcode.SubOpcode);
135  }
136 
137  if (!LineTableOpcode.UnknownOpcodeData.empty() || !IO.outputting())
138  IO.mapOptional("UnknownOpcodeData", LineTableOpcode.UnknownOpcodeData);
139  if (!LineTableOpcode.UnknownOpcodeData.empty() || !IO.outputting())
140  IO.mapOptional("StandardOpcodeData", LineTableOpcode.StandardOpcodeData);
141  if (!LineTableOpcode.FileEntry.Name.empty() || !IO.outputting())
142  IO.mapOptional("FileEntry", LineTableOpcode.FileEntry);
143  if (LineTableOpcode.Opcode == dwarf::DW_LNS_advance_line || !IO.outputting())
144  IO.mapOptional("SData", LineTableOpcode.SData);
145  IO.mapOptional("Data", LineTableOpcode.Data);
146 }
147 
149  IO &IO, DWARFYAML::LineTable &LineTable) {
150  IO.mapRequired("Length", LineTable.Length);
151  IO.mapRequired("Version", LineTable.Version);
152  IO.mapRequired("PrologueLength", LineTable.PrologueLength);
153  IO.mapRequired("MinInstLength", LineTable.MinInstLength);
154  if(LineTable.Version >= 4)
155  IO.mapRequired("MaxOpsPerInst", LineTable.MaxOpsPerInst);
156  IO.mapRequired("DefaultIsStmt", LineTable.DefaultIsStmt);
157  IO.mapRequired("LineBase", LineTable.LineBase);
158  IO.mapRequired("LineRange", LineTable.LineRange);
159  IO.mapRequired("OpcodeBase", LineTable.OpcodeBase);
160  IO.mapRequired("StandardOpcodeLengths", LineTable.StandardOpcodeLengths);
161  IO.mapRequired("IncludeDirs", LineTable.IncludeDirs);
162  IO.mapRequired("Files", LineTable.Files);
163  IO.mapRequired("Opcodes", LineTable.Opcodes);
164 }
165 
167  IO &IO, DWARFYAML::InitialLength &InitialLength) {
168  IO.mapRequired("TotalLength", InitialLength.TotalLength);
169  if (InitialLength.isDWARF64())
170  IO.mapRequired("TotalLength64", InitialLength.TotalLength64);
171 }
172 
173 } // end namespace yaml
174 
175 } // end namespace llvm
llvm::dwarf::Constants Children
Definition: DWARFYAML.h:56
PubSection PubNames
Definition: DWARFYAML.h:148
std::vector< AttributeAbbrev > Attributes
Definition: DWARFYAML.h:57
This class represents lattice values for constants.
Definition: AllocatorList.h:23
llvm::dwarf::UnitType Type
Definition: DWARFYAML.h:103
dwarf::LineNumberExtendedOps SubOpcode
Definition: DWARFYAML.h:119
dwarf::LineNumberOps Opcode
Definition: DWARFYAML.h:117
bool isEmpty() const
Definition: DWARFYAML.cpp:18
std::vector< Abbrev > AbbrevDecls
Definition: DWARFYAML.h:145
InitialLength Length
Definition: DWARFYAML.h:66
std::vector< uint8_t > StandardOpcodeLengths
Definition: DWARFYAML.h:137
std::vector< PubEntry > Entries
Definition: DWARFYAML.h:86
std::vector< ARangeDescriptor > Descriptors
Definition: DWARFYAML.h:71
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:126
PubSection GNUPubNames
Definition: DWARFYAML.h:151
std::vector< ARange > ARanges
Definition: DWARFYAML.h:147
std::vector< Unit > CompileUnits
Definition: DWARFYAML.h:154
std::vector< llvm::yaml::Hex8 > BlockData
Definition: DWARFYAML.h:92
llvm::yaml::Hex32 Code
Definition: DWARFYAML.h:54
InitialLength Length
Definition: DWARFYAML.h:101
std::vector< File > Files
Definition: DWARFYAML.h:139
llvm::yaml::Hex32 DieOffset
Definition: DWARFYAML.h:75
std::vector< LineTable > DebugLines
Definition: DWARFYAML.h:156
Instrumentation for Order File
std::vector< StringRef > IncludeDirs
Definition: DWARFYAML.h:138
std::vector< Entry > Entries
Definition: DWARFYAML.h:106
llvm::yaml::Hex64 Value
Definition: DWARFYAML.h:90
std::vector< FormValue > Values
Definition: DWARFYAML.h:97
llvm::yaml::Hex8 Descriptor
Definition: DWARFYAML.h:76
llvm::dwarf::Attribute Attribute
Definition: DWARFYAML.h:48
PubSection PubTypes
Definition: DWARFYAML.h:149
std::vector< StringRef > DebugStrings
Definition: DWARFYAML.h:146
llvm::yaml::Hex32 AbbrCode
Definition: DWARFYAML.h:96
PubSection GNUPubTypes
Definition: DWARFYAML.h:152
std::vector< llvm::yaml::Hex8 > UnknownOpcodeData
Definition: DWARFYAML.h:123
This file declares classes for handling the YAML representation of DWARF Debug Info.
std::vector< llvm::yaml::Hex64 > StandardOpcodeData
Definition: DWARFYAML.h:124
std::vector< LineTableOpcode > Opcodes
Definition: DWARFYAML.h:140
llvm::dwarf::Tag Tag
Definition: DWARFYAML.h:55