blob: f01d68028eb4f99507b74bbeea49eb766f986b82 [file] [log] [blame]
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +00001//===- llvm/CodeGen/DwarfDebug.h - Dwarf Debug Framework --------*- C++ -*-===//
Bill Wendling2f921f82009-05-15 09:23:25 +00002//
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 Kramera7c40ef2014-08-13 16:26:38 +000014#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
15#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
Bill Wendling2f921f82009-05-15 09:23:25 +000016
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +000017#include "AddressPool.h"
Alexey Samsonov414b6fb2014-04-30 21:34:11 +000018#include "DbgValueHistoryCalculator.h"
Reid Klecknerf9c275f2016-02-10 20:55:49 +000019#include "DebugHandlerBase.h"
Duncan P. N. Exon Smith364a3002015-04-17 21:34:47 +000020#include "DebugLocStream.h"
Chandler Carruthd9903882015-01-14 11:23:27 +000021#include "DwarfFile.h"
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +000022#include "llvm/ADT/ArrayRef.h"
Devang Patel018b29b2010-01-19 06:19:05 +000023#include "llvm/ADT/DenseMap.h"
Duncan P. N. Exon Smith62e0f452015-04-15 22:29:27 +000024#include "llvm/ADT/DenseSet.h"
Eric Christopheracbe42b2014-03-18 20:58:35 +000025#include "llvm/ADT/MapVector.h"
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +000026#include "llvm/ADT/STLExtras.h"
David Blaikie38b74bf2016-12-15 23:37:38 +000027#include "llvm/ADT/SetVector.h"
Eric Christopheracbe42b2014-03-18 20:58:35 +000028#include "llvm/ADT/SmallPtrSet.h"
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +000029#include "llvm/ADT/SmallVector.h"
Eric Christopheracbe42b2014-03-18 20:58:35 +000030#include "llvm/ADT/StringMap.h"
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +000031#include "llvm/ADT/StringRef.h"
32#include "llvm/BinaryFormat/Dwarf.h"
Jonas Devlieghere855fc3b2018-01-29 14:52:41 +000033#include "llvm/CodeGen/AccelTable.h"
Adrian Prantlc1197542014-05-30 21:10:13 +000034#include "llvm/CodeGen/MachineInstr.h"
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +000035#include "llvm/IR/DebugInfoMetadata.h"
Eric Christopheracbe42b2014-03-18 20:58:35 +000036#include "llvm/IR/DebugLoc.h"
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +000037#include "llvm/IR/Metadata.h"
David Blaikie4a2f95f2014-03-18 01:17:26 +000038#include "llvm/MC/MCDwarf.h"
Chris Lattner3f3fb972010-04-05 05:24:55 +000039#include "llvm/Support/Allocator.h"
Paul Robinson6c27a2c2015-12-16 19:58:30 +000040#include "llvm/Target/TargetOptions.h"
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +000041#include <cassert>
42#include <cstdint>
43#include <limits>
David Blaikief9b6a552014-04-22 22:39:41 +000044#include <memory>
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +000045#include <utility>
46#include <vector>
David Blaikief9b6a552014-04-22 22:39:41 +000047
Bill Wendling2f921f82009-05-15 09:23:25 +000048namespace llvm {
49
Adrian Prantl702bf5a2014-03-18 02:34:52 +000050class AsmPrinter;
Eric Christopher29e874d2014-03-07 22:40:37 +000051class ByteStreamer;
Duncan P. N. Exon Smith364a3002015-04-17 21:34:47 +000052class DebugLocEntry;
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +000053class DIE;
Eric Christopherce4a9442014-03-18 20:37:10 +000054class DwarfCompileUnit;
Eric Christopherce4a9442014-03-18 20:37:10 +000055class DwarfTypeUnit;
56class DwarfUnit;
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +000057class LexicalScope;
58class MachineFunction;
59class MCSection;
60class MCSymbol;
61class MDNode;
62class Module;
Bill Wendling2f921f82009-05-15 09:23:25 +000063
64//===----------------------------------------------------------------------===//
Duncan P. N. Exon Smithe6cc5312015-06-21 16:50:43 +000065/// This class is used to track local variable information.
Adrian Prantlca7e4702015-02-10 23:18:28 +000066///
Duncan P. N. Exon Smithe6cc5312015-06-21 16:50:43 +000067/// Variables can be created from allocas, in which case they're generated from
68/// the MMI table. Such variables can have multiple expressions and frame
Adrian Prantl67c24422017-02-17 19:42:32 +000069/// indices.
Adrian Prantlca7e4702015-02-10 23:18:28 +000070///
Duncan P. N. Exon Smithe6cc5312015-06-21 16:50:43 +000071/// Variables can be created from \c DBG_VALUE instructions. Those whose
72/// location changes over time use \a DebugLocListIndex, while those with a
73/// single instruction use \a MInsn and (optionally) a single entry of \a Expr.
74///
75/// Variables that have been optimized out use none of these fields.
Benjamin Kramer079b96e2013-09-11 18:05:11 +000076class DbgVariable {
Duncan P. N. Exon Smithe6cc5312015-06-21 16:50:43 +000077 const DILocalVariable *Var; /// Variable Descriptor.
78 const DILocation *IA; /// Inlined at location.
Duncan P. N. Exon Smithe6cc5312015-06-21 16:50:43 +000079 DIE *TheDIE = nullptr; /// Variable DIE.
80 unsigned DebugLocListIndex = ~0u; /// Offset in DebugLocs.
81 const MachineInstr *MInsn = nullptr; /// DBG_VALUE instruction.
Adrian Prantl67c24422017-02-17 19:42:32 +000082
83 struct FrameIndexExpr {
84 int FI;
85 const DIExpression *Expr;
86 };
87 mutable SmallVector<FrameIndexExpr, 1>
88 FrameIndexExprs; /// Frame index + expression.
Eric Christophera5a79422013-12-09 23:32:48 +000089
Devang Patelf20c4f72011-04-12 22:53:02 +000090public:
Duncan P. N. Exon Smithe6cc5312015-06-21 16:50:43 +000091 /// Construct a DbgVariable.
92 ///
93 /// Creates a variable without any DW_AT_location. Call \a initializeMMI()
94 /// for MMI entries, or \a initializeDbgValue() for DBG_VALUE instructions.
Duncan P. N. Exon Smitha59d3e52016-04-23 21:08:00 +000095 DbgVariable(const DILocalVariable *V, const DILocation *IA)
96 : Var(V), IA(IA) {}
Duncan P. N. Exon Smithe6cc5312015-06-21 16:50:43 +000097
98 /// Initialize from the MMI table.
99 void initializeMMI(const DIExpression *E, int FI) {
Adrian Prantl67c24422017-02-17 19:42:32 +0000100 assert(FrameIndexExprs.empty() && "Already initialized?");
Duncan P. N. Exon Smithe6cc5312015-06-21 16:50:43 +0000101 assert(!MInsn && "Already initialized?");
102
103 assert((!E || E->isValid()) && "Expected valid expression");
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +0000104 assert(FI != std::numeric_limits<int>::max() && "Expected valid index");
Duncan P. N. Exon Smithe6cc5312015-06-21 16:50:43 +0000105
Adrian Prantl67c24422017-02-17 19:42:32 +0000106 FrameIndexExprs.push_back({FI, E});
Adrian Prantl87b7eb92014-10-01 18:55:02 +0000107 }
Devang Patelf20c4f72011-04-12 22:53:02 +0000108
Duncan P. N. Exon Smithe6cc5312015-06-21 16:50:43 +0000109 /// Initialize from a DBG_VALUE instruction.
110 void initializeDbgValue(const MachineInstr *DbgValue) {
Adrian Prantl67c24422017-02-17 19:42:32 +0000111 assert(FrameIndexExprs.empty() && "Already initialized?");
Duncan P. N. Exon Smithe6cc5312015-06-21 16:50:43 +0000112 assert(!MInsn && "Already initialized?");
113
114 assert(Var == DbgValue->getDebugVariable() && "Wrong variable");
115 assert(IA == DbgValue->getDebugLoc()->getInlinedAt() && "Wrong inlined-at");
116
117 MInsn = DbgValue;
118 if (auto *E = DbgValue->getDebugExpression())
119 if (E->getNumElements())
Adrian Prantl67c24422017-02-17 19:42:32 +0000120 FrameIndexExprs.push_back({0, E});
Adrian Prantlca7e4702015-02-10 23:18:28 +0000121 }
Adrian Prantlc1197542014-05-30 21:10:13 +0000122
Devang Patelf20c4f72011-04-12 22:53:02 +0000123 // Accessors.
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000124 const DILocalVariable *getVariable() const { return Var; }
125 const DILocation *getInlinedAt() const { return IA; }
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +0000126
Adrian Prantl6f4746b12016-02-17 22:19:59 +0000127 const DIExpression *getSingleExpression() const {
Adrian Prantl67c24422017-02-17 19:42:32 +0000128 assert(MInsn && FrameIndexExprs.size() <= 1);
129 return FrameIndexExprs.size() ? FrameIndexExprs[0].Expr : nullptr;
Adrian Prantl6f4746b12016-02-17 22:19:59 +0000130 }
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +0000131
David Blaikiee071fc82014-04-25 17:32:19 +0000132 void setDIE(DIE &D) { TheDIE = &D; }
Eric Christophera5a79422013-12-09 23:32:48 +0000133 DIE *getDIE() const { return TheDIE; }
Duncan P. N. Exon Smith364a3002015-04-17 21:34:47 +0000134 void setDebugLocListIndex(unsigned O) { DebugLocListIndex = O; }
135 unsigned getDebugLocListIndex() const { return DebugLocListIndex; }
Duncan P. N. Exon Smith7348dda2015-04-14 02:22:36 +0000136 StringRef getName() const { return Var->getName(); }
Eric Christophera5a79422013-12-09 23:32:48 +0000137 const MachineInstr *getMInsn() const { return MInsn; }
Adrian Prantl67c24422017-02-17 19:42:32 +0000138 /// Get the FI entries, sorted by fragment offset.
139 ArrayRef<FrameIndexExpr> getFrameIndexExprs() const;
140 bool hasFrameIndexExprs() const { return !FrameIndexExprs.empty(); }
Bjorn Steinbrinkd36bbe92017-10-10 07:46:17 +0000141 void addMMIEntry(const DbgVariable &V);
Adrian Prantlca7e4702015-02-10 23:18:28 +0000142
Eric Christopher27527b22012-11-21 00:03:28 +0000143 // Translate tag to proper Dwarf tag.
David Blaikieefc403b2014-04-12 02:24:04 +0000144 dwarf::Tag getTag() const {
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +0000145 // FIXME: Why don't we just infer this tag and store it all along?
146 if (Var->isParameter())
Devang Patel6e4d2c92011-08-15 18:35:42 +0000147 return dwarf::DW_TAG_formal_parameter;
Eric Christopher27527b22012-11-21 00:03:28 +0000148
Devang Patel6e4d2c92011-08-15 18:35:42 +0000149 return dwarf::DW_TAG_variable;
150 }
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +0000151
Adrian Prantl857237e2015-07-13 18:25:29 +0000152 /// Return true if DbgVariable is artificial.
Eric Christophera5a79422013-12-09 23:32:48 +0000153 bool isArtificial() const {
Duncan P. N. Exon Smith7348dda2015-04-14 02:22:36 +0000154 if (Var->isArtificial())
Devang Pateld7d80aa2011-08-15 18:40:16 +0000155 return true;
Duncan P. N. Exon Smithb1055642015-04-16 01:01:28 +0000156 if (getType()->isArtificial())
Devang Pateld7d80aa2011-08-15 18:40:16 +0000157 return true;
158 return false;
159 }
Eric Christophere3417762012-09-12 23:36:19 +0000160
Eric Christophera5a79422013-12-09 23:32:48 +0000161 bool isObjectPointer() const {
Duncan P. N. Exon Smith7348dda2015-04-14 02:22:36 +0000162 if (Var->isObjectPointer())
Eric Christophere3417762012-09-12 23:36:19 +0000163 return true;
Duncan P. N. Exon Smithb1055642015-04-16 01:01:28 +0000164 if (getType()->isObjectPointer())
Eric Christophere3417762012-09-12 23:36:19 +0000165 return true;
166 return false;
167 }
Eric Christopher27527b22012-11-21 00:03:28 +0000168
Duncan P. N. Exon Smithe6cc5312015-06-21 16:50:43 +0000169 bool hasComplexAddress() const {
170 assert(MInsn && "Expected DBG_VALUE, not MMI variable");
Adrian Prantl67c24422017-02-17 19:42:32 +0000171 assert((FrameIndexExprs.empty() ||
172 (FrameIndexExprs.size() == 1 &&
173 FrameIndexExprs[0].Expr->getNumElements())) &&
174 "Invalid Expr for DBG_VALUE");
175 return !FrameIndexExprs.empty();
Devang Patelf20c4f72011-04-12 22:53:02 +0000176 }
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +0000177
Adrian Prantl1a1647c2014-03-18 02:34:58 +0000178 bool isBlockByrefVariable() const;
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000179 const DIType *getType() const;
Manman Renbe5576f2013-10-08 19:07:44 +0000180
181private:
Duncan P. N. Exon Smitha59d3e52016-04-23 21:08:00 +0000182 template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
183 return Ref.resolve();
184 }
Devang Patelf20c4f72011-04-12 22:53:02 +0000185};
186
Adrian Prantl857237e2015-07-13 18:25:29 +0000187/// Helper used to pair up a symbol and its DWARF compile unit.
Richard Mitton21101b32013-09-19 23:21:01 +0000188struct SymbolCU {
Eric Christopher4287a492013-12-09 23:57:44 +0000189 SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +0000190
Richard Mitton21101b32013-09-19 23:21:01 +0000191 const MCSymbol *Sym;
Eric Christopher4287a492013-12-09 23:57:44 +0000192 DwarfCompileUnit *CU;
Richard Mitton21101b32013-09-19 23:21:01 +0000193};
194
Pavel Labath6088c232018-04-04 14:42:14 +0000195/// The kind of accelerator tables we should emit.
196enum class AccelTableKind {
197 Default, ///< Platform default.
198 None, ///< None.
199 Apple, ///< .apple_names, .apple_namespaces, .apple_types, .apple_objc.
200 Dwarf, ///< DWARF v5 .debug_names.
201};
202
Adrian Prantl857237e2015-07-13 18:25:29 +0000203/// Collects and handles dwarf debug information.
Reid Klecknerf9c275f2016-02-10 20:55:49 +0000204class DwarfDebug : public DebugHandlerBase {
Adrian Prantl857237e2015-07-13 18:25:29 +0000205 /// All DIEValues are allocated through this allocator.
Benjamin Kramer07480082012-06-09 10:34:15 +0000206 BumpPtrAllocator DIEValueAllocator;
207
Adrian Prantl857237e2015-07-13 18:25:29 +0000208 /// Maps MDNode with its corresponding DwarfCompileUnit.
Eric Christopher179fba12014-01-29 22:06:23 +0000209 MapVector<const MDNode *, DwarfCompileUnit *> CUMap;
Bill Wendling2f921f82009-05-15 09:23:25 +0000210
Adrian Prantl857237e2015-07-13 18:25:29 +0000211 /// Maps a CU DIE with its corresponding DwarfCompileUnit.
Eric Christopher4287a492013-12-09 23:57:44 +0000212 DenseMap<const DIE *, DwarfCompileUnit *> CUDieMap;
Manman Rence20d462013-10-29 22:57:10 +0000213
Adrian Prantl857237e2015-07-13 18:25:29 +0000214 /// List of all labels used in aranges generation.
Alexey Samsonov4436bf02013-10-03 08:54:43 +0000215 std::vector<SymbolCU> ArangeLabels;
Richard Mitton21101b32013-09-19 23:21:01 +0000216
Adrian Prantl857237e2015-07-13 18:25:29 +0000217 /// Size of each symbol emitted (for those symbols that have a specific size).
Eric Christophera5a79422013-12-09 23:32:48 +0000218 DenseMap<const MCSymbol *, uint64_t> SymSize;
Richard Mitton089ed892013-09-23 17:56:20 +0000219
Adrian Prantl857237e2015-07-13 18:25:29 +0000220 /// Collection of abstract variables.
David Blaikieeb1a2722014-06-13 22:18:23 +0000221 SmallVector<std::unique_ptr<DbgVariable>, 64> ConcreteVariables;
Devang Patelf6eeaeb2009-11-10 23:06:00 +0000222
Adrian Prantl857237e2015-07-13 18:25:29 +0000223 /// Collection of DebugLocEntry. Stored in a linked list so that DIELocLists
224 /// can refer to them in spite of insertions into this list.
Duncan P. N. Exon Smith364a3002015-04-17 21:34:47 +0000225 DebugLocStream DebugLocs;
Devang Patel9fc11702010-05-25 23:40:22 +0000226
Adrian Prantl857237e2015-07-13 18:25:29 +0000227 /// This is a collection of subprogram MDNodes that are processed to
228 /// create DIEs.
David Blaikie38b74bf2016-12-15 23:37:38 +0000229 SetVector<const DISubprogram *, SmallVector<const DISubprogram *, 16>,
230 SmallPtrSet<const DISubprogram *, 16>>
231 ProcessedSPNodes;
Devang Patelf3b2db62010-06-28 18:25:03 +0000232
Adrian Prantl857237e2015-07-13 18:25:29 +0000233 /// If nonnull, stores the current machine function we're processing.
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +0000234 const MachineFunction *CurFn = nullptr;
Timur Iskhodzhanov1cd14442013-12-03 15:10:23 +0000235
Adrian Prantl857237e2015-07-13 18:25:29 +0000236 /// If nonnull, stores the CU in which the previous subprogram was contained.
Eric Christopher384f3fe2014-03-20 19:16:16 +0000237 const DwarfCompileUnit *PrevCU;
238
Adrian Prantl857237e2015-07-13 18:25:29 +0000239 /// As an optimization, there is no need to emit an entry in the directory
240 /// table for the same directory as DW_AT_comp_dir.
Nick Lewyckyd1ee7f82011-11-02 20:55:33 +0000241 StringRef CompilationDir;
242
Adrian Prantl857237e2015-07-13 18:25:29 +0000243 /// Holder for the file specific debug information.
Eric Christopherf8194852013-12-05 18:06:10 +0000244 DwarfFile InfoHolder;
Eric Christopherc8a310e2012-12-10 23:34:43 +0000245
Adrian Prantl857237e2015-07-13 18:25:29 +0000246 /// Holders for the various debug information flags that we might need to
247 /// have exposed. See accessor functions below for description.
David Blaikied51dea62015-07-01 18:07:16 +0000248
Peter Collingbourne7c384cc2016-02-11 19:57:46 +0000249 /// Map from MDNodes for user-defined types to their type signatures. Also
250 /// used to keep track of which types we have emitted type units for.
251 DenseMap<const MDNode *, uint64_t> TypeSignatures;
Eric Christopher67646432013-07-26 17:02:41 +0000252
Duncan P. N. Exon Smithc6246882015-04-20 21:17:32 +0000253 SmallVector<
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000254 std::pair<std::unique_ptr<DwarfTypeUnit>, const DICompositeType *>, 1>
Eric Christopherffc5ff32015-02-17 20:02:28 +0000255 TypeUnitsUnderConstruction;
David Blaikiee12b49a2014-04-26 17:27:38 +0000256
Adrian Prantl857237e2015-07-13 18:25:29 +0000257 /// Whether to use the GNU TLS opcode (instead of the standard opcode).
Paul Robinson78cc0822015-03-04 20:55:11 +0000258 bool UseGNUTLSOpcode;
259
Adrian Prantl6323ddf2016-05-17 21:07:16 +0000260 /// Whether to use DWARF 2 bitfields (instead of the DWARF 4 format).
261 bool UseDWARF2Bitfields;
262
Paul Robinson43d1e452016-04-18 22:41:41 +0000263 /// Whether to emit all linkage names, or just abstract subprograms.
264 bool UseAllLinkageNames;
Paul Robinson78046b42015-08-11 21:36:45 +0000265
Alexey Bataev0d6aead2018-02-20 15:28:08 +0000266 /// Use inlined strings.
267 bool UseInlineStrings = false;
268
Alexey Bataev648ed2d2018-03-20 16:04:40 +0000269 /// Whether to emit DWARF pub sections or not.
270 bool UsePubSections = true;
271
Alexey Bataev858a7dd2018-03-20 20:21:38 +0000272 /// Allow emission of .debug_ranges section.
273 bool UseRangesSection = true;
274
Alexey Bataevbff36082018-03-23 13:35:54 +0000275 /// True if the sections itself must be used as references and don't create
276 /// temp symbols inside DWARF sections.
277 bool UseSectionsAsReferences = false;
278
Adrian Prantl857237e2015-07-13 18:25:29 +0000279 /// DWARF5 Experimental Options
280 /// @{
Pavel Labath0cc03062018-04-04 14:54:08 +0000281 AccelTableKind TheAccelTableKind;
David Blaikiec53e18d2016-05-24 21:19:28 +0000282 bool HasAppleExtensionAttributes;
Eric Christophercdf218d2012-12-10 19:51:21 +0000283 bool HasSplitDwarf;
Manman Renac8062b2013-07-02 23:40:10 +0000284
Wolfgang Pieb456b5552018-01-26 18:52:58 +0000285 /// Whether to generate the DWARF v5 string offsets table.
286 /// It consists of a series of contributions, each preceded by a header.
287 /// The pre-DWARF v5 string offsets table for split dwarf is, in contrast,
288 /// a monolithic sequence of string offsets.
289 bool UseSegmentedStringOffsetsTable;
290
Adrian Prantl857237e2015-07-13 18:25:29 +0000291 /// Separated Dwarf Variables
292 /// In general these will all be for bits that are left in the
293 /// original object file, rather than things that are meant
294 /// to be in the .dwo sections.
Eric Christopherd79f5482012-12-10 19:51:13 +0000295
Adrian Prantl857237e2015-07-13 18:25:29 +0000296 /// Holder for the skeleton information.
Eric Christopherf8194852013-12-05 18:06:10 +0000297 DwarfFile SkeletonHolder;
Eric Christopherd79f5482012-12-10 19:51:13 +0000298
Adrian Prantl857237e2015-07-13 18:25:29 +0000299 /// Store file names for type units under fission in a line table
300 /// header that will be emitted into debug_line.dwo.
301 // FIXME: replace this with a map from comp_dir to table so that we
302 // can emit multiple tables during LTO each of which uses directory
303 // 0, referencing the comp_dir of all the type units that use it.
David Blaikie8287aff2014-03-18 02:13:23 +0000304 MCDwarfDwoLineTable SplitTypeUnitFileTable;
Adrian Prantl857237e2015-07-13 18:25:29 +0000305 /// @}
Jonas Devlieghere294e6892017-11-15 10:57:05 +0000306
Adrian Prantl857237e2015-07-13 18:25:29 +0000307 /// True iff there are multiple CUs in this module.
David Blaikie47f4b822014-03-19 00:11:28 +0000308 bool SingleCU;
David Blaikiee1c79742014-09-30 21:28:32 +0000309 bool IsDarwin;
David Blaikie47f4b822014-03-19 00:11:28 +0000310
David Blaikied75fb282014-04-23 21:20:10 +0000311 AddressPool AddrPool;
312
Pavel Labath6088c232018-04-04 14:42:14 +0000313 /// Accelerator tables.
314 AccelTable<DWARF5AccelTableData> AccelDebugNames;
Pavel Labatha7c457d2018-02-19 16:12:20 +0000315 AccelTable<AppleAccelTableOffsetData> AccelNames;
316 AccelTable<AppleAccelTableOffsetData> AccelObjC;
317 AccelTable<AppleAccelTableOffsetData> AccelNamespace;
318 AccelTable<AppleAccelTableTypeData> AccelTypes;
David Blaikie2406a0622014-04-23 23:37:35 +0000319
Paul Robinsonb9de1062015-07-15 22:04:54 +0000320 // Identify a debugger for "tuning" the debug info.
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +0000321 DebuggerKind DebuggerTuning = DebuggerKind::Default;
Paul Robinsonb9de1062015-07-15 22:04:54 +0000322
David Blaikie47f4b822014-03-19 00:11:28 +0000323 MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
324
Peter Collingbourne7c384cc2016-02-11 19:57:46 +0000325 const SmallVectorImpl<std::unique_ptr<DwarfCompileUnit>> &getUnits() {
Eric Christophera5a79422013-12-09 23:32:48 +0000326 return InfoHolder.getUnits();
327 }
David Blaikiefd1eff52013-11-26 19:14:34 +0000328
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +0000329 using InlinedVariable = DbgValueHistoryMap::InlinedVariable;
Duncan P. N. Exon Smith62e0f452015-04-15 22:29:27 +0000330
David Blaikie488393f2017-05-12 01:13:45 +0000331 void ensureAbstractVariableIsCreated(DwarfCompileUnit &CU, InlinedVariable Var,
David Blaikie6f9e8672014-06-13 23:52:55 +0000332 const MDNode *Scope);
David Blaikie488393f2017-05-12 01:13:45 +0000333 void ensureAbstractVariableIsCreatedIfScoped(DwarfCompileUnit &CU, InlinedVariable Var,
David Blaikie6f9e8672014-06-13 23:52:55 +0000334 const MDNode *Scope);
Devang Patelf6eeaeb2009-11-10 23:06:00 +0000335
David Blaikie488393f2017-05-12 01:13:45 +0000336 DbgVariable *createConcreteVariable(DwarfCompileUnit &TheCU,
337 LexicalScope &Scope, InlinedVariable IV);
Duncan P. N. Exon Smithe6cc5312015-06-21 16:50:43 +0000338
Adrian Prantl857237e2015-07-13 18:25:29 +0000339 /// Construct a DIE for this abstract scope.
David Blaikie488393f2017-05-12 01:13:45 +0000340 void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU, LexicalScope *Scope);
David Blaikie73cc7052014-10-09 20:36:27 +0000341
Pavel Labath3fb39c72018-04-18 12:11:59 +0000342 /// Helper function to add a name to the .debug_names table, using the
343 /// appropriate string pool.
344 void addAccelDebugName(StringRef Name, const DIE &Die);
345
David Blaikieeb1a2722014-06-13 22:18:23 +0000346 void finishVariableDefinitions();
347
David Blaikief7221ad2014-05-27 18:37:43 +0000348 void finishSubprogramDefinitions();
349
Adrian Prantl857237e2015-07-13 18:25:29 +0000350 /// Finish off debug information after all functions have been
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000351 /// processed.
Eric Christopher960ac372012-11-22 00:59:49 +0000352 void finalizeModuleInfo();
353
Adrian Prantl857237e2015-07-13 18:25:29 +0000354 /// Emit the debug info section.
Devang Patel930143b2009-11-21 02:48:08 +0000355 void emitDebugInfo();
Bill Wendling2f921f82009-05-15 09:23:25 +0000356
Adrian Prantl857237e2015-07-13 18:25:29 +0000357 /// Emit the abbreviation section.
Eric Christopher38371952012-11-20 23:30:11 +0000358 void emitAbbreviations();
Bill Wendling2f921f82009-05-15 09:23:25 +0000359
Wolfgang Pieb456b5552018-01-26 18:52:58 +0000360 /// Emit the string offsets table header.
361 void emitStringOffsetsTableHeader();
362
Adrian Prantl857237e2015-07-13 18:25:29 +0000363 /// Emit a specified accelerator table.
Jonas Devliegheree699dfa2018-01-29 14:52:34 +0000364 template <typename AccelTableT>
365 void emitAccel(AccelTableT &Accel, MCSection *Section, StringRef TableName);
David Blaikie6741bb02014-09-11 21:12:48 +0000366
Pavel Labath6088c232018-04-04 14:42:14 +0000367 /// Emit DWARF v5 accelerator table.
368 void emitAccelDebugNames();
369
Adrian Prantl857237e2015-07-13 18:25:29 +0000370 /// Emit visible names into a hashed accelerator table section.
Eric Christopher4996c702011-11-07 09:24:32 +0000371 void emitAccelNames();
Eric Christopher27527b22012-11-21 00:03:28 +0000372
Adrian Prantl857237e2015-07-13 18:25:29 +0000373 /// Emit objective C classes and categories into a hashed
Eric Christopher4996c702011-11-07 09:24:32 +0000374 /// accelerator table section.
375 void emitAccelObjC();
376
Adrian Prantl857237e2015-07-13 18:25:29 +0000377 /// Emit namespace dies into a hashed accelerator table.
Eric Christopher4996c702011-11-07 09:24:32 +0000378 void emitAccelNamespaces();
379
Adrian Prantl857237e2015-07-13 18:25:29 +0000380 /// Emit type dies into a hashed accelerator table.
Eric Christopher4996c702011-11-07 09:24:32 +0000381 void emitAccelTypes();
Eric Christopher27527b22012-11-21 00:03:28 +0000382
Peter Collingbourneb52e2362017-09-12 21:50:41 +0000383 /// Emit visible names and types into debug pubnames and pubtypes sections.
384 void emitDebugPubSections();
Krzysztof Parzyszek228daa62013-02-12 18:00:14 +0000385
Peter Collingbourneb52e2362017-09-12 21:50:41 +0000386 void emitDebugPubSection(bool GnuStyle, StringRef Name,
387 DwarfCompileUnit *TheU,
388 const StringMap<const DIE *> &Globals);
David Blaikie0f55e832014-03-11 23:18:15 +0000389
Amjad Aboudc0778412016-01-24 08:18:55 +0000390 /// Emit null-terminated strings into a debug str section.
Devang Patel930143b2009-11-21 02:48:08 +0000391 void emitDebugStr();
Bill Wendling2f921f82009-05-15 09:23:25 +0000392
Amjad Aboudd7cfb482016-01-07 14:28:20 +0000393 /// Emit variable locations into a debug loc section.
Devang Patel930143b2009-11-21 02:48:08 +0000394 void emitDebugLoc();
Bill Wendling2f921f82009-05-15 09:23:25 +0000395
Amjad Aboudd7cfb482016-01-07 14:28:20 +0000396 /// Emit variable locations into a debug loc dwo section.
David Blaikie94c1d7f2014-04-02 01:50:20 +0000397 void emitDebugLocDWO();
398
Amjad Aboudd7cfb482016-01-07 14:28:20 +0000399 /// Emit address ranges into a debug aranges section.
Eric Christopher7b30f2e42012-11-21 00:34:35 +0000400 void emitDebugARanges();
Bill Wendling2f921f82009-05-15 09:23:25 +0000401
Amjad Aboudd7cfb482016-01-07 14:28:20 +0000402 /// Emit address ranges into a debug ranges section.
Devang Patel930143b2009-11-21 02:48:08 +0000403 void emitDebugRanges();
Bill Wendling2f921f82009-05-15 09:23:25 +0000404
Amjad Aboudd7cfb482016-01-07 14:28:20 +0000405 /// Emit macros into a debug macinfo section.
406 void emitDebugMacinfo();
Amjad Aboud8bbce8a2016-02-01 14:09:41 +0000407 void emitMacro(DIMacro &M);
408 void emitMacroFile(DIMacroFile &F, DwarfCompileUnit &U);
409 void handleMacroNodes(DIMacroNodeArray Nodes, DwarfCompileUnit &U);
Amjad Aboudd7cfb482016-01-07 14:28:20 +0000410
Eric Christophercdf218d2012-12-10 19:51:21 +0000411 /// DWARF 5 Experimental Split Dwarf Emitters
Eric Christopher9c2ecd92012-11-30 23:59:06 +0000412
Adrian Prantl857237e2015-07-13 18:25:29 +0000413 /// Initialize common features of skeleton units.
David Blaikie65a74662014-04-25 18:26:14 +0000414 void initSkeletonUnit(const DwarfUnit &U, DIE &Die,
Peter Collingbourne7c384cc2016-02-11 19:57:46 +0000415 std::unique_ptr<DwarfCompileUnit> NewU);
David Blaikie38fe6342014-01-09 04:28:46 +0000416
Adrian Prantl857237e2015-07-13 18:25:29 +0000417 /// Construct the split debug info compile unit for the debug info
Eric Christophercdf218d2012-12-10 19:51:21 +0000418 /// section.
David Blaikief9b6a552014-04-22 22:39:41 +0000419 DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU);
Eric Christopher9c2ecd92012-11-30 23:59:06 +0000420
Adrian Prantl857237e2015-07-13 18:25:29 +0000421 /// Emit the debug info dwo section.
Eric Christopher9c2ecd92012-11-30 23:59:06 +0000422 void emitDebugInfoDWO();
423
Adrian Prantl857237e2015-07-13 18:25:29 +0000424 /// Emit the debug abbrev dwo section.
Eric Christopher3c5a1912012-12-19 22:02:53 +0000425 void emitDebugAbbrevDWO();
426
Adrian Prantl857237e2015-07-13 18:25:29 +0000427 /// Emit the debug line dwo section.
David Blaikie4a2f95f2014-03-18 01:17:26 +0000428 void emitDebugLineDWO();
429
Wolfgang Pieb456b5552018-01-26 18:52:58 +0000430 /// Emit the dwo stringoffsets table header.
431 void emitStringOffsetsTableHeaderDWO();
432
Adrian Prantl857237e2015-07-13 18:25:29 +0000433 /// Emit the debug str dwo section.
Eric Christopher3bf29fd2012-12-27 02:14:01 +0000434 void emitDebugStrDWO();
435
David Blaikie3c842622013-12-04 21:31:26 +0000436 /// Flags to let the linker know we have emitted new style pubnames. Only
437 /// emit it here if we don't have a skeleton CU for split dwarf.
David Blaikieb3cee2f2017-05-25 18:50:28 +0000438 void addGnuPubAttributes(DwarfCompileUnit &U, DIE &D) const;
David Blaikie3c842622013-12-04 21:31:26 +0000439
Adrian Prantl857237e2015-07-13 18:25:29 +0000440 /// Create new DwarfCompileUnit for the given metadata node with tag
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000441 /// DW_TAG_compile_unit.
David Blaikie07963bd2017-05-26 18:52:56 +0000442 DwarfCompileUnit &getOrCreateDwarfCompileUnit(const DICompileUnit *DIUnit);
Devang Patel1a0df9a2010-05-10 22:49:55 +0000443
Adrian Prantl857237e2015-07-13 18:25:29 +0000444 /// Construct imported_module or imported_declaration DIE.
David Blaikie8912df12014-08-31 05:41:15 +0000445 void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000446 const DIImportedEntity *N);
David Blaikie684fc532013-05-06 23:33:07 +0000447
Adrian Prantl857237e2015-07-13 18:25:29 +0000448 /// Register a source line with debug info. Returns the unique
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000449 /// label that was emitted and which provides correspondence to the
450 /// source line list.
Devang Patel34a66202011-05-11 19:22:19 +0000451 void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
452 unsigned Flags);
Eric Christopher27527b22012-11-21 00:03:28 +0000453
Adrian Prantl857237e2015-07-13 18:25:29 +0000454 /// Populate LexicalScope entries with variables' info.
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000455 void collectVariableInfo(DwarfCompileUnit &TheCU, const DISubprogram *SP,
Duncan P. N. Exon Smith62e0f452015-04-15 22:29:27 +0000456 DenseSet<InlinedVariable> &ProcessedVars);
Eric Christopher27527b22012-11-21 00:03:28 +0000457
Adrian Prantl857237e2015-07-13 18:25:29 +0000458 /// Build the location list for all DBG_VALUEs in the
Adrian Prantlb1416832014-08-01 22:11:58 +0000459 /// function that describe the same variable.
460 void buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
David Blaikiee1a26a62014-08-05 23:14:16 +0000461 const DbgValueHistoryMap::InstrRanges &Ranges);
Adrian Prantlb1416832014-08-01 22:11:58 +0000462
Matthias Braunef331ef2016-11-30 23:48:50 +0000463 /// Collect variable information from the side table maintained by MF.
David Blaikie488393f2017-05-12 01:13:45 +0000464 void collectVariableInfoFromMFTable(DwarfCompileUnit &TheCU,
465 DenseSet<InlinedVariable> &P);
Jakob Stoklund Olesen9a624fa2011-03-26 02:19:36 +0000466
Alexey Bataevbff36082018-03-23 13:35:54 +0000467 /// Emit the reference to the section.
468 void emitSectionReference(const DwarfCompileUnit &CU);
469
David Blaikieb2fbb4b2017-02-16 18:48:33 +0000470protected:
471 /// Gather pre-function debug information.
472 void beginFunctionImpl(const MachineFunction *MF) override;
473
474 /// Gather and emit post-function debug information.
475 void endFunctionImpl(const MachineFunction *MF) override;
476
477 void skippedNonDebugFunction() override;
478
Bill Wendling2f921f82009-05-15 09:23:25 +0000479public:
480 //===--------------------------------------------------------------------===//
481 // Main entry points.
482 //
Chris Lattnerf0d6bd32010-04-05 05:11:15 +0000483 DwarfDebug(AsmPrinter *A, Module *M);
Bill Wendling2f921f82009-05-15 09:23:25 +0000484
Reid Klecknerdd2647e2014-04-30 20:34:31 +0000485 ~DwarfDebug() override;
486
Adrian Prantl857237e2015-07-13 18:25:29 +0000487 /// Emit all Dwarf sections that should come prior to the
Bill Wendling2f921f82009-05-15 09:23:25 +0000488 /// content.
Eric Christopher58f41952012-11-19 22:42:15 +0000489 void beginModule();
Bill Wendling2f921f82009-05-15 09:23:25 +0000490
Adrian Prantl857237e2015-07-13 18:25:29 +0000491 /// Emit all Dwarf sections that should come after the content.
Craig Topper7b883b32014-03-08 06:31:39 +0000492 void endModule() override;
Bill Wendling2f921f82009-05-15 09:23:25 +0000493
Adrian Prantl857237e2015-07-13 18:25:29 +0000494 /// Process beginning of an instruction.
Craig Topper7b883b32014-03-08 06:31:39 +0000495 void beginInstruction(const MachineInstr *MI) override;
Bill Wendling2f921f82009-05-15 09:23:25 +0000496
Adrian Prantlee5feaf2015-07-15 17:01:41 +0000497 /// Perform an MD5 checksum of \p Identifier and return the lower 64 bits.
498 static uint64_t makeTypeSignature(StringRef Identifier);
499
Adrian Prantl857237e2015-07-13 18:25:29 +0000500 /// Add a DIE to the set of types that we're going to pull into
Eric Christopher67646432013-07-26 17:02:41 +0000501 /// type units.
David Blaikie15632ae2014-02-12 00:31:30 +0000502 void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000503 DIE &Die, const DICompositeType *CTy);
Eric Christopher67646432013-07-26 17:02:41 +0000504
Adrian Prantl857237e2015-07-13 18:25:29 +0000505 /// Add a label so that arange data can be generated for it.
Alexey Samsonov4436bf02013-10-03 08:54:43 +0000506 void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
Richard Mitton21101b32013-09-19 23:21:01 +0000507
Adrian Prantl857237e2015-07-13 18:25:29 +0000508 /// For symbols that have a size designated (e.g. common symbols),
Richard Mitton089ed892013-09-23 17:56:20 +0000509 /// this tracks that size.
Craig Topper7b883b32014-03-08 06:31:39 +0000510 void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {
Eric Christophera5a79422013-12-09 23:32:48 +0000511 SymSize[Sym] = Size;
512 }
Richard Mitton089ed892013-09-23 17:56:20 +0000513
Paul Robinson43d1e452016-04-18 22:41:41 +0000514 /// Returns whether we should emit all DW_AT_[MIPS_]linkage_name.
515 /// If not, we still might emit certain cases.
516 bool useAllLinkageNames() const { return UseAllLinkageNames; }
Paul Robinson78046b42015-08-11 21:36:45 +0000517
Adrian Prantl857237e2015-07-13 18:25:29 +0000518 /// Returns whether to use DW_OP_GNU_push_tls_address, instead of the
Paul Robinson78cc0822015-03-04 20:55:11 +0000519 /// standard DW_OP_form_tls_address opcode
520 bool useGNUTLSOpcode() const { return UseGNUTLSOpcode; }
521
Adrian Prantl6323ddf2016-05-17 21:07:16 +0000522 /// Returns whether to use the DWARF2 format for bitfields instyead of the
523 /// DWARF4 format.
524 bool useDWARF2Bitfields() const { return UseDWARF2Bitfields; }
525
Alexey Bataev0d6aead2018-02-20 15:28:08 +0000526 /// Returns whether to use inline strings.
527 bool useInlineStrings() const { return UseInlineStrings; }
528
Alexey Bataev648ed2d2018-03-20 16:04:40 +0000529 /// Returns whether GNU oub sections should be emitted.
530 bool usePubSections() const { return UsePubSections; }
531
Alexey Bataev858a7dd2018-03-20 20:21:38 +0000532 /// Returns whether ranges section should be emitted.
533 bool useRangesSection() const { return UseRangesSection; }
534
Alexey Bataevbff36082018-03-23 13:35:54 +0000535 /// Returns whether to use sections as labels rather than temp symbols.
536 bool useSectionsAsReferences() const {
537 return UseSectionsAsReferences;
538 }
539
Eric Christopher55c51812012-11-21 00:03:31 +0000540 // Experimental DWARF5 features.
541
Pavel Labath6088c232018-04-04 14:42:14 +0000542 /// Returns what kind (if any) of accelerator tables to emit.
Pavel Labath0cc03062018-04-04 14:54:08 +0000543 AccelTableKind getAccelTableKind() const { return TheAccelTableKind; }
Eric Christopher55c51812012-11-21 00:03:31 +0000544
David Blaikiec53e18d2016-05-24 21:19:28 +0000545 bool useAppleExtensionAttributes() const {
546 return HasAppleExtensionAttributes;
547 }
548
Adrian Prantl857237e2015-07-13 18:25:29 +0000549 /// Returns whether or not to change the current debug info for the
Eric Christophercdf218d2012-12-10 19:51:21 +0000550 /// split dwarf proposal support.
Eric Christopher411bd592014-03-06 00:00:53 +0000551 bool useSplitDwarf() const { return HasSplitDwarf; }
Manman Renac8062b2013-07-02 23:40:10 +0000552
Wolfgang Pieb456b5552018-01-26 18:52:58 +0000553 /// Returns whether to generate a string offsets table with (possibly shared)
554 /// contributions from each CU and type unit. This implies the use of
555 /// DW_FORM_strx* indirect references with DWARF v5 and beyond. Note that
556 /// DW_FORM_GNU_str_index is also an indirect reference, but it is used with
557 /// a pre-DWARF v5 implementation of split DWARF sections, which uses a
558 /// monolithic string offsets table.
559 bool useSegmentedStringOffsetsTable() const {
560 return UseSegmentedStringOffsetsTable;
561 }
562
David Blaikie488393f2017-05-12 01:13:45 +0000563 bool shareAcrossDWOCUs() const;
564
Manman Renac8062b2013-07-02 23:40:10 +0000565 /// Returns the Dwarf Version.
Greg Claytone6543972016-11-23 23:30:37 +0000566 uint16_t getDwarfVersion() const;
Manman Ren60352032013-09-05 18:48:31 +0000567
Eric Christopher384f3fe2014-03-20 19:16:16 +0000568 /// Returns the previous CU that was being updated
569 const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
David Blaikied0f10372014-09-09 23:13:01 +0000570 void setPrevCU(const DwarfCompileUnit *PrevCU) { this->PrevCU = PrevCU; }
Eric Christopher384f3fe2014-03-20 19:16:16 +0000571
Eric Christopher4f17ee02014-03-08 00:29:41 +0000572 /// Returns the entries for the .debug_loc section.
Duncan P. N. Exon Smith364a3002015-04-17 21:34:47 +0000573 const DebugLocStream &getDebugLocs() const { return DebugLocs; }
Eric Christopher4f17ee02014-03-08 00:29:41 +0000574
Adrian Prantl857237e2015-07-13 18:25:29 +0000575 /// Emit an entry for the debug loc section. This can be used to
Eric Christopher4f17ee02014-03-08 00:29:41 +0000576 /// handle an entry that's going to be emitted into the debug loc section.
Adrian Prantl92da14b2015-03-02 22:02:33 +0000577 void emitDebugLocEntry(ByteStreamer &Streamer,
Duncan P. N. Exon Smith364a3002015-04-17 21:34:47 +0000578 const DebugLocStream::Entry &Entry);
Eric Christopher4f17ee02014-03-08 00:29:41 +0000579
David Blaikie0e84adc2014-04-01 16:17:41 +0000580 /// Emit the location for a debug loc entry, including the size header.
Duncan P. N. Exon Smith364a3002015-04-17 21:34:47 +0000581 void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry);
David Blaikie0e84adc2014-04-01 16:17:41 +0000582
Eric Christopher87b9c492013-10-05 00:32:34 +0000583 /// Find the MDNode for the given reference.
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000584 template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
Duncan P. N. Exon Smitha59d3e52016-04-23 21:08:00 +0000585 return Ref.resolve();
Adrian Prantl1a1647c2014-03-18 02:34:58 +0000586 }
587
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000588 void addSubprogramNames(const DISubprogram *SP, DIE &Die);
David Blaikie2406a0622014-04-23 23:37:35 +0000589
David Blaikied75fb282014-04-23 21:20:10 +0000590 AddressPool &getAddressPool() { return AddrPool; }
David Blaikie2406a0622014-04-23 23:37:35 +0000591
David Blaikieb0b3fcf2014-04-25 18:52:29 +0000592 void addAccelName(StringRef Name, const DIE &Die);
David Blaikie0ee82b92014-04-24 00:53:32 +0000593
David Blaikieb0b3fcf2014-04-25 18:52:29 +0000594 void addAccelObjC(StringRef Name, const DIE &Die);
David Blaikieecf04152014-04-24 01:02:42 +0000595
David Blaikieb0b3fcf2014-04-25 18:52:29 +0000596 void addAccelNamespace(StringRef Name, const DIE &Die);
David Blaikie18d33752014-04-24 01:23:49 +0000597
David Blaikieb0b3fcf2014-04-25 18:52:29 +0000598 void addAccelType(StringRef Name, const DIE &Die, char Flags);
David Blaikiecda2aa82014-10-04 16:24:00 +0000599
600 const MachineFunction *getCurrentFunction() const { return CurFn; }
David Blaikie9c65b132014-10-08 22:20:02 +0000601
Adrian Prantl857237e2015-07-13 18:25:29 +0000602 /// A helper function to check whether the DIE for a given Scope is
David Blaikie9c65b132014-10-08 22:20:02 +0000603 /// going to be null.
604 bool isLexicalScopeDIENull(LexicalScope *Scope);
David Blaikieb3cee2f2017-05-25 18:50:28 +0000605
Jonas Devlieghere294e6892017-11-15 10:57:05 +0000606 /// Find the matching DwarfCompileUnit for the given CU DIE.
607 DwarfCompileUnit *lookupCU(const DIE *Die) { return CUDieMap.lookup(Die); }
Pavel Labath6088c232018-04-04 14:42:14 +0000608 const DwarfCompileUnit *lookupCU(const DIE *Die) const {
609 return CUDieMap.lookup(Die);
610 }
Jonas Devlieghere294e6892017-11-15 10:57:05 +0000611
Peter Collingbourneb52e2362017-09-12 21:50:41 +0000612 /// \defgroup DebuggerTuning Predicates to tune DWARF for a given debugger.
613 ///
614 /// Returns whether we are "tuning" for a given debugger.
615 /// @{
616 bool tuneForGDB() const { return DebuggerTuning == DebuggerKind::GDB; }
617 bool tuneForLLDB() const { return DebuggerTuning == DebuggerKind::LLDB; }
618 bool tuneForSCE() const { return DebuggerTuning == DebuggerKind::SCE; }
619 /// @}
Devang Patelf6eeaeb2009-11-10 23:06:00 +0000620};
Bill Wendling2f921f82009-05-15 09:23:25 +0000621
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +0000622} // end namespace llvm
623
624#endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H