1 //===- llvm/CodeGen/DwarfDebug.h - Dwarf Debug Framework --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains support for writing dwarf debug info into asm files.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
15 #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
17 #include "AddressPool.h"
18 #include "DebugLocStream.h"
19 #include "DwarfFile.h"
20 #include "llvm/ADT/ArrayRef.h"
21 #include "llvm/ADT/DenseMap.h"
22 #include "llvm/ADT/DenseSet.h"
23 #include "llvm/ADT/MapVector.h"
24 #include "llvm/ADT/STLExtras.h"
25 #include "llvm/ADT/SetVector.h"
26 #include "llvm/ADT/SmallPtrSet.h"
27 #include "llvm/ADT/SmallVector.h"
28 #include "llvm/ADT/StringMap.h"
29 #include "llvm/ADT/StringRef.h"
30 #include "llvm/BinaryFormat/Dwarf.h"
31 #include "llvm/CodeGen/AccelTable.h"
32 #include "llvm/CodeGen/DbgEntityHistoryCalculator.h"
33 #include "llvm/CodeGen/DebugHandlerBase.h"
34 #include "llvm/CodeGen/MachineInstr.h"
35 #include "llvm/IR/DebugInfoMetadata.h"
36 #include "llvm/IR/DebugLoc.h"
37 #include "llvm/IR/Metadata.h"
38 #include "llvm/MC/MCDwarf.h"
39 #include "llvm/Support/Allocator.h"
40 #include "llvm/Target/TargetOptions.h"
54 class DwarfCompileUnit;
58 class MachineFunction;
64 //===----------------------------------------------------------------------===//
65 /// This class is defined as the common parent of DbgVariable and DbgLabel
66 /// such that it could levarage polymorphism to extract common code for
67 /// DbgVariable and DbgLabel.
70 const DILocation *InlinedAt;
71 DIE *TheDIE = nullptr;
80 DbgEntity(const DINode *N, const DILocation *IA, unsigned ID)
81 : Entity(N), InlinedAt(IA), SubclassID(ID) {}
82 virtual ~DbgEntity() {}
86 const DINode *getEntity() const { return Entity; }
87 const DILocation *getInlinedAt() const { return InlinedAt; }
88 DIE *getDIE() const { return TheDIE; }
89 unsigned getDbgEntityID() const { return SubclassID; }
92 void setDIE(DIE &D) { TheDIE = &D; }
94 static bool classof(const DbgEntity *N) {
95 switch (N->getDbgEntityID()) {
105 //===----------------------------------------------------------------------===//
106 /// This class is used to track local variable information.
108 /// Variables can be created from allocas, in which case they're generated from
109 /// the MMI table. Such variables can have multiple expressions and frame
112 /// Variables can be created from \c DBG_VALUE instructions. Those whose
113 /// location changes over time use \a DebugLocListIndex, while those with a
114 /// single instruction use \a MInsn and (optionally) a single entry of \a Expr.
116 /// Variables that have been optimized out use none of these fields.
117 class DbgVariable : public DbgEntity {
118 unsigned DebugLocListIndex = ~0u; /// Offset in DebugLocs.
119 const MachineInstr *MInsn = nullptr; /// DBG_VALUE instruction.
121 struct FrameIndexExpr {
123 const DIExpression *Expr;
125 mutable SmallVector<FrameIndexExpr, 1>
126 FrameIndexExprs; /// Frame index + expression.
129 /// Construct a DbgVariable.
131 /// Creates a variable without any DW_AT_location. Call \a initializeMMI()
132 /// for MMI entries, or \a initializeDbgValue() for DBG_VALUE instructions.
133 DbgVariable(const DILocalVariable *V, const DILocation *IA)
134 : DbgEntity(V, IA, DbgVariableKind) {}
136 /// Initialize from the MMI table.
137 void initializeMMI(const DIExpression *E, int FI) {
138 assert(FrameIndexExprs.empty() && "Already initialized?");
139 assert(!MInsn && "Already initialized?");
141 assert((!E || E->isValid()) && "Expected valid expression");
142 assert(FI != std::numeric_limits<int>::max() && "Expected valid index");
144 FrameIndexExprs.push_back({FI, E});
147 /// Initialize from a DBG_VALUE instruction.
148 void initializeDbgValue(const MachineInstr *DbgValue) {
149 assert(FrameIndexExprs.empty() && "Already initialized?");
150 assert(!MInsn && "Already initialized?");
152 assert(getVariable() == DbgValue->getDebugVariable() && "Wrong variable");
153 assert(getInlinedAt() == DbgValue->getDebugLoc()->getInlinedAt() &&
157 if (auto *E = DbgValue->getDebugExpression())
158 if (E->getNumElements())
159 FrameIndexExprs.push_back({0, E});
163 const DILocalVariable *getVariable() const {
164 return cast<DILocalVariable>(getEntity());
167 const DIExpression *getSingleExpression() const {
168 assert(MInsn && FrameIndexExprs.size() <= 1);
169 return FrameIndexExprs.size() ? FrameIndexExprs[0].Expr : nullptr;
172 void setDebugLocListIndex(unsigned O) { DebugLocListIndex = O; }
173 unsigned getDebugLocListIndex() const { return DebugLocListIndex; }
174 StringRef getName() const { return getVariable()->getName(); }
175 const MachineInstr *getMInsn() const { return MInsn; }
176 /// Get the FI entries, sorted by fragment offset.
177 ArrayRef<FrameIndexExpr> getFrameIndexExprs() const;
178 bool hasFrameIndexExprs() const { return !FrameIndexExprs.empty(); }
179 void addMMIEntry(const DbgVariable &V);
181 // Translate tag to proper Dwarf tag.
182 dwarf::Tag getTag() const {
183 // FIXME: Why don't we just infer this tag and store it all along?
184 if (getVariable()->isParameter())
185 return dwarf::DW_TAG_formal_parameter;
187 return dwarf::DW_TAG_variable;
190 /// Return true if DbgVariable is artificial.
191 bool isArtificial() const {
192 if (getVariable()->isArtificial())
194 if (getType()->isArtificial())
199 bool isObjectPointer() const {
200 if (getVariable()->isObjectPointer())
202 if (getType()->isObjectPointer())
207 bool hasComplexAddress() const {
208 assert(MInsn && "Expected DBG_VALUE, not MMI variable");
209 assert((FrameIndexExprs.empty() ||
210 (FrameIndexExprs.size() == 1 &&
211 FrameIndexExprs[0].Expr->getNumElements())) &&
212 "Invalid Expr for DBG_VALUE");
213 return !FrameIndexExprs.empty();
216 bool isBlockByrefVariable() const;
217 const DIType *getType() const;
219 static bool classof(const DbgEntity *N) {
220 return N->getDbgEntityID() == DbgVariableKind;
224 template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
225 return Ref.resolve();
229 //===----------------------------------------------------------------------===//
230 /// This class is used to track label information.
232 /// Labels are collected from \c DBG_LABEL instructions.
233 class DbgLabel : public DbgEntity {
234 const MCSymbol *Sym; /// Symbol before DBG_LABEL instruction.
237 /// We need MCSymbol information to generate DW_AT_low_pc.
238 DbgLabel(const DILabel *L, const DILocation *IA, const MCSymbol *Sym = nullptr)
239 : DbgEntity(L, IA, DbgLabelKind), Sym(Sym) {}
243 const DILabel *getLabel() const { return cast<DILabel>(getEntity()); }
244 const MCSymbol *getSymbol() const { return Sym; }
246 StringRef getName() const { return getLabel()->getName(); }
249 /// Translate tag to proper Dwarf tag.
250 dwarf::Tag getTag() const {
251 return dwarf::DW_TAG_label;
254 static bool classof(const DbgEntity *N) {
255 return N->getDbgEntityID() == DbgLabelKind;
259 template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
260 return Ref.resolve();
264 /// Helper used to pair up a symbol and its DWARF compile unit.
266 SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
269 DwarfCompileUnit *CU;
272 /// The kind of accelerator tables we should emit.
273 enum class AccelTableKind {
274 Default, ///< Platform default.
276 Apple, ///< .apple_names, .apple_namespaces, .apple_types, .apple_objc.
277 Dwarf, ///< DWARF v5 .debug_names.
280 /// Collects and handles dwarf debug information.
281 class DwarfDebug : public DebugHandlerBase {
282 /// All DIEValues are allocated through this allocator.
283 BumpPtrAllocator DIEValueAllocator;
285 /// Maps MDNode with its corresponding DwarfCompileUnit.
286 MapVector<const MDNode *, DwarfCompileUnit *> CUMap;
288 /// Maps a CU DIE with its corresponding DwarfCompileUnit.
289 DenseMap<const DIE *, DwarfCompileUnit *> CUDieMap;
291 /// List of all labels used in aranges generation.
292 std::vector<SymbolCU> ArangeLabels;
294 /// Size of each symbol emitted (for those symbols that have a specific size).
295 DenseMap<const MCSymbol *, uint64_t> SymSize;
297 /// Collection of abstract variables/labels.
298 SmallVector<std::unique_ptr<DbgEntity>, 64> ConcreteEntities;
300 /// Collection of DebugLocEntry. Stored in a linked list so that DIELocLists
301 /// can refer to them in spite of insertions into this list.
302 DebugLocStream DebugLocs;
304 /// This is a collection of subprogram MDNodes that are processed to
306 SetVector<const DISubprogram *, SmallVector<const DISubprogram *, 16>,
307 SmallPtrSet<const DISubprogram *, 16>>
310 /// If nonnull, stores the current machine function we're processing.
311 const MachineFunction *CurFn = nullptr;
313 /// If nonnull, stores the CU in which the previous subprogram was contained.
314 const DwarfCompileUnit *PrevCU;
316 /// As an optimization, there is no need to emit an entry in the directory
317 /// table for the same directory as DW_AT_comp_dir.
318 StringRef CompilationDir;
320 /// Holder for the file specific debug information.
321 DwarfFile InfoHolder;
323 /// Holders for the various debug information flags that we might need to
324 /// have exposed. See accessor functions below for description.
326 /// Map from MDNodes for user-defined types to their type signatures. Also
327 /// used to keep track of which types we have emitted type units for.
328 DenseMap<const MDNode *, uint64_t> TypeSignatures;
330 DenseMap<const MCSection *, const MCSymbol *> SectionLabels;
333 std::pair<std::unique_ptr<DwarfTypeUnit>, const DICompositeType *>, 1>
334 TypeUnitsUnderConstruction;
336 /// Whether to use the GNU TLS opcode (instead of the standard opcode).
337 bool UseGNUTLSOpcode;
339 /// Whether to use DWARF 2 bitfields (instead of the DWARF 4 format).
340 bool UseDWARF2Bitfields;
342 /// Whether to emit all linkage names, or just abstract subprograms.
343 bool UseAllLinkageNames;
345 /// Use inlined strings.
346 bool UseInlineStrings = false;
348 /// Allow emission of .debug_ranges section.
349 bool UseRangesSection = true;
351 /// True if the sections itself must be used as references and don't create
352 /// temp symbols inside DWARF sections.
353 bool UseSectionsAsReferences = false;
355 ///Allow emission of the .debug_loc section.
356 bool UseLocSection = true;
358 /// Generate DWARF v4 type units.
359 bool GenerateTypeUnits;
361 /// DWARF5 Experimental Options
363 AccelTableKind TheAccelTableKind;
364 bool HasAppleExtensionAttributes;
367 /// Whether to generate the DWARF v5 string offsets table.
368 /// It consists of a series of contributions, each preceded by a header.
369 /// The pre-DWARF v5 string offsets table for split dwarf is, in contrast,
370 /// a monolithic sequence of string offsets.
371 bool UseSegmentedStringOffsetsTable;
373 /// Separated Dwarf Variables
374 /// In general these will all be for bits that are left in the
375 /// original object file, rather than things that are meant
376 /// to be in the .dwo sections.
378 /// Holder for the skeleton information.
379 DwarfFile SkeletonHolder;
381 /// Store file names for type units under fission in a line table
382 /// header that will be emitted into debug_line.dwo.
383 // FIXME: replace this with a map from comp_dir to table so that we
384 // can emit multiple tables during LTO each of which uses directory
385 // 0, referencing the comp_dir of all the type units that use it.
386 MCDwarfDwoLineTable SplitTypeUnitFileTable;
389 /// True iff there are multiple CUs in this module.
393 AddressPool AddrPool;
395 /// Accelerator tables.
396 AccelTable<DWARF5AccelTableData> AccelDebugNames;
397 AccelTable<AppleAccelTableOffsetData> AccelNames;
398 AccelTable<AppleAccelTableOffsetData> AccelObjC;
399 AccelTable<AppleAccelTableOffsetData> AccelNamespace;
400 AccelTable<AppleAccelTableTypeData> AccelTypes;
402 // Identify a debugger for "tuning" the debug info.
403 DebuggerKind DebuggerTuning = DebuggerKind::Default;
405 MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
407 const SmallVectorImpl<std::unique_ptr<DwarfCompileUnit>> &getUnits() {
408 return InfoHolder.getUnits();
411 using InlinedEntity = DbgValueHistoryMap::InlinedEntity;
413 void ensureAbstractEntityIsCreated(DwarfCompileUnit &CU,
415 const MDNode *Scope);
416 void ensureAbstractEntityIsCreatedIfScoped(DwarfCompileUnit &CU,
418 const MDNode *Scope);
420 DbgEntity *createConcreteEntity(DwarfCompileUnit &TheCU,
423 const DILocation *Location,
424 const MCSymbol *Sym = nullptr);
426 /// Construct a DIE for this abstract scope.
427 void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU, LexicalScope *Scope);
429 /// Construct DIEs for call site entries describing the calls in \p MF.
430 void constructCallSiteEntryDIEs(const DISubprogram &SP, DwarfCompileUnit &CU,
431 DIE &ScopeDIE, const MachineFunction &MF);
433 template <typename DataT>
434 void addAccelNameImpl(const DICompileUnit &CU, AccelTable<DataT> &AppleAccel,
435 StringRef Name, const DIE &Die);
437 void finishEntityDefinitions();
439 void finishSubprogramDefinitions();
441 /// Finish off debug information after all functions have been
443 void finalizeModuleInfo();
445 /// Emit the debug info section.
446 void emitDebugInfo();
448 /// Emit the abbreviation section.
449 void emitAbbreviations();
451 /// Emit the string offsets table header.
452 void emitStringOffsetsTableHeader();
454 /// Emit a specified accelerator table.
455 template <typename AccelTableT>
456 void emitAccel(AccelTableT &Accel, MCSection *Section, StringRef TableName);
458 /// Emit DWARF v5 accelerator table.
459 void emitAccelDebugNames();
461 /// Emit visible names into a hashed accelerator table section.
462 void emitAccelNames();
464 /// Emit objective C classes and categories into a hashed
465 /// accelerator table section.
466 void emitAccelObjC();
468 /// Emit namespace dies into a hashed accelerator table.
469 void emitAccelNamespaces();
471 /// Emit type dies into a hashed accelerator table.
472 void emitAccelTypes();
474 /// Emit visible names and types into debug pubnames and pubtypes sections.
475 void emitDebugPubSections();
477 void emitDebugPubSection(bool GnuStyle, StringRef Name,
478 DwarfCompileUnit *TheU,
479 const StringMap<const DIE *> &Globals);
481 /// Emit null-terminated strings into a debug str section.
484 /// Emit variable locations into a debug loc section.
487 /// Emit variable locations into a debug loc dwo section.
488 void emitDebugLocDWO();
490 /// Emit address ranges into a debug aranges section.
491 void emitDebugARanges();
493 /// Emit address ranges into a debug ranges section.
494 void emitDebugRanges();
495 void emitDebugRangesDWO();
497 /// Emit macros into a debug macinfo section.
498 void emitDebugMacinfo();
499 void emitMacro(DIMacro &M);
500 void emitMacroFile(DIMacroFile &F, DwarfCompileUnit &U);
501 void handleMacroNodes(DIMacroNodeArray Nodes, DwarfCompileUnit &U);
503 /// DWARF 5 Experimental Split Dwarf Emitters
505 /// Initialize common features of skeleton units.
506 void initSkeletonUnit(const DwarfUnit &U, DIE &Die,
507 std::unique_ptr<DwarfCompileUnit> NewU);
509 /// Construct the split debug info compile unit for the debug info section.
510 /// In DWARF v5, the skeleton unit DIE may have the following attributes:
511 /// DW_AT_addr_base, DW_AT_comp_dir, DW_AT_dwo_name, DW_AT_high_pc,
512 /// DW_AT_low_pc, DW_AT_ranges, DW_AT_stmt_list, and DW_AT_str_offsets_base.
513 /// Prior to DWARF v5 it may also have DW_AT_GNU_dwo_id. DW_AT_GNU_dwo_name
514 /// is used instead of DW_AT_dwo_name, Dw_AT_GNU_addr_base instead of
515 /// DW_AT_addr_base, and DW_AT_GNU_ranges_base instead of DW_AT_rnglists_base.
516 DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU);
518 /// Emit the debug info dwo section.
519 void emitDebugInfoDWO();
521 /// Emit the debug abbrev dwo section.
522 void emitDebugAbbrevDWO();
524 /// Emit the debug line dwo section.
525 void emitDebugLineDWO();
527 /// Emit the dwo stringoffsets table header.
528 void emitStringOffsetsTableHeaderDWO();
530 /// Emit the debug str dwo section.
531 void emitDebugStrDWO();
533 /// Emit DWO addresses.
534 void emitDebugAddr();
536 /// Flags to let the linker know we have emitted new style pubnames. Only
537 /// emit it here if we don't have a skeleton CU for split dwarf.
538 void addGnuPubAttributes(DwarfCompileUnit &U, DIE &D) const;
540 /// Create new DwarfCompileUnit for the given metadata node with tag
541 /// DW_TAG_compile_unit.
542 DwarfCompileUnit &getOrCreateDwarfCompileUnit(const DICompileUnit *DIUnit);
543 void finishUnitAttributes(const DICompileUnit *DIUnit,
544 DwarfCompileUnit &NewCU);
546 /// Construct imported_module or imported_declaration DIE.
547 void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
548 const DIImportedEntity *N);
550 /// Register a source line with debug info. Returns the unique
551 /// label that was emitted and which provides correspondence to the
552 /// source line list.
553 void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
556 /// Populate LexicalScope entries with variables' info.
557 void collectEntityInfo(DwarfCompileUnit &TheCU, const DISubprogram *SP,
558 DenseSet<InlinedEntity> &ProcessedVars);
560 /// Build the location list for all DBG_VALUEs in the
561 /// function that describe the same variable.
562 void buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
563 const DbgValueHistoryMap::InstrRanges &Ranges);
565 /// Collect variable information from the side table maintained by MF.
566 void collectVariableInfoFromMFTable(DwarfCompileUnit &TheCU,
567 DenseSet<InlinedEntity> &P);
569 /// Emit the reference to the section.
570 void emitSectionReference(const DwarfCompileUnit &CU);
573 /// Gather pre-function debug information.
574 void beginFunctionImpl(const MachineFunction *MF) override;
576 /// Gather and emit post-function debug information.
577 void endFunctionImpl(const MachineFunction *MF) override;
579 void skippedNonDebugFunction() override;
582 //===--------------------------------------------------------------------===//
583 // Main entry points.
585 DwarfDebug(AsmPrinter *A, Module *M);
587 ~DwarfDebug() override;
589 /// Emit all Dwarf sections that should come prior to the
593 /// Emit all Dwarf sections that should come after the content.
594 void endModule() override;
596 /// Process beginning of an instruction.
597 void beginInstruction(const MachineInstr *MI) override;
599 /// Perform an MD5 checksum of \p Identifier and return the lower 64 bits.
600 static uint64_t makeTypeSignature(StringRef Identifier);
602 /// Add a DIE to the set of types that we're going to pull into
604 void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
605 DIE &Die, const DICompositeType *CTy);
607 /// Add a label so that arange data can be generated for it.
608 void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
610 /// For symbols that have a size designated (e.g. common symbols),
611 /// this tracks that size.
612 void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {
616 /// Returns whether we should emit all DW_AT_[MIPS_]linkage_name.
617 /// If not, we still might emit certain cases.
618 bool useAllLinkageNames() const { return UseAllLinkageNames; }
620 /// Returns whether to use DW_OP_GNU_push_tls_address, instead of the
621 /// standard DW_OP_form_tls_address opcode
622 bool useGNUTLSOpcode() const { return UseGNUTLSOpcode; }
624 /// Returns whether to use the DWARF2 format for bitfields instyead of the
626 bool useDWARF2Bitfields() const { return UseDWARF2Bitfields; }
628 /// Returns whether to use inline strings.
629 bool useInlineStrings() const { return UseInlineStrings; }
631 /// Returns whether ranges section should be emitted.
632 bool useRangesSection() const { return UseRangesSection; }
634 /// Returns whether to use sections as labels rather than temp symbols.
635 bool useSectionsAsReferences() const {
636 return UseSectionsAsReferences;
639 /// Returns whether .debug_loc section should be emitted.
640 bool useLocSection() const { return UseLocSection; }
642 /// Returns whether to generate DWARF v4 type units.
643 bool generateTypeUnits() const { return GenerateTypeUnits; }
645 // Experimental DWARF5 features.
647 /// Returns what kind (if any) of accelerator tables to emit.
648 AccelTableKind getAccelTableKind() const { return TheAccelTableKind; }
650 bool useAppleExtensionAttributes() const {
651 return HasAppleExtensionAttributes;
654 /// Returns whether or not to change the current debug info for the
655 /// split dwarf proposal support.
656 bool useSplitDwarf() const { return HasSplitDwarf; }
658 /// Returns whether to generate a string offsets table with (possibly shared)
659 /// contributions from each CU and type unit. This implies the use of
660 /// DW_FORM_strx* indirect references with DWARF v5 and beyond. Note that
661 /// DW_FORM_GNU_str_index is also an indirect reference, but it is used with
662 /// a pre-DWARF v5 implementation of split DWARF sections, which uses a
663 /// monolithic string offsets table.
664 bool useSegmentedStringOffsetsTable() const {
665 return UseSegmentedStringOffsetsTable;
668 bool shareAcrossDWOCUs() const;
670 /// Returns the Dwarf Version.
671 uint16_t getDwarfVersion() const;
673 /// Returns the previous CU that was being updated
674 const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
675 void setPrevCU(const DwarfCompileUnit *PrevCU) { this->PrevCU = PrevCU; }
677 /// Returns the entries for the .debug_loc section.
678 const DebugLocStream &getDebugLocs() const { return DebugLocs; }
680 /// Emit an entry for the debug loc section. This can be used to
681 /// handle an entry that's going to be emitted into the debug loc section.
682 void emitDebugLocEntry(ByteStreamer &Streamer,
683 const DebugLocStream::Entry &Entry);
685 /// Emit the location for a debug loc entry, including the size header.
686 void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry);
688 /// Find the MDNode for the given reference.
689 template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
690 return Ref.resolve();
693 void addSubprogramNames(const DICompileUnit &CU, const DISubprogram *SP,
696 AddressPool &getAddressPool() { return AddrPool; }
698 void addAccelName(const DICompileUnit &CU, StringRef Name, const DIE &Die);
700 void addAccelObjC(const DICompileUnit &CU, StringRef Name, const DIE &Die);
702 void addAccelNamespace(const DICompileUnit &CU, StringRef Name,
705 void addAccelType(const DICompileUnit &CU, StringRef Name, const DIE &Die,
708 const MachineFunction *getCurrentFunction() const { return CurFn; }
710 /// A helper function to check whether the DIE for a given Scope is
711 /// going to be null.
712 bool isLexicalScopeDIENull(LexicalScope *Scope);
714 /// Find the matching DwarfCompileUnit for the given CU DIE.
715 DwarfCompileUnit *lookupCU(const DIE *Die) { return CUDieMap.lookup(Die); }
716 const DwarfCompileUnit *lookupCU(const DIE *Die) const {
717 return CUDieMap.lookup(Die);
720 /// \defgroup DebuggerTuning Predicates to tune DWARF for a given debugger.
722 /// Returns whether we are "tuning" for a given debugger.
724 bool tuneForGDB() const { return DebuggerTuning == DebuggerKind::GDB; }
725 bool tuneForLLDB() const { return DebuggerTuning == DebuggerKind::LLDB; }
726 bool tuneForSCE() const { return DebuggerTuning == DebuggerKind::SCE; }
729 void addSectionLabel(const MCSymbol *Sym);
730 const MCSymbol *getSectionLabel(const MCSection *S);
733 } // end namespace llvm
735 #endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H