LLVM: lib/ObjectYAML/DWARFYAML.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

18

19namespace llvm {

20

24

28 SecNames.insert("debug_str");

30 SecNames.insert("debug_aranges");

32 SecNames.insert("debug_ranges");

34 SecNames.insert("debug_line");

36 SecNames.insert("debug_addr");

38 SecNames.insert("debug_abbrev");

39 if (Units.empty())

40 SecNames.insert("debug_info");

42 SecNames.insert("debug_pubnames");

44 SecNames.insert("debug_pubtypes");

46 SecNames.insert("debug_gnu_pubnames");

48 SecNames.insert("debug_gnu_pubtypes");

50 SecNames.insert("debug_str_offsets");

52 SecNames.insert("debug_rnglists");

54 SecNames.insert("debug_loclists");

56 SecNames.insert("debug_names");

57 return SecNames;

58}

59

62 if (AbbrevTableInfoMap.empty()) {

63 uint64_t AbbrevTableOffset = 0;

65

67 auto It = AbbrevTableInfoMap.insert(

69 AbbrevTableOffset}});

70 if (!It.second)

73 "the ID (%" PRIu64 ") of abbrev table with index %zu has been used "

74 "by abbrev table with index %" PRIu64,

75 AbbrevTableID, Index, It.first->second.Index);

76

78 }

79 }

80

81 auto It = AbbrevTableInfoMap.find(ID);

82 if (It == AbbrevTableInfoMap.end())

84 "cannot find abbrev table whose ID is %" PRIu64,

86 return It->second;

87}

88

