LCOV - code coverage report
Current view: top level - lib/DebugInfo/DWARF - DWARFTypeUnit.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 27 28 96.4 %
Date: 2017-09-14 15:23:50 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- DWARFTypeUnit.cpp --------------------------------------------------===//
       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             : #include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
      11             : #include "llvm/DebugInfo/DIContext.h"
      12             : #include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
      13             : #include "llvm/DebugInfo/DWARF/DWARFDie.h"
      14             : #include "llvm/DebugInfo/DWARF/DWARFUnit.h"
      15             : #include "llvm/Support/Format.h"
      16             : #include "llvm/Support/raw_ostream.h"
      17             : #include <cinttypes>
      18             : 
      19             : using namespace llvm;
      20             : 
      21          50 : bool DWARFTypeUnit::extractImpl(DataExtractor debug_info,
      22             :                                 uint32_t *offset_ptr) {
      23          50 :   if (!DWARFUnit::extractImpl(debug_info, offset_ptr))
      24             :     return false;
      25          50 :   TypeHash = debug_info.getU64(offset_ptr);
      26          50 :   TypeOffset = debug_info.getU32(offset_ptr);
      27             :   // TypeOffset is relative to the beginning of the header,
      28             :   // so we have to account for the leading length field.
      29             :   // FIXME: The size of the length field is 12 in DWARF64.
      30          50 :   unsigned SizeOfLength = 4;
      31          50 :   return TypeOffset < getLength() + SizeOfLength;
      32             : }
      33             : 
      34          50 : void DWARFTypeUnit::dump(raw_ostream &OS, DIDumpOptions DumpOpts) {
      35          50 :   DWARFDie TD = getDIEForOffset(TypeOffset + getOffset());
      36          50 :   const char *Name = TD.getName(DINameKind::ShortName);
      37             : 
      38          50 :   if (DumpOpts.SummarizeTypes) {
      39           2 :     OS << "name = '" << Name << "'"
      40           6 :        << " type_signature = " << format("0x%016" PRIx64, TypeHash)
      41           6 :        << " length = " << format("0x%08x", getLength()) << '\n';
      42           2 :     return;
      43             :   }
      44             : 
      45         144 :   OS << format("0x%08x", getOffset()) << ": Type Unit:"
      46         144 :      << " length = " << format("0x%08x", getLength())
      47          96 :      << " version = " << format("0x%04x", getVersion());
      48          48 :   if (getVersion() >= 5)
      49           8 :     OS << " unit_type = " << dwarf::UnitTypeString(getUnitType());
      50         144 :   OS << " abbr_offset = " << format("0x%04x", getAbbreviations()->getOffset())
      51         144 :      << " addr_size = " << format("0x%02x", getAddressByteSize())
      52          48 :      << " name = '" << Name << "'"
      53         144 :      << " type_signature = " << format("0x%016" PRIx64, TypeHash)
      54         144 :      << " type_offset = " << format("0x%04x", TypeOffset)
      55         144 :      << " (next unit at " << format("0x%08x", getNextUnitOffset()) << ")\n";
      56             : 
      57         144 :   if (DWARFDie TU = getUnitDIE(false))
      58          48 :     TU.dump(OS, -1U, 0, DumpOpts);
      59             :   else
      60           0 :     OS << "<type unit can't be parsed!>\n\n";
      61             : }

Generated by: LCOV version 1.13