LCOV - code coverage report
Current view: top level - lib/DebugInfo/DWARF - DWARFDebugInfoEntry.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 18 26 69.2 %
Date: 2017-09-14 15:23:50 Functions: 1 2 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- DWARFDebugInfoEntry.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/DWARFDebugInfoEntry.h"
      11             : #include "llvm/ADT/Optional.h"
      12             : #include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
      13             : #include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
      14             : #include "llvm/DebugInfo/DWARF/DWARFUnit.h"
      15             : #include "llvm/Support/DataExtractor.h"
      16             : #include <cstddef>
      17             : #include <cstdint>
      18             : 
      19             : using namespace llvm;
      20             : using namespace dwarf;
      21             : 
      22           0 : bool DWARFDebugInfoEntry::extractFast(const DWARFUnit &U,
      23             :                                              uint32_t *OffsetPtr) {
      24           0 :   DWARFDataExtractor DebugInfoData = U.getDebugInfoExtractor();
      25           0 :   const uint32_t UEndOffset = U.getNextUnitOffset();
      26           0 :   return extractFast(U, OffsetPtr, DebugInfoData, UEndOffset, 0);
      27             : }
      28             : 
      29    18159016 : bool DWARFDebugInfoEntry::extractFast(const DWARFUnit &U, uint32_t *OffsetPtr,
      30             :                                       const DWARFDataExtractor &DebugInfoData,
      31             :                                       uint32_t UEndOffset, uint32_t D) {
      32    18159016 :   Offset = *OffsetPtr;
      33    18159016 :   Depth = D;
      34    36317424 :   if (Offset >= UEndOffset || !DebugInfoData.isValidOffset(Offset))
      35             :     return false;
      36    18158408 :   uint64_t AbbrCode = DebugInfoData.getULEB128(OffsetPtr);
      37    18158408 :   if (0 == AbbrCode) {
      38             :     // NULL debug tag entry.
      39     4043357 :     AbbrevDecl = nullptr;
      40     4043357 :     return true;
      41             :   }
      42    14115051 :   AbbrevDecl = U.getAbbreviations()->getAbbreviationDeclaration(AbbrCode);
      43    14115051 :   if (nullptr == AbbrevDecl) {
      44             :     // Restore the original offset.
      45           0 :     *OffsetPtr = Offset;
      46           0 :     return false;
      47             :   }
      48             :   // See if all attributes in this DIE have fixed byte sizes. If so, we can
      49             :   // just add this size to the offset to skip to the next DIE.
      50    14852952 :   if (Optional<size_t> FixedSize = AbbrevDecl->getFixedAttributesByteSize(U)) {
      51    13377150 :     *OffsetPtr += *FixedSize;
      52    26754300 :     return true;
      53             :   }
      54             : 
      55             :   // Skip all data in the .debug_info for the attributes
      56     4303979 :   for (const auto &AttrSpec : AbbrevDecl->attributes()) {
      57             :     // Check if this attribute has a fixed byte size.
      58     5656354 :     if (auto FixedSize = AttrSpec.getByteSize(U)) {
      59             :       // Attribute byte size if fixed, just add the size to the offset.
      60     1948624 :       *OffsetPtr += *FixedSize;
      61      879553 :     } else if (!DWARFFormValue::skipValue(AttrSpec.Form, DebugInfoData,
      62      879553 :                                           OffsetPtr, U.getFormParams())) {
      63             :       // We failed to skip this attribute's value, restore the original offset
      64             :       // and return the failure status.
      65           0 :       *OffsetPtr = Offset;
      66           0 :       return false;
      67             :     }
      68             :   }
      69             :   return true;
      70             : }

Generated by: LCOV version 1.13