Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- DWARFDebugInfoEntry.cpp --------------------------------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#include "llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h"
10
#include "llvm/ADT/Optional.h"
11
#include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
12
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
13
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
14
#include "llvm/Support/DataExtractor.h"
15
#include <cstddef>
16
#include <cstdint>
17
18
using namespace llvm;
19
using namespace dwarf;
20
21
bool DWARFDebugInfoEntry::extractFast(const DWARFUnit &U,
22
0
                                             uint32_t *OffsetPtr) {
23
0
  DWARFDataExtractor DebugInfoData = U.getDebugInfoExtractor();
24
0
  const uint32_t UEndOffset = U.getNextUnitOffset();
25
0
  return extractFast(U, OffsetPtr, DebugInfoData, UEndOffset, 0);
26
0
}
27
28
bool DWARFDebugInfoEntry::extractFast(const DWARFUnit &U, uint32_t *OffsetPtr,
29
                                      const DWARFDataExtractor &DebugInfoData,
30
17.3k
                                      uint32_t UEndOffset, uint32_t D) {
31
17.3k
  Offset = *OffsetPtr;
32
17.3k
  Depth = D;
33
17.3k
  if (Offset >= UEndOffset || 
!DebugInfoData.isValidOffset(Offset)17.1k
)
34
200
    return false;
35
17.1k
  uint64_t AbbrCode = DebugInfoData.getULEB128(OffsetPtr);
36
17.1k
  if (0 == AbbrCode) {
37
4.08k
    // NULL debug tag entry.
38
4.08k
    AbbrevDecl = nullptr;
39
4.08k
    return true;
40
4.08k
  }
41
13.1k
  AbbrevDecl = U.getAbbreviations()->getAbbreviationDeclaration(AbbrCode);
42
13.1k
  if (nullptr == AbbrevDecl) {
43
0
    // Restore the original offset.
44
0
    *OffsetPtr = Offset;
45
0
    return false;
46
0
  }
47
13.1k
  // See if all attributes in this DIE have fixed byte sizes. If so, we can
48
13.1k
  // just add this size to the offset to skip to the next DIE.
49
13.1k
  if (Optional<size_t> FixedSize = AbbrevDecl->getFixedAttributesByteSize(U)) {
50
7.82k
    *OffsetPtr += *FixedSize;
51
7.82k
    return true;
52
7.82k
  }
53
5.28k
54
5.28k
  // Skip all data in the .debug_info for the attributes
55
31.6k
  
for (const auto &AttrSpec : AbbrevDecl->attributes())5.28k
{
56
31.6k
    // Check if this attribute has a fixed byte size.
57
31.6k
    if (auto FixedSize = AttrSpec.getByteSize(U)) {
58
25.5k
      // Attribute byte size if fixed, just add the size to the offset.
59
25.5k
      *OffsetPtr += *FixedSize;
60
25.5k
    } else 
if (6.09k
!DWARFFormValue::skipValue(AttrSpec.Form, DebugInfoData,
61
6.09k
                                          OffsetPtr, U.getFormParams())) {
62
0
      // We failed to skip this attribute's value, restore the original offset
63
0
      // and return the failure status.
64
0
      *OffsetPtr = Offset;
65
0
      return false;
66
0
    }
67
31.6k
  }
68
5.28k
  return true;
69
5.28k
}