Coverage Report

Created: 2017-10-03 07:32

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/lld/lib/ReaderWriter/MachO/DebugInfo.h
Line
Count
Source (jump to first uncovered line)
1
//===- lib/ReaderWriter/MachO/File.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_READER_WRITER_MACHO_DEBUGINFO_H
11
#define LLD_READER_WRITER_MACHO_DEBUGINFO_H
12
13
#include "lld/Core/Atom.h"
14
#include <vector>
15
16
#include "llvm/Support/Format.h"
17
#include "llvm/Support/raw_ostream.h"
18
19
20
namespace lld {
21
namespace mach_o {
22
23
class DebugInfo {
24
public:
25
  enum class Kind {
26
    Dwarf,
27
    Stabs
28
  };
29
30
1
  Kind kind() const { return _kind; }
31
32
1
  void setAllocator(std::unique_ptr<llvm::BumpPtrAllocator> allocator) {
33
1
    _allocator = std::move(allocator);
34
1
  }
35
36
protected:
37
1
  DebugInfo(Kind kind) : _kind(kind) {}
38
39
private:
40
  std::unique_ptr<llvm::BumpPtrAllocator> _allocator;
41
  Kind _kind;
42
};
43
44
struct TranslationUnitSource {
45
  StringRef name;
46
  StringRef path;
47
};
48
49
class DwarfDebugInfo : public DebugInfo {
50
public:
51
  DwarfDebugInfo(TranslationUnitSource tu)
52
1
    : DebugInfo(Kind::Dwarf), _tu(std::move(tu)) {}
53
54
1
  static inline bool classof(const DebugInfo *di) {
55
1
    return di->kind() == Kind::Dwarf;
56
1
  }
57
58
1
  const TranslationUnitSource &translationUnitSource() const { return _tu; }
59
60
private:
61
  TranslationUnitSource _tu;
62
};
63
64
struct Stab {
65
  Stab(const Atom* atom, uint8_t type, uint8_t other, uint16_t desc,
66
       uint32_t value, StringRef str)
67
    : atom(atom), type(type), other(other), desc(desc), value(value),
68
8
      str(str) {}
69
70
  const class Atom*   atom;
71
  uint8_t             type;
72
  uint8_t             other;
73
  uint16_t            desc;
74
  uint32_t            value;
75
  StringRef           str;
76
};
77
78
0
inline raw_ostream& operator<<(raw_ostream &os, Stab &s) {
79
0
  os << "Stab -- atom: " << llvm::format("%p", s.atom) << ", type: " << (uint32_t)s.type
80
0
     << ", other: " << (uint32_t)s.other << ", desc: " << s.desc << ", value: " << s.value
81
0
     << ", str: '" << s.str << "'";
82
0
  return os;
83
0
}
84
85
class StabsDebugInfo : public DebugInfo {
86
public:
87
88
  typedef std::vector<Stab> StabsList;
89
90
  StabsDebugInfo(StabsList stabs)
91
0
    : DebugInfo(Kind::Stabs), _stabs(std::move(stabs)) {}
92
93
0
  static inline bool classof(const DebugInfo *di) {
94
0
    return di->kind() == Kind::Stabs;
95
0
  }
96
97
0
  const StabsList& stabs() const { return _stabs; }
98
99
public:
100
  StabsList _stabs;
101
};
102
103
} // end namespace mach_o
104
} // end namespace lld
105
106
#endif // LLD_READER_WRITER_MACHO_DEBUGINFO_H