10b57cec5SDimitry Andric //===- DWARFYAML.cpp - DWARF YAMLIO implementation ------------------------===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This file defines classes for handling the YAML representation of DWARF Debug 100b57cec5SDimitry Andric // Info. 110b57cec5SDimitry Andric // 120b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 130b57cec5SDimitry Andric 140b57cec5SDimitry Andric #include "llvm/ObjectYAML/DWARFYAML.h" 155ffd83dbSDimitry Andric #include "llvm/BinaryFormat/Dwarf.h" 16e8d8bef9SDimitry Andric #include "llvm/Support/Errc.h" 17e8d8bef9SDimitry Andric #include "llvm/Support/Error.h" 180b57cec5SDimitry Andric 190b57cec5SDimitry Andric namespace llvm { 200b57cec5SDimitry Andric 210b57cec5SDimitry Andric bool DWARFYAML::Data::isEmpty() const { 22e8d8bef9SDimitry Andric return getNonEmptySectionNames().empty(); 235ffd83dbSDimitry Andric } 245ffd83dbSDimitry Andric 25e8d8bef9SDimitry Andric SetVector<StringRef> DWARFYAML::Data::getNonEmptySectionNames() const { 265ffd83dbSDimitry Andric SetVector<StringRef> SecNames; 27e8d8bef9SDimitry Andric if (DebugStrings) 285ffd83dbSDimitry Andric SecNames.insert("debug_str"); 29e8d8bef9SDimitry Andric if (DebugAranges) 305ffd83dbSDimitry Andric SecNames.insert("debug_aranges"); 31e8d8bef9SDimitry Andric if (DebugRanges) 325ffd83dbSDimitry Andric SecNames.insert("debug_ranges"); 335ffd83dbSDimitry Andric if (!DebugLines.empty()) 345ffd83dbSDimitry Andric SecNames.insert("debug_line"); 35e8d8bef9SDimitry Andric if (DebugAddr) 365ffd83dbSDimitry Andric SecNames.insert("debug_addr"); 37e8d8bef9SDimitry Andric if (!DebugAbbrev.empty()) 385ffd83dbSDimitry Andric SecNames.insert("debug_abbrev"); 395ffd83dbSDimitry Andric if (!CompileUnits.empty()) 405ffd83dbSDimitry Andric SecNames.insert("debug_info"); 415ffd83dbSDimitry Andric if (PubNames) 425ffd83dbSDimitry Andric SecNames.insert("debug_pubnames"); 435ffd83dbSDimitry Andric if (PubTypes) 445ffd83dbSDimitry Andric SecNames.insert("debug_pubtypes"); 455ffd83dbSDimitry Andric if (GNUPubNames) 465ffd83dbSDimitry Andric SecNames.insert("debug_gnu_pubnames"); 475ffd83dbSDimitry Andric if (GNUPubTypes) 485ffd83dbSDimitry Andric SecNames.insert("debug_gnu_pubtypes"); 49e8d8bef9SDimitry Andric if (DebugStrOffsets) 50e8d8bef9SDimitry Andric SecNames.insert("debug_str_offsets"); 51e8d8bef9SDimitry Andric if (DebugRnglists) 52e8d8bef9SDimitry Andric SecNames.insert("debug_rnglists"); 53e8d8bef9SDimitry Andric if (DebugLoclists) 54e8d8bef9SDimitry Andric SecNames.insert("debug_loclists"); 555ffd83dbSDimitry Andric return SecNames; 560b57cec5SDimitry Andric } 570b57cec5SDimitry Andric 58e8d8bef9SDimitry Andric Expected<DWARFYAML::Data::AbbrevTableInfo> 59e8d8bef9SDimitry Andric DWARFYAML::Data::getAbbrevTableInfoByID(uint64_t ID) const { 60e8d8bef9SDimitry Andric if (AbbrevTableInfoMap.empty()) { 61e8d8bef9SDimitry Andric uint64_t AbbrevTableOffset = 0; 62*06c3fb27SDimitry Andric for (const auto &[Index, AbbrevTable] : enumerate(DebugAbbrev)) { 63e8d8bef9SDimitry Andric // If the abbrev table's ID isn't specified, we use the index as its ID. 64*06c3fb27SDimitry Andric uint64_t AbbrevTableID = AbbrevTable.ID.value_or(Index); 65e8d8bef9SDimitry Andric auto It = AbbrevTableInfoMap.insert( 66*06c3fb27SDimitry Andric {AbbrevTableID, AbbrevTableInfo{/*Index=*/Index, 67e8d8bef9SDimitry Andric /*Offset=*/AbbrevTableOffset}}); 68e8d8bef9SDimitry Andric if (!It.second) 69e8d8bef9SDimitry Andric return createStringError( 70e8d8bef9SDimitry Andric errc::invalid_argument, 71e8d8bef9SDimitry Andric "the ID (%" PRIu64 ") of abbrev table with index %zu has been used " 72e8d8bef9SDimitry Andric "by abbrev table with index %" PRIu64, 73*06c3fb27SDimitry Andric AbbrevTableID, Index, It.first->second.Index); 74e8d8bef9SDimitry Andric 75*06c3fb27SDimitry Andric AbbrevTableOffset += getAbbrevTableContentByIndex(Index).size(); 76e8d8bef9SDimitry Andric } 77e8d8bef9SDimitry Andric } 78e8d8bef9SDimitry Andric 79e8d8bef9SDimitry Andric auto It = AbbrevTableInfoMap.find(ID); 80e8d8bef9SDimitry Andric if (It == AbbrevTableInfoMap.end()) 81e8d8bef9SDimitry Andric return createStringError(errc::invalid_argument, 82e8d8bef9SDimitry Andric "cannot find abbrev table whose ID is %" PRIu64, 83e8d8bef9SDimitry Andric ID); 84e8d8bef9SDimitry Andric return It->second; 85e8d8bef9SDimitry Andric } 86e8d8bef9SDimitry Andric 870b57cec5SDimitry Andric namespace yaml { 880b57cec5SDimitry Andric 890b57cec5SDimitry Andric void MappingTraits<DWARFYAML::Data>::mapping(IO &IO, DWARFYAML::Data &DWARF) { 905ffd83dbSDimitry Andric void *OldContext = IO.getContext(); 915ffd83dbSDimitry Andric DWARFYAML::DWARFContext DWARFCtx; 925ffd83dbSDimitry Andric IO.setContext(&DWARFCtx); 930b57cec5SDimitry Andric IO.mapOptional("debug_str", DWARF.DebugStrings); 94e8d8bef9SDimitry Andric IO.mapOptional("debug_abbrev", DWARF.DebugAbbrev); 95e8d8bef9SDimitry Andric IO.mapOptional("debug_aranges", DWARF.DebugAranges); 965ffd83dbSDimitry Andric IO.mapOptional("debug_ranges", DWARF.DebugRanges); 970b57cec5SDimitry Andric IO.mapOptional("debug_pubnames", DWARF.PubNames); 980b57cec5SDimitry Andric IO.mapOptional("debug_pubtypes", DWARF.PubTypes); 995ffd83dbSDimitry Andric DWARFCtx.IsGNUPubSec = true; 1000b57cec5SDimitry Andric IO.mapOptional("debug_gnu_pubnames", DWARF.GNUPubNames); 1010b57cec5SDimitry Andric IO.mapOptional("debug_gnu_pubtypes", DWARF.GNUPubTypes); 1020b57cec5SDimitry Andric IO.mapOptional("debug_info", DWARF.CompileUnits); 1030b57cec5SDimitry Andric IO.mapOptional("debug_line", DWARF.DebugLines); 1045ffd83dbSDimitry Andric IO.mapOptional("debug_addr", DWARF.DebugAddr); 105e8d8bef9SDimitry Andric IO.mapOptional("debug_str_offsets", DWARF.DebugStrOffsets); 106e8d8bef9SDimitry Andric IO.mapOptional("debug_rnglists", DWARF.DebugRnglists); 107e8d8bef9SDimitry Andric IO.mapOptional("debug_loclists", DWARF.DebugLoclists); 1085ffd83dbSDimitry Andric IO.setContext(OldContext); 1090b57cec5SDimitry Andric } 1100b57cec5SDimitry Andric 111e8d8bef9SDimitry Andric void MappingTraits<DWARFYAML::AbbrevTable>::mapping( 112e8d8bef9SDimitry Andric IO &IO, DWARFYAML::AbbrevTable &AbbrevTable) { 113e8d8bef9SDimitry Andric IO.mapOptional("ID", AbbrevTable.ID); 114e8d8bef9SDimitry Andric IO.mapOptional("Table", AbbrevTable.Table); 115e8d8bef9SDimitry Andric } 116e8d8bef9SDimitry Andric 1170b57cec5SDimitry Andric void MappingTraits<DWARFYAML::Abbrev>::mapping(IO &IO, 1180b57cec5SDimitry Andric DWARFYAML::Abbrev &Abbrev) { 1195ffd83dbSDimitry Andric IO.mapOptional("Code", Abbrev.Code); 1200b57cec5SDimitry Andric IO.mapRequired("Tag", Abbrev.Tag); 1210b57cec5SDimitry Andric IO.mapRequired("Children", Abbrev.Children); 122e8d8bef9SDimitry Andric IO.mapOptional("Attributes", Abbrev.Attributes); 1230b57cec5SDimitry Andric } 1240b57cec5SDimitry Andric 1250b57cec5SDimitry Andric void MappingTraits<DWARFYAML::AttributeAbbrev>::mapping( 1260b57cec5SDimitry Andric IO &IO, DWARFYAML::AttributeAbbrev &AttAbbrev) { 1270b57cec5SDimitry Andric IO.mapRequired("Attribute", AttAbbrev.Attribute); 1280b57cec5SDimitry Andric IO.mapRequired("Form", AttAbbrev.Form); 1290b57cec5SDimitry Andric if(AttAbbrev.Form == dwarf::DW_FORM_implicit_const) 1300b57cec5SDimitry Andric IO.mapRequired("Value", AttAbbrev.Value); 1310b57cec5SDimitry Andric } 1320b57cec5SDimitry Andric 1330b57cec5SDimitry Andric void MappingTraits<DWARFYAML::ARangeDescriptor>::mapping( 1340b57cec5SDimitry Andric IO &IO, DWARFYAML::ARangeDescriptor &Descriptor) { 1350b57cec5SDimitry Andric IO.mapRequired("Address", Descriptor.Address); 1360b57cec5SDimitry Andric IO.mapRequired("Length", Descriptor.Length); 1370b57cec5SDimitry Andric } 1380b57cec5SDimitry Andric 1390b57cec5SDimitry Andric void MappingTraits<DWARFYAML::ARange>::mapping(IO &IO, 1405ffd83dbSDimitry Andric DWARFYAML::ARange &ARange) { 1415ffd83dbSDimitry Andric IO.mapOptional("Format", ARange.Format, dwarf::DWARF32); 142e8d8bef9SDimitry Andric IO.mapOptional("Length", ARange.Length); 1435ffd83dbSDimitry Andric IO.mapRequired("Version", ARange.Version); 1445ffd83dbSDimitry Andric IO.mapRequired("CuOffset", ARange.CuOffset); 145e8d8bef9SDimitry Andric IO.mapOptional("AddressSize", ARange.AddrSize); 146e8d8bef9SDimitry Andric IO.mapOptional("SegmentSelectorSize", ARange.SegSize, 0); 147e8d8bef9SDimitry Andric IO.mapOptional("Descriptors", ARange.Descriptors); 1485ffd83dbSDimitry Andric } 1495ffd83dbSDimitry Andric 1505ffd83dbSDimitry Andric void MappingTraits<DWARFYAML::RangeEntry>::mapping( 1515ffd83dbSDimitry Andric IO &IO, DWARFYAML::RangeEntry &Descriptor) { 1525ffd83dbSDimitry Andric IO.mapRequired("LowOffset", Descriptor.LowOffset); 1535ffd83dbSDimitry Andric IO.mapRequired("HighOffset", Descriptor.HighOffset); 1545ffd83dbSDimitry Andric } 1555ffd83dbSDimitry Andric 1565ffd83dbSDimitry Andric void MappingTraits<DWARFYAML::Ranges>::mapping(IO &IO, 1575ffd83dbSDimitry Andric DWARFYAML::Ranges &DebugRanges) { 1585ffd83dbSDimitry Andric IO.mapOptional("Offset", DebugRanges.Offset); 1595ffd83dbSDimitry Andric IO.mapOptional("AddrSize", DebugRanges.AddrSize); 1605ffd83dbSDimitry Andric IO.mapRequired("Entries", DebugRanges.Entries); 1610b57cec5SDimitry Andric } 1620b57cec5SDimitry Andric 1630b57cec5SDimitry Andric void MappingTraits<DWARFYAML::PubEntry>::mapping(IO &IO, 1640b57cec5SDimitry Andric DWARFYAML::PubEntry &Entry) { 1650b57cec5SDimitry Andric IO.mapRequired("DieOffset", Entry.DieOffset); 1665ffd83dbSDimitry Andric if (static_cast<DWARFYAML::DWARFContext *>(IO.getContext())->IsGNUPubSec) 1670b57cec5SDimitry Andric IO.mapRequired("Descriptor", Entry.Descriptor); 1680b57cec5SDimitry Andric IO.mapRequired("Name", Entry.Name); 1690b57cec5SDimitry Andric } 1700b57cec5SDimitry Andric 1710b57cec5SDimitry Andric void MappingTraits<DWARFYAML::PubSection>::mapping( 1720b57cec5SDimitry Andric IO &IO, DWARFYAML::PubSection &Section) { 173e8d8bef9SDimitry Andric IO.mapOptional("Format", Section.Format, dwarf::DWARF32); 1740b57cec5SDimitry Andric IO.mapRequired("Length", Section.Length); 1750b57cec5SDimitry Andric IO.mapRequired("Version", Section.Version); 1760b57cec5SDimitry Andric IO.mapRequired("UnitOffset", Section.UnitOffset); 1770b57cec5SDimitry Andric IO.mapRequired("UnitSize", Section.UnitSize); 1780b57cec5SDimitry Andric IO.mapRequired("Entries", Section.Entries); 1790b57cec5SDimitry Andric } 1800b57cec5SDimitry Andric 1810b57cec5SDimitry Andric void MappingTraits<DWARFYAML::Unit>::mapping(IO &IO, DWARFYAML::Unit &Unit) { 1825ffd83dbSDimitry Andric IO.mapOptional("Format", Unit.Format, dwarf::DWARF32); 183e8d8bef9SDimitry Andric IO.mapOptional("Length", Unit.Length); 1840b57cec5SDimitry Andric IO.mapRequired("Version", Unit.Version); 1850b57cec5SDimitry Andric if (Unit.Version >= 5) 1860b57cec5SDimitry Andric IO.mapRequired("UnitType", Unit.Type); 187e8d8bef9SDimitry Andric IO.mapOptional("AbbrevTableID", Unit.AbbrevTableID); 188e8d8bef9SDimitry Andric IO.mapOptional("AbbrOffset", Unit.AbbrOffset); 189e8d8bef9SDimitry Andric IO.mapOptional("AddrSize", Unit.AddrSize); 1900b57cec5SDimitry Andric IO.mapOptional("Entries", Unit.Entries); 1910b57cec5SDimitry Andric } 1920b57cec5SDimitry Andric 1930b57cec5SDimitry Andric void MappingTraits<DWARFYAML::Entry>::mapping(IO &IO, DWARFYAML::Entry &Entry) { 1940b57cec5SDimitry Andric IO.mapRequired("AbbrCode", Entry.AbbrCode); 195e8d8bef9SDimitry Andric IO.mapOptional("Values", Entry.Values); 1960b57cec5SDimitry Andric } 1970b57cec5SDimitry Andric 1980b57cec5SDimitry Andric void MappingTraits<DWARFYAML::FormValue>::mapping( 1990b57cec5SDimitry Andric IO &IO, DWARFYAML::FormValue &FormValue) { 2000b57cec5SDimitry Andric IO.mapOptional("Value", FormValue.Value); 2010b57cec5SDimitry Andric if (!FormValue.CStr.empty() || !IO.outputting()) 2020b57cec5SDimitry Andric IO.mapOptional("CStr", FormValue.CStr); 2030b57cec5SDimitry Andric if (!FormValue.BlockData.empty() || !IO.outputting()) 2040b57cec5SDimitry Andric IO.mapOptional("BlockData", FormValue.BlockData); 2050b57cec5SDimitry Andric } 2060b57cec5SDimitry Andric 2070b57cec5SDimitry Andric void MappingTraits<DWARFYAML::File>::mapping(IO &IO, DWARFYAML::File &File) { 2080b57cec5SDimitry Andric IO.mapRequired("Name", File.Name); 2090b57cec5SDimitry Andric IO.mapRequired("DirIdx", File.DirIdx); 2100b57cec5SDimitry Andric IO.mapRequired("ModTime", File.ModTime); 2110b57cec5SDimitry Andric IO.mapRequired("Length", File.Length); 2120b57cec5SDimitry Andric } 2130b57cec5SDimitry Andric 2140b57cec5SDimitry Andric void MappingTraits<DWARFYAML::LineTableOpcode>::mapping( 2150b57cec5SDimitry Andric IO &IO, DWARFYAML::LineTableOpcode &LineTableOpcode) { 2160b57cec5SDimitry Andric IO.mapRequired("Opcode", LineTableOpcode.Opcode); 2170b57cec5SDimitry Andric if (LineTableOpcode.Opcode == dwarf::DW_LNS_extended_op) { 218e8d8bef9SDimitry Andric IO.mapOptional("ExtLen", LineTableOpcode.ExtLen); 2190b57cec5SDimitry Andric IO.mapRequired("SubOpcode", LineTableOpcode.SubOpcode); 2200b57cec5SDimitry Andric } 2210b57cec5SDimitry Andric 2220b57cec5SDimitry Andric if (!LineTableOpcode.UnknownOpcodeData.empty() || !IO.outputting()) 2230b57cec5SDimitry Andric IO.mapOptional("UnknownOpcodeData", LineTableOpcode.UnknownOpcodeData); 2240b57cec5SDimitry Andric if (!LineTableOpcode.UnknownOpcodeData.empty() || !IO.outputting()) 2250b57cec5SDimitry Andric IO.mapOptional("StandardOpcodeData", LineTableOpcode.StandardOpcodeData); 2260b57cec5SDimitry Andric if (!LineTableOpcode.FileEntry.Name.empty() || !IO.outputting()) 2270b57cec5SDimitry Andric IO.mapOptional("FileEntry", LineTableOpcode.FileEntry); 2280b57cec5SDimitry Andric if (LineTableOpcode.Opcode == dwarf::DW_LNS_advance_line || !IO.outputting()) 2290b57cec5SDimitry Andric IO.mapOptional("SData", LineTableOpcode.SData); 2300b57cec5SDimitry Andric IO.mapOptional("Data", LineTableOpcode.Data); 2310b57cec5SDimitry Andric } 2320b57cec5SDimitry Andric 2330b57cec5SDimitry Andric void MappingTraits<DWARFYAML::LineTable>::mapping( 2340b57cec5SDimitry Andric IO &IO, DWARFYAML::LineTable &LineTable) { 2355ffd83dbSDimitry Andric IO.mapOptional("Format", LineTable.Format, dwarf::DWARF32); 236e8d8bef9SDimitry Andric IO.mapOptional("Length", LineTable.Length); 2370b57cec5SDimitry Andric IO.mapRequired("Version", LineTable.Version); 238e8d8bef9SDimitry Andric IO.mapOptional("PrologueLength", LineTable.PrologueLength); 2390b57cec5SDimitry Andric IO.mapRequired("MinInstLength", LineTable.MinInstLength); 2400b57cec5SDimitry Andric if(LineTable.Version >= 4) 2410b57cec5SDimitry Andric IO.mapRequired("MaxOpsPerInst", LineTable.MaxOpsPerInst); 2420b57cec5SDimitry Andric IO.mapRequired("DefaultIsStmt", LineTable.DefaultIsStmt); 2430b57cec5SDimitry Andric IO.mapRequired("LineBase", LineTable.LineBase); 2440b57cec5SDimitry Andric IO.mapRequired("LineRange", LineTable.LineRange); 245e8d8bef9SDimitry Andric IO.mapOptional("OpcodeBase", LineTable.OpcodeBase); 246e8d8bef9SDimitry Andric IO.mapOptional("StandardOpcodeLengths", LineTable.StandardOpcodeLengths); 247e8d8bef9SDimitry Andric IO.mapOptional("IncludeDirs", LineTable.IncludeDirs); 248e8d8bef9SDimitry Andric IO.mapOptional("Files", LineTable.Files); 249e8d8bef9SDimitry Andric IO.mapOptional("Opcodes", LineTable.Opcodes); 2500b57cec5SDimitry Andric } 2510b57cec5SDimitry Andric 2525ffd83dbSDimitry Andric void MappingTraits<DWARFYAML::SegAddrPair>::mapping( 2535ffd83dbSDimitry Andric IO &IO, DWARFYAML::SegAddrPair &SegAddrPair) { 2545ffd83dbSDimitry Andric IO.mapOptional("Segment", SegAddrPair.Segment, 0); 2555ffd83dbSDimitry Andric IO.mapOptional("Address", SegAddrPair.Address, 0); 2565ffd83dbSDimitry Andric } 2575ffd83dbSDimitry Andric 2585ffd83dbSDimitry Andric void MappingTraits<DWARFYAML::AddrTableEntry>::mapping( 2595ffd83dbSDimitry Andric IO &IO, DWARFYAML::AddrTableEntry &AddrTable) { 2605ffd83dbSDimitry Andric IO.mapOptional("Format", AddrTable.Format, dwarf::DWARF32); 2615ffd83dbSDimitry Andric IO.mapOptional("Length", AddrTable.Length); 2625ffd83dbSDimitry Andric IO.mapRequired("Version", AddrTable.Version); 2635ffd83dbSDimitry Andric IO.mapOptional("AddressSize", AddrTable.AddrSize); 2645ffd83dbSDimitry Andric IO.mapOptional("SegmentSelectorSize", AddrTable.SegSelectorSize, 0); 2655ffd83dbSDimitry Andric IO.mapOptional("Entries", AddrTable.SegAddrPairs); 2665ffd83dbSDimitry Andric } 2675ffd83dbSDimitry Andric 268e8d8bef9SDimitry Andric void MappingTraits<DWARFYAML::StringOffsetsTable>::mapping( 269e8d8bef9SDimitry Andric IO &IO, DWARFYAML::StringOffsetsTable &StrOffsetsTable) { 270e8d8bef9SDimitry Andric IO.mapOptional("Format", StrOffsetsTable.Format, dwarf::DWARF32); 271e8d8bef9SDimitry Andric IO.mapOptional("Length", StrOffsetsTable.Length); 272e8d8bef9SDimitry Andric IO.mapOptional("Version", StrOffsetsTable.Version, 5); 273e8d8bef9SDimitry Andric IO.mapOptional("Padding", StrOffsetsTable.Padding, 0); 274e8d8bef9SDimitry Andric IO.mapOptional("Offsets", StrOffsetsTable.Offsets); 275e8d8bef9SDimitry Andric } 276e8d8bef9SDimitry Andric 277e8d8bef9SDimitry Andric void MappingTraits<DWARFYAML::DWARFOperation>::mapping( 278e8d8bef9SDimitry Andric IO &IO, DWARFYAML::DWARFOperation &DWARFOperation) { 279e8d8bef9SDimitry Andric IO.mapRequired("Operator", DWARFOperation.Operator); 280e8d8bef9SDimitry Andric IO.mapOptional("Values", DWARFOperation.Values); 281e8d8bef9SDimitry Andric } 282e8d8bef9SDimitry Andric 283e8d8bef9SDimitry Andric void MappingTraits<DWARFYAML::RnglistEntry>::mapping( 284e8d8bef9SDimitry Andric IO &IO, DWARFYAML::RnglistEntry &RnglistEntry) { 285e8d8bef9SDimitry Andric IO.mapRequired("Operator", RnglistEntry.Operator); 286e8d8bef9SDimitry Andric IO.mapOptional("Values", RnglistEntry.Values); 287e8d8bef9SDimitry Andric } 288e8d8bef9SDimitry Andric 289e8d8bef9SDimitry Andric void MappingTraits<DWARFYAML::LoclistEntry>::mapping( 290e8d8bef9SDimitry Andric IO &IO, DWARFYAML::LoclistEntry &LoclistEntry) { 291e8d8bef9SDimitry Andric IO.mapRequired("Operator", LoclistEntry.Operator); 292e8d8bef9SDimitry Andric IO.mapOptional("Values", LoclistEntry.Values); 293e8d8bef9SDimitry Andric IO.mapOptional("DescriptionsLength", LoclistEntry.DescriptionsLength); 294e8d8bef9SDimitry Andric IO.mapOptional("Descriptions", LoclistEntry.Descriptions); 295e8d8bef9SDimitry Andric } 296e8d8bef9SDimitry Andric 297e8d8bef9SDimitry Andric template <typename EntryType> 298e8d8bef9SDimitry Andric void MappingTraits<DWARFYAML::ListEntries<EntryType>>::mapping( 299e8d8bef9SDimitry Andric IO &IO, DWARFYAML::ListEntries<EntryType> &ListEntries) { 300e8d8bef9SDimitry Andric IO.mapOptional("Entries", ListEntries.Entries); 301e8d8bef9SDimitry Andric IO.mapOptional("Content", ListEntries.Content); 302e8d8bef9SDimitry Andric } 303e8d8bef9SDimitry Andric 304e8d8bef9SDimitry Andric template <typename EntryType> 305e8d8bef9SDimitry Andric std::string MappingTraits<DWARFYAML::ListEntries<EntryType>>::validate( 306e8d8bef9SDimitry Andric IO &IO, DWARFYAML::ListEntries<EntryType> &ListEntries) { 307e8d8bef9SDimitry Andric if (ListEntries.Entries && ListEntries.Content) 308e8d8bef9SDimitry Andric return "Entries and Content can't be used together"; 309e8d8bef9SDimitry Andric return ""; 310e8d8bef9SDimitry Andric } 311e8d8bef9SDimitry Andric 312e8d8bef9SDimitry Andric template <typename EntryType> 313e8d8bef9SDimitry Andric void MappingTraits<DWARFYAML::ListTable<EntryType>>::mapping( 314e8d8bef9SDimitry Andric IO &IO, DWARFYAML::ListTable<EntryType> &ListTable) { 315e8d8bef9SDimitry Andric IO.mapOptional("Format", ListTable.Format, dwarf::DWARF32); 316e8d8bef9SDimitry Andric IO.mapOptional("Length", ListTable.Length); 317e8d8bef9SDimitry Andric IO.mapOptional("Version", ListTable.Version, 5); 318e8d8bef9SDimitry Andric IO.mapOptional("AddressSize", ListTable.AddrSize); 319e8d8bef9SDimitry Andric IO.mapOptional("SegmentSelectorSize", ListTable.SegSelectorSize, 0); 320e8d8bef9SDimitry Andric IO.mapOptional("OffsetEntryCount", ListTable.OffsetEntryCount); 321e8d8bef9SDimitry Andric IO.mapOptional("Offsets", ListTable.Offsets); 322e8d8bef9SDimitry Andric IO.mapOptional("Lists", ListTable.Lists); 3230b57cec5SDimitry Andric } 3240b57cec5SDimitry Andric 3250b57cec5SDimitry Andric } // end namespace yaml 3260b57cec5SDimitry Andric 3270b57cec5SDimitry Andric } // end namespace llvm 328