1 //===- lib/ReaderWriter/MachO/File.h ----------------------------*- C++ -*-===//
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLD_READER_WRITER_MACHO_DEBUGINFO_H
11 #define LLD_READER_WRITER_MACHO_DEBUGINFO_H
13 #include "lld/Core/Atom.h"
16 #include "llvm/Support/Format.h"
17 #include "llvm/Support/raw_ostream.h"
30 Kind kind() const { return _kind; }
32 void setAllocator(std::unique_ptr<llvm::BumpPtrAllocator> allocator) {
33 _allocator = std::move(allocator);
37 DebugInfo(Kind kind) : _kind(kind) {}
40 std::unique_ptr<llvm::BumpPtrAllocator> _allocator;
44 struct TranslationUnitSource {
49 class DwarfDebugInfo : public DebugInfo {
51 DwarfDebugInfo(TranslationUnitSource tu)
52 : DebugInfo(Kind::Dwarf), _tu(std::move(tu)) {}
54 static inline bool classof(const DebugInfo *di) {
55 return di->kind() == Kind::Dwarf;
58 const TranslationUnitSource &translationUnitSource() const { return _tu; }
61 TranslationUnitSource _tu;
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),
70 const class Atom* atom;
78 inline raw_ostream& operator<<(raw_ostream &os, Stab &s) {
79 os << "Stab -- atom: " << llvm::format("%p", s.atom) << ", type: " << (uint32_t)s.type
80 << ", other: " << (uint32_t)s.other << ", desc: " << s.desc << ", value: " << s.value
81 << ", str: '" << s.str << "'";
85 class StabsDebugInfo : public DebugInfo {
88 typedef std::vector<Stab> StabsList;
90 StabsDebugInfo(StabsList stabs)
91 : DebugInfo(Kind::Stabs), _stabs(std::move(stabs)) {}
93 static inline bool classof(const DebugInfo *di) {
94 return di->kind() == Kind::Stabs;
97 const StabsList& stabs() const { return _stabs; }
103 } // end namespace mach_o
104 } // end namespace lld
106 #endif // LLD_READER_WRITER_MACHO_DEBUGINFO_H