LCOV - code coverage report
Current view: top level - lib/ObjectYAML - DWARFYAML.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 120 123 97.6 %
Date: 2018-10-20 13:21:21 Functions: 15 15 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13