Coverage Report

Created: 2019-05-19 14:56

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