1 //===- lib/ReaderWriter/MachO/File.h ----------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLD_READER_WRITER_MACHO_DEBUGINFO_H
10 #define LLD_READER_WRITER_MACHO_DEBUGINFO_H
12 #include "lld/Core/Atom.h"
15 #include "llvm/Support/Format.h"
16 #include "llvm/Support/raw_ostream.h"
29 Kind kind() const { return _kind; }
31 void setAllocator(std::unique_ptr<llvm::BumpPtrAllocator> allocator) {
32 _allocator = std::move(allocator);
36 DebugInfo(Kind kind) : _kind(kind) {}
39 std::unique_ptr<llvm::BumpPtrAllocator> _allocator;
43 struct TranslationUnitSource {
48 class DwarfDebugInfo : public DebugInfo {
50 DwarfDebugInfo(TranslationUnitSource tu)
51 : DebugInfo(Kind::Dwarf), _tu(std::move(tu)) {}
53 static inline bool classof(const DebugInfo *di) {
54 return di->kind() == Kind::Dwarf;
57 const TranslationUnitSource &translationUnitSource() const { return _tu; }
60 TranslationUnitSource _tu;
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),
69 const class Atom* atom;
77 inline raw_ostream& operator<<(raw_ostream &os, Stab &s) {
78 os << "Stab -- atom: " << llvm::format("%p", s.atom) << ", type: " << (uint32_t)s.type
79 << ", other: " << (uint32_t)s.other << ", desc: " << s.desc << ", value: " << s.value
80 << ", str: '" << s.str << "'";
84 class StabsDebugInfo : public DebugInfo {
87 typedef std::vector<Stab> StabsList;
89 StabsDebugInfo(StabsList stabs)
90 : DebugInfo(Kind::Stabs), _stabs(std::move(stabs)) {}
92 static inline bool classof(const DebugInfo *di) {
93 return di->kind() == Kind::Stabs;
96 const StabsList& stabs() const { return _stabs; }
102 } // end namespace mach_o
103 } // end namespace lld
105 #endif // LLD_READER_WRITER_MACHO_DEBUGINFO_H