LCOV - code coverage report
Current view: top level - include/llvm/ObjectYAML - DWARFYAML.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 37 39 94.9 %
Date: 2017-09-14 15:23:50 Functions: 15 16 93.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- DWARFYAML.h - DWARF YAMLIO implementation ----------------*- C++ -*-===//
       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             : /// \file
      11             : /// \brief This file declares classes for handling the YAML representation
      12             : /// of DWARF Debug Info.
      13             : ///
      14             : //===----------------------------------------------------------------------===//
      15             : 
      16             : #ifndef LLVM_OBJECTYAML_DWARFYAML_H
      17             : #define LLVM_OBJECTYAML_DWARFYAML_H
      18             : 
      19             : #include "llvm/ADT/StringRef.h"
      20             : #include "llvm/BinaryFormat/Dwarf.h"
      21             : #include "llvm/Support/YAMLTraits.h"
      22             : #include <cstdint>
      23             : #include <vector>
      24             : 
      25             : namespace llvm {
      26             : namespace DWARFYAML {
      27             : 
      28             : struct InitialLength {
      29             :   uint32_t TotalLength;
      30             :   uint64_t TotalLength64;
      31             : 
      32             :   bool isDWARF64() const { return TotalLength == UINT32_MAX; }
      33             : 
      34             :   uint64_t getLength() const {
      35         137 :     return isDWARF64() ? TotalLength64 : TotalLength;
      36             :   }
      37             : 
      38             :   void setLength(uint64_t Len) {
      39           8 :     if (Len >= (uint64_t)UINT32_MAX) {
      40           0 :       TotalLength64 = Len;
      41           0 :       TotalLength = UINT32_MAX;
      42             :     } else {
      43           8 :       TotalLength = Len;
      44             :     }
      45             :   }
      46             : };
      47             : 
      48             : struct AttributeAbbrev {
      49             :   llvm::dwarf::Attribute Attribute;
      50             :   llvm::dwarf::Form Form;
      51             :   llvm::yaml::Hex64 Value; // Some DWARF5 attributes have values
      52             : };
      53             : 
      54         957 : struct Abbrev {
      55             :   llvm::yaml::Hex32 Code;
      56             :   llvm::dwarf::Tag Tag;
      57             :   llvm::dwarf::Constants Children;
      58             :   std::vector<AttributeAbbrev> Attributes;
      59             : };
      60             : 
      61             : struct ARangeDescriptor {
      62             :   llvm::yaml::Hex64 Address;
      63             :   uint64_t Length;
      64             : };
      65             : 
      66          56 : struct ARange {
      67             :   InitialLength Length;
      68             :   uint16_t Version;
      69             :   uint32_t CuOffset;
      70             :   uint8_t AddrSize;
      71             :   uint8_t SegSize;
      72             :   std::vector<ARangeDescriptor> Descriptors;
      73             : };
      74             : 
      75          18 : struct PubEntry {
      76             :   llvm::yaml::Hex32 DieOffset;
      77             :   llvm::yaml::Hex8 Descriptor;
      78             :   StringRef Name;
      79             : };
      80             : 
      81        1344 : struct PubSection {
      82             :   InitialLength Length;
      83             :   uint16_t Version;
      84             :   uint32_t UnitOffset;
      85             :   uint32_t UnitSize;
      86             :   bool IsGNUStyle = false;
      87             :   std::vector<PubEntry> Entries;
      88             : };
      89             : 
      90        3708 : struct FormValue {
      91             :   llvm::yaml::Hex64 Value;
      92             :   StringRef CStr;
      93             :   std::vector<llvm::yaml::Hex8> BlockData;
      94             : };
      95             : 
      96         670 : struct Entry {
      97             :   llvm::yaml::Hex32 AbbrCode;
      98             :   std::vector<FormValue> Values;
      99             : };
     100             : 
     101          74 : struct Unit {
     102             :   InitialLength Length;
     103             :   uint16_t Version;
     104             :   llvm::dwarf::UnitType Type; // Added in DWARF 5
     105             :   uint32_t AbbrOffset;
     106             :   uint8_t AddrSize;
     107             :   std::vector<Entry> Entries;
     108             : };
     109             : 
     110         185 : struct File {
     111             :   StringRef Name;
     112             :   uint64_t DirIdx;
     113             :   uint64_t ModTime;
     114             :   uint64_t Length;
     115             : };
     116             : 
     117        1760 : struct LineTableOpcode {
     118             :   dwarf::LineNumberOps Opcode;
     119             :   uint64_t ExtLen;
     120             :   dwarf::LineNumberExtendedOps SubOpcode;
     121             :   uint64_t Data;
     122             :   int64_t SData;
     123             :   File FileEntry;
     124             :   std::vector<llvm::yaml::Hex8> UnknownOpcodeData;
     125             :   std::vector<llvm::yaml::Hex64> StandardOpcodeData;
     126             : };
     127             : 
     128         114 : struct LineTable {
     129             :   InitialLength Length;
     130             :   uint16_t Version;
     131             :   uint64_t PrologueLength;
     132             :   uint8_t MinInstLength;
     133             :   uint8_t MaxOpsPerInst;
     134             :   uint8_t DefaultIsStmt;
     135             :   uint8_t LineBase;
     136             :   uint8_t LineRange;
     137             :   uint8_t OpcodeBase;
     138             :   std::vector<uint8_t> StandardOpcodeLengths;
     139             :   std::vector<StringRef> IncludeDirs;
     140             :   std::vector<File> Files;
     141             :   std::vector<LineTableOpcode> Opcodes;
     142             : };
     143             : 
     144        1344 : struct Data {
     145             :   bool IsLittleEndian;
     146             :   std::vector<Abbrev> AbbrevDecls;
     147             :   std::vector<StringRef> DebugStrings;
     148             :   std::vector<ARange> ARanges;
     149             :   PubSection PubNames;
     150             :   PubSection PubTypes;
     151             : 
     152             :   PubSection GNUPubNames;
     153             :   PubSection GNUPubTypes;
     154             : 
     155             :   std::vector<Unit> CompileUnits;
     156             : 
     157             :   std::vector<LineTable> DebugLines;
     158             : 
     159             :   bool isEmpty() const;
     160             : };
     161             : 
     162             : } // end namespace DWARFYAML
     163             : } // end namespace llvm
     164             : 
     165             : LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::Hex64)
     166             : LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::Hex8)
     167             : LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::AttributeAbbrev)
     168             : LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::Abbrev)
     169             : LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::ARangeDescriptor)
     170             : LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::ARange)
     171             : LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::PubEntry)
     172             : LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::Unit)
     173             : LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::FormValue)
     174             : LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::Entry)
     175             : LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::File)
     176             : LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::LineTable)
     177             : LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::LineTableOpcode)
     178             : 
     179             : namespace llvm {
     180             : namespace yaml {
     181             : 
     182             : template <> struct MappingTraits<DWARFYAML::Data> {
     183             :   static void mapping(IO &IO, DWARFYAML::Data &DWARF);
     184             : };
     185             : 
     186             : template <> struct MappingTraits<DWARFYAML::Abbrev> {
     187             :   static void mapping(IO &IO, DWARFYAML::Abbrev &Abbrev);
     188             : };
     189             : 
     190             : template <> struct MappingTraits<DWARFYAML::AttributeAbbrev> {
     191             :   static void mapping(IO &IO, DWARFYAML::AttributeAbbrev &AttAbbrev);
     192             : };
     193             : 
     194             : template <> struct MappingTraits<DWARFYAML::ARangeDescriptor> {
     195             :   static void mapping(IO &IO, DWARFYAML::ARangeDescriptor &Descriptor);
     196             : };
     197             : 
     198             : template <> struct MappingTraits<DWARFYAML::ARange> {
     199             :   static void mapping(IO &IO, DWARFYAML::ARange &Range);
     200             : };
     201             : 
     202             : template <> struct MappingTraits<DWARFYAML::PubEntry> {
     203             :   static void mapping(IO &IO, DWARFYAML::PubEntry &Entry);
     204             : };
     205             : 
     206             : template <> struct MappingTraits<DWARFYAML::PubSection> {
     207             :   static void mapping(IO &IO, DWARFYAML::PubSection &Section);
     208             : };
     209             : 
     210             : template <> struct MappingTraits<DWARFYAML::Unit> {
     211             :   static void mapping(IO &IO, DWARFYAML::Unit &Unit);
     212             : };
     213             : 
     214             : template <> struct MappingTraits<DWARFYAML::Entry> {
     215             :   static void mapping(IO &IO, DWARFYAML::Entry &Entry);
     216             : };
     217             : 
     218             : template <> struct MappingTraits<DWARFYAML::FormValue> {
     219             :   static void mapping(IO &IO, DWARFYAML::FormValue &FormValue);
     220             : };
     221             : 
     222             : template <> struct MappingTraits<DWARFYAML::File> {
     223             :   static void mapping(IO &IO, DWARFYAML::File &File);
     224             : };
     225             : 
     226             : template <> struct MappingTraits<DWARFYAML::LineTableOpcode> {
     227             :   static void mapping(IO &IO, DWARFYAML::LineTableOpcode &LineTableOpcode);
     228             : };
     229             : 
     230             : template <> struct MappingTraits<DWARFYAML::LineTable> {
     231             :   static void mapping(IO &IO, DWARFYAML::LineTable &LineTable);
     232             : };
     233             : 
     234             : template <> struct MappingTraits<DWARFYAML::InitialLength> {
     235             :   static void mapping(IO &IO, DWARFYAML::InitialLength &DWARF);
     236             : };
     237             : 
     238             : #define HANDLE_DW_TAG(unused, name, unused2, unused3)                          \
     239             :   io.enumCase(value, "DW_TAG_" #name, dwarf::DW_TAG_##name);
     240             : 
     241             : template <> struct ScalarEnumerationTraits<dwarf::Tag> {
     242          87 :   static void enumeration(IO &io, dwarf::Tag &value) {
     243             : #include "llvm/BinaryFormat/Dwarf.def"
     244          87 :     io.enumFallback<Hex16>(value);
     245          87 :   }
     246             : };
     247             : 
     248             : #define HANDLE_DW_LNS(unused, name)                                            \
     249             :   io.enumCase(value, "DW_LNS_" #name, dwarf::DW_LNS_##name);
     250             : 
     251             : template <> struct ScalarEnumerationTraits<dwarf::LineNumberOps> {
     252          82 :   static void enumeration(IO &io, dwarf::LineNumberOps &value) {
     253             : #include "llvm/BinaryFormat/Dwarf.def"
     254          82 :     io.enumFallback<Hex8>(value);
     255          82 :   }
     256             : };
     257             : 
     258             : #define HANDLE_DW_LNE(unused, name)                                            \
     259             :   io.enumCase(value, "DW_LNE_" #name, dwarf::DW_LNE_##name);
     260             : 
     261             : template <> struct ScalarEnumerationTraits<dwarf::LineNumberExtendedOps> {
     262          22 :   static void enumeration(IO &io, dwarf::LineNumberExtendedOps &value) {
     263             : #include "llvm/BinaryFormat/Dwarf.def"
     264          22 :     io.enumFallback<Hex16>(value);
     265          22 :   }
     266             : };
     267             : 
     268             : #define HANDLE_DW_AT(unused, name, unused2, unused3)                           \
     269             :   io.enumCase(value, "DW_AT_" #name, dwarf::DW_AT_##name);
     270             : 
     271             : template <> struct ScalarEnumerationTraits<dwarf::Attribute> {
     272         414 :   static void enumeration(IO &io, dwarf::Attribute &value) {
     273             : #include "llvm/BinaryFormat/Dwarf.def"
     274         414 :     io.enumFallback<Hex16>(value);
     275         414 :   }
     276             : };
     277             : 
     278             : #define HANDLE_DW_FORM(unused, name, unused2, unused3)                         \
     279             :   io.enumCase(value, "DW_FORM_" #name, dwarf::DW_FORM_##name);
     280             : 
     281             : template <> struct ScalarEnumerationTraits<dwarf::Form> {
     282         414 :   static void enumeration(IO &io, dwarf::Form &value) {
     283             : #include "llvm/BinaryFormat/Dwarf.def"
     284         414 :     io.enumFallback<Hex16>(value);
     285         414 :   }
     286             : };
     287             : 
     288             : #define HANDLE_DW_UT(unused, name)                                             \
     289             :   io.enumCase(value, "DW_UT_" #name, dwarf::DW_UT_##name);
     290             : 
     291             : template <> struct ScalarEnumerationTraits<dwarf::UnitType> {
     292           2 :   static void enumeration(IO &io, dwarf::UnitType &value) {
     293             : #include "llvm/BinaryFormat/Dwarf.def"
     294           2 :     io.enumFallback<Hex8>(value);
     295           2 :   }
     296             : };
     297             : 
     298             : template <> struct ScalarEnumerationTraits<dwarf::Constants> {
     299          87 :   static void enumeration(IO &io, dwarf::Constants &value) {
     300          87 :     io.enumCase(value, "DW_CHILDREN_no", dwarf::DW_CHILDREN_no);
     301          87 :     io.enumCase(value, "DW_CHILDREN_yes", dwarf::DW_CHILDREN_yes);
     302          87 :     io.enumFallback<Hex16>(value);
     303          87 :   }
     304             : };
     305             : 
     306             : } // end namespace yaml
     307             : } // end namespace llvm
     308             : 
     309             : #endif // LLVM_OBJECTYAML_DWARFYAML_H

Generated by: LCOV version 1.13