89namespace yaml {

90

91void MappingTraitsDWARFYAML::Data::mapping(IO &IO, DWARFYAML::Data &DWARF) {

92 void *OldContext = IO.getContext();

94 IO.setContext(&DWARFCtx);

95 IO.mapOptional("debug_str", DWARF.DebugStrings);

96 IO.mapOptional("debug_abbrev", DWARF.DebugAbbrev);

97 IO.mapOptional("debug_aranges", DWARF.DebugAranges);

98 IO.mapOptional("debug_ranges", DWARF.DebugRanges);

99 IO.mapOptional("debug_pubnames", DWARF.PubNames);

100 IO.mapOptional("debug_pubtypes", DWARF.PubTypes);

102 IO.mapOptional("debug_gnu_pubnames", DWARF.GNUPubNames);

103 IO.mapOptional("debug_gnu_pubtypes", DWARF.GNUPubTypes);

104 IO.mapOptional("debug_info", DWARF.Units);

105 IO.mapOptional("debug_line", DWARF.DebugLines);

106 IO.mapOptional("debug_addr", DWARF.DebugAddr);

107 IO.mapOptional("debug_str_offsets", DWARF.DebugStrOffsets);

108 IO.mapOptional("debug_rnglists", DWARF.DebugRnglists);

109 IO.mapOptional("debug_loclists", DWARF.DebugLoclists);

110 IO.mapOptional("debug_names", DWARF.DebugNames);

111 IO.setContext(OldContext);

112}

113

114void MappingTraitsDWARFYAML::AbbrevTable::mapping(

116 IO.mapOptional("ID", AbbrevTable.ID);

117 IO.mapOptional("Table", AbbrevTable.Table);

118}

119

120void MappingTraitsDWARFYAML::Abbrev::mapping(IO &IO,

121 DWARFYAML::Abbrev &Abbrev) {

122 IO.mapOptional("Code", Abbrev.Code);

123 IO.mapRequired("Tag", Abbrev.Tag);

124 IO.mapRequired("Children", Abbrev.Children);

125 IO.mapOptional("Attributes", Abbrev.Attributes);

126}

127

128void MappingTraitsDWARFYAML::IdxForm::mapping(IO &IO,

129 DWARFYAML::IdxForm &IdxForm) {

130 IO.mapRequired("Idx", IdxForm.Idx);

131 IO.mapRequired("Form", IdxForm.Form);

132}

133

134void MappingTraitsDWARFYAML::DebugNameAbbreviation::mapping(

135 IO &IO, DWARFYAML::DebugNameAbbreviation &DebugNameAbbreviation) {

136 IO.mapRequired("Code", DebugNameAbbreviation.Code);

137 IO.mapRequired("Tag", DebugNameAbbreviation.Tag);

138 IO.mapRequired("Indices", DebugNameAbbreviation.Indices);

139}

140

141void MappingTraitsDWARFYAML::DebugNameEntry::mapping(

142 IO &IO, DWARFYAML::DebugNameEntry &DebugNameEntry) {

143 IO.mapRequired("Name", DebugNameEntry.NameStrp);

144 IO.mapRequired("Code", DebugNameEntry.Code);

145 IO.mapOptional("Values", DebugNameEntry.Values);

146}

147

148void MappingTraitsDWARFYAML::DebugNamesSection::mapping(

149 IO &IO, DWARFYAML::DebugNamesSection &DebugNames) {

150 IO.mapRequired("Abbreviations", DebugNames.Abbrevs);

151 IO.mapRequired("Entries", DebugNames.Entries);

152}

153

154void MappingTraitsDWARFYAML::AttributeAbbrev::mapping(

155 IO &IO, DWARFYAML::AttributeAbbrev &AttAbbrev) {

156 IO.mapRequired("Attribute", AttAbbrev.Attribute);

157 IO.mapRequired("Form", AttAbbrev.Form);

158 if(AttAbbrev.Form == dwarf::DW_FORM_implicit_const)

159 IO.mapRequired("Value", AttAbbrev.Value);

160}

161

162void MappingTraitsDWARFYAML::ARangeDescriptor::mapping(

163 IO &IO, DWARFYAML::ARangeDescriptor &Descriptor) {

164 IO.mapRequired("Address", Descriptor.Address);

165 IO.mapRequired("Length", Descriptor.Length);

166}

167

168void MappingTraitsDWARFYAML::ARange::mapping(IO &IO,

169 DWARFYAML::ARange &ARange) {

170 IO.mapOptional("Format", ARange.Format, dwarf::DWARF32);

171 IO.mapOptional("Length", ARange.Length);

172 IO.mapRequired("Version", ARange.Version);

173 IO.mapRequired("CuOffset", ARange.CuOffset);

174 IO.mapOptional("AddressSize", ARange.AddrSize);

175 IO.mapOptional("SegmentSelectorSize", ARange.SegSize, 0);

176 IO.mapOptional("Descriptors", ARange.Descriptors);

177}

178

179void MappingTraitsDWARFYAML::RangeEntry::mapping(

180 IO &IO, DWARFYAML::RangeEntry &Descriptor) {

181 IO.mapRequired("LowOffset", Descriptor.LowOffset);

182 IO.mapRequired("HighOffset", Descriptor.HighOffset);

183}

184

185void MappingTraitsDWARFYAML::Ranges::mapping(IO &IO,

186 DWARFYAML::Ranges &DebugRanges) {

187 IO.mapOptional("Offset", DebugRanges.Offset);

188 IO.mapOptional("AddrSize", DebugRanges.AddrSize);

189 IO.mapRequired("Entries", DebugRanges.Entries);

190}

191

192void MappingTraitsDWARFYAML::PubEntry::mapping(IO &IO,

193 DWARFYAML::PubEntry &Entry) {

194 IO.mapRequired("DieOffset", Entry.DieOffset);

195 if (static_cast<DWARFYAML::DWARFContext *>(IO.getContext())->IsGNUPubSec)

196 IO.mapRequired("Descriptor", Entry.Descriptor);

197 IO.mapRequired("Name", Entry.Name);

198}

199

200void MappingTraitsDWARFYAML::PubSection::mapping(

201 IO &IO, DWARFYAML::PubSection &Section) {

202 IO.mapOptional("Format", Section.Format, dwarf::DWARF32);

203 IO.mapRequired("Length", Section.Length);

204 IO.mapRequired("Version", Section.Version);

205 IO.mapRequired("UnitOffset", Section.UnitOffset);

206 IO.mapRequired("UnitSize", Section.UnitSize);

207 IO.mapRequired("Entries", Section.Entries);

208}

209

210void MappingTraitsDWARFYAML::Unit::mapping(IO &IO, DWARFYAML::Unit &Unit) {

211 IO.mapOptional("Format", Unit.Format, dwarf::DWARF32);

212 IO.mapOptional("Length", Unit.Length);

213 IO.mapRequired("Version", Unit.Version);

214 if (Unit.Version >= 5)

215 IO.mapRequired("UnitType", Unit.Type);

216 IO.mapOptional("AbbrevTableID", Unit.AbbrevTableID);

217 IO.mapOptional("AbbrOffset", Unit.AbbrOffset);

218 IO.mapOptional("AddrSize", Unit.AddrSize);

219 if (Unit.Version >= 5) {

220 switch (Unit.Type) {

221 case dwarf::DW_UT_compile:

222 case dwarf::DW_UT_partial:

223 default:

224 break;

225 case dwarf::DW_UT_type:

226 case dwarf::DW_UT_split_type:

227 IO.mapRequired("TypeSignature", Unit.TypeSignatureOrDwoID);

228 IO.mapRequired("TypeOffset", Unit.TypeOffset);

229 break;

230 case dwarf::DW_UT_skeleton:

231 case dwarf::DW_UT_split_compile:

232 IO.mapRequired("DwoID", Unit.TypeSignatureOrDwoID);

233 }

234 }

235 IO.mapOptional("Entries", Unit.Entries);

236}

237

238void MappingTraitsDWARFYAML::Entry::mapping(IO &IO, DWARFYAML::Entry &Entry) {

239 IO.mapRequired("AbbrCode", Entry.AbbrCode);

240 IO.mapOptional("Values", Entry.Values);

241}

242

243void MappingTraitsDWARFYAML::FormValue::mapping(

244 IO &IO, DWARFYAML::FormValue &FormValue) {

245 IO.mapOptional("Value", FormValue.Value);

246 if (!FormValue.CStr.empty() || !IO.outputting())

247 IO.mapOptional("CStr", FormValue.CStr);

248 if (!FormValue.BlockData.empty() || !IO.outputting())

249 IO.mapOptional("BlockData", FormValue.BlockData);

250}

251

252void MappingTraitsDWARFYAML::File::mapping(IO &IO, DWARFYAML::File &File) {

253 IO.mapRequired("Name", File.Name);

254 IO.mapRequired("DirIdx", File.DirIdx);

255 IO.mapRequired("ModTime", File.ModTime);

256 IO.mapRequired("Length", File.Length);

257}

258

259void MappingTraitsDWARFYAML::LineTableOpcode::mapping(

260 IO &IO, DWARFYAML::LineTableOpcode &LineTableOpcode) {

261 IO.mapRequired("Opcode", LineTableOpcode.Opcode);

262 if (LineTableOpcode.Opcode == dwarf::DW_LNS_extended_op) {

263 IO.mapOptional("ExtLen", LineTableOpcode.ExtLen);

264 IO.mapRequired("SubOpcode", LineTableOpcode.SubOpcode);

265 }

266

267 if (!LineTableOpcode.UnknownOpcodeData.empty() || !IO.outputting())

268 IO.mapOptional("UnknownOpcodeData", LineTableOpcode.UnknownOpcodeData);

269 if (!LineTableOpcode.UnknownOpcodeData.empty() || !IO.outputting())

270 IO.mapOptional("StandardOpcodeData", LineTableOpcode.StandardOpcodeData);

271 if (!LineTableOpcode.FileEntry.Name.empty() || !IO.outputting())

272 IO.mapOptional("FileEntry", LineTableOpcode.FileEntry);

273 if (LineTableOpcode.Opcode == dwarf::DW_LNS_advance_line || !IO.outputting())

274 IO.mapOptional("SData", LineTableOpcode.SData);

275 IO.mapOptional("Data", LineTableOpcode.Data);

276}

277

278void MappingTraitsDWARFYAML::LineTable::mapping(

279 IO &IO, DWARFYAML::LineTable &LineTable) {

280 IO.mapOptional("Format", LineTable.Format, dwarf::DWARF32);

281 IO.mapOptional("Length", LineTable.Length);

282 IO.mapRequired("Version", LineTable.Version);

283 IO.mapOptional("PrologueLength", LineTable.PrologueLength);

284 IO.mapRequired("MinInstLength", LineTable.MinInstLength);

285 if(LineTable.Version >= 4)

286 IO.mapRequired("MaxOpsPerInst", LineTable.MaxOpsPerInst);

287 IO.mapRequired("DefaultIsStmt", LineTable.DefaultIsStmt);

288 IO.mapRequired("LineBase", LineTable.LineBase);

289 IO.mapRequired("LineRange", LineTable.LineRange);

290 IO.mapOptional("OpcodeBase", LineTable.OpcodeBase);

291 IO.mapOptional("StandardOpcodeLengths", LineTable.StandardOpcodeLengths);

292 IO.mapOptional("IncludeDirs", LineTable.IncludeDirs);

293 IO.mapOptional("Files", LineTable.Files);

294 IO.mapOptional("Opcodes", LineTable.Opcodes);

295}

296

297void MappingTraitsDWARFYAML::SegAddrPair::mapping(

298 IO &IO, DWARFYAML::SegAddrPair &SegAddrPair) {

299 IO.mapOptional("Segment", SegAddrPair.Segment, 0);

300 IO.mapOptional("Address", SegAddrPair.Address, 0);

301}

302

303void MappingTraitsDWARFYAML::AddrTableEntry::mapping(

304 IO &IO, DWARFYAML::AddrTableEntry &AddrTable) {

305 IO.mapOptional("Format", AddrTable.Format, dwarf::DWARF32);

306 IO.mapOptional("Length", AddrTable.Length);

307 IO.mapRequired("Version", AddrTable.Version);

308 IO.mapOptional("AddressSize", AddrTable.AddrSize);

309 IO.mapOptional("SegmentSelectorSize", AddrTable.SegSelectorSize, 0);

310 IO.mapOptional("Entries", AddrTable.SegAddrPairs);

311}

312

313void MappingTraitsDWARFYAML::StringOffsetsTable::mapping(

314 IO &IO, DWARFYAML::StringOffsetsTable &StrOffsetsTable) {

315 IO.mapOptional("Format", StrOffsetsTable.Format, dwarf::DWARF32);

316 IO.mapOptional("Length", StrOffsetsTable.Length);

317 IO.mapOptional("Version", StrOffsetsTable.Version, 5);

318 IO.mapOptional("Padding", StrOffsetsTable.Padding, 0);

319 IO.mapOptional("Offsets", StrOffsetsTable.Offsets);

320}

321

322void MappingTraitsDWARFYAML::DWARFOperation::mapping(

323 IO &IO, DWARFYAML::DWARFOperation &DWARFOperation) {

324 IO.mapRequired("Operator", DWARFOperation.Operator);

325 IO.mapOptional("Values", DWARFOperation.Values);

326}

327

328void MappingTraitsDWARFYAML::RnglistEntry::mapping(

329 IO &IO, DWARFYAML::RnglistEntry &RnglistEntry) {

330 IO.mapRequired("Operator", RnglistEntry.Operator);

331 IO.mapOptional("Values", RnglistEntry.Values);

332}

333

334void MappingTraitsDWARFYAML::LoclistEntry::mapping(

335 IO &IO, DWARFYAML::LoclistEntry &LoclistEntry) {

336 IO.mapRequired("Operator", LoclistEntry.Operator);

337 IO.mapOptional("Values", LoclistEntry.Values);

338 IO.mapOptional("DescriptionsLength", LoclistEntry.DescriptionsLength);

339 IO.mapOptional("Descriptions", LoclistEntry.Descriptions);

340}

341

342template

343void MappingTraits<DWARFYAML::ListEntries>::mapping(

344 IO &IO, DWARFYAML::ListEntries &ListEntries) {

345 IO.mapOptional("Entries", ListEntries.Entries);

346 IO.mapOptional("Content", ListEntries.Content);

347}

348

349template

350std::string MappingTraits<DWARFYAML::ListEntries>::validate(

351 IO &IO, DWARFYAML::ListEntries &ListEntries) {

352 if (ListEntries.Entries && ListEntries.Content)

353 return "Entries and Content can't be used together";

354 return "";

355}

356

357template

358void MappingTraits<DWARFYAML::ListTable>::mapping(

359 IO &IO, DWARFYAML::ListTable &ListTable) {

360 IO.mapOptional("Format", ListTable.Format, dwarf::DWARF32);

361 IO.mapOptional("Length", ListTable.Length);

362 IO.mapOptional("Version", ListTable.Version, 5);

363 IO.mapOptional("AddressSize", ListTable.AddrSize);

364 IO.mapOptional("SegmentSelectorSize", ListTable.SegSelectorSize, 0);

365 IO.mapOptional("OffsetEntryCount", ListTable.OffsetEntryCount);

366 IO.mapOptional("Offsets", ListTable.Offsets);

367 IO.mapOptional("Lists", ListTable.Lists);

368}

369

370}

