Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 1 | //===-- llvm/CodeGen/DwarfDebug.h - Dwarf Debug Framework ------*- C++ -*--===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file contains support for writing dwarf debug info into asm files. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 14 | #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H |
| 15 | #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 16 | |
David Blaikie | 85f80d7 | 2014-04-23 18:54:00 +0000 | [diff] [blame] | 17 | #include "DwarfFile.h" |
Timur Iskhodzhanov | 1cd1444 | 2013-12-03 15:10:23 +0000 | [diff] [blame] | 18 | #include "AsmPrinterHandler.h" |
Bill Wendling | e38859d | 2012-06-28 00:05:13 +0000 | [diff] [blame] | 19 | #include "DIE.h" |
Alexey Samsonov | 414b6fb | 2014-04-30 21:34:11 +0000 | [diff] [blame] | 20 | #include "DbgValueHistoryCalculator.h" |
David Blaikie | 1275e4f | 2014-04-01 21:49:04 +0000 | [diff] [blame] | 21 | #include "DebugLocEntry.h" |
David Blaikie | 0a456de | 2014-04-02 01:43:18 +0000 | [diff] [blame] | 22 | #include "DebugLocList.h" |
David Blaikie | 2406a062 | 2014-04-23 23:37:35 +0000 | [diff] [blame] | 23 | #include "DwarfAccelTable.h" |
Devang Patel | 018b29b | 2010-01-19 06:19:05 +0000 | [diff] [blame] | 24 | #include "llvm/ADT/DenseMap.h" |
Eric Christopher | acbe42b | 2014-03-18 20:58:35 +0000 | [diff] [blame] | 25 | #include "llvm/ADT/MapVector.h" |
| 26 | #include "llvm/ADT/SmallPtrSet.h" |
| 27 | #include "llvm/ADT/StringMap.h" |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 28 | #include "llvm/ADT/FoldingSet.h" |
Chandler Carruth | 802d755 | 2012-12-04 07:12:27 +0000 | [diff] [blame] | 29 | #include "llvm/CodeGen/LexicalScopes.h" |
Adrian Prantl | c119754 | 2014-05-30 21:10:13 +0000 | [diff] [blame] | 30 | #include "llvm/CodeGen/MachineInstr.h" |
Chandler Carruth | 9a4c9e5 | 2014-03-06 00:46:21 +0000 | [diff] [blame] | 31 | #include "llvm/IR/DebugInfo.h" |
Eric Christopher | acbe42b | 2014-03-18 20:58:35 +0000 | [diff] [blame] | 32 | #include "llvm/IR/DebugLoc.h" |
Chandler Carruth | 802d755 | 2012-12-04 07:12:27 +0000 | [diff] [blame] | 33 | #include "llvm/MC/MachineLocation.h" |
David Blaikie | 4a2f95f | 2014-03-18 01:17:26 +0000 | [diff] [blame] | 34 | #include "llvm/MC/MCDwarf.h" |
Chris Lattner | 3f3fb97 | 2010-04-05 05:24:55 +0000 | [diff] [blame] | 35 | #include "llvm/Support/Allocator.h" |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 36 | |
David Blaikie | f9b6a55 | 2014-04-22 22:39:41 +0000 | [diff] [blame] | 37 | #include <memory> |
| 38 | |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 39 | namespace llvm { |
| 40 | |
Adrian Prantl | 702bf5a | 2014-03-18 02:34:52 +0000 | [diff] [blame] | 41 | class AsmPrinter; |
Eric Christopher | 29e874d | 2014-03-07 22:40:37 +0000 | [diff] [blame] | 42 | class ByteStreamer; |
Chris Lattner | 88fce10 | 2012-01-26 20:44:57 +0000 | [diff] [blame] | 43 | class ConstantInt; |
| 44 | class ConstantFP; |
Eric Christopher | ce4a944 | 2014-03-18 20:37:10 +0000 | [diff] [blame] | 45 | class DwarfCompileUnit; |
| 46 | class DwarfDebug; |
| 47 | class DwarfTypeUnit; |
| 48 | class DwarfUnit; |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 49 | class MachineModuleInfo; |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 50 | |
| 51 | //===----------------------------------------------------------------------===// |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 52 | /// \brief This class is used to record source line correspondence. |
Benjamin Kramer | 079b96e | 2013-09-11 18:05:11 +0000 | [diff] [blame] | 53 | class SrcLineInfo { |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 54 | unsigned Line; // Source line number. |
| 55 | unsigned Column; // Source column. |
| 56 | unsigned SourceID; // Source ID number. |
| 57 | MCSymbol *Label; // Label in code ID number. |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 58 | public: |
Chris Lattner | b4666f4 | 2010-03-14 08:15:55 +0000 | [diff] [blame] | 59 | SrcLineInfo(unsigned L, unsigned C, unsigned S, MCSymbol *label) |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 60 | : Line(L), Column(C), SourceID(S), Label(label) {} |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 61 | |
| 62 | // Accessors |
| 63 | unsigned getLine() const { return Line; } |
| 64 | unsigned getColumn() const { return Column; } |
| 65 | unsigned getSourceID() const { return SourceID; } |
Chris Lattner | b4666f4 | 2010-03-14 08:15:55 +0000 | [diff] [blame] | 66 | MCSymbol *getLabel() const { return Label; } |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 67 | }; |
| 68 | |
Devang Patel | f20c4f7 | 2011-04-12 22:53:02 +0000 | [diff] [blame] | 69 | //===----------------------------------------------------------------------===// |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 70 | /// \brief This class is used to track local variable information. |
Benjamin Kramer | 079b96e | 2013-09-11 18:05:11 +0000 | [diff] [blame] | 71 | class DbgVariable { |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 72 | DIVariable Var; // Variable Descriptor. |
| 73 | DIE *TheDIE; // Variable DIE. |
| 74 | unsigned DotDebugLocOffset; // Offset in DotDebugLocEntries. |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 75 | const MachineInstr *MInsn; // DBG_VALUE instruction of the variable. |
Devang Patel | 3e4a965 | 2011-08-15 21:24:36 +0000 | [diff] [blame] | 76 | int FrameIndex; |
Manman Ren | b338860 | 2013-10-05 01:43:03 +0000 | [diff] [blame] | 77 | DwarfDebug *DD; |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 78 | |
Devang Patel | f20c4f7 | 2011-04-12 22:53:02 +0000 | [diff] [blame] | 79 | public: |
Adrian Prantl | c119754 | 2014-05-30 21:10:13 +0000 | [diff] [blame] | 80 | /// Construct a DbgVariable from a DIVariable. |
David Blaikie | 6f9e867 | 2014-06-13 23:52:55 +0000 | [diff] [blame] | 81 | DbgVariable(DIVariable V, DwarfDebug *DD) |
| 82 | : Var(V), TheDIE(nullptr), DotDebugLocOffset(~0U), MInsn(nullptr), |
| 83 | FrameIndex(~0), DD(DD) {} |
Devang Patel | f20c4f7 | 2011-04-12 22:53:02 +0000 | [diff] [blame] | 84 | |
Adrian Prantl | c119754 | 2014-05-30 21:10:13 +0000 | [diff] [blame] | 85 | /// Construct a DbgVariable from a DEBUG_VALUE. |
| 86 | /// AbstractVar may be NULL. |
David Blaikie | 6f9e867 | 2014-06-13 23:52:55 +0000 | [diff] [blame] | 87 | DbgVariable(const MachineInstr *DbgValue, DwarfDebug *DD) |
| 88 | : Var(DbgValue->getDebugVariable()), TheDIE(nullptr), |
| 89 | DotDebugLocOffset(~0U), MInsn(DbgValue), FrameIndex(~0), DD(DD) {} |
Adrian Prantl | c119754 | 2014-05-30 21:10:13 +0000 | [diff] [blame] | 90 | |
Devang Patel | f20c4f7 | 2011-04-12 22:53:02 +0000 | [diff] [blame] | 91 | // Accessors. |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 92 | DIVariable getVariable() const { return Var; } |
David Blaikie | e071fc8 | 2014-04-25 17:32:19 +0000 | [diff] [blame] | 93 | void setDIE(DIE &D) { TheDIE = &D; } |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 94 | DIE *getDIE() const { return TheDIE; } |
| 95 | void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; } |
| 96 | unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; } |
| 97 | StringRef getName() const { return Var.getName(); } |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 98 | const MachineInstr *getMInsn() const { return MInsn; } |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 99 | int getFrameIndex() const { return FrameIndex; } |
| 100 | void setFrameIndex(int FI) { FrameIndex = FI; } |
Eric Christopher | 27527b2 | 2012-11-21 00:03:28 +0000 | [diff] [blame] | 101 | // Translate tag to proper Dwarf tag. |
David Blaikie | efc403b | 2014-04-12 02:24:04 +0000 | [diff] [blame] | 102 | dwarf::Tag getTag() const { |
Devang Patel | 6e4d2c9 | 2011-08-15 18:35:42 +0000 | [diff] [blame] | 103 | if (Var.getTag() == dwarf::DW_TAG_arg_variable) |
| 104 | return dwarf::DW_TAG_formal_parameter; |
Eric Christopher | 27527b2 | 2012-11-21 00:03:28 +0000 | [diff] [blame] | 105 | |
Devang Patel | 6e4d2c9 | 2011-08-15 18:35:42 +0000 | [diff] [blame] | 106 | return dwarf::DW_TAG_variable; |
| 107 | } |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 108 | /// \brief Return true if DbgVariable is artificial. |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 109 | bool isArtificial() const { |
Devang Patel | d7d80aa | 2011-08-15 18:40:16 +0000 | [diff] [blame] | 110 | if (Var.isArtificial()) |
| 111 | return true; |
Eric Christopher | c1c8a1b | 2012-09-21 22:18:52 +0000 | [diff] [blame] | 112 | if (getType().isArtificial()) |
Devang Patel | d7d80aa | 2011-08-15 18:40:16 +0000 | [diff] [blame] | 113 | return true; |
| 114 | return false; |
| 115 | } |
Eric Christopher | e341776 | 2012-09-12 23:36:19 +0000 | [diff] [blame] | 116 | |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 117 | bool isObjectPointer() const { |
Eric Christopher | e341776 | 2012-09-12 23:36:19 +0000 | [diff] [blame] | 118 | if (Var.isObjectPointer()) |
| 119 | return true; |
Eric Christopher | c1c8a1b | 2012-09-21 22:18:52 +0000 | [diff] [blame] | 120 | if (getType().isObjectPointer()) |
Eric Christopher | e341776 | 2012-09-12 23:36:19 +0000 | [diff] [blame] | 121 | return true; |
| 122 | return false; |
| 123 | } |
Eric Christopher | 27527b2 | 2012-11-21 00:03:28 +0000 | [diff] [blame] | 124 | |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 125 | bool variableHasComplexAddress() const { |
Manman Ren | 7504ed4 | 2013-07-08 18:33:29 +0000 | [diff] [blame] | 126 | assert(Var.isVariable() && "Invalid complex DbgVariable!"); |
Devang Patel | f20c4f7 | 2011-04-12 22:53:02 +0000 | [diff] [blame] | 127 | return Var.hasComplexAddress(); |
| 128 | } |
Adrian Prantl | 1a1647c | 2014-03-18 02:34:58 +0000 | [diff] [blame] | 129 | bool isBlockByrefVariable() const; |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 130 | unsigned getNumAddrElements() const { |
Manman Ren | 7504ed4 | 2013-07-08 18:33:29 +0000 | [diff] [blame] | 131 | assert(Var.isVariable() && "Invalid complex DbgVariable!"); |
Devang Patel | f20c4f7 | 2011-04-12 22:53:02 +0000 | [diff] [blame] | 132 | return Var.getNumAddrElements(); |
| 133 | } |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 134 | uint64_t getAddrElement(unsigned i) const { return Var.getAddrElement(i); } |
Devang Patel | f20c4f7 | 2011-04-12 22:53:02 +0000 | [diff] [blame] | 135 | DIType getType() const; |
Manman Ren | be5576f | 2013-10-08 19:07:44 +0000 | [diff] [blame] | 136 | |
| 137 | private: |
| 138 | /// resolve - Look in the DwarfDebug map for the MDNode that |
| 139 | /// corresponds to the reference. |
| 140 | template <typename T> T resolve(DIRef<T> Ref) const; |
Devang Patel | f20c4f7 | 2011-04-12 22:53:02 +0000 | [diff] [blame] | 141 | }; |
| 142 | |
Eric Christopher | c8a310e | 2012-12-10 23:34:43 +0000 | [diff] [blame] | 143 | |
Eric Christopher | 670ee0e | 2013-10-24 21:20:23 +0000 | [diff] [blame] | 144 | /// \brief Helper used to pair up a symbol and its DWARF compile unit. |
Richard Mitton | 21101b3 | 2013-09-19 23:21:01 +0000 | [diff] [blame] | 145 | struct SymbolCU { |
Eric Christopher | 4287a49 | 2013-12-09 23:57:44 +0000 | [diff] [blame] | 146 | SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {} |
Richard Mitton | 21101b3 | 2013-09-19 23:21:01 +0000 | [diff] [blame] | 147 | const MCSymbol *Sym; |
Eric Christopher | 4287a49 | 2013-12-09 23:57:44 +0000 | [diff] [blame] | 148 | DwarfCompileUnit *CU; |
Richard Mitton | 21101b3 | 2013-09-19 23:21:01 +0000 | [diff] [blame] | 149 | }; |
| 150 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 151 | /// \brief Collects and handles dwarf debug information. |
Timur Iskhodzhanov | 1cd1444 | 2013-12-03 15:10:23 +0000 | [diff] [blame] | 152 | class DwarfDebug : public AsmPrinterHandler { |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 153 | // Target of Dwarf emission. |
Chris Lattner | 3a383cb | 2010-04-05 00:13:49 +0000 | [diff] [blame] | 154 | AsmPrinter *Asm; |
Chris Lattner | acda87b | 2010-04-05 05:31:04 +0000 | [diff] [blame] | 155 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 156 | // Collected machine module information. |
Chris Lattner | 3a383cb | 2010-04-05 00:13:49 +0000 | [diff] [blame] | 157 | MachineModuleInfo *MMI; |
| 158 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 159 | // All DIEValues are allocated through this allocator. |
Benjamin Kramer | 0748008 | 2012-06-09 10:34:15 +0000 | [diff] [blame] | 160 | BumpPtrAllocator DIEValueAllocator; |
| 161 | |
Eric Christopher | bfe7d29 | 2013-12-03 22:05:55 +0000 | [diff] [blame] | 162 | // Handle to the compile unit used for the inline extension handling, |
| 163 | // this is just so that the DIEValue allocator has a place to store |
| 164 | // the particular elements. |
| 165 | // FIXME: Store these off of DwarfDebug instead? |
Eric Christopher | 4287a49 | 2013-12-09 23:57:44 +0000 | [diff] [blame] | 166 | DwarfCompileUnit *FirstCU; |
Devang Patel | eb1bb4e | 2011-08-16 22:09:43 +0000 | [diff] [blame] | 167 | |
Eric Christopher | 4287a49 | 2013-12-09 23:57:44 +0000 | [diff] [blame] | 168 | // Maps MDNode with its corresponding DwarfCompileUnit. |
Eric Christopher | 179fba1 | 2014-01-29 22:06:23 +0000 | [diff] [blame] | 169 | MapVector<const MDNode *, DwarfCompileUnit *> CUMap; |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 170 | |
Eric Christopher | 4287a49 | 2013-12-09 23:57:44 +0000 | [diff] [blame] | 171 | // Maps subprogram MDNode with its corresponding DwarfCompileUnit. |
| 172 | DenseMap<const MDNode *, DwarfCompileUnit *> SPMap; |
Devang Patel | eb1bb4e | 2011-08-16 22:09:43 +0000 | [diff] [blame] | 173 | |
Eric Christopher | 4287a49 | 2013-12-09 23:57:44 +0000 | [diff] [blame] | 174 | // Maps a CU DIE with its corresponding DwarfCompileUnit. |
| 175 | DenseMap<const DIE *, DwarfCompileUnit *> CUDieMap; |
Manman Ren | ce20d46 | 2013-10-29 22:57:10 +0000 | [diff] [blame] | 176 | |
Eric Christopher | 47f2be8 | 2014-03-20 19:16:20 +0000 | [diff] [blame] | 177 | /// Maps MDNodes for type system with the corresponding DIEs. These DIEs can |
Manman Ren | 4dbdc90 | 2013-10-31 17:54:35 +0000 | [diff] [blame] | 178 | /// be shared across CUs, that is why we keep the map here instead |
Eric Christopher | 4287a49 | 2013-12-09 23:57:44 +0000 | [diff] [blame] | 179 | /// of in DwarfCompileUnit. |
Manman Ren | 4dbdc90 | 2013-10-31 17:54:35 +0000 | [diff] [blame] | 180 | DenseMap<const MDNode *, DIE *> MDTypeNodeToDieMap; |
| 181 | |
Alexey Samsonov | 4436bf0 | 2013-10-03 08:54:43 +0000 | [diff] [blame] | 182 | // List of all labels used in aranges generation. |
| 183 | std::vector<SymbolCU> ArangeLabels; |
Richard Mitton | 21101b3 | 2013-09-19 23:21:01 +0000 | [diff] [blame] | 184 | |
Richard Mitton | 089ed89 | 2013-09-23 17:56:20 +0000 | [diff] [blame] | 185 | // Size of each symbol emitted (for those symbols that have a specific size). |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 186 | DenseMap<const MCSymbol *, uint64_t> SymSize; |
Richard Mitton | 089ed89 | 2013-09-23 17:56:20 +0000 | [diff] [blame] | 187 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 188 | // Provides a unique id per text section. |
Richard Mitton | 21101b3 | 2013-09-19 23:21:01 +0000 | [diff] [blame] | 189 | typedef DenseMap<const MCSection *, SmallVector<SymbolCU, 8> > SectionMapType; |
| 190 | SectionMapType SectionMap; |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 191 | |
Eric Christopher | aba20dd | 2013-07-08 21:16:18 +0000 | [diff] [blame] | 192 | // List of arguments for current function. |
David Blaikie | afd2c6b | 2014-04-22 05:41:06 +0000 | [diff] [blame] | 193 | SmallVector<DbgVariable *, 8> CurrentFnArguments; |
Devang Patel | 6c622ef | 2011-03-01 22:58:55 +0000 | [diff] [blame] | 194 | |
Devang Patel | 7e62302 | 2011-08-10 20:55:27 +0000 | [diff] [blame] | 195 | LexicalScopes LScopes; |
Devang Patel | 95cd4b9 | 2010-03-25 15:09:44 +0000 | [diff] [blame] | 196 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 197 | // Collection of abstract subprogram DIEs. |
Devang Patel | a37a95e | 2010-07-07 22:20:57 +0000 | [diff] [blame] | 198 | DenseMap<const MDNode *, DIE *> AbstractSPDies; |
| 199 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 200 | // Collection of dbg variables of a scope. |
David Blaikie | afd2c6b | 2014-04-22 05:41:06 +0000 | [diff] [blame] | 201 | typedef DenseMap<LexicalScope *, SmallVector<DbgVariable *, 8> > |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 202 | ScopeVariablesMap; |
Craig Topper | 2b4a201 | 2013-07-03 04:40:27 +0000 | [diff] [blame] | 203 | ScopeVariablesMap ScopeVariables; |
Devang Patel | f6eeaeb | 2009-11-10 23:06:00 +0000 | [diff] [blame] | 204 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 205 | // Collection of abstract variables. |
David Blaikie | 825bdd2 | 2014-05-21 22:41:17 +0000 | [diff] [blame] | 206 | DenseMap<const MDNode *, std::unique_ptr<DbgVariable>> AbstractVariables; |
David Blaikie | eb1a272 | 2014-06-13 22:18:23 +0000 | [diff] [blame] | 207 | SmallVector<std::unique_ptr<DbgVariable>, 64> ConcreteVariables; |
Devang Patel | f6eeaeb | 2009-11-10 23:06:00 +0000 | [diff] [blame] | 208 | |
David Blaikie | 0a456de | 2014-04-02 01:43:18 +0000 | [diff] [blame] | 209 | // Collection of DebugLocEntry. Stored in a linked list so that DIELocLists |
| 210 | // can refer to them in spite of insertions into this list. |
| 211 | SmallVector<DebugLocList, 4> DotDebugLocEntries; |
Devang Patel | 9fc1170 | 2010-05-25 23:40:22 +0000 | [diff] [blame] | 212 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 213 | // Collection of subprogram DIEs that are marked (at the end of the module) |
| 214 | // as DW_AT_inline. |
Devang Patel | f6eeaeb | 2009-11-10 23:06:00 +0000 | [diff] [blame] | 215 | SmallPtrSet<DIE *, 4> InlinedSubprogramDIEs; |
| 216 | |
Eric Christopher | 48fef59 | 2012-12-20 21:58:40 +0000 | [diff] [blame] | 217 | // This is a collection of subprogram MDNodes that are processed to |
| 218 | // create DIEs. |
Devang Patel | f3b2db6 | 2010-06-28 18:25:03 +0000 | [diff] [blame] | 219 | SmallPtrSet<const MDNode *, 16> ProcessedSPNodes; |
| 220 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 221 | // Maps instruction with label emitted before instruction. |
Devang Patel | 6c74a87 | 2010-04-27 19:46:33 +0000 | [diff] [blame] | 222 | DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn; |
Devang Patel | 3ebd893 | 2010-04-08 16:50:29 +0000 | [diff] [blame] | 223 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 224 | // Maps instruction with label emitted after instruction. |
Devang Patel | 6c74a87 | 2010-04-27 19:46:33 +0000 | [diff] [blame] | 225 | DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn; |
Devang Patel | 3ebd893 | 2010-04-08 16:50:29 +0000 | [diff] [blame] | 226 | |
Alexey Samsonov | 414b6fb | 2014-04-30 21:34:11 +0000 | [diff] [blame] | 227 | // History of DBG_VALUE and clobber instructions for each user variable. |
Alexey Samsonov | 0436caa | 2014-04-30 23:02:40 +0000 | [diff] [blame] | 228 | // Variables are listed in order of appearance. |
Jakob Stoklund Olesen | 9a624fa | 2011-03-26 02:19:36 +0000 | [diff] [blame] | 229 | DbgValueHistoryMap DbgValues; |
Jakob Stoklund Olesen | ec0ac3c | 2011-03-22 22:33:08 +0000 | [diff] [blame] | 230 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 231 | // Previous instruction's location information. This is used to determine |
| 232 | // label location to indicate scope boundries in dwarf debug info. |
Chris Lattner | 915c5f9 | 2010-04-02 19:42:39 +0000 | [diff] [blame] | 233 | DebugLoc PrevInstLoc; |
Devang Patel | 12563b3 | 2010-04-16 23:33:45 +0000 | [diff] [blame] | 234 | MCSymbol *PrevLabel; |
Devang Patel | bd477be | 2010-03-29 17:20:31 +0000 | [diff] [blame] | 235 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 236 | // This location indicates end of function prologue and beginning of function |
| 237 | // body. |
Devang Patel | 34a6620 | 2011-05-11 19:22:19 +0000 | [diff] [blame] | 238 | DebugLoc PrologEndLoc; |
| 239 | |
Timur Iskhodzhanov | 1cd1444 | 2013-12-03 15:10:23 +0000 | [diff] [blame] | 240 | // If nonnull, stores the current machine function we're processing. |
| 241 | const MachineFunction *CurFn; |
| 242 | |
| 243 | // If nonnull, stores the current machine instruction we're processing. |
| 244 | const MachineInstr *CurMI; |
| 245 | |
Eric Christopher | 384f3fe | 2014-03-20 19:16:16 +0000 | [diff] [blame] | 246 | // If nonnull, stores the section that the previous function was allocated to |
| 247 | // emitting. |
| 248 | const MCSection *PrevSection; |
| 249 | |
| 250 | // If nonnull, stores the CU in which the previous subprogram was contained. |
| 251 | const DwarfCompileUnit *PrevCU; |
| 252 | |
Chris Lattner | 6629ca9 | 2010-04-04 22:59:04 +0000 | [diff] [blame] | 253 | // Section Symbols: these are assembler temporary labels that are emitted at |
| 254 | // the beginning of each supported dwarf section. These are used to form |
| 255 | // section offsets and are created by EmitSectionLabels. |
Rafael Espindola | a716096 | 2011-05-06 14:56:22 +0000 | [diff] [blame] | 256 | MCSymbol *DwarfInfoSectionSym, *DwarfAbbrevSectionSym; |
Devang Patel | 12563b3 | 2010-04-16 23:33:45 +0000 | [diff] [blame] | 257 | MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym; |
Eric Christopher | 55863be | 2013-04-07 03:43:09 +0000 | [diff] [blame] | 258 | MCSymbol *DwarfDebugLocSectionSym, *DwarfLineSectionSym, *DwarfAddrSectionSym; |
Devang Patel | 9fc1170 | 2010-05-25 23:40:22 +0000 | [diff] [blame] | 259 | MCSymbol *FunctionBeginSym, *FunctionEndSym; |
Eric Christopher | d866720 | 2013-12-30 17:22:27 +0000 | [diff] [blame] | 260 | MCSymbol *DwarfInfoDWOSectionSym, *DwarfAbbrevDWOSectionSym; |
David Blaikie | 29459ae | 2014-07-25 17:11:58 +0000 | [diff] [blame] | 261 | MCSymbol *DwarfTypesDWOSectionSym; |
David Blaikie | e12ab12 | 2014-04-01 16:09:49 +0000 | [diff] [blame] | 262 | MCSymbol *DwarfStrDWOSectionSym; |
Eric Christopher | 39eebfa | 2013-09-30 23:14:16 +0000 | [diff] [blame] | 263 | MCSymbol *DwarfGnuPubNamesSectionSym, *DwarfGnuPubTypesSectionSym; |
Devang Patel | 9c160e1 | 2010-07-08 20:10:35 +0000 | [diff] [blame] | 264 | |
Nick Lewycky | d1ee7f8 | 2011-11-02 20:55:33 +0000 | [diff] [blame] | 265 | // As an optimization, there is no need to emit an entry in the directory |
Eric Christopher | 808fd7b | 2013-07-03 01:57:23 +0000 | [diff] [blame] | 266 | // table for the same directory as DW_AT_comp_dir. |
Nick Lewycky | d1ee7f8 | 2011-11-02 20:55:33 +0000 | [diff] [blame] | 267 | StringRef CompilationDir; |
| 268 | |
Eric Christopher | 0f63d06 | 2013-12-03 00:45:45 +0000 | [diff] [blame] | 269 | // Counter for assigning globally unique IDs for ranges. |
| 270 | unsigned GlobalRangeCount; |
| 271 | |
Eric Christopher | c8a310e | 2012-12-10 23:34:43 +0000 | [diff] [blame] | 272 | // Holder for the file specific debug information. |
Eric Christopher | f819485 | 2013-12-05 18:06:10 +0000 | [diff] [blame] | 273 | DwarfFile InfoHolder; |
Eric Christopher | c8a310e | 2012-12-10 23:34:43 +0000 | [diff] [blame] | 274 | |
Eric Christopher | 0aa4a67 | 2012-12-10 22:25:41 +0000 | [diff] [blame] | 275 | // Holders for the various debug information flags that we might need to |
| 276 | // have exposed. See accessor functions below for description. |
| 277 | |
Eric Christopher | 070bf16 | 2013-07-03 01:57:26 +0000 | [diff] [blame] | 278 | // Holder for imported entities. |
| 279 | typedef SmallVector<std::pair<const MDNode *, const MDNode *>, 32> |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 280 | ImportedEntityMap; |
Eric Christopher | 070bf16 | 2013-07-03 01:57:26 +0000 | [diff] [blame] | 281 | ImportedEntityMap ScopesWithImportedEntities; |
| 282 | |
David Blaikie | 47f615e | 2013-12-17 23:32:35 +0000 | [diff] [blame] | 283 | // Map from MDNodes for user-defined types to the type units that describe |
| 284 | // them. |
| 285 | DenseMap<const MDNode *, const DwarfTypeUnit *> DwarfTypeUnits; |
Eric Christopher | 6764643 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 286 | |
David Blaikie | e12b49a | 2014-04-26 17:27:38 +0000 | [diff] [blame] | 287 | SmallVector<std::pair<std::unique_ptr<DwarfTypeUnit>, DICompositeType>, 1> TypeUnitsUnderConstruction; |
| 288 | |
Eric Christopher | 4d36ca0 | 2013-08-26 23:24:35 +0000 | [diff] [blame] | 289 | // Whether to emit the pubnames/pubtypes sections. |
| 290 | bool HasDwarfPubSections; |
| 291 | |
Eric Christopher | 1ad8457 | 2014-01-15 00:04:29 +0000 | [diff] [blame] | 292 | // Whether or not to use AT_ranges for compilation units. |
| 293 | bool HasCURanges; |
| 294 | |
Eric Christopher | 2037caf | 2014-01-28 00:49:26 +0000 | [diff] [blame] | 295 | // Whether we emitted a function into a section other than the default |
| 296 | // text. |
| 297 | bool UsedNonDefaultText; |
| 298 | |
Eric Christopher | 4d36ca0 | 2013-08-26 23:24:35 +0000 | [diff] [blame] | 299 | // Version of dwarf we're emitting. |
| 300 | unsigned DwarfVersion; |
| 301 | |
Eric Christopher | 0a13eb3 | 2013-11-21 22:56:11 +0000 | [diff] [blame] | 302 | // Maps from a type identifier to the actual MDNode. |
| 303 | DITypeIdentifierMap TypeIdentifierMap; |
| 304 | |
Eric Christopher | 42e3994 | 2012-11-29 22:56:13 +0000 | [diff] [blame] | 305 | // DWARF5 Experimental Options |
Eric Christopher | 7b30f2e4 | 2012-11-21 00:34:35 +0000 | [diff] [blame] | 306 | bool HasDwarfAccelTables; |
Eric Christopher | cdf218d | 2012-12-10 19:51:21 +0000 | [diff] [blame] | 307 | bool HasSplitDwarf; |
Manman Ren | ac8062b | 2013-07-02 23:40:10 +0000 | [diff] [blame] | 308 | |
Eric Christopher | d692c1d | 2012-12-11 19:42:09 +0000 | [diff] [blame] | 309 | // Separated Dwarf Variables |
Eric Christopher | d79f548 | 2012-12-10 19:51:13 +0000 | [diff] [blame] | 310 | // In general these will all be for bits that are left in the |
| 311 | // original object file, rather than things that are meant |
| 312 | // to be in the .dwo sections. |
| 313 | |
Eric Christopher | 3bf29fd | 2012-12-27 02:14:01 +0000 | [diff] [blame] | 314 | // Holder for the skeleton information. |
Eric Christopher | f819485 | 2013-12-05 18:06:10 +0000 | [diff] [blame] | 315 | DwarfFile SkeletonHolder; |
Eric Christopher | d79f548 | 2012-12-10 19:51:13 +0000 | [diff] [blame] | 316 | |
David Blaikie | 47f4b82 | 2014-03-19 00:11:28 +0000 | [diff] [blame] | 317 | /// Store file names for type units under fission in a line table header that |
| 318 | /// will be emitted into debug_line.dwo. |
| 319 | // FIXME: replace this with a map from comp_dir to table so that we can emit |
| 320 | // multiple tables during LTO each of which uses directory 0, referencing the |
| 321 | // comp_dir of all the type units that use it. |
David Blaikie | 8287aff | 2014-03-18 02:13:23 +0000 | [diff] [blame] | 322 | MCDwarfDwoLineTable SplitTypeUnitFileTable; |
David Blaikie | 4a2f95f | 2014-03-18 01:17:26 +0000 | [diff] [blame] | 323 | |
David Blaikie | 47f4b82 | 2014-03-19 00:11:28 +0000 | [diff] [blame] | 324 | // True iff there are multiple CUs in this module. |
| 325 | bool SingleCU; |
| 326 | |
David Blaikie | d75fb28 | 2014-04-23 21:20:10 +0000 | [diff] [blame] | 327 | AddressPool AddrPool; |
| 328 | |
David Blaikie | 2406a062 | 2014-04-23 23:37:35 +0000 | [diff] [blame] | 329 | DwarfAccelTable AccelNames; |
David Blaikie | 0ee82b9 | 2014-04-24 00:53:32 +0000 | [diff] [blame] | 330 | DwarfAccelTable AccelObjC; |
David Blaikie | ecf0415 | 2014-04-24 01:02:42 +0000 | [diff] [blame] | 331 | DwarfAccelTable AccelNamespace; |
David Blaikie | 18d3375 | 2014-04-24 01:23:49 +0000 | [diff] [blame] | 332 | DwarfAccelTable AccelTypes; |
David Blaikie | 2406a062 | 2014-04-23 23:37:35 +0000 | [diff] [blame] | 333 | |
David Blaikie | 2f04011 | 2014-07-25 16:10:16 +0000 | [diff] [blame] | 334 | DenseMap<const Function *, DISubprogram> FunctionDIs; |
| 335 | |
David Blaikie | 47f4b82 | 2014-03-19 00:11:28 +0000 | [diff] [blame] | 336 | MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &); |
| 337 | |
David Blaikie | afd2c6b | 2014-04-22 05:41:06 +0000 | [diff] [blame] | 338 | void addScopeVariable(LexicalScope *LS, DbgVariable *Var); |
Devang Patel | f6eeaeb | 2009-11-10 23:06:00 +0000 | [diff] [blame] | 339 | |
David Blaikie | c33b3cd | 2014-04-22 21:27:37 +0000 | [diff] [blame] | 340 | const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() { |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 341 | return InfoHolder.getUnits(); |
| 342 | } |
David Blaikie | fd1eff5 | 2013-11-26 19:14:34 +0000 | [diff] [blame] | 343 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 344 | /// \brief Find abstract variable associated with Var. |
David Blaikie | be7c677 | 2014-06-13 22:29:31 +0000 | [diff] [blame] | 345 | DbgVariable *getExistingAbstractVariable(const DIVariable &DV, |
David Blaikie | 36408e7 | 2014-06-04 23:50:52 +0000 | [diff] [blame] | 346 | DIVariable &Cleansed); |
David Blaikie | e847f13 | 2014-06-13 22:35:44 +0000 | [diff] [blame] | 347 | DbgVariable *getExistingAbstractVariable(const DIVariable &DV); |
David Blaikie | 6f9e867 | 2014-06-13 23:52:55 +0000 | [diff] [blame] | 348 | void createAbstractVariable(const DIVariable &DV, LexicalScope *Scope); |
| 349 | void ensureAbstractVariableIsCreated(const DIVariable &Var, |
| 350 | const MDNode *Scope); |
| 351 | void ensureAbstractVariableIsCreatedIfScoped(const DIVariable &Var, |
| 352 | const MDNode *Scope); |
Devang Patel | f6eeaeb | 2009-11-10 23:06:00 +0000 | [diff] [blame] | 353 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 354 | /// \brief Find DIE for the given subprogram and attach appropriate |
| 355 | /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global |
| 356 | /// variables in this scope then create and insert DIEs for these |
| 357 | /// variables. |
David Blaikie | e872a6e | 2014-04-29 15:58:35 +0000 | [diff] [blame] | 358 | DIE &updateSubprogramScopeDIE(DwarfCompileUnit &SPCU, DISubprogram SP); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 359 | |
Eric Christopher | 44e66c1 | 2013-12-03 00:45:56 +0000 | [diff] [blame] | 360 | /// \brief A helper function to check whether the DIE for a given Scope is |
| 361 | /// going to be null. |
Manman Ren | 2312ed3 | 2013-09-10 18:40:41 +0000 | [diff] [blame] | 362 | bool isLexicalScopeDIENull(LexicalScope *Scope); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 363 | |
Eric Christopher | be2513e | 2013-12-03 00:45:59 +0000 | [diff] [blame] | 364 | /// \brief A helper function to construct a RangeSpanList for a given |
| 365 | /// lexical scope. |
David Blaikie | 65a7466 | 2014-04-25 18:26:14 +0000 | [diff] [blame] | 366 | void addScopeRangeList(DwarfCompileUnit &TheCU, DIE &ScopeDIE, |
Eric Christopher | be2513e | 2013-12-03 00:45:59 +0000 | [diff] [blame] | 367 | const SmallVectorImpl<InsnRange> &Range); |
| 368 | |
Eric Christopher | 77913e039 | 2013-12-03 00:45:54 +0000 | [diff] [blame] | 369 | /// \brief Construct new DW_TAG_lexical_block for this scope and |
| 370 | /// attach DW_AT_low_pc/DW_AT_high_pc labels. |
David Blaikie | f244922 | 2014-04-28 20:36:45 +0000 | [diff] [blame] | 371 | std::unique_ptr<DIE> constructLexicalScopeDIE(DwarfCompileUnit &TheCU, |
| 372 | LexicalScope *Scope); |
Eric Christopher | 77913e039 | 2013-12-03 00:45:54 +0000 | [diff] [blame] | 373 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 374 | /// \brief This scope represents inlined body of a function. Construct |
| 375 | /// DIE to represent this concrete inlined copy of the function. |
David Blaikie | f244922 | 2014-04-28 20:36:45 +0000 | [diff] [blame] | 376 | std::unique_ptr<DIE> constructInlinedScopeDIE(DwarfCompileUnit &TheCU, |
| 377 | LexicalScope *Scope); |
Devang Patel | 930143b | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 378 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 379 | /// \brief Construct a DIE for this scope. |
David Blaikie | 6a150a8 | 2014-08-31 21:26:22 +0000 | [diff] [blame^] | 380 | void constructScopeDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope, |
| 381 | SmallVectorImpl<std::unique_ptr<DIE>> &FinalChildren); |
David Blaikie | 3fbf3b8 | 2014-08-31 18:04:28 +0000 | [diff] [blame] | 382 | DIE *createAndAddScopeChildren(DwarfCompileUnit &TheCU, LexicalScope *Scope, |
David Blaikie | 899ae61 | 2014-04-30 22:58:19 +0000 | [diff] [blame] | 383 | DIE &ScopeDIE); |
David Blaikie | e872a6e | 2014-04-29 15:58:35 +0000 | [diff] [blame] | 384 | /// \brief Construct a DIE for this abstract scope. |
David Blaikie | 4c1089d | 2014-04-29 23:43:06 +0000 | [diff] [blame] | 385 | void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &TheCU, |
| 386 | LexicalScope *Scope); |
David Blaikie | e872a6e | 2014-04-29 15:58:35 +0000 | [diff] [blame] | 387 | /// \brief Construct a DIE for this subprogram scope. |
David Blaikie | 4c1089d | 2014-04-29 23:43:06 +0000 | [diff] [blame] | 388 | DIE &constructSubprogramScopeDIE(DwarfCompileUnit &TheCU, |
| 389 | LexicalScope *Scope); |
Manman Ren | 2312ed3 | 2013-09-10 18:40:41 +0000 | [diff] [blame] | 390 | /// A helper function to create children of a Scope DIE. |
David Blaikie | f9b6a55 | 2014-04-22 22:39:41 +0000 | [diff] [blame] | 391 | DIE *createScopeChildrenDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope, |
David Blaikie | 6a150a8 | 2014-08-31 21:26:22 +0000 | [diff] [blame^] | 392 | SmallVectorImpl<std::unique_ptr<DIE>> &Children, |
| 393 | unsigned *ChildScopeCount = nullptr); |
Devang Patel | 930143b | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 394 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 395 | /// \brief Emit initial Dwarf sections with a label at the start of each one. |
Eric Christopher | 7b30f2e4 | 2012-11-21 00:34:35 +0000 | [diff] [blame] | 396 | void emitSectionLabels(); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 397 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 398 | /// \brief Compute the size and offset of a DIE given an incoming Offset. |
Eric Christopher | 1f0cbb8 | 2012-11-20 22:14:13 +0000 | [diff] [blame] | 399 | unsigned computeSizeAndOffset(DIE *Die, unsigned Offset); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 400 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 401 | /// \brief Compute the size and offset of all the DIEs. |
Devang Patel | 930143b | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 402 | void computeSizeAndOffsets(); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 403 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 404 | /// \brief Collect info for variables that were optimized out. |
Eric Christopher | 960ac37 | 2012-11-22 00:59:49 +0000 | [diff] [blame] | 405 | void collectDeadVariables(); |
| 406 | |
David Blaikie | eb1a272 | 2014-06-13 22:18:23 +0000 | [diff] [blame] | 407 | void finishVariableDefinitions(); |
| 408 | |
David Blaikie | f7221ad | 2014-05-27 18:37:43 +0000 | [diff] [blame] | 409 | void finishSubprogramDefinitions(); |
| 410 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 411 | /// \brief Finish off debug information after all functions have been |
| 412 | /// processed. |
Eric Christopher | 960ac37 | 2012-11-22 00:59:49 +0000 | [diff] [blame] | 413 | void finalizeModuleInfo(); |
| 414 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 415 | /// \brief Emit labels to close any remaining sections that have been left |
| 416 | /// open. |
Eric Christopher | 960ac37 | 2012-11-22 00:59:49 +0000 | [diff] [blame] | 417 | void endSections(); |
| 418 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 419 | /// \brief Emit the debug info section. |
Devang Patel | 930143b | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 420 | void emitDebugInfo(); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 421 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 422 | /// \brief Emit the abbreviation section. |
Eric Christopher | 3837195 | 2012-11-20 23:30:11 +0000 | [diff] [blame] | 423 | void emitAbbreviations(); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 424 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 425 | /// \brief Emit the last address of the section and the end of |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 426 | /// the line matrix. |
Devang Patel | 930143b | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 427 | void emitEndOfLineMatrix(unsigned SectionEnd); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 428 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 429 | /// \brief Emit visible names into a hashed accelerator table section. |
Eric Christopher | 4996c70 | 2011-11-07 09:24:32 +0000 | [diff] [blame] | 430 | void emitAccelNames(); |
Eric Christopher | 27527b2 | 2012-11-21 00:03:28 +0000 | [diff] [blame] | 431 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 432 | /// \brief Emit objective C classes and categories into a hashed |
Eric Christopher | 4996c70 | 2011-11-07 09:24:32 +0000 | [diff] [blame] | 433 | /// accelerator table section. |
| 434 | void emitAccelObjC(); |
| 435 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 436 | /// \brief Emit namespace dies into a hashed accelerator table. |
Eric Christopher | 4996c70 | 2011-11-07 09:24:32 +0000 | [diff] [blame] | 437 | void emitAccelNamespaces(); |
| 438 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 439 | /// \brief Emit type dies into a hashed accelerator table. |
Eric Christopher | 4996c70 | 2011-11-07 09:24:32 +0000 | [diff] [blame] | 440 | void emitAccelTypes(); |
Eric Christopher | 27527b2 | 2012-11-21 00:03:28 +0000 | [diff] [blame] | 441 | |
Krzysztof Parzyszek | 228daa6 | 2013-02-12 18:00:14 +0000 | [diff] [blame] | 442 | /// \brief Emit visible names into a debug pubnames section. |
Eric Christopher | dd1a012 | 2013-09-13 00:35:05 +0000 | [diff] [blame] | 443 | /// \param GnuStyle determines whether or not we want to emit |
| 444 | /// additional information into the table ala newer gcc for gdb |
| 445 | /// index. |
| 446 | void emitDebugPubNames(bool GnuStyle = false); |
Krzysztof Parzyszek | 228daa6 | 2013-02-12 18:00:14 +0000 | [diff] [blame] | 447 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 448 | /// \brief Emit visible types into a debug pubtypes section. |
Eric Christopher | dd1a012 | 2013-09-13 00:35:05 +0000 | [diff] [blame] | 449 | /// \param GnuStyle determines whether or not we want to emit |
| 450 | /// additional information into the table ala newer gcc for gdb |
| 451 | /// index. |
| 452 | void emitDebugPubTypes(bool GnuStyle = false); |
Devang Patel | 04d2f2d | 2009-11-24 01:14:22 +0000 | [diff] [blame] | 453 | |
David Blaikie | 0f55e83 | 2014-03-11 23:18:15 +0000 | [diff] [blame] | 454 | void |
| 455 | emitDebugPubSection(bool GnuStyle, const MCSection *PSec, StringRef Name, |
| 456 | const StringMap<const DIE *> &(DwarfUnit::*Accessor)() |
| 457 | const); |
| 458 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 459 | /// \brief Emit visible names into a debug str section. |
Devang Patel | 930143b | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 460 | void emitDebugStr(); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 461 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 462 | /// \brief Emit visible names into a debug loc section. |
Devang Patel | 930143b | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 463 | void emitDebugLoc(); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 464 | |
David Blaikie | 94c1d7f | 2014-04-02 01:50:20 +0000 | [diff] [blame] | 465 | /// \brief Emit visible names into a debug loc dwo section. |
| 466 | void emitDebugLocDWO(); |
| 467 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 468 | /// \brief Emit visible names into a debug aranges section. |
Eric Christopher | 7b30f2e4 | 2012-11-21 00:34:35 +0000 | [diff] [blame] | 469 | void emitDebugARanges(); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 470 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 471 | /// \brief Emit visible names into a debug ranges section. |
Devang Patel | 930143b | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 472 | void emitDebugRanges(); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 473 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 474 | /// \brief Emit inline info using custom format. |
Devang Patel | 930143b | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 475 | void emitDebugInlineInfo(); |
Bill Wendling | 2b128d7 | 2009-05-20 23:19:06 +0000 | [diff] [blame] | 476 | |
Eric Christopher | cdf218d | 2012-12-10 19:51:21 +0000 | [diff] [blame] | 477 | /// DWARF 5 Experimental Split Dwarf Emitters |
Eric Christopher | 9c2ecd9 | 2012-11-30 23:59:06 +0000 | [diff] [blame] | 478 | |
David Blaikie | 38fe634 | 2014-01-09 04:28:46 +0000 | [diff] [blame] | 479 | /// \brief Initialize common features of skeleton units. |
David Blaikie | 65a7466 | 2014-04-25 18:26:14 +0000 | [diff] [blame] | 480 | void initSkeletonUnit(const DwarfUnit &U, DIE &Die, |
David Blaikie | f9b6a55 | 2014-04-22 22:39:41 +0000 | [diff] [blame] | 481 | std::unique_ptr<DwarfUnit> NewU); |
David Blaikie | 38fe634 | 2014-01-09 04:28:46 +0000 | [diff] [blame] | 482 | |
Eric Christopher | cdf218d | 2012-12-10 19:51:21 +0000 | [diff] [blame] | 483 | /// \brief Construct the split debug info compile unit for the debug info |
| 484 | /// section. |
David Blaikie | f9b6a55 | 2014-04-22 22:39:41 +0000 | [diff] [blame] | 485 | DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU); |
Eric Christopher | 9c2ecd9 | 2012-11-30 23:59:06 +0000 | [diff] [blame] | 486 | |
David Blaikie | 15ed5eb | 2014-01-10 01:38:41 +0000 | [diff] [blame] | 487 | /// \brief Construct the split debug info compile unit for the debug info |
| 488 | /// section. |
David Blaikie | f9b6a55 | 2014-04-22 22:39:41 +0000 | [diff] [blame] | 489 | DwarfTypeUnit &constructSkeletonTU(DwarfTypeUnit &TU); |
David Blaikie | 15ed5eb | 2014-01-10 01:38:41 +0000 | [diff] [blame] | 490 | |
Eric Christopher | 9c2ecd9 | 2012-11-30 23:59:06 +0000 | [diff] [blame] | 491 | /// \brief Emit the debug info dwo section. |
| 492 | void emitDebugInfoDWO(); |
| 493 | |
Eric Christopher | 3c5a191 | 2012-12-19 22:02:53 +0000 | [diff] [blame] | 494 | /// \brief Emit the debug abbrev dwo section. |
| 495 | void emitDebugAbbrevDWO(); |
| 496 | |
David Blaikie | 4a2f95f | 2014-03-18 01:17:26 +0000 | [diff] [blame] | 497 | /// \brief Emit the debug line dwo section. |
| 498 | void emitDebugLineDWO(); |
| 499 | |
Eric Christopher | 3bf29fd | 2012-12-27 02:14:01 +0000 | [diff] [blame] | 500 | /// \brief Emit the debug str dwo section. |
| 501 | void emitDebugStrDWO(); |
| 502 | |
David Blaikie | 3c84262 | 2013-12-04 21:31:26 +0000 | [diff] [blame] | 503 | /// Flags to let the linker know we have emitted new style pubnames. Only |
| 504 | /// emit it here if we don't have a skeleton CU for split dwarf. |
David Blaikie | 65a7466 | 2014-04-25 18:26:14 +0000 | [diff] [blame] | 505 | void addGnuPubAttributes(DwarfUnit &U, DIE &D) const; |
David Blaikie | 3c84262 | 2013-12-04 21:31:26 +0000 | [diff] [blame] | 506 | |
Eric Christopher | 4287a49 | 2013-12-09 23:57:44 +0000 | [diff] [blame] | 507 | /// \brief Create new DwarfCompileUnit for the given metadata node with tag |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 508 | /// DW_TAG_compile_unit. |
David Blaikie | f9b6a55 | 2014-04-22 22:39:41 +0000 | [diff] [blame] | 509 | DwarfCompileUnit &constructDwarfCompileUnit(DICompileUnit DIUnit); |
Devang Patel | 1a0df9a | 2010-05-10 22:49:55 +0000 | [diff] [blame] | 510 | |
David Blaikie | 1fd4365 | 2013-05-07 21:35:53 +0000 | [diff] [blame] | 511 | /// \brief Construct imported_module or imported_declaration DIE. |
David Blaikie | 8912df1 | 2014-08-31 05:41:15 +0000 | [diff] [blame] | 512 | void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU, |
| 513 | const MDNode *N); |
David Blaikie | 684fc53 | 2013-05-06 23:33:07 +0000 | [diff] [blame] | 514 | |
| 515 | /// \brief Construct import_module DIE. |
David Blaikie | e0e8a3b | 2014-08-31 05:32:06 +0000 | [diff] [blame] | 516 | std::unique_ptr<DIE> |
| 517 | constructImportedEntityDIE(DwarfCompileUnit &TheCU, |
| 518 | const DIImportedEntity &Module); |
David Blaikie | 684fc53 | 2013-05-06 23:33:07 +0000 | [diff] [blame] | 519 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 520 | /// \brief Register a source line with debug info. Returns the unique |
| 521 | /// label that was emitted and which provides correspondence to the |
| 522 | /// source line list. |
Devang Patel | 34a6620 | 2011-05-11 19:22:19 +0000 | [diff] [blame] | 523 | void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope, |
| 524 | unsigned Flags); |
Eric Christopher | 27527b2 | 2012-11-21 00:03:28 +0000 | [diff] [blame] | 525 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 526 | /// \brief Indentify instructions that are marking the beginning of or |
| 527 | /// ending of a scope. |
Devang Patel | 359b013 | 2010-04-08 18:43:56 +0000 | [diff] [blame] | 528 | void identifyScopeMarkers(); |
Devang Patel | f1d5a1e | 2010-04-08 15:37:09 +0000 | [diff] [blame] | 529 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 530 | /// \brief If Var is an current function argument that add it in |
| 531 | /// CurrentFnArguments list. |
David Blaikie | afd2c6b | 2014-04-22 05:41:06 +0000 | [diff] [blame] | 532 | bool addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope); |
Devang Patel | 6c622ef | 2011-03-01 22:58:55 +0000 | [diff] [blame] | 533 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 534 | /// \brief Populate LexicalScope entries with variables' info. |
Craig Topper | 71b7b68 | 2014-08-21 05:55:13 +0000 | [diff] [blame] | 535 | void collectVariableInfo(SmallPtrSetImpl<const MDNode *> &ProcessedVars); |
Eric Christopher | 27527b2 | 2012-11-21 00:03:28 +0000 | [diff] [blame] | 536 | |
Adrian Prantl | b141683 | 2014-08-01 22:11:58 +0000 | [diff] [blame] | 537 | /// \brief Build the location list for all DBG_VALUEs in the |
| 538 | /// function that describe the same variable. |
| 539 | void buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc, |
David Blaikie | e1a26a6 | 2014-08-05 23:14:16 +0000 | [diff] [blame] | 540 | const DbgValueHistoryMap::InstrRanges &Ranges); |
Adrian Prantl | b141683 | 2014-08-01 22:11:58 +0000 | [diff] [blame] | 541 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 542 | /// \brief Collect variable information from the side table maintained |
| 543 | /// by MMI. |
Craig Topper | 71b7b68 | 2014-08-21 05:55:13 +0000 | [diff] [blame] | 544 | void collectVariableInfoFromMMITable(SmallPtrSetImpl<const MDNode *> &P); |
Jakob Stoklund Olesen | 9a624fa | 2011-03-26 02:19:36 +0000 | [diff] [blame] | 545 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 546 | /// \brief Ensure that a label will be emitted before MI. |
Jakob Stoklund Olesen | 9a624fa | 2011-03-26 02:19:36 +0000 | [diff] [blame] | 547 | void requestLabelBeforeInsn(const MachineInstr *MI) { |
Craig Topper | e73658d | 2014-04-28 04:05:08 +0000 | [diff] [blame] | 548 | LabelsBeforeInsn.insert(std::make_pair(MI, nullptr)); |
Jakob Stoklund Olesen | 9a624fa | 2011-03-26 02:19:36 +0000 | [diff] [blame] | 549 | } |
| 550 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 551 | /// \brief Return Label preceding the instruction. |
Eric Christopher | 962c908 | 2013-01-15 23:56:56 +0000 | [diff] [blame] | 552 | MCSymbol *getLabelBeforeInsn(const MachineInstr *MI); |
Jakob Stoklund Olesen | 9a624fa | 2011-03-26 02:19:36 +0000 | [diff] [blame] | 553 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 554 | /// \brief Ensure that a label will be emitted after MI. |
Jakob Stoklund Olesen | 9a624fa | 2011-03-26 02:19:36 +0000 | [diff] [blame] | 555 | void requestLabelAfterInsn(const MachineInstr *MI) { |
Craig Topper | e73658d | 2014-04-28 04:05:08 +0000 | [diff] [blame] | 556 | LabelsAfterInsn.insert(std::make_pair(MI, nullptr)); |
Jakob Stoklund Olesen | 9a624fa | 2011-03-26 02:19:36 +0000 | [diff] [blame] | 557 | } |
| 558 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 559 | /// \brief Return Label immediately following the instruction. |
Eric Christopher | 962c908 | 2013-01-15 23:56:56 +0000 | [diff] [blame] | 560 | MCSymbol *getLabelAfterInsn(const MachineInstr *MI); |
Jakob Stoklund Olesen | 9a624fa | 2011-03-26 02:19:36 +0000 | [diff] [blame] | 561 | |
David Blaikie | 4a3b84d | 2014-05-16 16:42:40 +0000 | [diff] [blame] | 562 | void attachRangesOrLowHighPC(DwarfCompileUnit &Unit, DIE &D, |
| 563 | const SmallVectorImpl<InsnRange> &Ranges); |
Frederic Riss | 9e32475 | 2014-08-28 19:09:29 +0000 | [diff] [blame] | 564 | void attachLowHighPC(DwarfCompileUnit &Unit, DIE &D, const MCSymbol *Begin, |
| 565 | const MCSymbol *End); |
David Blaikie | 4bd13b7 | 2014-03-07 18:49:45 +0000 | [diff] [blame] | 566 | |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 567 | public: |
| 568 | //===--------------------------------------------------------------------===// |
| 569 | // Main entry points. |
| 570 | // |
Chris Lattner | f0d6bd3 | 2010-04-05 05:11:15 +0000 | [diff] [blame] | 571 | DwarfDebug(AsmPrinter *A, Module *M); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 572 | |
Reid Kleckner | dd2647e | 2014-04-30 20:34:31 +0000 | [diff] [blame] | 573 | ~DwarfDebug() override; |
| 574 | |
Manman Ren | 4dbdc90 | 2013-10-31 17:54:35 +0000 | [diff] [blame] | 575 | void insertDIE(const MDNode *TypeMD, DIE *Die) { |
| 576 | MDTypeNodeToDieMap.insert(std::make_pair(TypeMD, Die)); |
| 577 | } |
| 578 | DIE *getDIE(const MDNode *TypeMD) { |
| 579 | return MDTypeNodeToDieMap.lookup(TypeMD); |
| 580 | } |
| 581 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 582 | /// \brief Emit all Dwarf sections that should come prior to the |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 583 | /// content. |
Eric Christopher | 58f4195 | 2012-11-19 22:42:15 +0000 | [diff] [blame] | 584 | void beginModule(); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 585 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 586 | /// \brief Emit all Dwarf sections that should come after the content. |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 587 | void endModule() override; |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 588 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 589 | /// \brief Gather pre-function debug information. |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 590 | void beginFunction(const MachineFunction *MF) override; |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 591 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 592 | /// \brief Gather and emit post-function debug information. |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 593 | void endFunction(const MachineFunction *MF) override; |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 594 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 595 | /// \brief Process beginning of an instruction. |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 596 | void beginInstruction(const MachineInstr *MI) override; |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 597 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 598 | /// \brief Process end of an instruction. |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 599 | void endInstruction() override; |
Devang Patel | f20c4f7 | 2011-04-12 22:53:02 +0000 | [diff] [blame] | 600 | |
Eric Christopher | 6764643 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 601 | /// \brief Add a DIE to the set of types that we're going to pull into |
| 602 | /// type units. |
David Blaikie | 15632ae | 2014-02-12 00:31:30 +0000 | [diff] [blame] | 603 | void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier, |
David Blaikie | 65a7466 | 2014-04-25 18:26:14 +0000 | [diff] [blame] | 604 | DIE &Die, DICompositeType CTy); |
Eric Christopher | 6764643 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 605 | |
Richard Mitton | 21101b3 | 2013-09-19 23:21:01 +0000 | [diff] [blame] | 606 | /// \brief Add a label so that arange data can be generated for it. |
Alexey Samsonov | 4436bf0 | 2013-10-03 08:54:43 +0000 | [diff] [blame] | 607 | void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); } |
Richard Mitton | 21101b3 | 2013-09-19 23:21:01 +0000 | [diff] [blame] | 608 | |
Richard Mitton | 089ed89 | 2013-09-23 17:56:20 +0000 | [diff] [blame] | 609 | /// \brief For symbols that have a size designated (e.g. common symbols), |
| 610 | /// this tracks that size. |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 611 | void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override { |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 612 | SymSize[Sym] = Size; |
| 613 | } |
Richard Mitton | 089ed89 | 2013-09-23 17:56:20 +0000 | [diff] [blame] | 614 | |
Eric Christopher | a2de826 | 2012-12-15 00:04:07 +0000 | [diff] [blame] | 615 | /// \brief Recursively Emits a debug information entry. |
David Blaikie | b818418 | 2014-04-14 22:45:02 +0000 | [diff] [blame] | 616 | void emitDIE(DIE &Die); |
Eric Christopher | a2de826 | 2012-12-15 00:04:07 +0000 | [diff] [blame] | 617 | |
Eric Christopher | 55c5181 | 2012-11-21 00:03:31 +0000 | [diff] [blame] | 618 | // Experimental DWARF5 features. |
| 619 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 620 | /// \brief Returns whether or not to emit tables that dwarf consumers can |
| 621 | /// use to accelerate lookup. |
Eric Christopher | 411bd59 | 2014-03-06 00:00:53 +0000 | [diff] [blame] | 622 | bool useDwarfAccelTables() const { return HasDwarfAccelTables; } |
Eric Christopher | 55c5181 | 2012-11-21 00:03:31 +0000 | [diff] [blame] | 623 | |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 624 | /// \brief Returns whether or not to change the current debug info for the |
Eric Christopher | cdf218d | 2012-12-10 19:51:21 +0000 | [diff] [blame] | 625 | /// split dwarf proposal support. |
Eric Christopher | 411bd59 | 2014-03-06 00:00:53 +0000 | [diff] [blame] | 626 | bool useSplitDwarf() const { return HasSplitDwarf; } |
Manman Ren | ac8062b | 2013-07-02 23:40:10 +0000 | [diff] [blame] | 627 | |
| 628 | /// Returns the Dwarf Version. |
| 629 | unsigned getDwarfVersion() const { return DwarfVersion; } |
Manman Ren | 6035203 | 2013-09-05 18:48:31 +0000 | [diff] [blame] | 630 | |
Eric Christopher | a27220f | 2014-03-05 22:41:20 +0000 | [diff] [blame] | 631 | /// Returns the section symbol for the .debug_loc section. |
| 632 | MCSymbol *getDebugLocSym() const { return DwarfDebugLocSectionSym; } |
| 633 | |
Eric Christopher | 384f3fe | 2014-03-20 19:16:16 +0000 | [diff] [blame] | 634 | /// Returns the previous section that was emitted into. |
| 635 | const MCSection *getPrevSection() const { return PrevSection; } |
| 636 | |
| 637 | /// Returns the previous CU that was being updated |
| 638 | const DwarfCompileUnit *getPrevCU() const { return PrevCU; } |
| 639 | |
Eric Christopher | 4f17ee0 | 2014-03-08 00:29:41 +0000 | [diff] [blame] | 640 | /// Returns the entries for the .debug_loc section. |
David Blaikie | 0a456de | 2014-04-02 01:43:18 +0000 | [diff] [blame] | 641 | const SmallVectorImpl<DebugLocList> & |
David Blaikie | 84d8e18 | 2014-03-24 22:38:38 +0000 | [diff] [blame] | 642 | getDebugLocEntries() const { |
Eric Christopher | 4f17ee0 | 2014-03-08 00:29:41 +0000 | [diff] [blame] | 643 | return DotDebugLocEntries; |
| 644 | } |
| 645 | |
| 646 | /// \brief Emit an entry for the debug loc section. This can be used to |
| 647 | /// handle an entry that's going to be emitted into the debug loc section. |
Eric Christopher | 05135fb | 2014-03-18 02:18:24 +0000 | [diff] [blame] | 648 | void emitDebugLocEntry(ByteStreamer &Streamer, const DebugLocEntry &Entry); |
Adrian Prantl | b141683 | 2014-08-01 22:11:58 +0000 | [diff] [blame] | 649 | /// \brief emit a single value for the debug loc section. |
| 650 | void emitDebugLocValue(ByteStreamer &Streamer, |
| 651 | const DebugLocEntry::Value &Value); |
| 652 | /// Emits an optimal (=sorted) sequence of DW_OP_pieces. |
| 653 | void emitLocPieces(ByteStreamer &Streamer, |
| 654 | const DITypeIdentifierMap &Map, |
| 655 | ArrayRef<DebugLocEntry::Value> Values); |
Eric Christopher | 4f17ee0 | 2014-03-08 00:29:41 +0000 | [diff] [blame] | 656 | |
David Blaikie | 0e84adc | 2014-04-01 16:17:41 +0000 | [diff] [blame] | 657 | /// Emit the location for a debug loc entry, including the size header. |
| 658 | void emitDebugLocEntryLocation(const DebugLocEntry &Entry); |
| 659 | |
Eric Christopher | 87b9c49 | 2013-10-05 00:32:34 +0000 | [diff] [blame] | 660 | /// Find the MDNode for the given reference. |
| 661 | template <typename T> T resolve(DIRef<T> Ref) const { |
Manman Ren | 34b3dcc | 2013-09-10 18:30:07 +0000 | [diff] [blame] | 662 | return Ref.resolve(TypeIdentifierMap); |
| 663 | } |
Manman Ren | 6035203 | 2013-09-05 18:48:31 +0000 | [diff] [blame] | 664 | |
Adrian Prantl | 1a1647c | 2014-03-18 02:34:58 +0000 | [diff] [blame] | 665 | /// \brief Return the TypeIdentifierMap. |
Eric Christopher | c0bd5f8 | 2014-03-18 20:39:54 +0000 | [diff] [blame] | 666 | const DITypeIdentifierMap &getTypeIdentifierMap() const { |
Adrian Prantl | 1a1647c | 2014-03-18 02:34:58 +0000 | [diff] [blame] | 667 | return TypeIdentifierMap; |
| 668 | } |
| 669 | |
Eric Christopher | dd50838 | 2014-03-06 00:00:56 +0000 | [diff] [blame] | 670 | /// Find the DwarfCompileUnit for the given CU Die. |
| 671 | DwarfCompileUnit *lookupUnit(const DIE *CU) const { |
| 672 | return CUDieMap.lookup(CU); |
| 673 | } |
Manman Ren | 3eb9dff | 2013-09-09 19:05:21 +0000 | [diff] [blame] | 674 | /// isSubprogramContext - Return true if Context is either a subprogram |
| 675 | /// or another context nested inside a subprogram. |
| 676 | bool isSubprogramContext(const MDNode *Context); |
David Blaikie | d75fb28 | 2014-04-23 21:20:10 +0000 | [diff] [blame] | 677 | |
David Blaikie | b0b3fcf | 2014-04-25 18:52:29 +0000 | [diff] [blame] | 678 | void addSubprogramNames(DISubprogram SP, DIE &Die); |
David Blaikie | 2406a062 | 2014-04-23 23:37:35 +0000 | [diff] [blame] | 679 | |
David Blaikie | d75fb28 | 2014-04-23 21:20:10 +0000 | [diff] [blame] | 680 | AddressPool &getAddressPool() { return AddrPool; } |
David Blaikie | 2406a062 | 2014-04-23 23:37:35 +0000 | [diff] [blame] | 681 | |
David Blaikie | b0b3fcf | 2014-04-25 18:52:29 +0000 | [diff] [blame] | 682 | void addAccelName(StringRef Name, const DIE &Die); |
David Blaikie | 0ee82b9 | 2014-04-24 00:53:32 +0000 | [diff] [blame] | 683 | |
David Blaikie | b0b3fcf | 2014-04-25 18:52:29 +0000 | [diff] [blame] | 684 | void addAccelObjC(StringRef Name, const DIE &Die); |
David Blaikie | ecf0415 | 2014-04-24 01:02:42 +0000 | [diff] [blame] | 685 | |
David Blaikie | b0b3fcf | 2014-04-25 18:52:29 +0000 | [diff] [blame] | 686 | void addAccelNamespace(StringRef Name, const DIE &Die); |
David Blaikie | 18d3375 | 2014-04-24 01:23:49 +0000 | [diff] [blame] | 687 | |
David Blaikie | b0b3fcf | 2014-04-25 18:52:29 +0000 | [diff] [blame] | 688 | void addAccelType(StringRef Name, const DIE &Die, char Flags); |
Devang Patel | f6eeaeb | 2009-11-10 23:06:00 +0000 | [diff] [blame] | 689 | }; |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 690 | } // End of namespace llvm |
| 691 | |
| 692 | #endif |