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"
39 class DwarfCompileUnit;
43 class MachineModuleInfo;
45 //===----------------------------------------------------------------------===//
46 /// \brief This class is used to record source line correspondence.
48 unsigned Line; // Source line number.
49 unsigned Column; // Source column.
50 unsigned SourceID; // Source ID number.
51 MCSymbol *Label; // Label in code ID number.
53 SrcLineInfo(unsigned L, unsigned C, unsigned S, MCSymbol *label)
54 : Line(L), Column(C), SourceID(S), Label(label) {}
57 unsigned getLine() const { return Line; }
58 unsigned getColumn() const { return Column; }
59 unsigned getSourceID() const { return SourceID; }
60 MCSymbol *getLabel() const { return Label; }
63 //===----------------------------------------------------------------------===//
64 /// \brief This class is used to track local variable information.
66 DIVariable Var; // Variable Descriptor.
67 DIE *TheDIE; // Variable DIE.
68 unsigned DotDebugLocOffset; // Offset in DotDebugLocEntries.
69 DbgVariable *AbsVar; // Corresponding Abstract variable, if any.
70 const MachineInstr *MInsn; // DBG_VALUE instruction of the variable.
75 // AbsVar may be NULL.
76 DbgVariable(DIVariable V, DbgVariable *AV, DwarfDebug *DD)
77 : Var(V), TheDIE(0), DotDebugLocOffset(~0U), AbsVar(AV), MInsn(0),
78 FrameIndex(~0), DD(DD) {}
81 DIVariable getVariable() const { return Var; }
82 void setDIE(DIE *D) { TheDIE = D; }
83 DIE *getDIE() const { return TheDIE; }
84 void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; }
85 unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; }
86 StringRef getName() const { return Var.getName(); }
87 DbgVariable *getAbstractVariable() const { return AbsVar; }
88 const MachineInstr *getMInsn() const { return MInsn; }
89 void setMInsn(const MachineInstr *M) { MInsn = M; }
90 int getFrameIndex() const { return FrameIndex; }
91 void setFrameIndex(int FI) { FrameIndex = FI; }
92 // Translate tag to proper Dwarf tag.
93 dwarf::Tag getTag() const {
94 if (Var.getTag() == dwarf::DW_TAG_arg_variable)
95 return dwarf::DW_TAG_formal_parameter;
97 return dwarf::DW_TAG_variable;
99 /// \brief Return true if DbgVariable is artificial.
100 bool isArtificial() const {
101 if (Var.isArtificial())
103 if (getType().isArtificial())
108 bool isObjectPointer() const {
109 if (Var.isObjectPointer())
111 if (getType().isObjectPointer())
116 bool variableHasComplexAddress() const {
117 assert(Var.isVariable() && "Invalid complex DbgVariable!");
118 return Var.hasComplexAddress();
120 bool isBlockByrefVariable() const;
121 unsigned getNumAddrElements() const {
122 assert(Var.isVariable() && "Invalid complex DbgVariable!");
123 return Var.getNumAddrElements();
125 uint64_t getAddrElement(unsigned i) const { return Var.getAddrElement(i); }
126 DIType getType() const;
129 /// resolve - Look in the DwarfDebug map for the MDNode that
130 /// corresponds to the reference.
131 template <typename T> T resolve(DIRef<T> Ref) const;
134 /// \brief Collects and handles information specific to a particular
135 /// collection of units. This collection represents all of the units
136 /// that will be ultimately output into a single object file.
138 // Target of Dwarf emission, used for sizing of abbreviations.
141 // Used to uniquely define abbreviations.
142 FoldingSet<DIEAbbrev> AbbreviationsSet;
144 // A list of all the unique abbreviations in use.
145 std::vector<DIEAbbrev *> Abbreviations;
147 // A pointer to all units in the section.
148 SmallVector<std::unique_ptr<DwarfUnit>, 1> CUs;
150 // Collection of strings for this unit and assorted symbols.
151 // A String->Symbol mapping of strings used by indirect
153 typedef StringMap<std::pair<MCSymbol *, unsigned>, BumpPtrAllocator &>
156 unsigned NextStringPoolNumber;
157 std::string StringPref;
159 struct AddressPoolEntry {
162 AddressPoolEntry(unsigned Number, bool TLS) : Number(Number), TLS(TLS) {}
164 // Collection of addresses for this unit and assorted labels.
165 // A Symbol->unsigned mapping of addresses used by indirect
167 typedef DenseMap<const MCSymbol *, AddressPoolEntry> AddrPool;
168 AddrPool AddressPool;
171 DwarfFile(AsmPrinter *AP, const char *Pref, BumpPtrAllocator &DA);
175 const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() { return CUs; }
177 /// \brief Compute the size and offset of a DIE given an incoming Offset.
178 unsigned computeSizeAndOffset(DIE &Die, unsigned Offset);
180 /// \brief Compute the size and offset of all the DIEs.
181 void computeSizeAndOffsets();
183 /// \brief Define a unique number for the abbreviation.
184 void assignAbbrevNumber(DIEAbbrev &Abbrev);
186 /// \brief Add a unit to the list of CUs.
187 void addUnit(DwarfUnit *CU);
189 /// \brief Emit all of the units to the section listed with the given
190 /// abbreviation section.
191 void emitUnits(DwarfDebug *DD, const MCSymbol *ASectionSym);
193 /// \brief Emit a set of abbreviations to the specific section.
194 void emitAbbrevs(const MCSection *);
196 /// \brief Emit all of the strings to the section given.
197 void emitStrings(const MCSection *StrSection, const MCSection *OffsetSection,
198 const MCSymbol *StrSecSym);
200 /// \brief Emit all of the addresses to the section given.
201 void emitAddresses(const MCSection *AddrSection);
203 /// \brief Returns the entry into the start of the pool.
204 MCSymbol *getStringPoolSym();
206 /// \brief Returns an entry into the string pool with the given
208 MCSymbol *getStringPoolEntry(StringRef Str);
210 /// \brief Returns the index into the string pool with the given
212 unsigned getStringPoolIndex(StringRef Str);
214 /// \brief Returns the string pool.
215 StrPool *getStringPool() { return &StringPool; }
217 /// \brief Returns the index into the address pool with the given
219 unsigned getAddrPoolIndex(const MCSymbol *Sym, bool TLS = false);
221 /// \brief Returns the address pool.
222 AddrPool *getAddrPool() { return &AddressPool; }
225 /// \brief Helper used to pair up a symbol and its DWARF compile unit.
227 SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
229 DwarfCompileUnit *CU;
232 /// \brief Collects and handles dwarf debug information.
233 class DwarfDebug : public AsmPrinterHandler {
234 // Target of Dwarf emission.
237 // Collected machine module information.
238 MachineModuleInfo *MMI;
240 // All DIEValues are allocated through this allocator.
241 BumpPtrAllocator DIEValueAllocator;
243 // Handle to the compile unit used for the inline extension handling,
244 // this is just so that the DIEValue allocator has a place to store
245 // the particular elements.
246 // FIXME: Store these off of DwarfDebug instead?
247 DwarfCompileUnit *FirstCU;
249 // Maps MDNode with its corresponding DwarfCompileUnit.
250 MapVector<const MDNode *, DwarfCompileUnit *> CUMap;
252 // Maps subprogram MDNode with its corresponding DwarfCompileUnit.
253 DenseMap<const MDNode *, DwarfCompileUnit *> SPMap;
255 // Maps a CU DIE with its corresponding DwarfCompileUnit.
256 DenseMap<const DIE *, DwarfCompileUnit *> CUDieMap;
258 /// Maps MDNodes for type system with the corresponding DIEs. These DIEs can
259 /// be shared across CUs, that is why we keep the map here instead
260 /// of in DwarfCompileUnit.
261 DenseMap<const MDNode *, DIE *> MDTypeNodeToDieMap;
263 // List of all labels used in aranges generation.
264 std::vector<SymbolCU> ArangeLabels;
266 // Size of each symbol emitted (for those symbols that have a specific size).
267 DenseMap<const MCSymbol *, uint64_t> SymSize;
269 // Provides a unique id per text section.
270 typedef DenseMap<const MCSection *, SmallVector<SymbolCU, 8> > SectionMapType;
271 SectionMapType SectionMap;
273 // List of arguments for current function.
274 SmallVector<DbgVariable *, 8> CurrentFnArguments;
276 LexicalScopes LScopes;
278 // Collection of abstract subprogram DIEs.
279 DenseMap<const MDNode *, DIE *> AbstractSPDies;
281 // Collection of dbg variables of a scope.
282 typedef DenseMap<LexicalScope *, SmallVector<DbgVariable *, 8> >
284 ScopeVariablesMap ScopeVariables;
286 // Collection of abstract variables.
287 DenseMap<const MDNode *, DbgVariable *> AbstractVariables;
289 // Collection of DebugLocEntry. Stored in a linked list so that DIELocLists
290 // can refer to them in spite of insertions into this list.
291 SmallVector<DebugLocList, 4> DotDebugLocEntries;
293 // Collection of subprogram DIEs that are marked (at the end of the module)
295 SmallPtrSet<DIE *, 4> InlinedSubprogramDIEs;
297 // This is a collection of subprogram MDNodes that are processed to
299 SmallPtrSet<const MDNode *, 16> ProcessedSPNodes;
301 // Maps instruction with label emitted before instruction.
302 DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn;
304 // Maps instruction with label emitted after instruction.
305 DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn;
307 // Every user variable mentioned by a DBG_VALUE instruction in order of
309 SmallVector<const MDNode *, 8> UserVariables;
311 // For each user variable, keep a list of DBG_VALUE instructions in order.
312 // The list can also contain normal instructions that clobber the previous
314 typedef DenseMap<const MDNode *, SmallVector<const MachineInstr *, 4> >
316 DbgValueHistoryMap DbgValues;
318 // Previous instruction's location information. This is used to determine
319 // label location to indicate scope boundries in dwarf debug info.
320 DebugLoc PrevInstLoc;
323 // This location indicates end of function prologue and beginning of function
325 DebugLoc PrologEndLoc;
327 // If nonnull, stores the current machine function we're processing.
328 const MachineFunction *CurFn;
330 // If nonnull, stores the current machine instruction we're processing.
331 const MachineInstr *CurMI;
333 // If nonnull, stores the section that the previous function was allocated to
335 const MCSection *PrevSection;
337 // If nonnull, stores the CU in which the previous subprogram was contained.
338 const DwarfCompileUnit *PrevCU;
340 // Section Symbols: these are assembler temporary labels that are emitted at
341 // the beginning of each supported dwarf section. These are used to form
342 // section offsets and are created by EmitSectionLabels.
343 MCSymbol *DwarfInfoSectionSym, *DwarfAbbrevSectionSym;
344 MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym;
345 MCSymbol *DwarfDebugLocSectionSym, *DwarfLineSectionSym, *DwarfAddrSectionSym;
346 MCSymbol *FunctionBeginSym, *FunctionEndSym;
347 MCSymbol *DwarfInfoDWOSectionSym, *DwarfAbbrevDWOSectionSym;
348 MCSymbol *DwarfStrDWOSectionSym;
349 MCSymbol *DwarfGnuPubNamesSectionSym, *DwarfGnuPubTypesSectionSym;
351 // As an optimization, there is no need to emit an entry in the directory
352 // table for the same directory as DW_AT_comp_dir.
353 StringRef CompilationDir;
355 // Counter for assigning globally unique IDs for ranges.
356 unsigned GlobalRangeCount;
358 // Holder for the file specific debug information.
359 DwarfFile InfoHolder;
361 // Holders for the various debug information flags that we might need to
362 // have exposed. See accessor functions below for description.
364 // Holder for imported entities.
365 typedef SmallVector<std::pair<const MDNode *, const MDNode *>, 32>
367 ImportedEntityMap ScopesWithImportedEntities;
369 // Map from MDNodes for user-defined types to the type units that describe
371 DenseMap<const MDNode *, const DwarfTypeUnit *> DwarfTypeUnits;
373 // Whether to emit the pubnames/pubtypes sections.
374 bool HasDwarfPubSections;
376 // Whether or not to use AT_ranges for compilation units.
379 // Whether we emitted a function into a section other than the default
381 bool UsedNonDefaultText;
383 // Version of dwarf we're emitting.
384 unsigned DwarfVersion;
386 // Maps from a type identifier to the actual MDNode.
387 DITypeIdentifierMap TypeIdentifierMap;
389 // DWARF5 Experimental Options
390 bool HasDwarfAccelTables;
393 // Separated Dwarf Variables
394 // In general these will all be for bits that are left in the
395 // original object file, rather than things that are meant
396 // to be in the .dwo sections.
398 // Holder for the skeleton information.
399 DwarfFile SkeletonHolder;
401 /// Store file names for type units under fission in a line table header that
402 /// will be emitted into debug_line.dwo.
403 // FIXME: replace this with a map from comp_dir to table so that we can emit
404 // multiple tables during LTO each of which uses directory 0, referencing the
405 // comp_dir of all the type units that use it.
406 MCDwarfDwoLineTable SplitTypeUnitFileTable;
408 // True iff there are multiple CUs in this module.
411 MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
413 void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
415 const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() {
416 return InfoHolder.getUnits();
419 /// \brief Find abstract variable associated with Var.
420 DbgVariable *findAbstractVariable(DIVariable &Var, DebugLoc Loc);
422 /// \brief Find DIE for the given subprogram and attach appropriate
423 /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
424 /// variables in this scope then create and insert DIEs for these
426 DIE *updateSubprogramScopeDIE(DwarfCompileUnit *SPCU, DISubprogram SP);
428 /// \brief A helper function to check whether the DIE for a given Scope is
429 /// going to be null.
430 bool isLexicalScopeDIENull(LexicalScope *Scope);
432 /// \brief A helper function to construct a RangeSpanList for a given
434 void addScopeRangeList(DwarfCompileUnit *TheCU, DIE *ScopeDIE,
435 const SmallVectorImpl<InsnRange> &Range);
437 /// \brief Construct new DW_TAG_lexical_block for this scope and
438 /// attach DW_AT_low_pc/DW_AT_high_pc labels.
439 DIE *constructLexicalScopeDIE(DwarfCompileUnit *TheCU, LexicalScope *Scope);
441 /// \brief This scope represents inlined body of a function. Construct
442 /// DIE to represent this concrete inlined copy of the function.
443 DIE *constructInlinedScopeDIE(DwarfCompileUnit *TheCU, LexicalScope *Scope);
445 /// \brief Construct a DIE for this scope.
446 DIE *constructScopeDIE(DwarfCompileUnit *TheCU, LexicalScope *Scope);
447 /// A helper function to create children of a Scope DIE.
448 DIE *createScopeChildrenDIE(DwarfCompileUnit *TheCU, LexicalScope *Scope,
449 SmallVectorImpl<DIE *> &Children);
451 /// \brief Emit initial Dwarf sections with a label at the start of each one.
452 void emitSectionLabels();
454 /// \brief Compute the size and offset of a DIE given an incoming Offset.
455 unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
457 /// \brief Compute the size and offset of all the DIEs.
458 void computeSizeAndOffsets();
460 /// \brief Attach DW_AT_inline attribute with inlined subprogram DIEs.
461 void computeInlinedDIEs();
463 /// \brief Collect info for variables that were optimized out.
464 void collectDeadVariables();
466 /// \brief Finish off debug information after all functions have been
468 void finalizeModuleInfo();
470 /// \brief Emit labels to close any remaining sections that have been left
474 /// \brief Emit the debug info section.
475 void emitDebugInfo();
477 /// \brief Emit the abbreviation section.
478 void emitAbbreviations();
480 /// \brief Emit the last address of the section and the end of
482 void emitEndOfLineMatrix(unsigned SectionEnd);
484 /// \brief Emit visible names into a hashed accelerator table section.
485 void emitAccelNames();
487 /// \brief Emit objective C classes and categories into a hashed
488 /// accelerator table section.
489 void emitAccelObjC();
491 /// \brief Emit namespace dies into a hashed accelerator table.
492 void emitAccelNamespaces();
494 /// \brief Emit type dies into a hashed accelerator table.
495 void emitAccelTypes();
497 /// \brief Emit visible names into a debug pubnames section.
498 /// \param GnuStyle determines whether or not we want to emit
499 /// additional information into the table ala newer gcc for gdb
501 void emitDebugPubNames(bool GnuStyle = false);
503 /// \brief Emit visible types into a debug pubtypes section.
504 /// \param GnuStyle determines whether or not we want to emit
505 /// additional information into the table ala newer gcc for gdb
507 void emitDebugPubTypes(bool GnuStyle = false);
510 emitDebugPubSection(bool GnuStyle, const MCSection *PSec, StringRef Name,
511 const StringMap<const DIE *> &(DwarfUnit::*Accessor)()
514 /// \brief Emit visible names into a debug str section.
517 /// \brief Emit visible names into a debug loc section.
520 /// \brief Emit visible names into a debug loc dwo section.
521 void emitDebugLocDWO();
523 /// \brief Emit visible names into a debug aranges section.
524 void emitDebugARanges();
526 /// \brief Emit visible names into a debug ranges section.
527 void emitDebugRanges();
529 /// \brief Emit inline info using custom format.
530 void emitDebugInlineInfo();
532 /// DWARF 5 Experimental Split Dwarf Emitters
534 /// \brief Initialize common features of skeleton units.
535 void initSkeletonUnit(const DwarfUnit *U, DIE *Die, DwarfUnit *NewU);
537 /// \brief Construct the split debug info compile unit for the debug info
539 DwarfCompileUnit *constructSkeletonCU(const DwarfCompileUnit *CU);
541 /// \brief Construct the split debug info compile unit for the debug info
543 DwarfTypeUnit *constructSkeletonTU(DwarfTypeUnit *TU);
545 /// \brief Emit the debug info dwo section.
546 void emitDebugInfoDWO();
548 /// \brief Emit the debug abbrev dwo section.
549 void emitDebugAbbrevDWO();
551 /// \brief Emit the debug line dwo section.
552 void emitDebugLineDWO();
554 /// \brief Emit the debug str dwo section.
555 void emitDebugStrDWO();
557 /// Flags to let the linker know we have emitted new style pubnames. Only
558 /// emit it here if we don't have a skeleton CU for split dwarf.
559 void addGnuPubAttributes(DwarfUnit *U, DIE *D) const;
561 /// \brief Create new DwarfCompileUnit for the given metadata node with tag
562 /// DW_TAG_compile_unit.
563 DwarfCompileUnit *constructDwarfCompileUnit(DICompileUnit DIUnit);
565 /// \brief Construct subprogram DIE.
566 void constructSubprogramDIE(DwarfCompileUnit *TheCU, const MDNode *N);
568 /// \brief Construct imported_module or imported_declaration DIE.
569 void constructImportedEntityDIE(DwarfCompileUnit *TheCU, const MDNode *N);
571 /// \brief Construct import_module DIE.
572 void constructImportedEntityDIE(DwarfCompileUnit *TheCU, const MDNode *N,
575 /// \brief Construct import_module DIE.
576 void constructImportedEntityDIE(DwarfCompileUnit *TheCU,
577 const DIImportedEntity &Module, DIE *Context);
579 /// \brief Register a source line with debug info. Returns the unique
580 /// label that was emitted and which provides correspondence to the
581 /// source line list.
582 void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
585 /// \brief Indentify instructions that are marking the beginning of or
586 /// ending of a scope.
587 void identifyScopeMarkers();
589 /// \brief If Var is an current function argument that add it in
590 /// CurrentFnArguments list.
591 bool addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope);
593 /// \brief Populate LexicalScope entries with variables' info.
594 void collectVariableInfo(SmallPtrSet<const MDNode *, 16> &ProcessedVars);
596 /// \brief Collect variable information from the side table maintained
598 void collectVariableInfoFromMMITable(SmallPtrSet<const MDNode *, 16> &P);
600 /// \brief Ensure that a label will be emitted before MI.
601 void requestLabelBeforeInsn(const MachineInstr *MI) {
602 LabelsBeforeInsn.insert(std::make_pair(MI, (MCSymbol *)0));
605 /// \brief Return Label preceding the instruction.
606 MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
608 /// \brief Ensure that a label will be emitted after MI.
609 void requestLabelAfterInsn(const MachineInstr *MI) {
610 LabelsAfterInsn.insert(std::make_pair(MI, (MCSymbol *)0));
613 /// \brief Return Label immediately following the instruction.
614 MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
616 void attachLowHighPC(DwarfCompileUnit *Unit, DIE *D, MCSymbol *Begin,
620 //===--------------------------------------------------------------------===//
621 // Main entry points.
623 DwarfDebug(AsmPrinter *A, Module *M);
625 void insertDIE(const MDNode *TypeMD, DIE *Die) {
626 MDTypeNodeToDieMap.insert(std::make_pair(TypeMD, Die));
628 DIE *getDIE(const MDNode *TypeMD) {
629 return MDTypeNodeToDieMap.lookup(TypeMD);
632 /// \brief Emit all Dwarf sections that should come prior to the
636 /// \brief Emit all Dwarf sections that should come after the content.
637 void endModule() override;
639 /// \brief Gather pre-function debug information.
640 void beginFunction(const MachineFunction *MF) override;
642 /// \brief Gather and emit post-function debug information.
643 void endFunction(const MachineFunction *MF) override;
645 /// \brief Process beginning of an instruction.
646 void beginInstruction(const MachineInstr *MI) override;
648 /// \brief Process end of an instruction.
649 void endInstruction() override;
651 /// \brief Add a DIE to the set of types that we're going to pull into
653 void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
654 DIE *Die, DICompositeType CTy);
656 /// \brief Add a label so that arange data can be generated for it.
657 void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
659 /// \brief For symbols that have a size designated (e.g. common symbols),
660 /// this tracks that size.
661 void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {
665 /// \brief Recursively Emits a debug information entry.
666 void emitDIE(DIE &Die);
668 // Experimental DWARF5 features.
670 /// \brief Returns whether or not to emit tables that dwarf consumers can
671 /// use to accelerate lookup.
672 bool useDwarfAccelTables() const { return HasDwarfAccelTables; }
674 /// \brief Returns whether or not to change the current debug info for the
675 /// split dwarf proposal support.
676 bool useSplitDwarf() const { return HasSplitDwarf; }
678 /// Returns the Dwarf Version.
679 unsigned getDwarfVersion() const { return DwarfVersion; }
681 /// Returns the section symbol for the .debug_loc section.
682 MCSymbol *getDebugLocSym() const { return DwarfDebugLocSectionSym; }
684 /// Returns the previous section that was emitted into.
685 const MCSection *getPrevSection() const { return PrevSection; }
687 /// Returns the previous CU that was being updated
688 const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
690 /// Returns the entries for the .debug_loc section.
691 const SmallVectorImpl<DebugLocList> &
692 getDebugLocEntries() const {
693 return DotDebugLocEntries;
696 /// \brief Emit an entry for the debug loc section. This can be used to
697 /// handle an entry that's going to be emitted into the debug loc section.
698 void emitDebugLocEntry(ByteStreamer &Streamer, const DebugLocEntry &Entry);
700 /// Emit the location for a debug loc entry, including the size header.
701 void emitDebugLocEntryLocation(const DebugLocEntry &Entry);
703 /// Find the MDNode for the given reference.
704 template <typename T> T resolve(DIRef<T> Ref) const {
705 return Ref.resolve(TypeIdentifierMap);
708 /// \brief Return the TypeIdentifierMap.
709 const DITypeIdentifierMap &getTypeIdentifierMap() const {
710 return TypeIdentifierMap;
713 /// Find the DwarfCompileUnit for the given CU Die.
714 DwarfCompileUnit *lookupUnit(const DIE *CU) const {
715 return CUDieMap.lookup(CU);
717 /// isSubprogramContext - Return true if Context is either a subprogram
718 /// or another context nested inside a subprogram.
719 bool isSubprogramContext(const MDNode *Context);
721 } // End of namespace llvm