371

372}

This file declares classes for handling the YAML representation of DWARF Debug Info.

This file contains constants used for implementing Dwarf debug support.

Tagged union holding either a T or a Error.

A vector that has set insertion semantics.

bool insert(const value_type &X)

Insert a new element into the SetVector.

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

This is an optimization pass for GlobalISel generic memory operations.

auto enumerate(FirstRange &&First, RestRanges &&...Rest)

Given two or more input ranges, returns a new range whose values are tuples (A, B,...

Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)

Create formatted StringError object.

std::vector< Abbrev > Table

std::optional< uint64_t > ID

Class that contains helpful context information when mapping YAML into DWARF data structures.

std::vector< Unit > Units

std::vector< LineTable > DebugLines

std::optional< std::vector< AddrTableEntry > > DebugAddr

std::optional< std::vector< Ranges > > DebugRanges

std::optional< std::vector< ListTable< LoclistEntry > > > DebugLoclists

std::vector< AbbrevTable > DebugAbbrev

LLVM_ABI Expected< AbbrevTableInfo > getAbbrevTableInfoByID(uint64_t ID) const

Definition DWARFYAML.cpp:61

std::optional< PubSection > GNUPubNames

std::optional< std::vector< ARange > > DebugAranges

LLVM_ABI StringRef getAbbrevTableContentByIndex(uint64_t Index) const

std::optional< PubSection > GNUPubTypes

LLVM_ABI SetVector< StringRef > getNonEmptySectionNames() const

Definition DWARFYAML.cpp:25

std::optional< std::vector< StringOffsetsTable > > DebugStrOffsets

std::optional< std::vector< StringRef > > DebugStrings

std::optional< std::vector< ListTable< RnglistEntry > > > DebugRnglists

std::optional< PubSection > PubNames

std::optional< DebugNamesSection > DebugNames

std::optional< PubSection > PubTypes

LLVM_ABI bool isEmpty() const

Definition DWARFYAML.cpp:21