Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
Line
Count
Source (jump to first uncovered line)
1
//===- DWARFDebugAranges.h --------------------------------------*- C++ -*-===//
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
#ifndef LLVM_DEBUGINFO_DWARFDEBUGARANGES_H
10
#define LLVM_DEBUGINFO_DWARFDEBUGARANGES_H
11
12
#include "llvm/ADT/DenseSet.h"
13
#include "llvm/Support/DataExtractor.h"
14
#include <cstdint>
15
#include <vector>
16
17
namespace llvm {
18
19
class DWARFContext;
20
21
class DWARFDebugAranges {
22
public:
23
  void generate(DWARFContext *CTX);
24
  uint32_t findAddress(uint64_t Address) const;
25
26
private:
27
  void clear();
28
  void extract(DataExtractor DebugArangesData);
29
30
  /// Call appendRange multiple times and then call construct.
31
  void appendRange(uint32_t CUOffset, uint64_t LowPC, uint64_t HighPC);
32
  void construct();
33
34
  struct Range {
35
    explicit Range(uint64_t LowPC = -1ULL, uint64_t HighPC = -1ULL,
36
                   uint32_t CUOffset = -1U)
37
586
      : LowPC(LowPC), Length(HighPC - LowPC), CUOffset(CUOffset) {}
38
39
30
    void setHighPC(uint64_t HighPC) {
40
30
      if (HighPC == -1ULL || HighPC <= LowPC)
41
0
        Length = 0;
42
30
      else
43
30
        Length = HighPC - LowPC;
44
30
    }
45
46
1.61k
    uint64_t HighPC() const {
47
1.61k
      if (Length)
48
1.61k
        return LowPC + Length;
49
0
      return -1ULL;
50
0
    }
51
52
0
    bool operator<(const Range &other) const {
53
0
      return LowPC < other.LowPC;
54
0
    }
55
56
    uint64_t LowPC; /// Start of address range.
57
    uint32_t Length; /// End of address range (not including this address).
58
    uint32_t CUOffset; /// Offset of the compile unit or die.
59
  };
60
61
  struct RangeEndpoint {
62
    uint64_t Address;
63
    uint32_t CUOffset;
64
    bool IsRangeStart;
65
66
    RangeEndpoint(uint64_t Address, uint32_t CUOffset, bool IsRangeStart)
67
1.33k
        : Address(Address), CUOffset(CUOffset), IsRangeStart(IsRangeStart) {}
68
69
8.39k
    bool operator<(const RangeEndpoint &Other) const {
70
8.39k
      return Address < Other.Address;
71
8.39k
    }
72
  };
73
74
  using RangeColl = std::vector<Range>;
75
  using RangeCollIterator = RangeColl::const_iterator;
76
77
  std::vector<RangeEndpoint> Endpoints;
78
  RangeColl Aranges;
79
  DenseSet<uint32_t> ParsedCUOffsets;
80
};
81
82
} // end namespace llvm
83
84
#endif // LLVM_DEBUGINFO_DWARFDEBUGARANGES_H