| Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 1 | //===- llvm/CodeGen/DwarfDebug.h - Dwarf Debug Framework --------*- C++ -*-===// | 
| Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 2 | // | 
| Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 | 
| Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 6 | // | 
|  | 7 | //===----------------------------------------------------------------------===// | 
|  | 8 | // | 
|  | 9 | // This file contains support for writing dwarf debug info into asm files. | 
|  | 10 | // | 
|  | 11 | //===----------------------------------------------------------------------===// | 
|  | 12 |  | 
| Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 13 | #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H | 
|  | 14 | #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H | 
| Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 15 |  | 
| Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 16 | #include "AddressPool.h" | 
| Duncan P. N. Exon Smith | 364a300 | 2015-04-17 21:34:47 +0000 | [diff] [blame] | 17 | #include "DebugLocStream.h" | 
| Nikola Prica | abc1dff | 2019-06-10 08:41:06 +0000 | [diff] [blame] | 18 | #include "DebugLocEntry.h" | 
| Chandler Carruth | d990388 | 2015-01-14 11:23:27 +0000 | [diff] [blame] | 19 | #include "DwarfFile.h" | 
| Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 20 | #include "llvm/ADT/ArrayRef.h" | 
| Devang Patel | 018b29b | 2010-01-19 06:19:05 +0000 | [diff] [blame] | 21 | #include "llvm/ADT/DenseMap.h" | 
| Duncan P. N. Exon Smith | 62e0f45 | 2015-04-15 22:29:27 +0000 | [diff] [blame] | 22 | #include "llvm/ADT/DenseSet.h" | 
| Eric Christopher | acbe42b | 2014-03-18 20:58:35 +0000 | [diff] [blame] | 23 | #include "llvm/ADT/MapVector.h" | 
| Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 24 | #include "llvm/ADT/STLExtras.h" | 
| David Blaikie | 38b74bf | 2016-12-15 23:37:38 +0000 | [diff] [blame] | 25 | #include "llvm/ADT/SetVector.h" | 
| Eric Christopher | acbe42b | 2014-03-18 20:58:35 +0000 | [diff] [blame] | 26 | #include "llvm/ADT/SmallPtrSet.h" | 
| Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 27 | #include "llvm/ADT/SmallVector.h" | 
| Eric Christopher | acbe42b | 2014-03-18 20:58:35 +0000 | [diff] [blame] | 28 | #include "llvm/ADT/StringMap.h" | 
| Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 29 | #include "llvm/ADT/StringRef.h" | 
|  | 30 | #include "llvm/BinaryFormat/Dwarf.h" | 
| Jonas Devlieghere | 855fc3b | 2018-01-29 14:52:41 +0000 | [diff] [blame] | 31 | #include "llvm/CodeGen/AccelTable.h" | 
| Yonghong Song | 61b189e | 2018-12-18 23:10:17 +0000 | [diff] [blame] | 32 | #include "llvm/CodeGen/DbgEntityHistoryCalculator.h" | 
|  | 33 | #include "llvm/CodeGen/DebugHandlerBase.h" | 
| Adrian Prantl | c119754 | 2014-05-30 21:10:13 +0000 | [diff] [blame] | 34 | #include "llvm/CodeGen/MachineInstr.h" | 
| Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 35 | #include "llvm/IR/DebugInfoMetadata.h" | 
| Eric Christopher | acbe42b | 2014-03-18 20:58:35 +0000 | [diff] [blame] | 36 | #include "llvm/IR/DebugLoc.h" | 
| Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 37 | #include "llvm/IR/Metadata.h" | 
| David Blaikie | 4a2f95f | 2014-03-18 01:17:26 +0000 | [diff] [blame] | 38 | #include "llvm/MC/MCDwarf.h" | 
| Chris Lattner | 3f3fb97 | 2010-04-05 05:24:55 +0000 | [diff] [blame] | 39 | #include "llvm/Support/Allocator.h" | 
| Paul Robinson | 6c27a2c | 2015-12-16 19:58:30 +0000 | [diff] [blame] | 40 | #include "llvm/Target/TargetOptions.h" | 
| Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 41 | #include <cassert> | 
|  | 42 | #include <cstdint> | 
|  | 43 | #include <limits> | 
| David Blaikie | f9b6a55 | 2014-04-22 22:39:41 +0000 | [diff] [blame] | 44 | #include <memory> | 
| Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 45 | #include <utility> | 
|  | 46 | #include <vector> | 
| David Blaikie | f9b6a55 | 2014-04-22 22:39:41 +0000 | [diff] [blame] | 47 |  | 
| Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 48 | namespace llvm { | 
|  | 49 |  | 
| Adrian Prantl | 702bf5a | 2014-03-18 02:34:52 +0000 | [diff] [blame] | 50 | class AsmPrinter; | 
| Eric Christopher | 29e874d | 2014-03-07 22:40:37 +0000 | [diff] [blame] | 51 | class ByteStreamer; | 
| Duncan P. N. Exon Smith | 364a300 | 2015-04-17 21:34:47 +0000 | [diff] [blame] | 52 | class DebugLocEntry; | 
| Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 53 | class DIE; | 
| Eric Christopher | ce4a944 | 2014-03-18 20:37:10 +0000 | [diff] [blame] | 54 | class DwarfCompileUnit; | 
| Djordje Todorovic | a0d4505 | 2019-06-27 13:52:34 +0000 | [diff] [blame] | 55 | class DwarfExpression; | 
| Eric Christopher | ce4a944 | 2014-03-18 20:37:10 +0000 | [diff] [blame] | 56 | class DwarfTypeUnit; | 
|  | 57 | class DwarfUnit; | 
| Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 58 | class LexicalScope; | 
|  | 59 | class MachineFunction; | 
|  | 60 | class MCSection; | 
|  | 61 | class MCSymbol; | 
|  | 62 | class MDNode; | 
|  | 63 | class Module; | 
| Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 64 |  | 
|  | 65 | //===----------------------------------------------------------------------===// | 
| Hsiangkai Wang | 2532ac8 | 2018-08-17 15:22:04 +0000 | [diff] [blame] | 66 | /// This class is defined as the common parent of DbgVariable and DbgLabel | 
|  | 67 | /// such that it could levarage polymorphism to extract common code for | 
|  | 68 | /// DbgVariable and DbgLabel. | 
|  | 69 | class DbgEntity { | 
|  | 70 | const DINode *Entity; | 
|  | 71 | const DILocation *InlinedAt; | 
|  | 72 | DIE *TheDIE = nullptr; | 
|  | 73 | unsigned SubclassID; | 
|  | 74 |  | 
|  | 75 | public: | 
|  | 76 | enum DbgEntityKind { | 
|  | 77 | DbgVariableKind, | 
|  | 78 | DbgLabelKind | 
|  | 79 | }; | 
|  | 80 |  | 
|  | 81 | DbgEntity(const DINode *N, const DILocation *IA, unsigned ID) | 
|  | 82 | : Entity(N), InlinedAt(IA), SubclassID(ID) {} | 
|  | 83 | virtual ~DbgEntity() {} | 
|  | 84 |  | 
|  | 85 | /// Accessors. | 
|  | 86 | /// @{ | 
|  | 87 | const DINode *getEntity() const { return Entity; } | 
|  | 88 | const DILocation *getInlinedAt() const { return InlinedAt; } | 
|  | 89 | DIE *getDIE() const { return TheDIE; } | 
|  | 90 | unsigned getDbgEntityID() const { return SubclassID; } | 
|  | 91 | /// @} | 
|  | 92 |  | 
|  | 93 | void setDIE(DIE &D) { TheDIE = &D; } | 
|  | 94 |  | 
|  | 95 | static bool classof(const DbgEntity *N) { | 
|  | 96 | switch (N->getDbgEntityID()) { | 
|  | 97 | default: | 
|  | 98 | return false; | 
|  | 99 | case DbgVariableKind: | 
|  | 100 | case DbgLabelKind: | 
|  | 101 | return true; | 
|  | 102 | } | 
|  | 103 | } | 
|  | 104 | }; | 
|  | 105 |  | 
|  | 106 | //===----------------------------------------------------------------------===// | 
| Duncan P. N. Exon Smith | e6cc531 | 2015-06-21 16:50:43 +0000 | [diff] [blame] | 107 | /// This class is used to track local variable information. | 
| Adrian Prantl | ca7e470 | 2015-02-10 23:18:28 +0000 | [diff] [blame] | 108 | /// | 
| Duncan P. N. Exon Smith | e6cc531 | 2015-06-21 16:50:43 +0000 | [diff] [blame] | 109 | /// Variables can be created from allocas, in which case they're generated from | 
|  | 110 | /// the MMI table.  Such variables can have multiple expressions and frame | 
| Adrian Prantl | 67c2442 | 2017-02-17 19:42:32 +0000 | [diff] [blame] | 111 | /// indices. | 
| Adrian Prantl | ca7e470 | 2015-02-10 23:18:28 +0000 | [diff] [blame] | 112 | /// | 
| Duncan P. N. Exon Smith | e6cc531 | 2015-06-21 16:50:43 +0000 | [diff] [blame] | 113 | /// Variables can be created from \c DBG_VALUE instructions.  Those whose | 
|  | 114 | /// location changes over time use \a DebugLocListIndex, while those with a | 
| Nikola Prica | abc1dff | 2019-06-10 08:41:06 +0000 | [diff] [blame] | 115 | /// single location use \a ValueLoc and (optionally) a single entry of \a Expr. | 
| Duncan P. N. Exon Smith | e6cc531 | 2015-06-21 16:50:43 +0000 | [diff] [blame] | 116 | /// | 
|  | 117 | /// Variables that have been optimized out use none of these fields. | 
| Hsiangkai Wang | 2532ac8 | 2018-08-17 15:22:04 +0000 | [diff] [blame] | 118 | class DbgVariable : public DbgEntity { | 
| Nikola Prica | abc1dff | 2019-06-10 08:41:06 +0000 | [diff] [blame] | 119 | /// Offset in DebugLocs. | 
|  | 120 | unsigned DebugLocListIndex = ~0u; | 
|  | 121 | /// Single value location description. | 
| Nikola Prica | 076ae0d | 2019-06-13 10:23:26 +0000 | [diff] [blame] | 122 | std::unique_ptr<DbgValueLoc> ValueLoc = nullptr; | 
| Adrian Prantl | 67c2442 | 2017-02-17 19:42:32 +0000 | [diff] [blame] | 123 |  | 
|  | 124 | struct FrameIndexExpr { | 
|  | 125 | int FI; | 
|  | 126 | const DIExpression *Expr; | 
|  | 127 | }; | 
|  | 128 | mutable SmallVector<FrameIndexExpr, 1> | 
|  | 129 | FrameIndexExprs; /// Frame index + expression. | 
| Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 130 |  | 
| Devang Patel | f20c4f7 | 2011-04-12 22:53:02 +0000 | [diff] [blame] | 131 | public: | 
| Duncan P. N. Exon Smith | e6cc531 | 2015-06-21 16:50:43 +0000 | [diff] [blame] | 132 | /// Construct a DbgVariable. | 
|  | 133 | /// | 
|  | 134 | /// Creates a variable without any DW_AT_location.  Call \a initializeMMI() | 
|  | 135 | /// for MMI entries, or \a initializeDbgValue() for DBG_VALUE instructions. | 
| Duncan P. N. Exon Smith | a59d3e5 | 2016-04-23 21:08:00 +0000 | [diff] [blame] | 136 | DbgVariable(const DILocalVariable *V, const DILocation *IA) | 
| Hsiangkai Wang | 2532ac8 | 2018-08-17 15:22:04 +0000 | [diff] [blame] | 137 | : DbgEntity(V, IA, DbgVariableKind) {} | 
| Duncan P. N. Exon Smith | e6cc531 | 2015-06-21 16:50:43 +0000 | [diff] [blame] | 138 |  | 
|  | 139 | /// Initialize from the MMI table. | 
|  | 140 | void initializeMMI(const DIExpression *E, int FI) { | 
| Adrian Prantl | 67c2442 | 2017-02-17 19:42:32 +0000 | [diff] [blame] | 141 | assert(FrameIndexExprs.empty() && "Already initialized?"); | 
| Nikola Prica | abc1dff | 2019-06-10 08:41:06 +0000 | [diff] [blame] | 142 | assert(!ValueLoc.get() && "Already initialized?"); | 
| Duncan P. N. Exon Smith | e6cc531 | 2015-06-21 16:50:43 +0000 | [diff] [blame] | 143 |  | 
|  | 144 | assert((!E || E->isValid()) && "Expected valid expression"); | 
| Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 145 | assert(FI != std::numeric_limits<int>::max() && "Expected valid index"); | 
| Duncan P. N. Exon Smith | e6cc531 | 2015-06-21 16:50:43 +0000 | [diff] [blame] | 146 |  | 
| Adrian Prantl | 67c2442 | 2017-02-17 19:42:32 +0000 | [diff] [blame] | 147 | FrameIndexExprs.push_back({FI, E}); | 
| Adrian Prantl | 87b7eb9 | 2014-10-01 18:55:02 +0000 | [diff] [blame] | 148 | } | 
| Devang Patel | f20c4f7 | 2011-04-12 22:53:02 +0000 | [diff] [blame] | 149 |  | 
| Nikola Prica | abc1dff | 2019-06-10 08:41:06 +0000 | [diff] [blame] | 150 | // Initialize variable's location. | 
| Nikola Prica | 076ae0d | 2019-06-13 10:23:26 +0000 | [diff] [blame] | 151 | void initializeDbgValue(DbgValueLoc Value) { | 
| Adrian Prantl | 67c2442 | 2017-02-17 19:42:32 +0000 | [diff] [blame] | 152 | assert(FrameIndexExprs.empty() && "Already initialized?"); | 
| Nikola Prica | abc1dff | 2019-06-10 08:41:06 +0000 | [diff] [blame] | 153 | assert(!ValueLoc && "Already initialized?"); | 
|  | 154 | assert(!Value.getExpression()->isFragment() && "Fragments not supported."); | 
| Duncan P. N. Exon Smith | e6cc531 | 2015-06-21 16:50:43 +0000 | [diff] [blame] | 155 |  | 
| Jonas Devlieghere | 0eaee54 | 2019-08-15 15:54:37 +0000 | [diff] [blame] | 156 | ValueLoc = std::make_unique<DbgValueLoc>(Value); | 
| Nikola Prica | abc1dff | 2019-06-10 08:41:06 +0000 | [diff] [blame] | 157 | if (auto *E = ValueLoc->getExpression()) | 
| Duncan P. N. Exon Smith | e6cc531 | 2015-06-21 16:50:43 +0000 | [diff] [blame] | 158 | if (E->getNumElements()) | 
| Adrian Prantl | 67c2442 | 2017-02-17 19:42:32 +0000 | [diff] [blame] | 159 | FrameIndexExprs.push_back({0, E}); | 
| Adrian Prantl | ca7e470 | 2015-02-10 23:18:28 +0000 | [diff] [blame] | 160 | } | 
| Adrian Prantl | c119754 | 2014-05-30 21:10:13 +0000 | [diff] [blame] | 161 |  | 
| Nikola Prica | abc1dff | 2019-06-10 08:41:06 +0000 | [diff] [blame] | 162 | /// Initialize from a DBG_VALUE instruction. | 
|  | 163 | void initializeDbgValue(const MachineInstr *DbgValue); | 
|  | 164 |  | 
| Devang Patel | f20c4f7 | 2011-04-12 22:53:02 +0000 | [diff] [blame] | 165 | // Accessors. | 
| Hsiangkai Wang | 2532ac8 | 2018-08-17 15:22:04 +0000 | [diff] [blame] | 166 | const DILocalVariable *getVariable() const { | 
|  | 167 | return cast<DILocalVariable>(getEntity()); | 
|  | 168 | } | 
| Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 169 |  | 
| Adrian Prantl | 6f4746b1 | 2016-02-17 22:19:59 +0000 | [diff] [blame] | 170 | const DIExpression *getSingleExpression() const { | 
| Nikola Prica | abc1dff | 2019-06-10 08:41:06 +0000 | [diff] [blame] | 171 | assert(ValueLoc.get() && FrameIndexExprs.size() <= 1); | 
| Adrian Prantl | 67c2442 | 2017-02-17 19:42:32 +0000 | [diff] [blame] | 172 | return FrameIndexExprs.size() ? FrameIndexExprs[0].Expr : nullptr; | 
| Adrian Prantl | 6f4746b1 | 2016-02-17 22:19:59 +0000 | [diff] [blame] | 173 | } | 
| Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 174 |  | 
| Duncan P. N. Exon Smith | 364a300 | 2015-04-17 21:34:47 +0000 | [diff] [blame] | 175 | void setDebugLocListIndex(unsigned O) { DebugLocListIndex = O; } | 
|  | 176 | unsigned getDebugLocListIndex() const { return DebugLocListIndex; } | 
| Hsiangkai Wang | 2532ac8 | 2018-08-17 15:22:04 +0000 | [diff] [blame] | 177 | StringRef getName() const { return getVariable()->getName(); } | 
| Nikola Prica | 076ae0d | 2019-06-13 10:23:26 +0000 | [diff] [blame] | 178 | const DbgValueLoc *getValueLoc() const { return ValueLoc.get(); } | 
| Adrian Prantl | 67c2442 | 2017-02-17 19:42:32 +0000 | [diff] [blame] | 179 | /// Get the FI entries, sorted by fragment offset. | 
|  | 180 | ArrayRef<FrameIndexExpr> getFrameIndexExprs() const; | 
|  | 181 | bool hasFrameIndexExprs() const { return !FrameIndexExprs.empty(); } | 
| Bjorn Steinbrink | d36bbe9 | 2017-10-10 07:46:17 +0000 | [diff] [blame] | 182 | void addMMIEntry(const DbgVariable &V); | 
| Adrian Prantl | ca7e470 | 2015-02-10 23:18:28 +0000 | [diff] [blame] | 183 |  | 
| Eric Christopher | 27527b2 | 2012-11-21 00:03:28 +0000 | [diff] [blame] | 184 | // Translate tag to proper Dwarf tag. | 
| David Blaikie | efc403b | 2014-04-12 02:24:04 +0000 | [diff] [blame] | 185 | dwarf::Tag getTag() const { | 
| Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 186 | // FIXME: Why don't we just infer this tag and store it all along? | 
| Hsiangkai Wang | 2532ac8 | 2018-08-17 15:22:04 +0000 | [diff] [blame] | 187 | if (getVariable()->isParameter()) | 
| Devang Patel | 6e4d2c9 | 2011-08-15 18:35:42 +0000 | [diff] [blame] | 188 | return dwarf::DW_TAG_formal_parameter; | 
| Eric Christopher | 27527b2 | 2012-11-21 00:03:28 +0000 | [diff] [blame] | 189 |  | 
| Devang Patel | 6e4d2c9 | 2011-08-15 18:35:42 +0000 | [diff] [blame] | 190 | return dwarf::DW_TAG_variable; | 
|  | 191 | } | 
| Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 192 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 193 | /// Return true if DbgVariable is artificial. | 
| Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 194 | bool isArtificial() const { | 
| Hsiangkai Wang | 2532ac8 | 2018-08-17 15:22:04 +0000 | [diff] [blame] | 195 | if (getVariable()->isArtificial()) | 
| Devang Patel | d7d80aa | 2011-08-15 18:40:16 +0000 | [diff] [blame] | 196 | return true; | 
| Duncan P. N. Exon Smith | b105564 | 2015-04-16 01:01:28 +0000 | [diff] [blame] | 197 | if (getType()->isArtificial()) | 
| Devang Patel | d7d80aa | 2011-08-15 18:40:16 +0000 | [diff] [blame] | 198 | return true; | 
|  | 199 | return false; | 
|  | 200 | } | 
| Eric Christopher | e341776 | 2012-09-12 23:36:19 +0000 | [diff] [blame] | 201 |  | 
| Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 202 | bool isObjectPointer() const { | 
| Hsiangkai Wang | 2532ac8 | 2018-08-17 15:22:04 +0000 | [diff] [blame] | 203 | if (getVariable()->isObjectPointer()) | 
| Eric Christopher | e341776 | 2012-09-12 23:36:19 +0000 | [diff] [blame] | 204 | return true; | 
| Duncan P. N. Exon Smith | b105564 | 2015-04-16 01:01:28 +0000 | [diff] [blame] | 205 | if (getType()->isObjectPointer()) | 
| Eric Christopher | e341776 | 2012-09-12 23:36:19 +0000 | [diff] [blame] | 206 | return true; | 
|  | 207 | return false; | 
|  | 208 | } | 
| Eric Christopher | 27527b2 | 2012-11-21 00:03:28 +0000 | [diff] [blame] | 209 |  | 
| Duncan P. N. Exon Smith | e6cc531 | 2015-06-21 16:50:43 +0000 | [diff] [blame] | 210 | bool hasComplexAddress() const { | 
| Nikola Prica | abc1dff | 2019-06-10 08:41:06 +0000 | [diff] [blame] | 211 | assert(ValueLoc.get() && "Expected DBG_VALUE, not MMI variable"); | 
| Adrian Prantl | 67c2442 | 2017-02-17 19:42:32 +0000 | [diff] [blame] | 212 | assert((FrameIndexExprs.empty() || | 
|  | 213 | (FrameIndexExprs.size() == 1 && | 
|  | 214 | FrameIndexExprs[0].Expr->getNumElements())) && | 
|  | 215 | "Invalid Expr for DBG_VALUE"); | 
|  | 216 | return !FrameIndexExprs.empty(); | 
| Devang Patel | f20c4f7 | 2011-04-12 22:53:02 +0000 | [diff] [blame] | 217 | } | 
| Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 218 |  | 
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 219 | const DIType *getType() const; | 
| Manman Ren | be5576f | 2013-10-08 19:07:44 +0000 | [diff] [blame] | 220 |  | 
| Hsiangkai Wang | 2532ac8 | 2018-08-17 15:22:04 +0000 | [diff] [blame] | 221 | static bool classof(const DbgEntity *N) { | 
|  | 222 | return N->getDbgEntityID() == DbgVariableKind; | 
|  | 223 | } | 
| Hsiangkai Wang | 2532ac8 | 2018-08-17 15:22:04 +0000 | [diff] [blame] | 224 | }; | 
|  | 225 |  | 
|  | 226 | //===----------------------------------------------------------------------===// | 
|  | 227 | /// This class is used to track label information. | 
|  | 228 | /// | 
|  | 229 | /// Labels are collected from \c DBG_LABEL instructions. | 
|  | 230 | class DbgLabel : public DbgEntity { | 
|  | 231 | const MCSymbol *Sym;                  /// Symbol before DBG_LABEL instruction. | 
|  | 232 |  | 
|  | 233 | public: | 
|  | 234 | /// We need MCSymbol information to generate DW_AT_low_pc. | 
|  | 235 | DbgLabel(const DILabel *L, const DILocation *IA, const MCSymbol *Sym = nullptr) | 
|  | 236 | : DbgEntity(L, IA, DbgLabelKind), Sym(Sym) {} | 
|  | 237 |  | 
|  | 238 | /// Accessors. | 
|  | 239 | /// @{ | 
|  | 240 | const DILabel *getLabel() const { return cast<DILabel>(getEntity()); } | 
|  | 241 | const MCSymbol *getSymbol() const { return Sym; } | 
|  | 242 |  | 
|  | 243 | StringRef getName() const { return getLabel()->getName(); } | 
|  | 244 | /// @} | 
|  | 245 |  | 
|  | 246 | /// Translate tag to proper Dwarf tag. | 
|  | 247 | dwarf::Tag getTag() const { | 
|  | 248 | return dwarf::DW_TAG_label; | 
|  | 249 | } | 
|  | 250 |  | 
|  | 251 | static bool classof(const DbgEntity *N) { | 
|  | 252 | return N->getDbgEntityID() == DbgLabelKind; | 
|  | 253 | } | 
| Devang Patel | f20c4f7 | 2011-04-12 22:53:02 +0000 | [diff] [blame] | 254 | }; | 
|  | 255 |  | 
| Djordje Todorovic | b9973f8 | 2019-07-31 16:51:28 +0000 | [diff] [blame] | 256 | /// Used for tracking debug info about call site parameters. | 
|  | 257 | class DbgCallSiteParam { | 
|  | 258 | private: | 
|  | 259 | unsigned Register; ///< Parameter register at the callee entry point. | 
|  | 260 | DbgValueLoc Value; ///< Corresponding location for the parameter value at | 
|  | 261 | ///< the call site. | 
|  | 262 | public: | 
|  | 263 | DbgCallSiteParam(unsigned Reg, DbgValueLoc Val) | 
|  | 264 | : Register(Reg), Value(Val) { | 
|  | 265 | assert(Reg && "Parameter register cannot be undef"); | 
|  | 266 | } | 
|  | 267 |  | 
|  | 268 | unsigned getRegister() const { return Register; } | 
|  | 269 | DbgValueLoc getValue() const { return Value; } | 
|  | 270 | }; | 
|  | 271 |  | 
|  | 272 | /// Collection used for storing debug call site parameters. | 
|  | 273 | using ParamSet = SmallVector<DbgCallSiteParam, 4>; | 
|  | 274 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 275 | /// Helper used to pair up a symbol and its DWARF compile unit. | 
| Richard Mitton | 21101b3 | 2013-09-19 23:21:01 +0000 | [diff] [blame] | 276 | struct SymbolCU { | 
| Eric Christopher | 4287a49 | 2013-12-09 23:57:44 +0000 | [diff] [blame] | 277 | SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {} | 
| Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 278 |  | 
| Richard Mitton | 21101b3 | 2013-09-19 23:21:01 +0000 | [diff] [blame] | 279 | const MCSymbol *Sym; | 
| Eric Christopher | 4287a49 | 2013-12-09 23:57:44 +0000 | [diff] [blame] | 280 | DwarfCompileUnit *CU; | 
| Richard Mitton | 21101b3 | 2013-09-19 23:21:01 +0000 | [diff] [blame] | 281 | }; | 
|  | 282 |  | 
| Pavel Labath | 6088c23 | 2018-04-04 14:42:14 +0000 | [diff] [blame] | 283 | /// The kind of accelerator tables we should emit. | 
|  | 284 | enum class AccelTableKind { | 
|  | 285 | Default, ///< Platform default. | 
|  | 286 | None,    ///< None. | 
|  | 287 | Apple,   ///< .apple_names, .apple_namespaces, .apple_types, .apple_objc. | 
|  | 288 | Dwarf,   ///< DWARF v5 .debug_names. | 
|  | 289 | }; | 
|  | 290 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 291 | /// Collects and handles dwarf debug information. | 
| Reid Kleckner | f9c275f | 2016-02-10 20:55:49 +0000 | [diff] [blame] | 292 | class DwarfDebug : public DebugHandlerBase { | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 293 | /// All DIEValues are allocated through this allocator. | 
| Benjamin Kramer | 0748008 | 2012-06-09 10:34:15 +0000 | [diff] [blame] | 294 | BumpPtrAllocator DIEValueAllocator; | 
|  | 295 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 296 | /// Maps MDNode with its corresponding DwarfCompileUnit. | 
| Eric Christopher | 179fba1 | 2014-01-29 22:06:23 +0000 | [diff] [blame] | 297 | MapVector<const MDNode *, DwarfCompileUnit *> CUMap; | 
| Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 298 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 299 | /// Maps a CU DIE with its corresponding DwarfCompileUnit. | 
| Eric Christopher | 4287a49 | 2013-12-09 23:57:44 +0000 | [diff] [blame] | 300 | DenseMap<const DIE *, DwarfCompileUnit *> CUDieMap; | 
| Manman Ren | ce20d46 | 2013-10-29 22:57:10 +0000 | [diff] [blame] | 301 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 302 | /// List of all labels used in aranges generation. | 
| Alexey Samsonov | 4436bf0 | 2013-10-03 08:54:43 +0000 | [diff] [blame] | 303 | std::vector<SymbolCU> ArangeLabels; | 
| Richard Mitton | 21101b3 | 2013-09-19 23:21:01 +0000 | [diff] [blame] | 304 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 305 | /// 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] | 306 | DenseMap<const MCSymbol *, uint64_t> SymSize; | 
| Richard Mitton | 089ed89 | 2013-09-23 17:56:20 +0000 | [diff] [blame] | 307 |  | 
| Hsiangkai Wang | 2532ac8 | 2018-08-17 15:22:04 +0000 | [diff] [blame] | 308 | /// Collection of abstract variables/labels. | 
|  | 309 | SmallVector<std::unique_ptr<DbgEntity>, 64> ConcreteEntities; | 
| Devang Patel | f6eeaeb | 2009-11-10 23:06:00 +0000 | [diff] [blame] | 310 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 311 | /// Collection of DebugLocEntry. Stored in a linked list so that DIELocLists | 
|  | 312 | /// can refer to them in spite of insertions into this list. | 
| Duncan P. N. Exon Smith | 364a300 | 2015-04-17 21:34:47 +0000 | [diff] [blame] | 313 | DebugLocStream DebugLocs; | 
| Devang Patel | 9fc1170 | 2010-05-25 23:40:22 +0000 | [diff] [blame] | 314 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 315 | /// This is a collection of subprogram MDNodes that are processed to | 
|  | 316 | /// create DIEs. | 
| David Blaikie | 38b74bf | 2016-12-15 23:37:38 +0000 | [diff] [blame] | 317 | SetVector<const DISubprogram *, SmallVector<const DISubprogram *, 16>, | 
|  | 318 | SmallPtrSet<const DISubprogram *, 16>> | 
|  | 319 | ProcessedSPNodes; | 
| Devang Patel | f3b2db6 | 2010-06-28 18:25:03 +0000 | [diff] [blame] | 320 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 321 | /// If nonnull, stores the current machine function we're processing. | 
| Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 322 | const MachineFunction *CurFn = nullptr; | 
| Timur Iskhodzhanov | 1cd1444 | 2013-12-03 15:10:23 +0000 | [diff] [blame] | 323 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 324 | /// If nonnull, stores the CU in which the previous subprogram was contained. | 
| Eric Christopher | 384f3fe | 2014-03-20 19:16:16 +0000 | [diff] [blame] | 325 | const DwarfCompileUnit *PrevCU; | 
|  | 326 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 327 | /// As an optimization, there is no need to emit an entry in the directory | 
|  | 328 | /// table for the same directory as DW_AT_comp_dir. | 
| Nick Lewycky | d1ee7f8 | 2011-11-02 20:55:33 +0000 | [diff] [blame] | 329 | StringRef CompilationDir; | 
|  | 330 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 331 | /// Holder for the file specific debug information. | 
| Eric Christopher | f819485 | 2013-12-05 18:06:10 +0000 | [diff] [blame] | 332 | DwarfFile InfoHolder; | 
| Eric Christopher | c8a310e | 2012-12-10 23:34:43 +0000 | [diff] [blame] | 333 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 334 | /// Holders for the various debug information flags that we might need to | 
|  | 335 | /// have exposed. See accessor functions below for description. | 
| David Blaikie | d51dea6 | 2015-07-01 18:07:16 +0000 | [diff] [blame] | 336 |  | 
| Peter Collingbourne | 7c384cc | 2016-02-11 19:57:46 +0000 | [diff] [blame] | 337 | /// Map from MDNodes for user-defined types to their type signatures. Also | 
|  | 338 | /// used to keep track of which types we have emitted type units for. | 
|  | 339 | DenseMap<const MDNode *, uint64_t> TypeSignatures; | 
| Eric Christopher | 6764643 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 340 |  | 
| David Blaikie | 60fddac | 2018-10-24 23:36:29 +0000 | [diff] [blame] | 341 | DenseMap<const MCSection *, const MCSymbol *> SectionLabels; | 
|  | 342 |  | 
| Duncan P. N. Exon Smith | c624688 | 2015-04-20 21:17:32 +0000 | [diff] [blame] | 343 | SmallVector< | 
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 344 | std::pair<std::unique_ptr<DwarfTypeUnit>, const DICompositeType *>, 1> | 
| Eric Christopher | ffc5ff3 | 2015-02-17 20:02:28 +0000 | [diff] [blame] | 345 | TypeUnitsUnderConstruction; | 
| David Blaikie | e12b49a | 2014-04-26 17:27:38 +0000 | [diff] [blame] | 346 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 347 | /// Whether to use the GNU TLS opcode (instead of the standard opcode). | 
| Paul Robinson | 78cc082 | 2015-03-04 20:55:11 +0000 | [diff] [blame] | 348 | bool UseGNUTLSOpcode; | 
|  | 349 |  | 
| Adrian Prantl | 6323ddf | 2016-05-17 21:07:16 +0000 | [diff] [blame] | 350 | /// Whether to use DWARF 2 bitfields (instead of the DWARF 4 format). | 
|  | 351 | bool UseDWARF2Bitfields; | 
|  | 352 |  | 
| Paul Robinson | 43d1e45 | 2016-04-18 22:41:41 +0000 | [diff] [blame] | 353 | /// Whether to emit all linkage names, or just abstract subprograms. | 
|  | 354 | bool UseAllLinkageNames; | 
| Paul Robinson | 78046b4 | 2015-08-11 21:36:45 +0000 | [diff] [blame] | 355 |  | 
| Alexey Bataev | 0d6aead | 2018-02-20 15:28:08 +0000 | [diff] [blame] | 356 | /// Use inlined strings. | 
|  | 357 | bool UseInlineStrings = false; | 
|  | 358 |  | 
| Alexey Bataev | 858a7dd | 2018-03-20 20:21:38 +0000 | [diff] [blame] | 359 | /// Allow emission of .debug_ranges section. | 
|  | 360 | bool UseRangesSection = true; | 
|  | 361 |  | 
| Alexey Bataev | bff3608 | 2018-03-23 13:35:54 +0000 | [diff] [blame] | 362 | /// True if the sections itself must be used as references and don't create | 
|  | 363 | /// temp symbols inside DWARF sections. | 
|  | 364 | bool UseSectionsAsReferences = false; | 
|  | 365 |  | 
| Alexey Bataev | 2a03d42 | 2018-06-29 14:23:28 +0000 | [diff] [blame] | 366 | ///Allow emission of the .debug_loc section. | 
|  | 367 | bool UseLocSection = true; | 
|  | 368 |  | 
| Pavel Labath | f9adc20 | 2018-07-20 12:59:05 +0000 | [diff] [blame] | 369 | /// Generate DWARF v4 type units. | 
|  | 370 | bool GenerateTypeUnits; | 
|  | 371 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 372 | /// DWARF5 Experimental Options | 
|  | 373 | /// @{ | 
| Pavel Labath | 0cc0306 | 2018-04-04 14:54:08 +0000 | [diff] [blame] | 374 | AccelTableKind TheAccelTableKind; | 
| David Blaikie | c53e18d | 2016-05-24 21:19:28 +0000 | [diff] [blame] | 375 | bool HasAppleExtensionAttributes; | 
| Eric Christopher | cdf218d | 2012-12-10 19:51:21 +0000 | [diff] [blame] | 376 | bool HasSplitDwarf; | 
| Manman Ren | ac8062b | 2013-07-02 23:40:10 +0000 | [diff] [blame] | 377 |  | 
| Wolfgang Pieb | 456b555 | 2018-01-26 18:52:58 +0000 | [diff] [blame] | 378 | /// Whether to generate the DWARF v5 string offsets table. | 
|  | 379 | /// It consists of a series of contributions, each preceded by a header. | 
|  | 380 | /// The pre-DWARF v5 string offsets table for split dwarf is, in contrast, | 
|  | 381 | /// a monolithic sequence of string offsets. | 
|  | 382 | bool UseSegmentedStringOffsetsTable; | 
|  | 383 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 384 | /// Separated Dwarf Variables | 
|  | 385 | /// In general these will all be for bits that are left in the | 
|  | 386 | /// original object file, rather than things that are meant | 
|  | 387 | /// to be in the .dwo sections. | 
| Eric Christopher | d79f548 | 2012-12-10 19:51:13 +0000 | [diff] [blame] | 388 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 389 | /// Holder for the skeleton information. | 
| Eric Christopher | f819485 | 2013-12-05 18:06:10 +0000 | [diff] [blame] | 390 | DwarfFile SkeletonHolder; | 
| Eric Christopher | d79f548 | 2012-12-10 19:51:13 +0000 | [diff] [blame] | 391 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 392 | /// Store file names for type units under fission in a line table | 
|  | 393 | /// header that will be emitted into debug_line.dwo. | 
|  | 394 | // FIXME: replace this with a map from comp_dir to table so that we | 
|  | 395 | // can emit multiple tables during LTO each of which uses directory | 
|  | 396 | // 0, referencing the comp_dir of all the type units that use it. | 
| David Blaikie | 8287aff | 2014-03-18 02:13:23 +0000 | [diff] [blame] | 397 | MCDwarfDwoLineTable SplitTypeUnitFileTable; | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 398 | /// @} | 
| Jonas Devlieghere | 294e689 | 2017-11-15 10:57:05 +0000 | [diff] [blame] | 399 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 400 | /// True iff there are multiple CUs in this module. | 
| David Blaikie | 47f4b82 | 2014-03-19 00:11:28 +0000 | [diff] [blame] | 401 | bool SingleCU; | 
| David Blaikie | e1c7974 | 2014-09-30 21:28:32 +0000 | [diff] [blame] | 402 | bool IsDarwin; | 
| David Blaikie | 47f4b82 | 2014-03-19 00:11:28 +0000 | [diff] [blame] | 403 |  | 
| David Blaikie | d75fb28 | 2014-04-23 21:20:10 +0000 | [diff] [blame] | 404 | AddressPool AddrPool; | 
|  | 405 |  | 
| Pavel Labath | 6088c23 | 2018-04-04 14:42:14 +0000 | [diff] [blame] | 406 | /// Accelerator tables. | 
|  | 407 | AccelTable<DWARF5AccelTableData> AccelDebugNames; | 
| Pavel Labath | a7c457d | 2018-02-19 16:12:20 +0000 | [diff] [blame] | 408 | AccelTable<AppleAccelTableOffsetData> AccelNames; | 
|  | 409 | AccelTable<AppleAccelTableOffsetData> AccelObjC; | 
|  | 410 | AccelTable<AppleAccelTableOffsetData> AccelNamespace; | 
|  | 411 | AccelTable<AppleAccelTableTypeData> AccelTypes; | 
| David Blaikie | 2406a062 | 2014-04-23 23:37:35 +0000 | [diff] [blame] | 412 |  | 
| Paul Robinson | b9de106 | 2015-07-15 22:04:54 +0000 | [diff] [blame] | 413 | // Identify a debugger for "tuning" the debug info. | 
| Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 414 | DebuggerKind DebuggerTuning = DebuggerKind::Default; | 
| Paul Robinson | b9de106 | 2015-07-15 22:04:54 +0000 | [diff] [blame] | 415 |  | 
| David Blaikie | 47f4b82 | 2014-03-19 00:11:28 +0000 | [diff] [blame] | 416 | MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &); | 
|  | 417 |  | 
| Peter Collingbourne | 7c384cc | 2016-02-11 19:57:46 +0000 | [diff] [blame] | 418 | const SmallVectorImpl<std::unique_ptr<DwarfCompileUnit>> &getUnits() { | 
| Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 419 | return InfoHolder.getUnits(); | 
|  | 420 | } | 
| David Blaikie | fd1eff5 | 2013-11-26 19:14:34 +0000 | [diff] [blame] | 421 |  | 
| Hsiangkai Wang | 760c1ab | 2018-09-06 02:22:06 +0000 | [diff] [blame] | 422 | using InlinedEntity = DbgValueHistoryMap::InlinedEntity; | 
| Duncan P. N. Exon Smith | 62e0f45 | 2015-04-15 22:29:27 +0000 | [diff] [blame] | 423 |  | 
| Hsiangkai Wang | 2532ac8 | 2018-08-17 15:22:04 +0000 | [diff] [blame] | 424 | void ensureAbstractEntityIsCreated(DwarfCompileUnit &CU, | 
|  | 425 | const DINode *Node, | 
|  | 426 | const MDNode *Scope); | 
|  | 427 | void ensureAbstractEntityIsCreatedIfScoped(DwarfCompileUnit &CU, | 
|  | 428 | const DINode *Node, | 
|  | 429 | const MDNode *Scope); | 
| Devang Patel | f6eeaeb | 2009-11-10 23:06:00 +0000 | [diff] [blame] | 430 |  | 
| Hsiangkai Wang | 2532ac8 | 2018-08-17 15:22:04 +0000 | [diff] [blame] | 431 | DbgEntity *createConcreteEntity(DwarfCompileUnit &TheCU, | 
|  | 432 | LexicalScope &Scope, | 
|  | 433 | const DINode *Node, | 
|  | 434 | const DILocation *Location, | 
|  | 435 | const MCSymbol *Sym = nullptr); | 
| Duncan P. N. Exon Smith | e6cc531 | 2015-06-21 16:50:43 +0000 | [diff] [blame] | 436 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 437 | /// Construct a DIE for this abstract scope. | 
| David Blaikie | 488393f | 2017-05-12 01:13:45 +0000 | [diff] [blame] | 438 | void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU, LexicalScope *Scope); | 
| David Blaikie | 73cc705 | 2014-10-09 20:36:27 +0000 | [diff] [blame] | 439 |  | 
| Vedant Kumar | 5931b4e | 2018-10-05 20:37:17 +0000 | [diff] [blame] | 440 | /// Construct DIEs for call site entries describing the calls in \p MF. | 
|  | 441 | void constructCallSiteEntryDIEs(const DISubprogram &SP, DwarfCompileUnit &CU, | 
|  | 442 | DIE &ScopeDIE, const MachineFunction &MF); | 
|  | 443 |  | 
| Pavel Labath | 7f7e606 | 2018-07-20 15:24:13 +0000 | [diff] [blame] | 444 | template <typename DataT> | 
| David Blaikie | 66cf14d | 2018-08-16 21:29:55 +0000 | [diff] [blame] | 445 | void addAccelNameImpl(const DICompileUnit &CU, AccelTable<DataT> &AppleAccel, | 
|  | 446 | StringRef Name, const DIE &Die); | 
| Pavel Labath | 3fb39c7 | 2018-04-18 12:11:59 +0000 | [diff] [blame] | 447 |  | 
| Hsiangkai Wang | 2532ac8 | 2018-08-17 15:22:04 +0000 | [diff] [blame] | 448 | void finishEntityDefinitions(); | 
| David Blaikie | eb1a272 | 2014-06-13 22:18:23 +0000 | [diff] [blame] | 449 |  | 
| David Blaikie | f7221ad | 2014-05-27 18:37:43 +0000 | [diff] [blame] | 450 | void finishSubprogramDefinitions(); | 
|  | 451 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 452 | /// Finish off debug information after all functions have been | 
| Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 453 | /// processed. | 
| Eric Christopher | 960ac37 | 2012-11-22 00:59:49 +0000 | [diff] [blame] | 454 | void finalizeModuleInfo(); | 
|  | 455 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 456 | /// Emit the debug info section. | 
| Devang Patel | 930143b | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 457 | void emitDebugInfo(); | 
| Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 458 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 459 | /// Emit the abbreviation section. | 
| Eric Christopher | 3837195 | 2012-11-20 23:30:11 +0000 | [diff] [blame] | 460 | void emitAbbreviations(); | 
| Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 461 |  | 
| Wolfgang Pieb | 456b555 | 2018-01-26 18:52:58 +0000 | [diff] [blame] | 462 | /// Emit the string offsets table header. | 
|  | 463 | void emitStringOffsetsTableHeader(); | 
|  | 464 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 465 | /// Emit a specified accelerator table. | 
| Jonas Devlieghere | e699dfa | 2018-01-29 14:52:34 +0000 | [diff] [blame] | 466 | template <typename AccelTableT> | 
|  | 467 | void emitAccel(AccelTableT &Accel, MCSection *Section, StringRef TableName); | 
| David Blaikie | 6741bb0 | 2014-09-11 21:12:48 +0000 | [diff] [blame] | 468 |  | 
| Pavel Labath | 6088c23 | 2018-04-04 14:42:14 +0000 | [diff] [blame] | 469 | /// Emit DWARF v5 accelerator table. | 
|  | 470 | void emitAccelDebugNames(); | 
|  | 471 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 472 | /// Emit visible names into a hashed accelerator table section. | 
| Eric Christopher | 4996c70 | 2011-11-07 09:24:32 +0000 | [diff] [blame] | 473 | void emitAccelNames(); | 
| Eric Christopher | 27527b2 | 2012-11-21 00:03:28 +0000 | [diff] [blame] | 474 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 475 | /// Emit objective C classes and categories into a hashed | 
| Eric Christopher | 4996c70 | 2011-11-07 09:24:32 +0000 | [diff] [blame] | 476 | /// accelerator table section. | 
|  | 477 | void emitAccelObjC(); | 
|  | 478 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 479 | /// Emit namespace dies into a hashed accelerator table. | 
| Eric Christopher | 4996c70 | 2011-11-07 09:24:32 +0000 | [diff] [blame] | 480 | void emitAccelNamespaces(); | 
|  | 481 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 482 | /// Emit type dies into a hashed accelerator table. | 
| Eric Christopher | 4996c70 | 2011-11-07 09:24:32 +0000 | [diff] [blame] | 483 | void emitAccelTypes(); | 
| Eric Christopher | 27527b2 | 2012-11-21 00:03:28 +0000 | [diff] [blame] | 484 |  | 
| Peter Collingbourne | b52e236 | 2017-09-12 21:50:41 +0000 | [diff] [blame] | 485 | /// Emit visible names and types into debug pubnames and pubtypes sections. | 
|  | 486 | void emitDebugPubSections(); | 
| Krzysztof Parzyszek | 228daa6 | 2013-02-12 18:00:14 +0000 | [diff] [blame] | 487 |  | 
| Peter Collingbourne | b52e236 | 2017-09-12 21:50:41 +0000 | [diff] [blame] | 488 | void emitDebugPubSection(bool GnuStyle, StringRef Name, | 
|  | 489 | DwarfCompileUnit *TheU, | 
|  | 490 | const StringMap<const DIE *> &Globals); | 
| David Blaikie | 0f55e83 | 2014-03-11 23:18:15 +0000 | [diff] [blame] | 491 |  | 
| Amjad Aboud | c077841 | 2016-01-24 08:18:55 +0000 | [diff] [blame] | 492 | /// Emit null-terminated strings into a debug str section. | 
| Devang Patel | 930143b | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 493 | void emitDebugStr(); | 
| Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 494 |  | 
| Amjad Aboud | d7cfb48 | 2016-01-07 14:28:20 +0000 | [diff] [blame] | 495 | /// Emit variable locations into a debug loc section. | 
| Devang Patel | 930143b | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 496 | void emitDebugLoc(); | 
| Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 497 |  | 
| Amjad Aboud | d7cfb48 | 2016-01-07 14:28:20 +0000 | [diff] [blame] | 498 | /// Emit variable locations into a debug loc dwo section. | 
| David Blaikie | 94c1d7f | 2014-04-02 01:50:20 +0000 | [diff] [blame] | 499 | void emitDebugLocDWO(); | 
|  | 500 |  | 
| Amjad Aboud | d7cfb48 | 2016-01-07 14:28:20 +0000 | [diff] [blame] | 501 | /// Emit address ranges into a debug aranges section. | 
| Eric Christopher | 7b30f2e4 | 2012-11-21 00:34:35 +0000 | [diff] [blame] | 502 | void emitDebugARanges(); | 
| Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 503 |  | 
| Amjad Aboud | d7cfb48 | 2016-01-07 14:28:20 +0000 | [diff] [blame] | 504 | /// Emit address ranges into a debug ranges section. | 
| Devang Patel | 930143b | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 505 | void emitDebugRanges(); | 
| David Blaikie | c4af8bf | 2018-10-20 07:36:39 +0000 | [diff] [blame] | 506 | void emitDebugRangesDWO(); | 
| Wolfgang Pieb | fcf3810 | 2018-07-12 18:18:21 +0000 | [diff] [blame] | 507 |  | 
| Amjad Aboud | d7cfb48 | 2016-01-07 14:28:20 +0000 | [diff] [blame] | 508 | /// Emit macros into a debug macinfo section. | 
|  | 509 | void emitDebugMacinfo(); | 
| Amjad Aboud | 8bbce8a | 2016-02-01 14:09:41 +0000 | [diff] [blame] | 510 | void emitMacro(DIMacro &M); | 
|  | 511 | void emitMacroFile(DIMacroFile &F, DwarfCompileUnit &U); | 
|  | 512 | void handleMacroNodes(DIMacroNodeArray Nodes, DwarfCompileUnit &U); | 
| Amjad Aboud | d7cfb48 | 2016-01-07 14:28:20 +0000 | [diff] [blame] | 513 |  | 
| Eric Christopher | cdf218d | 2012-12-10 19:51:21 +0000 | [diff] [blame] | 514 | /// DWARF 5 Experimental Split Dwarf Emitters | 
| Eric Christopher | 9c2ecd9 | 2012-11-30 23:59:06 +0000 | [diff] [blame] | 515 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 516 | /// Initialize common features of skeleton units. | 
| David Blaikie | 65a7466 | 2014-04-25 18:26:14 +0000 | [diff] [blame] | 517 | void initSkeletonUnit(const DwarfUnit &U, DIE &Die, | 
| Peter Collingbourne | 7c384cc | 2016-02-11 19:57:46 +0000 | [diff] [blame] | 518 | std::unique_ptr<DwarfCompileUnit> NewU); | 
| David Blaikie | 38fe634 | 2014-01-09 04:28:46 +0000 | [diff] [blame] | 519 |  | 
| Wolfgang Pieb | 9ea6508 | 2018-07-26 22:48:52 +0000 | [diff] [blame] | 520 | /// Construct the split debug info compile unit for the debug info section. | 
|  | 521 | /// In DWARF v5, the skeleton unit DIE may have the following attributes: | 
|  | 522 | /// DW_AT_addr_base, DW_AT_comp_dir, DW_AT_dwo_name, DW_AT_high_pc, | 
|  | 523 | /// DW_AT_low_pc, DW_AT_ranges, DW_AT_stmt_list, and DW_AT_str_offsets_base. | 
|  | 524 | /// Prior to DWARF v5 it may also have DW_AT_GNU_dwo_id. DW_AT_GNU_dwo_name | 
|  | 525 | /// is used instead of DW_AT_dwo_name, Dw_AT_GNU_addr_base instead of | 
|  | 526 | /// DW_AT_addr_base, and DW_AT_GNU_ranges_base instead of DW_AT_rnglists_base. | 
| David Blaikie | f9b6a55 | 2014-04-22 22:39:41 +0000 | [diff] [blame] | 527 | DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU); | 
| Eric Christopher | 9c2ecd9 | 2012-11-30 23:59:06 +0000 | [diff] [blame] | 528 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 529 | /// Emit the debug info dwo section. | 
| Eric Christopher | 9c2ecd9 | 2012-11-30 23:59:06 +0000 | [diff] [blame] | 530 | void emitDebugInfoDWO(); | 
|  | 531 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 532 | /// Emit the debug abbrev dwo section. | 
| Eric Christopher | 3c5a191 | 2012-12-19 22:02:53 +0000 | [diff] [blame] | 533 | void emitDebugAbbrevDWO(); | 
|  | 534 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 535 | /// Emit the debug line dwo section. | 
| David Blaikie | 4a2f95f | 2014-03-18 01:17:26 +0000 | [diff] [blame] | 536 | void emitDebugLineDWO(); | 
|  | 537 |  | 
| Wolfgang Pieb | 456b555 | 2018-01-26 18:52:58 +0000 | [diff] [blame] | 538 | /// Emit the dwo stringoffsets table header. | 
|  | 539 | void emitStringOffsetsTableHeaderDWO(); | 
|  | 540 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 541 | /// Emit the debug str dwo section. | 
| Eric Christopher | 3bf29fd | 2012-12-27 02:14:01 +0000 | [diff] [blame] | 542 | void emitDebugStrDWO(); | 
|  | 543 |  | 
| Victor Leschuk | 64e0c56 | 2018-08-01 05:48:06 +0000 | [diff] [blame] | 544 | /// Emit DWO addresses. | 
|  | 545 | void emitDebugAddr(); | 
|  | 546 |  | 
| David Blaikie | 3c84262 | 2013-12-04 21:31:26 +0000 | [diff] [blame] | 547 | /// Flags to let the linker know we have emitted new style pubnames. Only | 
|  | 548 | /// emit it here if we don't have a skeleton CU for split dwarf. | 
| David Blaikie | b3cee2f | 2017-05-25 18:50:28 +0000 | [diff] [blame] | 549 | void addGnuPubAttributes(DwarfCompileUnit &U, DIE &D) const; | 
| David Blaikie | 3c84262 | 2013-12-04 21:31:26 +0000 | [diff] [blame] | 550 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 551 | /// Create new DwarfCompileUnit for the given metadata node with tag | 
| Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 552 | /// DW_TAG_compile_unit. | 
| David Blaikie | 07963bd | 2017-05-26 18:52:56 +0000 | [diff] [blame] | 553 | DwarfCompileUnit &getOrCreateDwarfCompileUnit(const DICompileUnit *DIUnit); | 
| David Blaikie | 560ff35 | 2018-12-14 22:44:46 +0000 | [diff] [blame] | 554 | void finishUnitAttributes(const DICompileUnit *DIUnit, | 
|  | 555 | DwarfCompileUnit &NewCU); | 
| Devang Patel | 1a0df9a | 2010-05-10 22:49:55 +0000 | [diff] [blame] | 556 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 557 | /// Construct imported_module or imported_declaration DIE. | 
| David Blaikie | 8912df1 | 2014-08-31 05:41:15 +0000 | [diff] [blame] | 558 | void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU, | 
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 559 | const DIImportedEntity *N); | 
| David Blaikie | 684fc53 | 2013-05-06 23:33:07 +0000 | [diff] [blame] | 560 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 561 | /// Register a source line with debug info. Returns the unique | 
| Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 562 | /// label that was emitted and which provides correspondence to the | 
|  | 563 | /// source line list. | 
| Devang Patel | 34a6620 | 2011-05-11 19:22:19 +0000 | [diff] [blame] | 564 | void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope, | 
|  | 565 | unsigned Flags); | 
| Eric Christopher | 27527b2 | 2012-11-21 00:03:28 +0000 | [diff] [blame] | 566 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 567 | /// Populate LexicalScope entries with variables' info. | 
| Hsiangkai Wang | 2532ac8 | 2018-08-17 15:22:04 +0000 | [diff] [blame] | 568 | void collectEntityInfo(DwarfCompileUnit &TheCU, const DISubprogram *SP, | 
| Hsiangkai Wang | 760c1ab | 2018-09-06 02:22:06 +0000 | [diff] [blame] | 569 | DenseSet<InlinedEntity> &ProcessedVars); | 
| Eric Christopher | 27527b2 | 2012-11-21 00:03:28 +0000 | [diff] [blame] | 570 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 571 | /// Build the location list for all DBG_VALUEs in the | 
| Nikola Prica | abc1dff | 2019-06-10 08:41:06 +0000 | [diff] [blame] | 572 | /// function that describe the same variable. If the resulting | 
|  | 573 | /// list has only one entry that is valid for entire variable's | 
|  | 574 | /// scope return true. | 
|  | 575 | bool buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc, | 
| David Stenberg | 6feef56 | 2019-04-10 09:07:43 +0000 | [diff] [blame] | 576 | const DbgValueHistoryMap::Entries &Entries); | 
| Adrian Prantl | b141683 | 2014-08-01 22:11:58 +0000 | [diff] [blame] | 577 |  | 
| Matthias Braun | ef331ef | 2016-11-30 23:48:50 +0000 | [diff] [blame] | 578 | /// Collect variable information from the side table maintained by MF. | 
| David Blaikie | 488393f | 2017-05-12 01:13:45 +0000 | [diff] [blame] | 579 | void collectVariableInfoFromMFTable(DwarfCompileUnit &TheCU, | 
| Hsiangkai Wang | 760c1ab | 2018-09-06 02:22:06 +0000 | [diff] [blame] | 580 | DenseSet<InlinedEntity> &P); | 
| Jakob Stoklund Olesen | 9a624fa | 2011-03-26 02:19:36 +0000 | [diff] [blame] | 581 |  | 
| Alexey Bataev | bff3608 | 2018-03-23 13:35:54 +0000 | [diff] [blame] | 582 | /// Emit the reference to the section. | 
|  | 583 | void emitSectionReference(const DwarfCompileUnit &CU); | 
|  | 584 |  | 
| David Blaikie | b2fbb4b | 2017-02-16 18:48:33 +0000 | [diff] [blame] | 585 | protected: | 
|  | 586 | /// Gather pre-function debug information. | 
|  | 587 | void beginFunctionImpl(const MachineFunction *MF) override; | 
|  | 588 |  | 
|  | 589 | /// Gather and emit post-function debug information. | 
|  | 590 | void endFunctionImpl(const MachineFunction *MF) override; | 
|  | 591 |  | 
|  | 592 | void skippedNonDebugFunction() override; | 
|  | 593 |  | 
| Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 594 | public: | 
|  | 595 | //===--------------------------------------------------------------------===// | 
|  | 596 | // Main entry points. | 
|  | 597 | // | 
| Chris Lattner | f0d6bd3 | 2010-04-05 05:11:15 +0000 | [diff] [blame] | 598 | DwarfDebug(AsmPrinter *A, Module *M); | 
| Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 599 |  | 
| Reid Kleckner | dd2647e | 2014-04-30 20:34:31 +0000 | [diff] [blame] | 600 | ~DwarfDebug() override; | 
|  | 601 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 602 | /// Emit all Dwarf sections that should come prior to the | 
| Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 603 | /// content. | 
| Eric Christopher | 58f4195 | 2012-11-19 22:42:15 +0000 | [diff] [blame] | 604 | void beginModule(); | 
| Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 605 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 606 | /// Emit all Dwarf sections that should come after the content. | 
| Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 607 | void endModule() override; | 
| Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 608 |  | 
| Alexey Bataev | 9d5974a | 2019-01-22 17:24:16 +0000 | [diff] [blame] | 609 | /// Emits inital debug location directive. | 
|  | 610 | DebugLoc emitInitialLocDirective(const MachineFunction &MF, unsigned CUID); | 
|  | 611 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 612 | /// Process beginning of an instruction. | 
| Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 613 | void beginInstruction(const MachineInstr *MI) override; | 
| Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 614 |  | 
| Adrian Prantl | ee5feaf | 2015-07-15 17:01:41 +0000 | [diff] [blame] | 615 | /// Perform an MD5 checksum of \p Identifier and return the lower 64 bits. | 
|  | 616 | static uint64_t makeTypeSignature(StringRef Identifier); | 
|  | 617 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 618 | /// Add a DIE to the set of types that we're going to pull into | 
| Eric Christopher | 6764643 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 619 | /// type units. | 
| David Blaikie | 15632ae | 2014-02-12 00:31:30 +0000 | [diff] [blame] | 620 | void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier, | 
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 621 | DIE &Die, const DICompositeType *CTy); | 
| Eric Christopher | 6764643 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 622 |  | 
| David Blaikie | 832c7d9 | 2019-04-24 18:09:44 +0000 | [diff] [blame] | 623 | friend class NonTypeUnitContext; | 
|  | 624 | class NonTypeUnitContext { | 
|  | 625 | DwarfDebug *DD; | 
|  | 626 | decltype(DwarfDebug::TypeUnitsUnderConstruction) TypeUnitsUnderConstruction; | 
|  | 627 | friend class DwarfDebug; | 
|  | 628 | NonTypeUnitContext(DwarfDebug *DD); | 
|  | 629 | public: | 
|  | 630 | NonTypeUnitContext(NonTypeUnitContext&&) = default; | 
|  | 631 | ~NonTypeUnitContext(); | 
|  | 632 | }; | 
|  | 633 |  | 
|  | 634 | NonTypeUnitContext enterNonTypeUnitContext(); | 
|  | 635 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 636 | /// Add a label so that arange data can be generated for it. | 
| Alexey Samsonov | 4436bf0 | 2013-10-03 08:54:43 +0000 | [diff] [blame] | 637 | void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); } | 
| Richard Mitton | 21101b3 | 2013-09-19 23:21:01 +0000 | [diff] [blame] | 638 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 639 | /// For symbols that have a size designated (e.g. common symbols), | 
| Richard Mitton | 089ed89 | 2013-09-23 17:56:20 +0000 | [diff] [blame] | 640 | /// this tracks that size. | 
| Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 641 | void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override { | 
| Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 642 | SymSize[Sym] = Size; | 
|  | 643 | } | 
| Richard Mitton | 089ed89 | 2013-09-23 17:56:20 +0000 | [diff] [blame] | 644 |  | 
| Paul Robinson | 43d1e45 | 2016-04-18 22:41:41 +0000 | [diff] [blame] | 645 | /// Returns whether we should emit all DW_AT_[MIPS_]linkage_name. | 
|  | 646 | /// If not, we still might emit certain cases. | 
|  | 647 | bool useAllLinkageNames() const { return UseAllLinkageNames; } | 
| Paul Robinson | 78046b4 | 2015-08-11 21:36:45 +0000 | [diff] [blame] | 648 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 649 | /// Returns whether to use DW_OP_GNU_push_tls_address, instead of the | 
| Paul Robinson | 78cc082 | 2015-03-04 20:55:11 +0000 | [diff] [blame] | 650 | /// standard DW_OP_form_tls_address opcode | 
|  | 651 | bool useGNUTLSOpcode() const { return UseGNUTLSOpcode; } | 
|  | 652 |  | 
| Adrian Prantl | 6323ddf | 2016-05-17 21:07:16 +0000 | [diff] [blame] | 653 | /// Returns whether to use the DWARF2 format for bitfields instyead of the | 
|  | 654 | /// DWARF4 format. | 
|  | 655 | bool useDWARF2Bitfields() const { return UseDWARF2Bitfields; } | 
|  | 656 |  | 
| Alexey Bataev | 0d6aead | 2018-02-20 15:28:08 +0000 | [diff] [blame] | 657 | /// Returns whether to use inline strings. | 
|  | 658 | bool useInlineStrings() const { return UseInlineStrings; } | 
|  | 659 |  | 
| Alexey Bataev | 858a7dd | 2018-03-20 20:21:38 +0000 | [diff] [blame] | 660 | /// Returns whether ranges section should be emitted. | 
|  | 661 | bool useRangesSection() const { return UseRangesSection; } | 
|  | 662 |  | 
| Alexey Bataev | bff3608 | 2018-03-23 13:35:54 +0000 | [diff] [blame] | 663 | /// Returns whether to use sections as labels rather than temp symbols. | 
|  | 664 | bool useSectionsAsReferences() const { | 
|  | 665 | return UseSectionsAsReferences; | 
|  | 666 | } | 
|  | 667 |  | 
| Alexey Bataev | 2a03d42 | 2018-06-29 14:23:28 +0000 | [diff] [blame] | 668 | /// Returns whether .debug_loc section should be emitted. | 
|  | 669 | bool useLocSection() const { return UseLocSection; } | 
|  | 670 |  | 
| Pavel Labath | f9adc20 | 2018-07-20 12:59:05 +0000 | [diff] [blame] | 671 | /// Returns whether to generate DWARF v4 type units. | 
|  | 672 | bool generateTypeUnits() const { return GenerateTypeUnits; } | 
|  | 673 |  | 
| Eric Christopher | 55c5181 | 2012-11-21 00:03:31 +0000 | [diff] [blame] | 674 | // Experimental DWARF5 features. | 
|  | 675 |  | 
| Pavel Labath | 6088c23 | 2018-04-04 14:42:14 +0000 | [diff] [blame] | 676 | /// Returns what kind (if any) of accelerator tables to emit. | 
| Pavel Labath | 0cc0306 | 2018-04-04 14:54:08 +0000 | [diff] [blame] | 677 | AccelTableKind getAccelTableKind() const { return TheAccelTableKind; } | 
| Eric Christopher | 55c5181 | 2012-11-21 00:03:31 +0000 | [diff] [blame] | 678 |  | 
| David Blaikie | c53e18d | 2016-05-24 21:19:28 +0000 | [diff] [blame] | 679 | bool useAppleExtensionAttributes() const { | 
|  | 680 | return HasAppleExtensionAttributes; | 
|  | 681 | } | 
|  | 682 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 683 | /// Returns whether or not to change the current debug info for the | 
| Eric Christopher | cdf218d | 2012-12-10 19:51:21 +0000 | [diff] [blame] | 684 | /// split dwarf proposal support. | 
| Eric Christopher | 411bd59 | 2014-03-06 00:00:53 +0000 | [diff] [blame] | 685 | bool useSplitDwarf() const { return HasSplitDwarf; } | 
| Manman Ren | ac8062b | 2013-07-02 23:40:10 +0000 | [diff] [blame] | 686 |  | 
| Wolfgang Pieb | 456b555 | 2018-01-26 18:52:58 +0000 | [diff] [blame] | 687 | /// Returns whether to generate a string offsets table with (possibly shared) | 
|  | 688 | /// contributions from each CU and type unit. This implies the use of | 
|  | 689 | /// DW_FORM_strx* indirect references with DWARF v5 and beyond. Note that | 
|  | 690 | /// DW_FORM_GNU_str_index is also an indirect reference, but it is used with | 
|  | 691 | /// a pre-DWARF v5 implementation of split DWARF sections, which uses a | 
|  | 692 | /// monolithic string offsets table. | 
|  | 693 | bool useSegmentedStringOffsetsTable() const { | 
|  | 694 | return UseSegmentedStringOffsetsTable; | 
|  | 695 | } | 
|  | 696 |  | 
| David Blaikie | 488393f | 2017-05-12 01:13:45 +0000 | [diff] [blame] | 697 | bool shareAcrossDWOCUs() const; | 
|  | 698 |  | 
| Manman Ren | ac8062b | 2013-07-02 23:40:10 +0000 | [diff] [blame] | 699 | /// Returns the Dwarf Version. | 
| Greg Clayton | e654397 | 2016-11-23 23:30:37 +0000 | [diff] [blame] | 700 | uint16_t getDwarfVersion() const; | 
| Manman Ren | 6035203 | 2013-09-05 18:48:31 +0000 | [diff] [blame] | 701 |  | 
| Eric Christopher | 384f3fe | 2014-03-20 19:16:16 +0000 | [diff] [blame] | 702 | /// Returns the previous CU that was being updated | 
|  | 703 | const DwarfCompileUnit *getPrevCU() const { return PrevCU; } | 
| David Blaikie | d0f1037 | 2014-09-09 23:13:01 +0000 | [diff] [blame] | 704 | void setPrevCU(const DwarfCompileUnit *PrevCU) { this->PrevCU = PrevCU; } | 
| Eric Christopher | 384f3fe | 2014-03-20 19:16:16 +0000 | [diff] [blame] | 705 |  | 
| Eric Christopher | 4f17ee0 | 2014-03-08 00:29:41 +0000 | [diff] [blame] | 706 | /// Returns the entries for the .debug_loc section. | 
| Duncan P. N. Exon Smith | 364a300 | 2015-04-17 21:34:47 +0000 | [diff] [blame] | 707 | const DebugLocStream &getDebugLocs() const { return DebugLocs; } | 
| Eric Christopher | 4f17ee0 | 2014-03-08 00:29:41 +0000 | [diff] [blame] | 708 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 709 | /// Emit an entry for the debug loc section. This can be used to | 
| Eric Christopher | 4f17ee0 | 2014-03-08 00:29:41 +0000 | [diff] [blame] | 710 | /// handle an entry that's going to be emitted into the debug loc section. | 
| Adrian Prantl | 92da14b | 2015-03-02 22:02:33 +0000 | [diff] [blame] | 711 | void emitDebugLocEntry(ByteStreamer &Streamer, | 
| Markus Lavin | b86ce21 | 2019-03-19 13:16:28 +0000 | [diff] [blame] | 712 | const DebugLocStream::Entry &Entry, | 
|  | 713 | const DwarfCompileUnit *CU); | 
| Eric Christopher | 4f17ee0 | 2014-03-08 00:29:41 +0000 | [diff] [blame] | 714 |  | 
| David Blaikie | 0e84adc | 2014-04-01 16:17:41 +0000 | [diff] [blame] | 715 | /// Emit the location for a debug loc entry, including the size header. | 
| Markus Lavin | b86ce21 | 2019-03-19 13:16:28 +0000 | [diff] [blame] | 716 | void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry, | 
|  | 717 | const DwarfCompileUnit *CU); | 
| David Blaikie | 0e84adc | 2014-04-01 16:17:41 +0000 | [diff] [blame] | 718 |  | 
| David Blaikie | 66cf14d | 2018-08-16 21:29:55 +0000 | [diff] [blame] | 719 | void addSubprogramNames(const DICompileUnit &CU, const DISubprogram *SP, | 
|  | 720 | DIE &Die); | 
| David Blaikie | 2406a062 | 2014-04-23 23:37:35 +0000 | [diff] [blame] | 721 |  | 
| David Blaikie | d75fb28 | 2014-04-23 21:20:10 +0000 | [diff] [blame] | 722 | AddressPool &getAddressPool() { return AddrPool; } | 
| David Blaikie | 2406a062 | 2014-04-23 23:37:35 +0000 | [diff] [blame] | 723 |  | 
| David Blaikie | 66cf14d | 2018-08-16 21:29:55 +0000 | [diff] [blame] | 724 | void addAccelName(const DICompileUnit &CU, StringRef Name, const DIE &Die); | 
| David Blaikie | 0ee82b9 | 2014-04-24 00:53:32 +0000 | [diff] [blame] | 725 |  | 
| David Blaikie | 66cf14d | 2018-08-16 21:29:55 +0000 | [diff] [blame] | 726 | void addAccelObjC(const DICompileUnit &CU, StringRef Name, const DIE &Die); | 
| David Blaikie | ecf0415 | 2014-04-24 01:02:42 +0000 | [diff] [blame] | 727 |  | 
| David Blaikie | 66cf14d | 2018-08-16 21:29:55 +0000 | [diff] [blame] | 728 | void addAccelNamespace(const DICompileUnit &CU, StringRef Name, | 
|  | 729 | const DIE &Die); | 
| David Blaikie | 18d3375 | 2014-04-24 01:23:49 +0000 | [diff] [blame] | 730 |  | 
| David Blaikie | 66cf14d | 2018-08-16 21:29:55 +0000 | [diff] [blame] | 731 | void addAccelType(const DICompileUnit &CU, StringRef Name, const DIE &Die, | 
|  | 732 | char Flags); | 
| David Blaikie | cda2aa8 | 2014-10-04 16:24:00 +0000 | [diff] [blame] | 733 |  | 
|  | 734 | const MachineFunction *getCurrentFunction() const { return CurFn; } | 
| David Blaikie | 9c65b13 | 2014-10-08 22:20:02 +0000 | [diff] [blame] | 735 |  | 
| Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 736 | /// A helper function to check whether the DIE for a given Scope is | 
| David Blaikie | 9c65b13 | 2014-10-08 22:20:02 +0000 | [diff] [blame] | 737 | /// going to be null. | 
|  | 738 | bool isLexicalScopeDIENull(LexicalScope *Scope); | 
| David Blaikie | b3cee2f | 2017-05-25 18:50:28 +0000 | [diff] [blame] | 739 |  | 
| Jonas Devlieghere | 294e689 | 2017-11-15 10:57:05 +0000 | [diff] [blame] | 740 | /// Find the matching DwarfCompileUnit for the given CU DIE. | 
|  | 741 | DwarfCompileUnit *lookupCU(const DIE *Die) { return CUDieMap.lookup(Die); } | 
| Pavel Labath | 6088c23 | 2018-04-04 14:42:14 +0000 | [diff] [blame] | 742 | const DwarfCompileUnit *lookupCU(const DIE *Die) const { | 
|  | 743 | return CUDieMap.lookup(Die); | 
|  | 744 | } | 
| Jonas Devlieghere | 294e689 | 2017-11-15 10:57:05 +0000 | [diff] [blame] | 745 |  | 
| Peter Collingbourne | b52e236 | 2017-09-12 21:50:41 +0000 | [diff] [blame] | 746 | /// \defgroup DebuggerTuning Predicates to tune DWARF for a given debugger. | 
|  | 747 | /// | 
|  | 748 | /// Returns whether we are "tuning" for a given debugger. | 
|  | 749 | /// @{ | 
|  | 750 | bool tuneForGDB() const { return DebuggerTuning == DebuggerKind::GDB; } | 
|  | 751 | bool tuneForLLDB() const { return DebuggerTuning == DebuggerKind::LLDB; } | 
|  | 752 | bool tuneForSCE() const { return DebuggerTuning == DebuggerKind::SCE; } | 
|  | 753 | /// @} | 
| David Blaikie | 60fddac | 2018-10-24 23:36:29 +0000 | [diff] [blame] | 754 |  | 
|  | 755 | void addSectionLabel(const MCSymbol *Sym); | 
|  | 756 | const MCSymbol *getSectionLabel(const MCSection *S); | 
| Djordje Todorovic | a0d4505 | 2019-06-27 13:52:34 +0000 | [diff] [blame] | 757 |  | 
|  | 758 | static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT, | 
|  | 759 | const DbgValueLoc &Value, | 
|  | 760 | DwarfExpression &DwarfExpr); | 
| Devang Patel | f6eeaeb | 2009-11-10 23:06:00 +0000 | [diff] [blame] | 761 | }; | 
| Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 762 |  | 
| Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 763 | } // end namespace llvm | 
|  | 764 |  | 
|  | 765 | #endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H |