LCOV - code coverage report
Current view: top level - lib/DebugInfo/DWARF - DWARFTypeUnit.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 26 27 96.3 %
Date: 2018-02-18 16:14:26 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          56 : bool DWARFTypeUnit::extractImpl(DataExtractor debug_info,
      22             :                                 uint32_t *offset_ptr) {
      23          56 :   if (!DWARFUnit::extractImpl(debug_info, offset_ptr))
      24             :     return false;
      25          56 :   TypeHash = debug_info.getU64(offset_ptr);
      26          56 :   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             :   unsigned SizeOfLength = 4;
      31          56 :   return TypeOffset < getLength() + SizeOfLength;
      32             : }
      33             : 
      34          52 : void DWARFTypeUnit::dump(raw_ostream &OS, DIDumpOptions DumpOpts) {
      35          52 :   DWARFDie TD = getDIEForOffset(TypeOffset + getOffset());
      36          52 :   const char *Name = TD.getName(DINameKind::ShortName);
      37             : 
      38          52 :   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         100 :   OS << format("0x%08x", getOffset()) << ": Type Unit:"
      46         150 :      << " length = " << format("0x%08x", getLength())
      47         100 :      << " version = " << format("0x%04x", getVersion());
      48          50 :   if (getVersion() >= 5)
      49          11 :     OS << " unit_type = " << dwarf::UnitTypeString(getUnitType());
      50         150 :   OS << " abbr_offset = " << format("0x%04x", getAbbreviations()->getOffset())
      51         150 :      << " addr_size = " << format("0x%02x", getAddressByteSize())
      52          50 :      << " name = '" << Name << "'"
      53         150 :      << " type_signature = " << format("0x%016" PRIx64, TypeHash)
      54         150 :      << " type_offset = " << format("0x%04x", TypeOffset)
      55         100 :      << " (next unit at " << format("0x%08x", getNextUnitOffset()) << ")\n";
      56             : 
      57          50 :   if (DWARFDie TU = getUnitDIE(false))
      58          50 :     TU.dump(OS, 0, DumpOpts);
      59             :   else
      60           0 :     OS << "<type unit can't be parsed!>\n\n";
      61             : }

Generated by: LCOV version 1.13