Coverage Report

Created: 2017-09-19 22:28

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/lld/ELF/GdbIndex.h
Line
Count
Source (jump to first uncovered line)
1
//===- GdbIndex.h --------------------------------------------*- C++ -*-===//
2
//
3
//                             The LLVM Linker
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===-------------------------------------------------------------------===//
9
10
#ifndef LLD_ELF_GDB_INDEX_H
11
#define LLD_ELF_GDB_INDEX_H
12
13
#include "InputFiles.h"
14
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
15
#include "llvm/Object/ELF.h"
16
17
namespace lld {
18
namespace elf {
19
20
class InputSection;
21
22
struct LLDDWARFSection final : public llvm::DWARFSection {
23
  InputSectionBase *Sec = nullptr;
24
};
25
26
template <class ELFT> class LLDDwarfObj final : public llvm::DWARFObject {
27
  ObjFile<ELFT> *Obj;
28
  LLDDWARFSection InfoSection;
29
  LLDDWARFSection RangeSection;
30
  LLDDWARFSection LineSection;
31
  StringRef AbbrevSection;
32
  StringRef GnuPubNamesSection;
33
  StringRef GnuPubTypesSection;
34
35
  template <class RelTy>
36
  llvm::Optional<llvm::RelocAddrEntry> findAux(const InputSectionBase &Sec,
37
                                               uint64_t Pos,
38
                                               ArrayRef<RelTy> Rels) const;
39
40
public:
41
  explicit LLDDwarfObj(ObjFile<ELFT> *Obj);
42
18
  const llvm::DWARFSection &getInfoSection() const override {
43
18
    return InfoSection;
44
18
  }
Unexecuted instantiation: lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getInfoSection() const
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getInfoSection() const
Line
Count
Source
42
16
  const llvm::DWARFSection &getInfoSection() const override {
43
16
    return InfoSection;
44
16
  }
Unexecuted instantiation: lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getInfoSection() const
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getInfoSection() const
Line
Count
Source
42
2
  const llvm::DWARFSection &getInfoSection() const override {
43
2
    return InfoSection;
44
2
  }
45
18
  const llvm::DWARFSection &getRangeSection() const override {
46
18
    return RangeSection;
47
18
  }
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRangeSection() const
Line
Count
Source
45
2
  const llvm::DWARFSection &getRangeSection() const override {
46
2
    return RangeSection;
47
2
  }
Unexecuted instantiation: lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRangeSection() const
Unexecuted instantiation: lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRangeSection() const
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRangeSection() const
Line
Count
Source
45
16
  const llvm::DWARFSection &getRangeSection() const override {
46
16
    return RangeSection;
47
16
  }
48
136
  const llvm::DWARFSection &getLineSection() const override {
49
136
    return LineSection;
50
136
  }
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getLineSection() const
Line
Count
Source
48
1
  const llvm::DWARFSection &getLineSection() const override {
49
1
    return LineSection;
50
1
  }
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getLineSection() const
Line
Count
Source
48
122
  const llvm::DWARFSection &getLineSection() const override {
49
122
    return LineSection;
50
122
  }
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getLineSection() const
Line
Count
Source
48
12
  const llvm::DWARFSection &getLineSection() const override {
49
12
    return LineSection;
50
12
  }
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getLineSection() const
Line
Count
Source
48
1
  const llvm::DWARFSection &getLineSection() const override {
49
1
    return LineSection;
50
1
  }
51
0
  StringRef getCUIndexSection() const override { return ""; }
Unexecuted instantiation: lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getCUIndexSection() const
Unexecuted instantiation: lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getCUIndexSection() const
Unexecuted instantiation: lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getCUIndexSection() const
Unexecuted instantiation: lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getCUIndexSection() const
52
8
  StringRef getAbbrevSection() const override { return AbbrevSection; }
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getAbbrevSection() const
Line
Count
Source
52
1
  StringRef getAbbrevSection() const override { return AbbrevSection; }
Unexecuted instantiation: lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getAbbrevSection() const
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getAbbrevSection() const
Line
Count
Source
52
7
  StringRef getAbbrevSection() const override { return AbbrevSection; }
Unexecuted instantiation: lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getAbbrevSection() const
53
18
  StringRef getStringSection() const override { return ""; }
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getStringSection() const
Line
Count
Source
53
2
  StringRef getStringSection() const override { return ""; }
Unexecuted instantiation: lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getStringSection() const
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getStringSection() const
Line
Count
Source
53
16
  StringRef getStringSection() const override { return ""; }
Unexecuted instantiation: lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getStringSection() const
54
9
  StringRef getGnuPubNamesSection() const override {
55
9
    return GnuPubNamesSection;
56
9
  }
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getGnuPubNamesSection() const
Line
Count
Source
54
1
  StringRef getGnuPubNamesSection() const override {
55
1
    return GnuPubNamesSection;
56
1
  }
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getGnuPubNamesSection() const
Line
Count
Source
54
8
  StringRef getGnuPubNamesSection() const override {
55
8
    return GnuPubNamesSection;
56
8
  }
Unexecuted instantiation: lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getGnuPubNamesSection() const
Unexecuted instantiation: lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getGnuPubNamesSection() const
57
9
  StringRef getGnuPubTypesSection() const override {
58
9
    return GnuPubTypesSection;
59
9
  }
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getGnuPubTypesSection() const
Line
Count
Source
57
1
  StringRef getGnuPubTypesSection() const override {
58
1
    return GnuPubTypesSection;
59
1
  }
Unexecuted instantiation: lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getGnuPubTypesSection() const
Unexecuted instantiation: lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getGnuPubTypesSection() const
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getGnuPubTypesSection() const
Line
Count
Source
57
8
  StringRef getGnuPubTypesSection() const override {
58
8
    return GnuPubTypesSection;
59
8
  }
60
25
  bool isLittleEndian() const override {
61
25
    return ELFT::TargetEndianness == llvm::support::little;
62
25
  }
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isLittleEndian() const
Line
Count
Source
60
3
  bool isLittleEndian() const override {
61
3
    return ELFT::TargetEndianness == llvm::support::little;
62
3
  }
Unexecuted instantiation: lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isLittleEndian() const
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isLittleEndian() const
Line
Count
Source
60
22
  bool isLittleEndian() const override {
61
22
    return ELFT::TargetEndianness == llvm::support::little;
62
22
  }
Unexecuted instantiation: lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isLittleEndian() const
63
  llvm::Optional<llvm::RelocAddrEntry> find(const llvm::DWARFSection &Sec,
64
                                            uint64_t Pos) const override;
65
};
66
67
// Struct represents single entry of address area of gdb index.
68
struct AddressEntry {
69
  InputSection *Section;
70
  uint64_t LowAddress;
71
  uint64_t HighAddress;
72
  uint32_t CuIndex;
73
};
74
75
// Struct represents single entry of compilation units list area of gdb index.
76
// It consist of CU offset in .debug_info section and it's size.
77
struct CompilationUnitEntry {
78
  uint64_t CuOffset;
79
  uint64_t CuLength;
80
};
81
82
// Represents data about symbol and type names which are used
83
// to build symbol table and constant pool area of gdb index.
84
struct NameTypeEntry {
85
  StringRef Name;
86
  uint8_t Type;
87
};
88
89
// We fill one GdbIndexDataChunk for each object where scan of
90
// debug information performed. That information futher used
91
// for filling gdb index section areas.
92
struct GdbIndexChunk {
93
  InputSection *DebugInfoSec;
94
  std::vector<AddressEntry> AddressArea;
95
  std::vector<CompilationUnitEntry> CompilationUnits;
96
  std::vector<NameTypeEntry> NamesAndTypes;
97
};
98
99
// Element of GdbHashTab hash table.
100
struct GdbSymbol {
101
  GdbSymbol(uint32_t Hash, size_t Offset)
102
4
      : NameHash(Hash), NameOffset(Offset) {}
103
  uint32_t NameHash;
104
  size_t NameOffset;
105
  size_t CuVectorIndex;
106
};
107
108
// This class manages the hashed symbol table for the .gdb_index section.
109
// The hash value for a table entry is computed by applying an iterative hash
110
// function to the symbol's name.
111
class GdbHashTab final {
112
public:
113
  std::pair<bool, GdbSymbol *> add(uint32_t Hash, size_t Offset);
114
115
  void finalizeContents();
116
8.20k
  size_t getCapacity() { return Table.size(); }
117
8.19k
  GdbSymbol *getSymbol(size_t I) { return Table[I]; }
118
119
private:
120
  llvm::DenseMap<size_t, GdbSymbol *> Map;
121
  std::vector<GdbSymbol *> Table;
122
};
123
124
} // namespace elf
125
} // namespace lld
126
127
#endif