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: 2017-09-14 15:23:50 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          69 : bool DWARFYAML::Data::isEmpty() const {
      20         207 :   return 0 == DebugStrings.size() + AbbrevDecls.size();
      21             : }
      22             : 
      23             : namespace yaml {
      24             : 
      25          34 : void MappingTraits<DWARFYAML::Data>::mapping(IO &IO, DWARFYAML::Data &DWARF) {
      26          34 :   auto oldContext = IO.getContext();
      27          34 :   IO.setContext(&DWARF);
      28          68 :   IO.mapOptional("debug_str", DWARF.DebugStrings);
      29          68 :   IO.mapOptional("debug_abbrev", DWARF.AbbrevDecls);
      30          68 :   if (!DWARF.ARanges.empty() || !IO.outputting())
      31          27 :     IO.mapOptional("debug_aranges", DWARF.ARanges);
      32          68 :   if (!DWARF.PubNames.Entries.empty() || !IO.outputting())
      33          25 :     IO.mapOptional("debug_pubnames", DWARF.PubNames);
      34          68 :   if (!DWARF.PubTypes.Entries.empty() || !IO.outputting())
      35          25 :     IO.mapOptional("debug_pubtypes", DWARF.PubTypes);
      36          68 :   if (!DWARF.GNUPubNames.Entries.empty() || !IO.outputting())
      37          23 :     IO.mapOptional("debug_gnu_pubnames", DWARF.GNUPubNames);
      38          68 :   if (!DWARF.GNUPubTypes.Entries.empty() || !IO.outputting())
      39          23 :     IO.mapOptional("debug_gnu_pubtypes", DWARF.GNUPubTypes);
      40          68 :   IO.mapOptional("debug_info", DWARF.CompileUnits);
      41          68 :   IO.mapOptional("debug_line", DWARF.DebugLines);
      42          34 :   IO.setContext(&oldContext);
      43          34 : }
      44             : 
      45          87 : void MappingTraits<DWARFYAML::Abbrev>::mapping(IO &IO,
      46             :                                                DWARFYAML::Abbrev &Abbrev) {
      47         174 :   IO.mapRequired("Code", Abbrev.Code);
      48         174 :   IO.mapRequired("Tag", Abbrev.Tag);
      49         174 :   IO.mapRequired("Children", Abbrev.Children);
      50         174 :   IO.mapRequired("Attributes", Abbrev.Attributes);
      51          87 : }
      52             : 
      53         414 : void MappingTraits<DWARFYAML::AttributeAbbrev>::mapping(
      54             :     IO &IO, DWARFYAML::AttributeAbbrev &AttAbbrev) {
      55         828 :   IO.mapRequired("Attribute", AttAbbrev.Attribute);
      56         828 :   IO.mapRequired("Form", AttAbbrev.Form);
      57         414 :   if(AttAbbrev.Form == dwarf::DW_FORM_implicit_const)
      58           2 :     IO.mapRequired("Value", AttAbbrev.Value);
      59         414 : }
      60             : 
      61           8 : void MappingTraits<DWARFYAML::ARangeDescriptor>::mapping(
      62             :     IO &IO, DWARFYAML::ARangeDescriptor &Descriptor) {
      63          16 :   IO.mapRequired("Address", Descriptor.Address);
      64          16 :   IO.mapRequired("Length", Descriptor.Length);
      65           8 : }
      66             : 
      67           8 : void MappingTraits<DWARFYAML::ARange>::mapping(IO &IO,
      68             :                                                DWARFYAML::ARange &Range) {
      69          16 :   IO.mapRequired("Length", Range.Length);
      70          16 :   IO.mapRequired("Version", Range.Version);
      71          16 :   IO.mapRequired("CuOffset", Range.CuOffset);
      72          16 :   IO.mapRequired("AddrSize", Range.AddrSize);
      73          16 :   IO.mapRequired("SegSize", Range.SegSize);
      74          16 :   IO.mapRequired("Descriptors", Range.Descriptors);
      75           8 : }
      76             : 
      77          12 : void MappingTraits<DWARFYAML::PubEntry>::mapping(IO &IO,
      78             :                                                  DWARFYAML::PubEntry &Entry) {
      79          24 :   IO.mapRequired("DieOffset", Entry.DieOffset);
      80          12 :   if (reinterpret_cast<DWARFYAML::PubSection *>(IO.getContext())->IsGNUStyle)
      81           0 :     IO.mapRequired("Descriptor", Entry.Descriptor);
      82          24 :   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          16 :   IO.mapRequired("Length", Section.Length);
      91          16 :   IO.mapRequired("Version", Section.Version);
      92          16 :   IO.mapRequired("UnitOffset", Section.UnitOffset);
      93          16 :   IO.mapRequired("UnitSize", Section.UnitSize);
      94          16 :   IO.mapRequired("Entries", Section.Entries);
      95             : 
      96           8 :   IO.setContext(OldContext);
      97           8 : }
      98             : 
      99          21 : void MappingTraits<DWARFYAML::Unit>::mapping(IO &IO, DWARFYAML::Unit &Unit) {
     100          42 :   IO.mapRequired("Length", Unit.Length);
     101          42 :   IO.mapRequired("Version", Unit.Version);
     102          21 :   if (Unit.Version >= 5)
     103           2 :     IO.mapRequired("UnitType", Unit.Type);
     104          42 :   IO.mapRequired("AbbrOffset", Unit.AbbrOffset);
     105          42 :   IO.mapRequired("AddrSize", Unit.AddrSize);
     106          42 :   IO.mapOptional("Entries", Unit.Entries);
     107          21 : }
     108             : 
     109          82 : void MappingTraits<DWARFYAML::Entry>::mapping(IO &IO, DWARFYAML::Entry &Entry) {
     110         164 :   IO.mapRequired("AbbrCode", Entry.AbbrCode);
     111         164 :   IO.mapRequired("Values", Entry.Values);
     112          82 : }
     113             : 
     114         282 : void MappingTraits<DWARFYAML::FormValue>::mapping(
     115             :     IO &IO, DWARFYAML::FormValue &FormValue) {
     116         564 :   IO.mapOptional("Value", FormValue.Value);
     117         564 :   if (!FormValue.CStr.empty() || !IO.outputting())
     118         155 :     IO.mapOptional("CStr", FormValue.CStr);
     119         564 :   if (!FormValue.BlockData.empty() || !IO.outputting())
     120         167 :     IO.mapOptional("BlockData", FormValue.BlockData);
     121         282 : }
     122             : 
     123          12 : void MappingTraits<DWARFYAML::File>::mapping(IO &IO, DWARFYAML::File &File) {
     124          24 :   IO.mapRequired("Name", File.Name);
     125          24 :   IO.mapRequired("DirIdx", File.DirIdx);
     126          24 :   IO.mapRequired("ModTime", File.ModTime);
     127          24 :   IO.mapRequired("Length", File.Length);
     128          12 : }
     129             : 
     130          82 : void MappingTraits<DWARFYAML::LineTableOpcode>::mapping(
     131             :     IO &IO, DWARFYAML::LineTableOpcode &LineTableOpcode) {
     132         164 :   IO.mapRequired("Opcode", LineTableOpcode.Opcode);
     133          82 :   if (LineTableOpcode.Opcode == dwarf::DW_LNS_extended_op) {
     134          44 :     IO.mapRequired("ExtLen", LineTableOpcode.ExtLen);
     135          22 :     IO.mapRequired("SubOpcode", LineTableOpcode.SubOpcode);
     136             :   }
     137             : 
     138         164 :   if (!LineTableOpcode.UnknownOpcodeData.empty() || !IO.outputting())
     139          55 :     IO.mapOptional("UnknownOpcodeData", LineTableOpcode.UnknownOpcodeData);
     140         164 :   if (!LineTableOpcode.UnknownOpcodeData.empty() || !IO.outputting())
     141          55 :     IO.mapOptional("StandardOpcodeData", LineTableOpcode.StandardOpcodeData);
     142         164 :   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         164 :   IO.mapOptional("Data", LineTableOpcode.Data);
     147          82 : }
     148             : 
     149          11 : void MappingTraits<DWARFYAML::LineTable>::mapping(
     150             :     IO &IO, DWARFYAML::LineTable &LineTable) {
     151          22 :   IO.mapRequired("Length", LineTable.Length);
     152          22 :   IO.mapRequired("Version", LineTable.Version);
     153          22 :   IO.mapRequired("PrologueLength", LineTable.PrologueLength);
     154          22 :   IO.mapRequired("MinInstLength", LineTable.MinInstLength);
     155          11 :   if(LineTable.Version >= 4)
     156           0 :     IO.mapRequired("MaxOpsPerInst", LineTable.MaxOpsPerInst);
     157          22 :   IO.mapRequired("DefaultIsStmt", LineTable.DefaultIsStmt);
     158          22 :   IO.mapRequired("LineBase", LineTable.LineBase);
     159          22 :   IO.mapRequired("LineRange", LineTable.LineRange);
     160          22 :   IO.mapRequired("OpcodeBase", LineTable.OpcodeBase);
     161          22 :   IO.mapRequired("StandardOpcodeLengths", LineTable.StandardOpcodeLengths);
     162          22 :   IO.mapRequired("IncludeDirs", LineTable.IncludeDirs);
     163          22 :   IO.mapRequired("Files", LineTable.Files);
     164          22 :   IO.mapRequired("Opcodes", LineTable.Opcodes);
     165          11 : }
     166             : 
     167          48 : void MappingTraits<DWARFYAML::InitialLength>::mapping(
     168             :     IO &IO, DWARFYAML::InitialLength &InitialLength) {
     169          96 :   IO.mapRequired("TotalLength", InitialLength.TotalLength);
     170          48 :   if (InitialLength.isDWARF64())
     171           0 :     IO.mapRequired("TotalLength64", InitialLength.TotalLength64);
     172          48 : }
     173             : 
     174             : } // end namespace yaml
     175             : 
     176             : } // end namespace llvm

Generated by: LCOV version 1.13