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 CODEGEN_ASMPRINTER_DWARFDEBUG_H__
15 #define CODEGEN_ASMPRINTER_DWARFDEBUG_H__
17 #include "AsmPrinterHandler.h"
19 #include "DebugLocEntry.h"
20 #include "DebugLocList.h"
21 #include "llvm/ADT/DenseMap.h"
22 #include "llvm/ADT/MapVector.h"
23 #include "llvm/ADT/SmallPtrSet.h"
24 #include "llvm/ADT/StringMap.h"
25 #include "llvm/ADT/FoldingSet.h"
26 #include "llvm/CodeGen/LexicalScopes.h"
27 #include "llvm/IR/DebugInfo.h"
28 #include "llvm/IR/DebugLoc.h"
29 #include "llvm/MC/MachineLocation.h"
30 #include "llvm/MC/MCDwarf.h"
31 #include "llvm/Support/Allocator.h"
41 class DwarfCompileUnit;
45 class MachineModuleInfo;
47 //===----------------------------------------------------------------------===//
48 /// \brief This class is used to record source line correspondence.
50 unsigned Line; // Source line number.
51 unsigned Column; // Source column.
52 unsigned SourceID; // Source ID number.
53 MCSymbol *Label; // Label in code ID number.
55 SrcLineInfo(unsigned L, unsigned C, unsigned S, MCSymbol *label)
56 : Line(L), Column(C), SourceID(S), Label(label) {}
59 unsigned getLine() const { return Line; }
60 unsigned getColumn() const { return Column; }
61 unsigned getSourceID() const { return SourceID; }
62 MCSymbol *getLabel() const { return Label; }
65 //===----------------------------------------------------------------------===//
66 /// \brief This class is used to track local variable information.
68 DIVariable Var; // Variable Descriptor.
69 DIE *TheDIE; // Variable DIE.
70 unsigned DotDebugLocOffset; // Offset in DotDebugLocEntries.
71 DbgVariable *AbsVar; // Corresponding Abstract variable, if any.
72 const MachineInstr *MInsn; // DBG_VALUE instruction of the variable.
77 // AbsVar may be NULL.
78 DbgVariable(DIVariable V, DbgVariable *AV, DwarfDebug *DD)
79 : Var(V), TheDIE(0), DotDebugLocOffset(~0U), AbsVar(AV), MInsn(0),
80 FrameIndex(~0), DD(DD) {}
83 DIVariable getVariable() const { return Var; }
84 void setDIE(DIE *D) { TheDIE = D; }
85 DIE *getDIE() const { return TheDIE; }
86 void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; }
87 unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; }
88 StringRef getName() const { return Var.getName(); }
89 DbgVariable *getAbstractVariable() const { return AbsVar; }
90 const MachineInstr *getMInsn() const { return MInsn; }
91 void setMInsn(const MachineInstr *M) { MInsn = M; }
92 int getFrameIndex() const { return FrameIndex; }
93 void setFrameIndex(int FI) { FrameIndex = FI; }
94 // Translate tag to proper Dwarf tag.
95 dwarf::Tag getTag() const {
96 if (Var.getTag() == dwarf::DW_TAG_arg_variable)
97 return dwarf::DW_TAG_formal_parameter;
99 return dwarf::DW_TAG_variable;
101 /// \brief Return true if DbgVariable is artificial.
102 bool isArtificial() const {
103 if (Var.isArtificial())
105 if (getType().isArtificial())
110 bool isObjectPointer() const {
111 if (Var.isObjectPointer())
113 if (getType().isObjectPointer())
118 bool variableHasComplexAddress() const {
119 assert(Var.isVariable() && "Invalid complex DbgVariable!");
120 return Var.hasComplexAddress();
122 bool isBlockByrefVariable() const;
123 unsigned getNumAddrElements() const {
124 assert(Var.isVariable() && "Invalid complex DbgVariable!");
125 return Var.getNumAddrElements();
127 uint64_t getAddrElement(unsigned i) const { return Var.getAddrElement(i); }
128 DIType getType() const;
131 /// resolve - Look in the DwarfDebug map for the MDNode that
132 /// corresponds to the reference.
133 template <typename T> T resolve(DIRef<T> Ref) const;
136 /// \brief Collects and handles information specific to a particular
137 /// collection of units. This collection represents all of the units
138 /// that will be ultimately output into a single object file.
140 // Target of Dwarf emission, used for sizing of abbreviations.
143 // Used to uniquely define abbreviations.
144 FoldingSet<DIEAbbrev> AbbreviationsSet;
146 // A list of all the unique abbreviations in use.
147 std::vector<DIEAbbrev *> Abbreviations;
149 // A pointer to all units in the section.
150 SmallVector<DwarfUnit *, 1> CUs;
152 // Collection of strings for this unit and assorted symbols.
153 // A String->Symbol mapping of strings used by indirect
155 typedef StringMap<std::pair<MCSymbol *, unsigned>, BumpPtrAllocator &>
158 unsigned NextStringPoolNumber;
159 std::string StringPref;
161 struct AddressPoolEntry {
164 AddressPoolEntry(unsigned Number, bool TLS) : Number(Number), TLS(TLS) {}
166 // Collection of addresses for this unit and assorted labels.
167 // A Symbol->unsigned mapping of addresses used by indirect
169 typedef DenseMap<const MCSymbol *, AddressPoolEntry> AddrPool;
170 AddrPool AddressPool;
171 unsigned NextAddrPoolNumber;
174 DwarfFile(AsmPrinter *AP, const char *Pref, BumpPtrAllocator &DA)
175 : Asm(AP), StringPool(DA), NextStringPoolNumber(0), StringPref(Pref),
176 AddressPool(), NextAddrPoolNumber(0) {}
180 const SmallVectorImpl<DwarfUnit *> &getUnits() { return CUs; }
182 /// \brief Compute the size and offset of a DIE given an incoming Offset.
183 unsigned computeSizeAndOffset(DIE &Die, unsigned Offset);
185 /// \brief Compute the size and offset of all the DIEs.
186 void computeSizeAndOffsets();
188 /// \brief Define a unique number for the abbreviation.
189 void assignAbbrevNumber(DIEAbbrev &Abbrev);
191 /// \brief Add a unit to the list of CUs.
192 void addUnit(DwarfUnit *CU) { CUs.push_back(CU); }
194 /// \brief Emit all of the units to the section listed with the given
195 /// abbreviation section.
196 void emitUnits(DwarfDebug *DD, const MCSymbol *ASectionSym);
198 /// \brief Emit a set of abbreviations to the specific section.
199 void emitAbbrevs(const MCSection *);
201 /// \brief Emit all of the strings to the section given.
202 void emitStrings(const MCSection *StrSection, const MCSection *OffsetSection,
203 const MCSymbol *StrSecSym);
205 /// \brief Emit all of the addresses to the section given.
206 void emitAddresses(const MCSection *AddrSection);
208 /// \brief Returns the entry into the start of the pool.
209 MCSymbol *getStringPoolSym();
211 /// \brief Returns an entry into the string pool with the given
213 MCSymbol *getStringPoolEntry(StringRef Str);
215 /// \brief Returns the index into the string pool with the given
217 unsigned getStringPoolIndex(StringRef Str);
219 /// \brief Returns the string pool.
220 StrPool *getStringPool() { return &StringPool; }
222 /// \brief Returns the index into the address pool with the given
224 unsigned getAddrPoolIndex(const MCSymbol *Sym, bool TLS = false);
226 /// \brief Returns the address pool.
227 AddrPool *getAddrPool() { return &AddressPool; }
230 /// \brief Helper used to pair up a symbol and its DWARF compile unit.
232 SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
234 DwarfCompileUnit *CU;
237 /// \brief Collects and handles dwarf debug information.
238 class DwarfDebug : public AsmPrinterHandler {
239 // Target of Dwarf emission.
242 // Collected machine module information.
243 MachineModuleInfo *MMI;
245 // All DIEValues are allocated through this allocator.
246 BumpPtrAllocator DIEValueAllocator;
248 // Handle to the compile unit used for the inline extension handling,
249 // this is just so that the DIEValue allocator has a place to store
250 // the particular elements.
251 // FIXME: Store these off of DwarfDebug instead?
252 DwarfCompileUnit *FirstCU;
254 // Maps MDNode with its corresponding DwarfCompileUnit.
255 MapVector<const MDNode *, DwarfCompileUnit *> CUMap;
257 // Maps subprogram MDNode with its corresponding DwarfCompileUnit.
258 DenseMap<const MDNode *, DwarfCompileUnit *> SPMap;
260 // Maps a CU DIE with its corresponding DwarfCompileUnit.
261 DenseMap<const DIE *, DwarfCompileUnit *> CUDieMap;
263 /// Maps MDNodes for type system with the corresponding DIEs. These DIEs can
264 /// be shared across CUs, that is why we keep the map here instead
265 /// of in DwarfCompileUnit.
266 DenseMap<const MDNode *, DIE *> MDTypeNodeToDieMap;
268 // List of all labels used in aranges generation.
269 std::vector<SymbolCU> ArangeLabels;
271 // Size of each symbol emitted (for those symbols that have a specific size).
272 DenseMap<const MCSymbol *, uint64_t> SymSize;
274 // Provides a unique id per text section.
275 typedef DenseMap<const MCSection *, SmallVector<SymbolCU, 8> > SectionMapType;
276 SectionMapType SectionMap;
278 // List of arguments for current function.
279 // Linked list use to maintain pointer validity. Singly linked list could
280 // suffice with some contortions to addCurrentFnArgument.
281 std::list<DbgVariable> CurrentFnArguments;
283 LexicalScopes LScopes;
285 // Collection of abstract subprogram DIEs.
286 DenseMap<const MDNode *, DIE *> AbstractSPDies;
288 // Collection of dbg variables of a scope.
289 // Linked list use to maintain pointer validity. Singly linked list could
290 // suffice with some contortions to addScopeVariable.
291 typedef DenseMap<LexicalScope *, std::list<DbgVariable>>
293 ScopeVariablesMap ScopeVariables;
295 // Collection of abstract variables.
296 DenseMap<const MDNode *, DbgVariable *> AbstractVariables;
298 // Collection of DebugLocEntry. Stored in a linked list so that DIELocLists
299 // can refer to them in spite of insertions into this list.
300 SmallVector<DebugLocList, 4> DotDebugLocEntries;
302 // Collection of subprogram DIEs that are marked (at the end of the module)
304 SmallPtrSet<DIE *, 4> InlinedSubprogramDIEs;
306 // This is a collection of subprogram MDNodes that are processed to
308 SmallPtrSet<const MDNode *, 16> ProcessedSPNodes;
310 // Maps instruction with label emitted before instruction.
311 DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn;
313 // Maps instruction with label emitted after instruction.
314 DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn;
316 // Every user variable mentioned by a DBG_VALUE instruction in order of
318 SmallVector<const MDNode *, 8> UserVariables;
320 // For each user variable, keep a list of DBG_VALUE instructions in order.
321 // The list can also contain normal instructions that clobber the previous
323 typedef DenseMap<const MDNode *, SmallVector<const MachineInstr *, 4> >
325 DbgValueHistoryMap DbgValues;
327 // Previous instruction's location information. This is used to determine
328 // label location to indicate scope boundries in dwarf debug info.
329 DebugLoc PrevInstLoc;
332 // This location indicates end of function prologue and beginning of function
334 DebugLoc PrologEndLoc;
336 // If nonnull, stores the current machine function we're processing.
337 const MachineFunction *CurFn;
339 // If nonnull, stores the current machine instruction we're processing.
340 const MachineInstr *CurMI;
342 // If nonnull, stores the section that the previous function was allocated to
344 const MCSection *PrevSection;
346 // If nonnull, stores the CU in which the previous subprogram was contained.
347 const DwarfCompileUnit *PrevCU;
349 // Section Symbols: these are assembler temporary labels that are emitted at
350 // the beginning of each supported dwarf section. These are used to form
351 // section offsets and are created by EmitSectionLabels.
352 MCSymbol *DwarfInfoSectionSym, *DwarfAbbrevSectionSym;
353 MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym;
354 MCSymbol *DwarfDebugLocSectionSym, *DwarfLineSectionSym, *DwarfAddrSectionSym;
355 MCSymbol *FunctionBeginSym, *FunctionEndSym;
356 MCSymbol *DwarfInfoDWOSectionSym, *DwarfAbbrevDWOSectionSym;
357 MCSymbol *DwarfStrDWOSectionSym;
358 MCSymbol *DwarfGnuPubNamesSectionSym, *DwarfGnuPubTypesSectionSym;
360 // As an optimization, there is no need to emit an entry in the directory
361 // table for the same directory as DW_AT_comp_dir.
362 StringRef CompilationDir;
364 // Counter for assigning globally unique IDs for ranges.
365 unsigned GlobalRangeCount;
367 // Holder for the file specific debug information.
368 DwarfFile InfoHolder;
370 // Holders for the various debug information flags that we might need to
371 // have exposed. See accessor functions below for description.
373 // Holder for imported entities.
374 typedef SmallVector<std::pair<const MDNode *, const MDNode *>, 32>
376 ImportedEntityMap ScopesWithImportedEntities;
378 // Map from MDNodes for user-defined types to the type units that describe
380 DenseMap<const MDNode *, const DwarfTypeUnit *> DwarfTypeUnits;
382 // Whether to emit the pubnames/pubtypes sections.
383 bool HasDwarfPubSections;
385 // Whether or not to use AT_ranges for compilation units.
388 // Whether we emitted a function into a section other than the default
390 bool UsedNonDefaultText;
392 // Version of dwarf we're emitting.
393 unsigned DwarfVersion;
395 // Maps from a type identifier to the actual MDNode.
396 DITypeIdentifierMap TypeIdentifierMap;
398 // DWARF5 Experimental Options
399 bool HasDwarfAccelTables;
402 // Separated Dwarf Variables
403 // In general these will all be for bits that are left in the
404 // original object file, rather than things that are meant
405 // to be in the .dwo sections.
407 // Holder for the skeleton information.
408 DwarfFile SkeletonHolder;
410 /// Store file names for type units under fission in a line table header that
411 /// will be emitted into debug_line.dwo.
412 // FIXME: replace this with a map from comp_dir to table so that we can emit
413 // multiple tables during LTO each of which uses directory 0, referencing the
414 // comp_dir of all the type units that use it.
415 MCDwarfDwoLineTable SplitTypeUnitFileTable;
417 // True iff there are multiple CUs in this module.
420 MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
422 DbgVariable &addScopeVariable(LexicalScope *LS, DbgVariable Var);
424 const SmallVectorImpl<DwarfUnit *> &getUnits() {
425 return InfoHolder.getUnits();
428 /// \brief Find abstract variable associated with Var.
429 DbgVariable *findAbstractVariable(DIVariable &Var, DebugLoc Loc);
431 /// \brief Find DIE for the given subprogram and attach appropriate
432 /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
433 /// variables in this scope then create and insert DIEs for these
435 DIE *updateSubprogramScopeDIE(DwarfCompileUnit *SPCU, DISubprogram SP);
437 /// \brief A helper function to check whether the DIE for a given Scope is
438 /// going to be null.
439 bool isLexicalScopeDIENull(LexicalScope *Scope);
441 /// \brief A helper function to construct a RangeSpanList for a given
443 void addScopeRangeList(DwarfCompileUnit *TheCU, DIE *ScopeDIE,
444 const SmallVectorImpl<InsnRange> &Range);
446 /// \brief Construct new DW_TAG_lexical_block for this scope and
447 /// attach DW_AT_low_pc/DW_AT_high_pc labels.
448 DIE *constructLexicalScopeDIE(DwarfCompileUnit *TheCU, LexicalScope *Scope);
450 /// \brief This scope represents inlined body of a function. Construct
451 /// DIE to represent this concrete inlined copy of the function.
452 DIE *constructInlinedScopeDIE(DwarfCompileUnit *TheCU, LexicalScope *Scope);
454 /// \brief Construct a DIE for this scope.
455 DIE *constructScopeDIE(DwarfCompileUnit *TheCU, LexicalScope *Scope);
456 /// A helper function to create children of a Scope DIE.
457 DIE *createScopeChildrenDIE(DwarfCompileUnit *TheCU, LexicalScope *Scope,
458 SmallVectorImpl<DIE *> &Children);
460 /// \brief Emit initial Dwarf sections with a label at the start of each one.
461 void emitSectionLabels();
463 /// \brief Compute the size and offset of a DIE given an incoming Offset.
464 unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
466 /// \brief Compute the size and offset of all the DIEs.
467 void computeSizeAndOffsets();
469 /// \brief Attach DW_AT_inline attribute with inlined subprogram DIEs.
470 void computeInlinedDIEs();
472 /// \brief Collect info for variables that were optimized out.
473 void collectDeadVariables();
475 /// \brief Finish off debug information after all functions have been
477 void finalizeModuleInfo();
479 /// \brief Emit labels to close any remaining sections that have been left
483 /// \brief Emit the debug info section.
484 void emitDebugInfo();
486 /// \brief Emit the abbreviation section.
487 void emitAbbreviations();
489 /// \brief Emit the last address of the section and the end of
491 void emitEndOfLineMatrix(unsigned SectionEnd);
493 /// \brief Emit visible names into a hashed accelerator table section.
494 void emitAccelNames();
496 /// \brief Emit objective C classes and categories into a hashed
497 /// accelerator table section.
498 void emitAccelObjC();
500 /// \brief Emit namespace dies into a hashed accelerator table.
501 void emitAccelNamespaces();
503 /// \brief Emit type dies into a hashed accelerator table.
504 void emitAccelTypes();
506 /// \brief Emit visible names into a debug pubnames section.
507 /// \param GnuStyle determines whether or not we want to emit
508 /// additional information into the table ala newer gcc for gdb
510 void emitDebugPubNames(bool GnuStyle = false);
512 /// \brief Emit visible types into a debug pubtypes section.
513 /// \param GnuStyle determines whether or not we want to emit
514 /// additional information into the table ala newer gcc for gdb
516 void emitDebugPubTypes(bool GnuStyle = false);
519 emitDebugPubSection(bool GnuStyle, const MCSection *PSec, StringRef Name,
520 const StringMap<const DIE *> &(DwarfUnit::*Accessor)()
523 /// \brief Emit visible names into a debug str section.
526 /// \brief Emit visible names into a debug loc section.
529 /// \brief Emit visible names into a debug loc dwo section.
530 void emitDebugLocDWO();
532 /// \brief Emit visible names into a debug aranges section.
533 void emitDebugARanges();
535 /// \brief Emit visible names into a debug ranges section.
536 void emitDebugRanges();
538 /// \brief Emit inline info using custom format.
539 void emitDebugInlineInfo();
541 /// DWARF 5 Experimental Split Dwarf Emitters
543 /// \brief Initialize common features of skeleton units.
544 void initSkeletonUnit(const DwarfUnit *U, DIE *Die, DwarfUnit *NewU);
546 /// \brief Construct the split debug info compile unit for the debug info
548 DwarfCompileUnit *constructSkeletonCU(const DwarfCompileUnit *CU);
550 /// \brief Construct the split debug info compile unit for the debug info
552 DwarfTypeUnit *constructSkeletonTU(DwarfTypeUnit *TU);
554 /// \brief Emit the debug info dwo section.
555 void emitDebugInfoDWO();
557 /// \brief Emit the debug abbrev dwo section.
558 void emitDebugAbbrevDWO();
560 /// \brief Emit the debug line dwo section.
561 void emitDebugLineDWO();
563 /// \brief Emit the debug str dwo section.
564 void emitDebugStrDWO();
566 /// Flags to let the linker know we have emitted new style pubnames. Only
567 /// emit it here if we don't have a skeleton CU for split dwarf.
568 void addGnuPubAttributes(DwarfUnit *U, DIE *D) const;
570 /// \brief Create new DwarfCompileUnit for the given metadata node with tag
571 /// DW_TAG_compile_unit.
572 DwarfCompileUnit *constructDwarfCompileUnit(DICompileUnit DIUnit);
574 /// \brief Construct subprogram DIE.
575 void constructSubprogramDIE(DwarfCompileUnit *TheCU, const MDNode *N);
577 /// \brief Construct imported_module or imported_declaration DIE.
578 void constructImportedEntityDIE(DwarfCompileUnit *TheCU, const MDNode *N);
580 /// \brief Construct import_module DIE.
581 void constructImportedEntityDIE(DwarfCompileUnit *TheCU, const MDNode *N,
584 /// \brief Construct import_module DIE.
585 void constructImportedEntityDIE(DwarfCompileUnit *TheCU,
586 const DIImportedEntity &Module, DIE *Context);
588 /// \brief Register a source line with debug info. Returns the unique
589 /// label that was emitted and which provides correspondence to the
590 /// source line list.
591 void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
594 /// \brief Indentify instructions that are marking the beginning of or
595 /// ending of a scope.
596 void identifyScopeMarkers();
598 /// \brief If Var is an current function argument that add it in
599 /// CurrentFnArguments list.
600 DbgVariable *addCurrentFnArgument(DbgVariable &Var, LexicalScope *Scope);
602 DbgVariable &addVariable(DbgVariable Var, LexicalScope *Scope);
604 /// \brief Populate LexicalScope entries with variables' info.
605 void collectVariableInfo(SmallPtrSet<const MDNode *, 16> &ProcessedVars);
607 /// \brief Collect variable information from the side table maintained
609 void collectVariableInfoFromMMITable(SmallPtrSet<const MDNode *, 16> &P);
611 /// \brief Ensure that a label will be emitted before MI.
612 void requestLabelBeforeInsn(const MachineInstr *MI) {
613 LabelsBeforeInsn.insert(std::make_pair(MI, (MCSymbol *)0));
616 /// \brief Return Label preceding the instruction.
617 MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
619 /// \brief Ensure that a label will be emitted after MI.
620 void requestLabelAfterInsn(const MachineInstr *MI) {
621 LabelsAfterInsn.insert(std::make_pair(MI, (MCSymbol *)0));
624 /// \brief Return Label immediately following the instruction.
625 MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
627 void attachLowHighPC(DwarfCompileUnit *Unit, DIE *D, MCSymbol *Begin,
631 //===--------------------------------------------------------------------===//
632 // Main entry points.
634 DwarfDebug(AsmPrinter *A, Module *M);
636 void insertDIE(const MDNode *TypeMD, DIE *Die) {
637 MDTypeNodeToDieMap.insert(std::make_pair(TypeMD, Die));
639 DIE *getDIE(const MDNode *TypeMD) {
640 return MDTypeNodeToDieMap.lookup(TypeMD);
643 /// \brief Emit all Dwarf sections that should come prior to the
647 /// \brief Emit all Dwarf sections that should come after the content.
648 void endModule() override;
650 /// \brief Gather pre-function debug information.
651 void beginFunction(const MachineFunction *MF) override;
653 /// \brief Gather and emit post-function debug information.
654 void endFunction(const MachineFunction *MF) override;
656 /// \brief Process beginning of an instruction.
657 void beginInstruction(const MachineInstr *MI) override;
659 /// \brief Process end of an instruction.
660 void endInstruction() override;
662 /// \brief Add a DIE to the set of types that we're going to pull into
664 void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
665 DIE *Die, DICompositeType CTy);
667 /// \brief Add a label so that arange data can be generated for it.
668 void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
670 /// \brief For symbols that have a size designated (e.g. common symbols),
671 /// this tracks that size.
672 void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {
676 /// \brief Recursively Emits a debug information entry.
677 void emitDIE(DIE &Die);
679 // Experimental DWARF5 features.
681 /// \brief Returns whether or not to emit tables that dwarf consumers can
682 /// use to accelerate lookup.
683 bool useDwarfAccelTables() const { return HasDwarfAccelTables; }
685 /// \brief Returns whether or not to change the current debug info for the
686 /// split dwarf proposal support.
687 bool useSplitDwarf() const { return HasSplitDwarf; }
689 /// Returns the Dwarf Version.
690 unsigned getDwarfVersion() const { return DwarfVersion; }
692 /// Returns the section symbol for the .debug_loc section.
693 MCSymbol *getDebugLocSym() const { return DwarfDebugLocSectionSym; }
695 /// Returns the previous section that was emitted into.
696 const MCSection *getPrevSection() const { return PrevSection; }
698 /// Returns the previous CU that was being updated
699 const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
701 /// Returns the entries for the .debug_loc section.
702 const SmallVectorImpl<DebugLocList> &
703 getDebugLocEntries() const {
704 return DotDebugLocEntries;
707 /// \brief Emit an entry for the debug loc section. This can be used to
708 /// handle an entry that's going to be emitted into the debug loc section.
709 void emitDebugLocEntry(ByteStreamer &Streamer, const DebugLocEntry &Entry);
711 /// Emit the location for a debug loc entry, including the size header.
712 void emitDebugLocEntryLocation(const DebugLocEntry &Entry);
714 /// Find the MDNode for the given reference.
715 template <typename T> T resolve(DIRef<T> Ref) const {
716 return Ref.resolve(TypeIdentifierMap);
719 /// \brief Return the TypeIdentifierMap.
720 const DITypeIdentifierMap &getTypeIdentifierMap() const {
721 return TypeIdentifierMap;
724 /// Find the DwarfCompileUnit for the given CU Die.
725 DwarfCompileUnit *lookupUnit(const DIE *CU) const {
726 return CUDieMap.lookup(CU);
728 /// isSubprogramContext - Return true if Context is either a subprogram
729 /// or another context nested inside a subprogram.
730 bool isSubprogramContext(const MDNode *Context);
732 } // End of namespace llvm