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

Generated by: LCOV version 1.13