|
9 | 9 | #ifndef LLVM_DWARFLINKER_DWARFLINKER_H
|
10 | 10 | #define LLVM_DWARFLINKER_DWARFLINKER_H
|
11 | 11 |
|
| 12 | +#include "llvm/CodeGen/AccelTable.h" |
12 | 13 | #include "llvm/CodeGen/NonRelocatableStringpool.h"
|
13 | 14 | #include "llvm/DWARFLinker/DWARFLinkerDeclContext.h"
|
14 | 15 | #include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
|
15 | 16 | #include "llvm/DebugInfo/DWARF/DWARFContext.h"
|
| 17 | +#include "llvm/MC/MCDwarf.h" |
16 | 18 | #include <map>
|
17 | 19 |
|
18 | 20 | namespace llvm {
|
@@ -81,6 +83,116 @@ class AddressesMap {
|
81 | 83 | virtual void clear() = 0;
|
82 | 84 | };
|
83 | 85 |
|
| 86 | +/// DwarfEmitter presents interface to generate all debug info tables. |
| 87 | +class DwarfEmitter { |
| 88 | +public: |
| 89 | + virtual ~DwarfEmitter(); |
| 90 | + |
| 91 | + /// Emit DIE containing warnings. |
| 92 | + virtual void emitPaperTrailWarningsDie(const Triple &Triple, DIE &Die) = 0; |
| 93 | + |
| 94 | + /// Emit section named SecName with content equals to |
| 95 | + /// corresponding section in Obj. |
| 96 | + virtual void emitSectionContents(const object::ObjectFile &Obj, |
| 97 | + StringRef SecName) = 0; |
| 98 | + |
| 99 | + /// Emit the abbreviation table \p Abbrevs to the debug_abbrev section. |
| 100 | + virtual void |
| 101 | + emitAbbrevs(const std::vector<std::unique_ptr<DIEAbbrev>> &Abbrevs, |
| 102 | + unsigned DwarfVersion) = 0; |
| 103 | + |
| 104 | + /// Emit the string table described by \p Pool. |
| 105 | + virtual void emitStrings(const NonRelocatableStringpool &Pool) = 0; |
| 106 | + |
| 107 | + /// Emit DWARF debug names. |
| 108 | + virtual void |
| 109 | + emitDebugNames(AccelTable<DWARF5AccelTableStaticData> &Table) = 0; |
| 110 | + |
| 111 | + /// Emit Apple namespaces accelerator table. |
| 112 | + virtual void |
| 113 | + emitAppleNamespaces(AccelTable<AppleAccelTableStaticOffsetData> &Table) = 0; |
| 114 | + |
| 115 | + /// Emit Apple names accelerator table. |
| 116 | + virtual void |
| 117 | + emitAppleNames(AccelTable<AppleAccelTableStaticOffsetData> &Table) = 0; |
| 118 | + |
| 119 | + /// Emit Apple Objective-C accelerator table. |
| 120 | + virtual void |
| 121 | + emitAppleObjc(AccelTable<AppleAccelTableStaticOffsetData> &Table) = 0; |
| 122 | + |
| 123 | + /// Emit Apple type accelerator table. |
| 124 | + virtual void |
| 125 | + emitAppleTypes(AccelTable<AppleAccelTableStaticTypeData> &Table) = 0; |
| 126 | + |
| 127 | + /// Emit debug_ranges for \p FuncRange by translating the |
| 128 | + /// original \p Entries. |
| 129 | + virtual void emitRangesEntries( |
| 130 | + int64_t UnitPcOffset, uint64_t OrigLowPc, |
| 131 | + const FunctionIntervals::const_iterator &FuncRange, |
| 132 | + const std::vector<DWARFDebugRangeList::RangeListEntry> &Entries, |
| 133 | + unsigned AddressSize) = 0; |
| 134 | + |
| 135 | + /// Emit debug_aranges entries for \p Unit and if \p DoRangesSection is true, |
| 136 | + /// also emit the debug_ranges entries for the DW_TAG_compile_unit's |
| 137 | + /// DW_AT_ranges attribute. |
| 138 | + virtual void emitUnitRangesEntries(CompileUnit &Unit, |
| 139 | + bool DoRangesSection) = 0; |
| 140 | + |
| 141 | + /// Copy the debug_line over to the updated binary while unobfuscating the |
| 142 | + /// file names and directories. |
| 143 | + virtual void translateLineTable(DataExtractor LineData, uint64_t Offset) = 0; |
| 144 | + |
| 145 | + /// Emit the line table described in \p Rows into the debug_line section. |
| 146 | + virtual void emitLineTableForUnit(MCDwarfLineTableParams Params, |
| 147 | + StringRef PrologueBytes, |
| 148 | + unsigned MinInstLength, |
| 149 | + std::vector<DWARFDebugLine::Row> &Rows, |
| 150 | + unsigned AdddressSize) = 0; |
| 151 | + |
| 152 | + /// Emit the .debug_pubnames contribution for \p Unit. |
| 153 | + virtual void emitPubNamesForUnit(const CompileUnit &Unit) = 0; |
| 154 | + |
| 155 | + /// Emit the .debug_pubtypes contribution for \p Unit. |
| 156 | + virtual void emitPubTypesForUnit(const CompileUnit &Unit) = 0; |
| 157 | + |
| 158 | + /// Emit a CIE. |
| 159 | + virtual void emitCIE(StringRef CIEBytes) = 0; |
| 160 | + |
| 161 | + /// Emit an FDE with data \p Bytes. |
| 162 | + virtual void emitFDE(uint32_t CIEOffset, uint32_t AddreSize, uint32_t Address, |
| 163 | + StringRef Bytes) = 0; |
| 164 | + |
| 165 | + /// Emit the debug_loc contribution for \p Unit by copying the entries from |
| 166 | + /// \p Dwarf and offsetting them. Update the location attributes to point to |
| 167 | + /// the new entries. |
| 168 | + virtual void emitLocationsForUnit( |
| 169 | + const CompileUnit &Unit, DWARFContext &Dwarf, |
| 170 | + std::function<void(StringRef, SmallVectorImpl<uint8_t> &)> |
| 171 | + ProcessExpr) = 0; |
| 172 | + |
| 173 | + /// Emit the compilation unit header for \p Unit in the |
| 174 | + /// debug_info section. |
| 175 | + /// |
| 176 | + /// As a side effect, this also switches the current Dwarf version |
| 177 | + /// of the MC layer to the one of U.getOrigUnit(). |
| 178 | + virtual void emitCompileUnitHeader(CompileUnit &Unit) = 0; |
| 179 | + |
| 180 | + /// Recursively emit the DIE tree rooted at \p Die. |
| 181 | + virtual void emitDIE(DIE &Die) = 0; |
| 182 | + |
| 183 | + /// Returns size of generated .debug_line section. |
| 184 | + virtual uint64_t getLineSectionSize() const = 0; |
| 185 | + |
| 186 | + /// Returns size of generated .debug_frame section. |
| 187 | + virtual uint64_t getFrameSectionSize() const = 0; |
| 188 | + |
| 189 | + /// Returns size of generated .debug_ranges section. |
| 190 | + virtual uint64_t getRangesSectionSize() const = 0; |
| 191 | + |
| 192 | + /// Returns size of generated .debug_info section. |
| 193 | + virtual uint64_t getDebugInfoSectionSize() const = 0; |
| 194 | +}; |
| 195 | + |
84 | 196 | } // end namespace llvm
|
85 | 197 |
|
86 | 198 | #endif // LLVM_DWARFLINKER_DWARFLINKER_H
|
0 commit comments