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 "llvm/ADT/DenseMap.h"
21 #include "llvm/ADT/MapVector.h"
22 #include "llvm/ADT/SmallPtrSet.h"
23 #include "llvm/ADT/StringMap.h"
24 #include "llvm/ADT/FoldingSet.h"
25 #include "llvm/CodeGen/LexicalScopes.h"
26 #include "llvm/IR/DebugInfo.h"
27 #include "llvm/IR/DebugLoc.h"
28 #include "llvm/MC/MachineLocation.h"
29 #include "llvm/MC/MCDwarf.h"
30 #include "llvm/Support/Allocator.h"
38 class DwarfCompileUnit;
42 class MachineModuleInfo;
44 //===----------------------------------------------------------------------===//
45 /// \brief This class is used to record source line correspondence.
47 unsigned Line; // Source line number.
48 unsigned Column; // Source column.
49 unsigned SourceID; // Source ID number.
50 MCSymbol *Label; // Label in code ID number.
52 SrcLineInfo(unsigned L, unsigned C, unsigned S, MCSymbol *label)
53 : Line(L), Column(C), SourceID(S), Label(label) {}
56 unsigned getLine() const { return Line; }
57 unsigned getColumn() const { return Column; }
58 unsigned getSourceID() const { return SourceID; }
59 MCSymbol *getLabel() const { return Label; }
62 //===----------------------------------------------------------------------===//
63 /// \brief This class is used to track local variable information.
65 DIVariable Var; // Variable Descriptor.
66 DIE *TheDIE; // Variable DIE.
67 unsigned DotDebugLocOffset; // Offset in DotDebugLocEntries.
68 DbgVariable *AbsVar; // Corresponding Abstract variable, if any.
69 const MachineInstr *MInsn; // DBG_VALUE instruction of the variable.
74 // AbsVar may be NULL.
75 DbgVariable(DIVariable V, DbgVariable *AV, DwarfDebug *DD)
76 : Var(V), TheDIE(0), DotDebugLocOffset(~0U), AbsVar(AV), MInsn(0),
77 FrameIndex(~0), DD(DD) {}
80 DIVariable getVariable() const { return Var; }
81 void setDIE(DIE *D) { TheDIE = D; }
82 DIE *getDIE() const { return TheDIE; }
83 void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; }
84 unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; }
85 StringRef getName() const { return Var.getName(); }
86 DbgVariable *getAbstractVariable() const { return AbsVar; }
87 const MachineInstr *getMInsn() const { return MInsn; }
88 void setMInsn(const MachineInstr *M) { MInsn = M; }
89 int getFrameIndex() const { return FrameIndex; }
90 void setFrameIndex(int FI) { FrameIndex = FI; }
91 // Translate tag to proper Dwarf tag.
92 uint16_t getTag() const {
93 if (Var.getTag() == dwarf::DW_TAG_arg_variable)
94 return dwarf::DW_TAG_formal_parameter;
96 return dwarf::DW_TAG_variable;
98 /// \brief Return true if DbgVariable is artificial.
99 bool isArtificial() const {
100 if (Var.isArtificial())
102 if (getType().isArtificial())
107 bool isObjectPointer() const {
108 if (Var.isObjectPointer())
110 if (getType().isObjectPointer())
115 bool variableHasComplexAddress() const {
116 assert(Var.isVariable() && "Invalid complex DbgVariable!");
117 return Var.hasComplexAddress();
119 bool isBlockByrefVariable() const;
120 unsigned getNumAddrElements() const {
121 assert(Var.isVariable() && "Invalid complex DbgVariable!");
122 return Var.getNumAddrElements();
124 uint64_t getAddrElement(unsigned i) const { return Var.getAddrElement(i); }
125 DIType getType() const;
128 /// resolve - Look in the DwarfDebug map for the MDNode that
129 /// corresponds to the reference.
130 template <typename T> T resolve(DIRef<T> Ref) const;
133 /// \brief Collects and handles information specific to a particular
134 /// collection of units. This collection represents all of the units
135 /// that will be ultimately output into a single object file.
137 // Target of Dwarf emission, used for sizing of abbreviations.
140 // Used to uniquely define abbreviations.
141 FoldingSet<DIEAbbrev> AbbreviationsSet;
143 // A list of all the unique abbreviations in use.
144 std::vector<DIEAbbrev *> Abbreviations;
146 // A pointer to all units in the section.
147 SmallVector<DwarfUnit *, 1> CUs;
149 // Collection of strings for this unit and assorted symbols.
150 // A String->Symbol mapping of strings used by indirect
152 typedef StringMap<std::pair<MCSymbol *, unsigned>, BumpPtrAllocator &>
155 unsigned NextStringPoolNumber;
156 std::string StringPref;
158 struct AddressPoolEntry {
161 AddressPoolEntry(unsigned Number, bool TLS) : Number(Number), TLS(TLS) {}
163 // Collection of addresses for this unit and assorted labels.
164 // A Symbol->unsigned mapping of addresses used by indirect
166 typedef DenseMap<const MCSymbol *, AddressPoolEntry> AddrPool;
167 AddrPool AddressPool;
168 unsigned NextAddrPoolNumber;
171 DwarfFile(AsmPrinter *AP, const char *Pref, BumpPtrAllocator &DA)
172 : Asm(AP), StringPool(DA), NextStringPoolNumber(0), StringPref(Pref),
173 AddressPool(), NextAddrPoolNumber(0) {}
177 const SmallVectorImpl<DwarfUnit *> &getUnits() { return CUs; }
179 /// \brief Compute the size and offset of a DIE given an incoming Offset.
180 unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
182 /// \brief Compute the size and offset of all the DIEs.
183 void computeSizeAndOffsets();
185 /// \brief Define a unique number for the abbreviation.
186 void assignAbbrevNumber(DIEAbbrev &Abbrev);
188 /// \brief Add a unit to the list of CUs.
189 void addUnit(DwarfUnit *CU) { CUs.push_back(CU); }
191 /// \brief Emit all of the units to the section listed with the given
192 /// abbreviation section.
193 void emitUnits(DwarfDebug *DD, const MCSymbol *ASectionSym);
195 /// \brief Emit a set of abbreviations to the specific section.
196 void emitAbbrevs(const MCSection *);
198 /// \brief Emit all of the strings to the section given.
199 void emitStrings(const MCSection *StrSection, const MCSection *OffsetSection,
200 const MCSymbol *StrSecSym);
202 /// \brief Emit all of the addresses to the section given.
203 void emitAddresses(const MCSection *AddrSection);
205 /// \brief Returns the entry into the start of the pool.
206 MCSymbol *getStringPoolSym();
208 /// \brief Returns an entry into the string pool with the given
210 MCSymbol *getStringPoolEntry(StringRef Str);
212 /// \brief Returns the index into the string pool with the given
214 unsigned getStringPoolIndex(StringRef Str);
216 /// \brief Returns the string pool.
217 StrPool *getStringPool() { return &StringPool; }
219 /// \brief Returns the index into the address pool with the given
221 unsigned getAddrPoolIndex(const MCSymbol *Sym, bool TLS = false);
223 /// \brief Returns the address pool.
224 AddrPool *getAddrPool() { return &AddressPool; }
227 /// \brief Helper used to pair up a symbol and its DWARF compile unit.
229 SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
231 DwarfCompileUnit *CU;
234 /// \brief Collects and handles dwarf debug information.
235 class DwarfDebug : public AsmPrinterHandler {
236 // Target of Dwarf emission.
239 // Collected machine module information.
240 MachineModuleInfo *MMI;
242 // All DIEValues are allocated through this allocator.
243 BumpPtrAllocator DIEValueAllocator;
245 // Handle to the compile unit used for the inline extension handling,
246 // this is just so that the DIEValue allocator has a place to store
247 // the particular elements.
248 // FIXME: Store these off of DwarfDebug instead?
249 DwarfCompileUnit *FirstCU;
251 // Maps MDNode with its corresponding DwarfCompileUnit.
252 MapVector<const MDNode *, DwarfCompileUnit *> CUMap;
254 // Maps subprogram MDNode with its corresponding DwarfCompileUnit.
255 DenseMap<const MDNode *, DwarfCompileUnit *> SPMap;
257 // Maps a CU DIE with its corresponding DwarfCompileUnit.
258 DenseMap<const DIE *, DwarfCompileUnit *> CUDieMap;
260 /// Maps MDNodes for type system with the corresponding DIEs. These DIEs can
261 /// be shared across CUs, that is why we keep the map here instead
262 /// of in DwarfCompileUnit.
263 DenseMap<const MDNode *, DIE *> MDTypeNodeToDieMap;
265 // List of all labels used in aranges generation.
266 std::vector<SymbolCU> ArangeLabels;
268 // Size of each symbol emitted (for those symbols that have a specific size).
269 DenseMap<const MCSymbol *, uint64_t> SymSize;
271 // Provides a unique id per text section.
272 typedef DenseMap<const MCSection *, SmallVector<SymbolCU, 8> > SectionMapType;
273 SectionMapType SectionMap;
275 // List of arguments for current function.
276 SmallVector<DbgVariable *, 8> CurrentFnArguments;
278 LexicalScopes LScopes;
280 // Collection of abstract subprogram DIEs.
281 DenseMap<const MDNode *, DIE *> AbstractSPDies;
283 // Collection of dbg variables of a scope.
284 typedef DenseMap<LexicalScope *, SmallVector<DbgVariable *, 8> >
286 ScopeVariablesMap ScopeVariables;
288 // Collection of abstract variables.
289 DenseMap<const MDNode *, DbgVariable *> AbstractVariables;
291 // Collection of DebugLocEntry.
292 SmallVector<SmallVector<DebugLocEntry, 4>, 4> DotDebugLocEntries;
294 // Collection of subprogram DIEs that are marked (at the end of the module)
296 SmallPtrSet<DIE *, 4> InlinedSubprogramDIEs;
298 // This is a collection of subprogram MDNodes that are processed to
300 SmallPtrSet<const MDNode *, 16> ProcessedSPNodes;
302 // Maps instruction with label emitted before instruction.
303 DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn;
305 // Maps instruction with label emitted after instruction.
306 DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn;
308 // Every user variable mentioned by a DBG_VALUE instruction in order of
310 SmallVector<const MDNode *, 8> UserVariables;
312 // For each user variable, keep a list of DBG_VALUE instructions in order.
313 // The list can also contain normal instructions that clobber the previous
315 typedef DenseMap<const MDNode *, SmallVector<const MachineInstr *, 4> >
317 DbgValueHistoryMap DbgValues;
319 // Previous instruction's location information. This is used to determine
320 // label location to indicate scope boundries in dwarf debug info.
321 DebugLoc PrevInstLoc;
324 // This location indicates end of function prologue and beginning of function
326 DebugLoc PrologEndLoc;
328 // If nonnull, stores the current machine function we're processing.
329 const MachineFunction *CurFn;
331 // If nonnull, stores the current machine instruction we're processing.
332 const MachineInstr *CurMI;
334 // If nonnull, stores the section that the previous function was allocated to
336 const MCSection *PrevSection;
338 // If nonnull, stores the CU in which the previous subprogram was contained.
339 const DwarfCompileUnit *PrevCU;
341 // Section Symbols: these are assembler temporary labels that are emitted at
342 // the beginning of each supported dwarf section. These are used to form
343 // section offsets and are created by EmitSectionLabels.
344 MCSymbol *DwarfInfoSectionSym, *DwarfAbbrevSectionSym;
345 MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym;
346 MCSymbol *DwarfDebugLocSectionSym, *DwarfLineSectionSym, *DwarfAddrSectionSym;
347 MCSymbol *FunctionBeginSym, *FunctionEndSym;
348 MCSymbol *DwarfInfoDWOSectionSym, *DwarfAbbrevDWOSectionSym;
349 MCSymbol *DwarfStrDWOSectionSym;
350 MCSymbol *DwarfGnuPubNamesSectionSym, *DwarfGnuPubTypesSectionSym;
352 // As an optimization, there is no need to emit an entry in the directory
353 // table for the same directory as DW_AT_comp_dir.
354 StringRef CompilationDir;
356 // Counter for assigning globally unique IDs for ranges.
357 unsigned GlobalRangeCount;
359 // Holder for the file specific debug information.
360 DwarfFile InfoHolder;
362 // Holders for the various debug information flags that we might need to
363 // have exposed. See accessor functions below for description.
365 // Holder for imported entities.
366 typedef SmallVector<std::pair<const MDNode *, const MDNode *>, 32>
368 ImportedEntityMap ScopesWithImportedEntities;
370 // Map from MDNodes for user-defined types to the type units that describe
372 DenseMap<const MDNode *, const DwarfTypeUnit *> DwarfTypeUnits;
374 // Whether to emit the pubnames/pubtypes sections.
375 bool HasDwarfPubSections;
377 // Whether or not to use AT_ranges for compilation units.
380 // Whether we emitted a function into a section other than the default
382 bool UsedNonDefaultText;
384 // Version of dwarf we're emitting.
385 unsigned DwarfVersion;
387 // Maps from a type identifier to the actual MDNode.
388 DITypeIdentifierMap TypeIdentifierMap;
390 // DWARF5 Experimental Options
391 bool HasDwarfAccelTables;
394 // Separated Dwarf Variables
395 // In general these will all be for bits that are left in the
396 // original object file, rather than things that are meant
397 // to be in the .dwo sections.
399 // Holder for the skeleton information.
400 DwarfFile SkeletonHolder;
402 /// Store file names for type units under fission in a line table header that
403 /// will be emitted into debug_line.dwo.
404 // FIXME: replace this with a map from comp_dir to table so that we can emit
405 // multiple tables during LTO each of which uses directory 0, referencing the
406 // comp_dir of all the type units that use it.
407 MCDwarfDwoLineTable SplitTypeUnitFileTable;
409 // True iff there are multiple CUs in this module.
412 MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
414 void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
416 const SmallVectorImpl<DwarfUnit *> &getUnits() {
417 return InfoHolder.getUnits();
420 /// \brief Find abstract variable associated with Var.
421 DbgVariable *findAbstractVariable(DIVariable &Var, DebugLoc Loc);
423 /// \brief Find DIE for the given subprogram and attach appropriate
424 /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
425 /// variables in this scope then create and insert DIEs for these
427 DIE *updateSubprogramScopeDIE(DwarfCompileUnit *SPCU, DISubprogram SP);
429 /// \brief A helper function to check whether the DIE for a given Scope is
430 /// going to be null.
431 bool isLexicalScopeDIENull(LexicalScope *Scope);
433 /// \brief A helper function to construct a RangeSpanList for a given
435 void addScopeRangeList(DwarfCompileUnit *TheCU, DIE *ScopeDIE,
436 const SmallVectorImpl<InsnRange> &Range);
438 /// \brief Construct new DW_TAG_lexical_block for this scope and
439 /// attach DW_AT_low_pc/DW_AT_high_pc labels.
440 DIE *constructLexicalScopeDIE(DwarfCompileUnit *TheCU, LexicalScope *Scope);
442 /// \brief This scope represents inlined body of a function. Construct
443 /// DIE to represent this concrete inlined copy of the function.
444 DIE *constructInlinedScopeDIE(DwarfCompileUnit *TheCU, LexicalScope *Scope);
446 /// \brief Construct a DIE for this scope.
447 DIE *constructScopeDIE(DwarfCompileUnit *TheCU, LexicalScope *Scope);
448 /// A helper function to create children of a Scope DIE.
449 DIE *createScopeChildrenDIE(DwarfCompileUnit *TheCU, LexicalScope *Scope,
450 SmallVectorImpl<DIE *> &Children);
452 /// \brief Emit initial Dwarf sections with a label at the start of each one.
453 void emitSectionLabels();
455 /// \brief Compute the size and offset of a DIE given an incoming Offset.
456 unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
458 /// \brief Compute the size and offset of all the DIEs.
459 void computeSizeAndOffsets();
461 /// \brief Attach DW_AT_inline attribute with inlined subprogram DIEs.
462 void computeInlinedDIEs();
464 /// \brief Collect info for variables that were optimized out.
465 void collectDeadVariables();
467 /// \brief Finish off debug information after all functions have been
469 void finalizeModuleInfo();
471 /// \brief Emit labels to close any remaining sections that have been left
475 /// \brief Emit the debug info section.
476 void emitDebugInfo();
478 /// \brief Emit the abbreviation section.
479 void emitAbbreviations();
481 /// \brief Emit the last address of the section and the end of
483 void emitEndOfLineMatrix(unsigned SectionEnd);
485 /// \brief Emit visible names into a hashed accelerator table section.
486 void emitAccelNames();
488 /// \brief Emit objective C classes and categories into a hashed
489 /// accelerator table section.
490 void emitAccelObjC();
492 /// \brief Emit namespace dies into a hashed accelerator table.
493 void emitAccelNamespaces();
495 /// \brief Emit type dies into a hashed accelerator table.
496 void emitAccelTypes();
498 /// \brief Emit visible names into a debug pubnames section.
499 /// \param GnuStyle determines whether or not we want to emit
500 /// additional information into the table ala newer gcc for gdb
502 void emitDebugPubNames(bool GnuStyle = false);
504 /// \brief Emit visible types into a debug pubtypes section.
505 /// \param GnuStyle determines whether or not we want to emit
506 /// additional information into the table ala newer gcc for gdb
508 void emitDebugPubTypes(bool GnuStyle = false);
511 emitDebugPubSection(bool GnuStyle, const MCSection *PSec, StringRef Name,
512 const StringMap<const DIE *> &(DwarfUnit::*Accessor)()
515 /// \brief Emit visible names into a debug str section.
518 /// \brief Emit visible names into a debug loc section.
521 /// \brief Emit visible names into a debug aranges section.
522 void emitDebugARanges();
524 /// \brief Emit visible names into a debug ranges section.
525 void emitDebugRanges();
527 /// \brief Emit inline info using custom format.
528 void emitDebugInlineInfo();
530 /// DWARF 5 Experimental Split Dwarf Emitters
532 /// \brief Initialize common features of skeleton units.
533 void initSkeletonUnit(const DwarfUnit *U, DIE *Die, DwarfUnit *NewU);
535 /// \brief Construct the split debug info compile unit for the debug info
537 DwarfCompileUnit *constructSkeletonCU(const DwarfCompileUnit *CU);
539 /// \brief Construct the split debug info compile unit for the debug info
541 DwarfTypeUnit *constructSkeletonTU(DwarfTypeUnit *TU);
543 /// \brief Emit the debug info dwo section.
544 void emitDebugInfoDWO();
546 /// \brief Emit the debug abbrev dwo section.
547 void emitDebugAbbrevDWO();
549 /// \brief Emit the debug line dwo section.
550 void emitDebugLineDWO();
552 /// \brief Emit the debug str dwo section.
553 void emitDebugStrDWO();
555 /// Flags to let the linker know we have emitted new style pubnames. Only
556 /// emit it here if we don't have a skeleton CU for split dwarf.
557 void addGnuPubAttributes(DwarfUnit *U, DIE *D) const;
559 /// \brief Create new DwarfCompileUnit for the given metadata node with tag
560 /// DW_TAG_compile_unit.
561 DwarfCompileUnit *constructDwarfCompileUnit(DICompileUnit DIUnit);
563 /// \brief Construct subprogram DIE.
564 void constructSubprogramDIE(DwarfCompileUnit *TheCU, const MDNode *N);
566 /// \brief Construct imported_module or imported_declaration DIE.
567 void constructImportedEntityDIE(DwarfCompileUnit *TheCU, const MDNode *N);
569 /// \brief Construct import_module DIE.
570 void constructImportedEntityDIE(DwarfCompileUnit *TheCU, const MDNode *N,
573 /// \brief Construct import_module DIE.
574 void constructImportedEntityDIE(DwarfCompileUnit *TheCU,
575 const DIImportedEntity &Module, DIE *Context);
577 /// \brief Register a source line with debug info. Returns the unique
578 /// label that was emitted and which provides correspondence to the
579 /// source line list.
580 void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
583 /// \brief Indentify instructions that are marking the beginning of or
584 /// ending of a scope.
585 void identifyScopeMarkers();
587 /// \brief If Var is an current function argument that add it in
588 /// CurrentFnArguments list.
589 bool addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope);
591 /// \brief Populate LexicalScope entries with variables' info.
592 void collectVariableInfo(SmallPtrSet<const MDNode *, 16> &ProcessedVars);
594 /// \brief Collect variable information from the side table maintained
596 void collectVariableInfoFromMMITable(SmallPtrSet<const MDNode *, 16> &P);
598 /// \brief Ensure that a label will be emitted before MI.
599 void requestLabelBeforeInsn(const MachineInstr *MI) {
600 LabelsBeforeInsn.insert(std::make_pair(MI, (MCSymbol *)0));
603 /// \brief Return Label preceding the instruction.
604 MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
606 /// \brief Ensure that a label will be emitted after MI.
607 void requestLabelAfterInsn(const MachineInstr *MI) {
608 LabelsAfterInsn.insert(std::make_pair(MI, (MCSymbol *)0));
611 /// \brief Return Label immediately following the instruction.
612 MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
614 void attachLowHighPC(DwarfCompileUnit *Unit, DIE *D, MCSymbol *Begin,
618 //===--------------------------------------------------------------------===//
619 // Main entry points.
621 DwarfDebug(AsmPrinter *A, Module *M);
623 void insertDIE(const MDNode *TypeMD, DIE *Die) {
624 MDTypeNodeToDieMap.insert(std::make_pair(TypeMD, Die));
626 DIE *getDIE(const MDNode *TypeMD) {
627 return MDTypeNodeToDieMap.lookup(TypeMD);
630 /// \brief Emit all Dwarf sections that should come prior to the
634 /// \brief Emit all Dwarf sections that should come after the content.
635 void endModule() override;
637 /// \brief Gather pre-function debug information.
638 void beginFunction(const MachineFunction *MF) override;
640 /// \brief Gather and emit post-function debug information.
641 void endFunction(const MachineFunction *MF) override;
643 /// \brief Process beginning of an instruction.
644 void beginInstruction(const MachineInstr *MI) override;
646 /// \brief Process end of an instruction.
647 void endInstruction() override;
649 /// \brief Add a DIE to the set of types that we're going to pull into
651 void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
652 DIE *Die, DICompositeType CTy);
654 /// \brief Add a label so that arange data can be generated for it.
655 void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
657 /// \brief For symbols that have a size designated (e.g. common symbols),
658 /// this tracks that size.
659 void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {
663 /// \brief Recursively Emits a debug information entry.
664 void emitDIE(DIE *Die);
666 // Experimental DWARF5 features.
668 /// \brief Returns whether or not to emit tables that dwarf consumers can
669 /// use to accelerate lookup.
670 bool useDwarfAccelTables() const { return HasDwarfAccelTables; }
672 /// \brief Returns whether or not to change the current debug info for the
673 /// split dwarf proposal support.
674 bool useSplitDwarf() const { return HasSplitDwarf; }
676 /// Returns the Dwarf Version.
677 unsigned getDwarfVersion() const { return DwarfVersion; }
679 /// Returns the section symbol for the .debug_loc section.
680 MCSymbol *getDebugLocSym() const { return DwarfDebugLocSectionSym; }
682 /// Returns the previous section that was emitted into.
683 const MCSection *getPrevSection() const { return PrevSection; }
685 /// Returns the previous CU that was being updated
686 const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
688 /// Returns the entries for the .debug_loc section.
689 const SmallVectorImpl<SmallVector<DebugLocEntry, 4>> &
690 getDebugLocEntries() const {
691 return DotDebugLocEntries;
694 /// \brief Emit an entry for the debug loc section. This can be used to
695 /// handle an entry that's going to be emitted into the debug loc section.
696 void emitDebugLocEntry(ByteStreamer &Streamer, const DebugLocEntry &Entry);
698 /// Emit the location for a debug loc entry, including the size header.
699 void emitDebugLocEntryLocation(const DebugLocEntry &Entry);
701 /// Find the MDNode for the given reference.
702 template <typename T> T resolve(DIRef<T> Ref) const {
703 return Ref.resolve(TypeIdentifierMap);
706 /// \brief Return the TypeIdentifierMap.
707 const DITypeIdentifierMap &getTypeIdentifierMap() const {
708 return TypeIdentifierMap;
711 /// Find the DwarfCompileUnit for the given CU Die.
712 DwarfCompileUnit *lookupUnit(const DIE *CU) const {
713 return CUDieMap.lookup(CU);
715 /// isSubprogramContext - Return true if Context is either a subprogram
716 /// or another context nested inside a subprogram.
717 bool isSubprogramContext(const MDNode *Context);
719 } // End of namespace llvm