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__
18 #include "llvm/ADT/DenseMap.h"
19 #include "llvm/ADT/FoldingSet.h"
20 #include "llvm/ADT/SetVector.h"
21 #include "llvm/ADT/SmallPtrSet.h"
22 #include "llvm/ADT/StringMap.h"
23 #include "llvm/CodeGen/AsmPrinter.h"
24 #include "llvm/CodeGen/LexicalScopes.h"
25 #include "llvm/DebugInfo.h"
26 #include "llvm/MC/MachineLocation.h"
27 #include "llvm/Support/Allocator.h"
28 #include "llvm/Support/DebugLoc.h"
36 class MachineFrameInfo;
37 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 /// \brief This struct describes location entries emitted in the .debug_loc
65 class DotDebugLocEntry {
66 // Begin and end symbols for the address range that this location is valid.
67 const MCSymbol *Begin;
70 // Type of entry that this represents.
77 enum EntryType EntryKind;
81 const ConstantFP *CFP;
82 const ConstantInt *CIP;
85 // The location in the machine frame.
88 // The variable to which this location entry corresponds.
89 const MDNode *Variable;
91 // Whether this location has been merged.
95 DotDebugLocEntry() : Begin(0), End(0), Variable(0), Merged(false) {
98 DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, MachineLocation &L,
100 : Begin(B), End(E), Loc(L), Variable(V), Merged(false) {
102 EntryKind = E_Location;
104 DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, int64_t i)
105 : Begin(B), End(E), Variable(0), Merged(false) {
107 EntryKind = E_Integer;
109 DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, const ConstantFP *FPtr)
110 : Begin(B), End(E), Variable(0), Merged(false) {
111 Constants.CFP = FPtr;
112 EntryKind = E_ConstantFP;
114 DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E,
115 const ConstantInt *IPtr)
116 : Begin(B), End(E), Variable(0), Merged(false) {
117 Constants.CIP = IPtr;
118 EntryKind = E_ConstantInt;
121 /// \brief Empty entries are also used as a trigger to emit temp label. Such
122 /// labels are referenced is used to find debug_loc offset for a given DIE.
123 bool isEmpty() { return Begin == 0 && End == 0; }
124 bool isMerged() { return Merged; }
125 void Merge(DotDebugLocEntry *Next) {
126 if (!(Begin && Loc == Next->Loc && End == Next->Begin))
131 bool isLocation() const { return EntryKind == E_Location; }
132 bool isInt() const { return EntryKind == E_Integer; }
133 bool isConstantFP() const { return EntryKind == E_ConstantFP; }
134 bool isConstantInt() const { return EntryKind == E_ConstantInt; }
135 int64_t getInt() const { return Constants.Int; }
136 const ConstantFP *getConstantFP() const { return Constants.CFP; }
137 const ConstantInt *getConstantInt() const { return Constants.CIP; }
138 const MDNode *getVariable() const { return Variable; }
139 const MCSymbol *getBeginSym() const { return Begin; }
140 const MCSymbol *getEndSym() const { return End; }
141 MachineLocation getLoc() const { return Loc; }
144 //===----------------------------------------------------------------------===//
145 /// \brief This class is used to track local variable information.
147 DIVariable Var; // Variable Descriptor.
148 DIE *TheDIE; // Variable DIE.
149 unsigned DotDebugLocOffset; // Offset in DotDebugLocEntries.
150 DbgVariable *AbsVar; // Corresponding Abstract variable, if any.
151 const MachineInstr *MInsn; // DBG_VALUE instruction of the variable.
155 // AbsVar may be NULL.
156 DbgVariable(DIVariable V, DbgVariable *AV, DwarfDebug *DD)
157 : Var(V), TheDIE(0), DotDebugLocOffset(~0U), AbsVar(AV), MInsn(0),
158 FrameIndex(~0), DD(DD) {}
161 DIVariable getVariable() const { return Var; }
162 void setDIE(DIE *D) { TheDIE = D; }
163 DIE *getDIE() const { return TheDIE; }
164 void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; }
165 unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; }
166 StringRef getName() const { return Var.getName(); }
167 DbgVariable *getAbstractVariable() const { return AbsVar; }
168 const MachineInstr *getMInsn() const { return MInsn; }
169 void setMInsn(const MachineInstr *M) { MInsn = M; }
170 int getFrameIndex() const { return FrameIndex; }
171 void setFrameIndex(int FI) { FrameIndex = FI; }
172 // Translate tag to proper Dwarf tag.
173 uint16_t getTag() const {
174 if (Var.getTag() == dwarf::DW_TAG_arg_variable)
175 return dwarf::DW_TAG_formal_parameter;
177 return dwarf::DW_TAG_variable;
179 /// \brief Return true if DbgVariable is artificial.
180 bool isArtificial() const {
181 if (Var.isArtificial())
183 if (getType().isArtificial())
188 bool isObjectPointer() const {
189 if (Var.isObjectPointer())
191 if (getType().isObjectPointer())
196 bool variableHasComplexAddress() const {
197 assert(Var.isVariable() && "Invalid complex DbgVariable!");
198 return Var.hasComplexAddress();
200 bool isBlockByrefVariable() const {
201 assert(Var.isVariable() && "Invalid complex DbgVariable!");
202 return Var.isBlockByrefVariable();
204 unsigned getNumAddrElements() const {
205 assert(Var.isVariable() && "Invalid complex DbgVariable!");
206 return Var.getNumAddrElements();
208 uint64_t getAddrElement(unsigned i) const {
209 return Var.getAddrElement(i);
211 DIType getType() const;
214 /// \brief Collects and handles information specific to a particular
215 /// collection of units.
217 // Target of Dwarf emission, used for sizing of abbreviations.
220 // Used to uniquely define abbreviations.
221 FoldingSet<DIEAbbrev> *AbbreviationsSet;
223 // A list of all the unique abbreviations in use.
224 std::vector<DIEAbbrev *> *Abbreviations;
226 // A pointer to all units in the section.
227 SmallVector<CompileUnit *, 1> CUs;
229 // Collection of strings for this unit and assorted symbols.
230 // A String->Symbol mapping of strings used by indirect
232 typedef StringMap<std::pair<MCSymbol*, unsigned>,
233 BumpPtrAllocator&> StrPool;
235 unsigned NextStringPoolNumber;
236 std::string StringPref;
238 // Collection of addresses for this unit and assorted labels.
239 // A Symbol->unsigned mapping of addresses used by indirect
241 typedef DenseMap<const MCExpr *, unsigned> AddrPool;
242 AddrPool AddressPool;
243 unsigned NextAddrPoolNumber;
246 DwarfUnits(AsmPrinter *AP, FoldingSet<DIEAbbrev> *AS,
247 std::vector<DIEAbbrev *> *A, const char *Pref,
248 BumpPtrAllocator &DA)
249 : Asm(AP), AbbreviationsSet(AS), Abbreviations(A), StringPool(DA),
250 NextStringPoolNumber(0), StringPref(Pref), AddressPool(),
251 NextAddrPoolNumber(0) {}
253 /// \brief Compute the size and offset of a DIE given an incoming Offset.
254 unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
256 /// \brief Compute the size and offset of all the DIEs.
257 void computeSizeAndOffsets();
259 /// \brief Define a unique number for the abbreviation.
260 void assignAbbrevNumber(DIEAbbrev &Abbrev);
262 /// \brief Add a unit to the list of CUs.
263 void addUnit(CompileUnit *CU) { CUs.push_back(CU); }
265 /// \brief Emit all of the units to the section listed with the given
266 /// abbreviation section.
267 void emitUnits(DwarfDebug *DD, const MCSection *USection,
268 const MCSection *ASection, const MCSymbol *ASectionSym);
270 /// \brief Emit all of the strings to the section given.
271 void emitStrings(const MCSection *StrSection, const MCSection *OffsetSection,
272 const MCSymbol *StrSecSym);
274 /// \brief Emit all of the addresses to the section given.
275 void emitAddresses(const MCSection *AddrSection);
277 /// \brief Returns the entry into the start of the pool.
278 MCSymbol *getStringPoolSym();
280 /// \brief Returns an entry into the string pool with the given
282 MCSymbol *getStringPoolEntry(StringRef Str);
284 /// \brief Returns the index into the string pool with the given
286 unsigned getStringPoolIndex(StringRef Str);
288 /// \brief Returns the string pool.
289 StrPool *getStringPool() { return &StringPool; }
291 /// \brief Returns the index into the address pool with the given
293 unsigned getAddrPoolIndex(const MCExpr *Sym);
294 unsigned getAddrPoolIndex(const MCSymbol *Sym);
296 /// \brief Returns the address pool.
297 AddrPool *getAddrPool() { return &AddressPool; }
299 /// \brief for a given compile unit DIE, returns offset from beginning of
301 unsigned getCUOffset(DIE *Die);
304 /// \brief Helper used to pair up a symbol and it's DWARF compile unit.
306 SymbolCU(CompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
311 /// \brief Collects and handles dwarf debug information.
313 // Target of Dwarf emission.
316 // Collected machine module information.
317 MachineModuleInfo *MMI;
319 // All DIEValues are allocated through this allocator.
320 BumpPtrAllocator DIEValueAllocator;
322 // Handle to the a compile unit used for the inline extension handling.
323 CompileUnit *FirstCU;
325 // Maps MDNode with its corresponding CompileUnit.
326 DenseMap <const MDNode *, CompileUnit *> CUMap;
328 // Maps subprogram MDNode with its corresponding CompileUnit.
329 DenseMap <const MDNode *, CompileUnit *> SPMap;
331 /// Maps type MDNode with its corresponding DIE. These DIEs can be
332 /// shared across CUs, that is why we keep the map here instead
333 /// of in CompileUnit.
334 DenseMap<const MDNode *, DIE *> MDTypeNodeToDieMap;
335 /// Maps subprogram MDNode with its corresponding DIE.
336 DenseMap<const MDNode *, DIE *> MDSPNodeToDieMap;
337 /// Maps static member MDNode with its corresponding DIE.
338 DenseMap<const MDNode *, DIE *> MDStaticMemberNodeToDieMap;
340 /// Specifies a worklist item. Sometimes, when we try to add an attribute to
341 /// a DIE, the DIE is not yet added to its owner yet, so we don't know whether
342 /// we should use ref_addr or ref4. We create a worklist that will be
343 /// processed during finalization to add attributes with the correct form
344 /// (ref_addr or ref4).
345 struct DIEEntryWorkItem {
349 DIEEntryWorkItem(DIE *D, uint16_t A, DIEEntry *E) :
350 Die(D), Attribute(A), Entry(E) {
353 SmallVector<DIEEntryWorkItem, 64> DIEEntryWorklist;
355 // Used to uniquely define abbreviations.
356 FoldingSet<DIEAbbrev> AbbreviationsSet;
358 // A list of all the unique abbreviations in use.
359 std::vector<DIEAbbrev *> Abbreviations;
361 // Stores the current file ID for a given compile unit.
362 DenseMap <unsigned, unsigned> FileIDCUMap;
363 // Source id map, i.e. CUID, source filename and directory,
364 // separated by a zero byte, mapped to a unique id.
365 StringMap<unsigned, BumpPtrAllocator&> SourceIdMap;
367 // List of all labels used in aranges generation.
368 std::vector<SymbolCU> ArangeLabels;
370 // Size of each symbol emitted (for those symbols that have a specific size).
371 DenseMap <const MCSymbol *, uint64_t> SymSize;
373 // Provides a unique id per text section.
374 typedef DenseMap<const MCSection *, SmallVector<SymbolCU, 8> > SectionMapType;
375 SectionMapType SectionMap;
377 // List of arguments for current function.
378 SmallVector<DbgVariable *, 8> CurrentFnArguments;
380 LexicalScopes LScopes;
382 // Collection of abstract subprogram DIEs.
383 DenseMap<const MDNode *, DIE *> AbstractSPDies;
385 // Collection of dbg variables of a scope.
386 typedef DenseMap<LexicalScope *,
387 SmallVector<DbgVariable *, 8> > ScopeVariablesMap;
388 ScopeVariablesMap ScopeVariables;
390 // Collection of abstract variables.
391 DenseMap<const MDNode *, DbgVariable *> AbstractVariables;
393 // Collection of DotDebugLocEntry.
394 SmallVector<DotDebugLocEntry, 4> DotDebugLocEntries;
396 // Collection of subprogram DIEs that are marked (at the end of the module)
398 SmallPtrSet<DIE *, 4> InlinedSubprogramDIEs;
400 // This is a collection of subprogram MDNodes that are processed to
402 SmallPtrSet<const MDNode *, 16> ProcessedSPNodes;
404 // Maps instruction with label emitted before instruction.
405 DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn;
407 // Maps instruction with label emitted after instruction.
408 DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn;
410 // Every user variable mentioned by a DBG_VALUE instruction in order of
412 SmallVector<const MDNode*, 8> UserVariables;
414 // For each user variable, keep a list of DBG_VALUE instructions in order.
415 // The list can also contain normal instructions that clobber the previous
417 typedef DenseMap<const MDNode*, SmallVector<const MachineInstr*, 4> >
419 DbgValueHistoryMap DbgValues;
421 SmallVector<const MCSymbol *, 8> DebugRangeSymbols;
423 // Previous instruction's location information. This is used to determine
424 // label location to indicate scope boundries in dwarf debug info.
425 DebugLoc PrevInstLoc;
428 // This location indicates end of function prologue and beginning of function
430 DebugLoc PrologEndLoc;
432 // Section Symbols: these are assembler temporary labels that are emitted at
433 // the beginning of each supported dwarf section. These are used to form
434 // section offsets and are created by EmitSectionLabels.
435 MCSymbol *DwarfInfoSectionSym, *DwarfAbbrevSectionSym;
436 MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym;
437 MCSymbol *DwarfDebugLocSectionSym, *DwarfLineSectionSym, *DwarfAddrSectionSym;
438 MCSymbol *FunctionBeginSym, *FunctionEndSym;
439 MCSymbol *DwarfAbbrevDWOSectionSym, *DwarfStrDWOSectionSym;
440 MCSymbol *DwarfGnuPubNamesSectionSym, *DwarfGnuPubTypesSectionSym;
442 // As an optimization, there is no need to emit an entry in the directory
443 // table for the same directory as DW_AT_comp_dir.
444 StringRef CompilationDir;
446 // Counter for assigning globally unique IDs for CUs.
447 unsigned GlobalCUIndexCount;
449 // Holder for the file specific debug information.
450 DwarfUnits InfoHolder;
452 // Holders for the various debug information flags that we might need to
453 // have exposed. See accessor functions below for description.
455 // Whether or not we're emitting info for older versions of gdb on darwin.
456 bool IsDarwinGDBCompat;
458 // Holder for imported entities.
459 typedef SmallVector<std::pair<const MDNode *, const MDNode *>, 32>
461 ImportedEntityMap ScopesWithImportedEntities;
463 // Holder for types that are going to be extracted out into a type unit.
464 std::vector<DIE *> TypeUnits;
466 // Whether to emit the pubnames/pubtypes sections.
467 bool HasDwarfPubSections;
469 // Version of dwarf we're emitting.
470 unsigned DwarfVersion;
472 // DWARF5 Experimental Options
473 bool HasDwarfAccelTables;
476 // Separated Dwarf Variables
477 // In general these will all be for bits that are left in the
478 // original object file, rather than things that are meant
479 // to be in the .dwo sections.
481 // The CUs left in the original object file for separated debug info.
482 SmallVector<CompileUnit *, 1> SkeletonCUs;
484 // Used to uniquely define abbreviations for the skeleton emission.
485 FoldingSet<DIEAbbrev> SkeletonAbbrevSet;
487 // A list of all the unique abbreviations in use.
488 std::vector<DIEAbbrev *> SkeletonAbbrevs;
490 // Holder for the skeleton information.
491 DwarfUnits SkeletonHolder;
493 // Maps from a type identifier to the actual MDNode.
494 DITypeIdentifierMap TypeIdentifierMap;
498 void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
500 /// \brief Find abstract variable associated with Var.
501 DbgVariable *findAbstractVariable(DIVariable &Var, DebugLoc Loc);
503 /// \brief Find DIE for the given subprogram and attach appropriate
504 /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
505 /// variables in this scope then create and insert DIEs for these
507 DIE *updateSubprogramScopeDIE(CompileUnit *SPCU, const MDNode *SPNode);
509 /// \brief Construct new DW_TAG_lexical_block for this scope and
510 /// attach DW_AT_low_pc/DW_AT_high_pc labels.
511 DIE *constructLexicalScopeDIE(CompileUnit *TheCU, LexicalScope *Scope);
512 /// A helper function to check whether the DIE for a given Scope is going
514 bool isLexicalScopeDIENull(LexicalScope *Scope);
516 /// \brief This scope represents inlined body of a function. Construct
517 /// DIE to represent this concrete inlined copy of the function.
518 DIE *constructInlinedScopeDIE(CompileUnit *TheCU, LexicalScope *Scope);
520 /// \brief Construct a DIE for this scope.
521 DIE *constructScopeDIE(CompileUnit *TheCU, LexicalScope *Scope);
522 /// A helper function to create children of a Scope DIE.
523 DIE *createScopeChildrenDIE(CompileUnit *TheCU, LexicalScope *Scope,
524 SmallVectorImpl<DIE*> &Children);
526 /// \brief Emit initial Dwarf sections with a label at the start of each one.
527 void emitSectionLabels();
529 /// \brief Compute the size and offset of a DIE given an incoming Offset.
530 unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
532 /// \brief Compute the size and offset of all the DIEs.
533 void computeSizeAndOffsets();
535 /// \brief Attach DW_AT_inline attribute with inlined subprogram DIEs.
536 void computeInlinedDIEs();
538 /// \brief Collect info for variables that were optimized out.
539 void collectDeadVariables();
541 /// \brief Finish off debug information after all functions have been
543 void finalizeModuleInfo();
545 /// \brief Emit labels to close any remaining sections that have been left
549 /// \brief Emit a set of abbreviations to the specific section.
550 void emitAbbrevs(const MCSection *, std::vector<DIEAbbrev*> *);
552 /// \brief Emit the debug info section.
553 void emitDebugInfo();
555 /// \brief Emit the abbreviation section.
556 void emitAbbreviations();
558 /// \brief Emit the last address of the section and the end of
560 void emitEndOfLineMatrix(unsigned SectionEnd);
562 /// \brief Emit visible names into a hashed accelerator table section.
563 void emitAccelNames();
565 /// \brief Emit objective C classes and categories into a hashed
566 /// accelerator table section.
567 void emitAccelObjC();
569 /// \brief Emit namespace dies into a hashed accelerator table.
570 void emitAccelNamespaces();
572 /// \brief Emit type dies into a hashed accelerator table.
573 void emitAccelTypes();
575 /// \brief Emit visible names into a debug pubnames section.
576 /// \param GnuStyle determines whether or not we want to emit
577 /// additional information into the table ala newer gcc for gdb
579 void emitDebugPubNames(bool GnuStyle = false);
581 /// \brief Emit visible types into a debug pubtypes section.
582 /// \param GnuStyle determines whether or not we want to emit
583 /// additional information into the table ala newer gcc for gdb
585 void emitDebugPubTypes(bool GnuStyle = false);
587 /// \brief Emit visible names into a debug str section.
590 /// \brief Emit visible names into a debug loc section.
593 /// \brief Emit visible names into a debug aranges section.
594 void emitDebugARanges();
596 /// \brief Emit visible names into a debug ranges section.
597 void emitDebugRanges();
599 /// \brief Emit visible names into a debug macinfo section.
600 void emitDebugMacInfo();
602 /// \brief Emit inline info using custom format.
603 void emitDebugInlineInfo();
605 /// DWARF 5 Experimental Split Dwarf Emitters
607 /// \brief Construct the split debug info compile unit for the debug info
609 CompileUnit *constructSkeletonCU(const CompileUnit *CU);
611 /// \brief Emit the local split abbreviations.
612 void emitSkeletonAbbrevs(const MCSection *);
614 /// \brief Emit the debug info dwo section.
615 void emitDebugInfoDWO();
617 /// \brief Emit the debug abbrev dwo section.
618 void emitDebugAbbrevDWO();
620 /// \brief Emit the debug str dwo section.
621 void emitDebugStrDWO();
623 /// \brief Create new CompileUnit for the given metadata node with tag
624 /// DW_TAG_compile_unit.
625 CompileUnit *constructCompileUnit(const MDNode *N);
627 /// \brief Construct subprogram DIE.
628 void constructSubprogramDIE(CompileUnit *TheCU, const MDNode *N);
630 /// \brief Construct imported_module or imported_declaration DIE.
631 void constructImportedEntityDIE(CompileUnit *TheCU, const MDNode *N);
633 /// \brief Construct import_module DIE.
634 void constructImportedEntityDIE(CompileUnit *TheCU, const MDNode *N,
637 /// \brief Construct import_module DIE.
638 void constructImportedEntityDIE(CompileUnit *TheCU,
639 const DIImportedEntity &Module,
642 /// \brief Register a source line with debug info. Returns the unique
643 /// label that was emitted and which provides correspondence to the
644 /// source line list.
645 void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
648 /// \brief Indentify instructions that are marking the beginning of or
649 /// ending of a scope.
650 void identifyScopeMarkers();
652 /// \brief If Var is an current function argument that add it in
653 /// CurrentFnArguments list.
654 bool addCurrentFnArgument(const MachineFunction *MF,
655 DbgVariable *Var, LexicalScope *Scope);
657 /// \brief Populate LexicalScope entries with variables' info.
658 void collectVariableInfo(const MachineFunction *,
659 SmallPtrSet<const MDNode *, 16> &ProcessedVars);
661 /// \brief Collect variable information from the side table maintained
663 void collectVariableInfoFromMMITable(const MachineFunction * MF,
664 SmallPtrSet<const MDNode *, 16> &P);
666 /// \brief Ensure that a label will be emitted before MI.
667 void requestLabelBeforeInsn(const MachineInstr *MI) {
668 LabelsBeforeInsn.insert(std::make_pair(MI, (MCSymbol*)0));
671 /// \brief Return Label preceding the instruction.
672 MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
674 /// \brief Ensure that a label will be emitted after MI.
675 void requestLabelAfterInsn(const MachineInstr *MI) {
676 LabelsAfterInsn.insert(std::make_pair(MI, (MCSymbol*)0));
679 /// \brief Return Label immediately following the instruction.
680 MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
683 //===--------------------------------------------------------------------===//
684 // Main entry points.
686 DwarfDebug(AsmPrinter *A, Module *M);
689 void insertTypeDIE(const MDNode *TypeMD, DIE *Die) {
690 MDTypeNodeToDieMap.insert(std::make_pair(TypeMD, Die));
692 DIE *getTypeDIE(const MDNode *TypeMD) {
693 return MDTypeNodeToDieMap.lookup(TypeMD);
695 void insertSPDIE(const MDNode *SPMD, DIE *Die) {
696 MDSPNodeToDieMap.insert(std::make_pair(SPMD, Die));
698 DIE *getSPDIE(const MDNode *SPMD) {
699 return MDSPNodeToDieMap.lookup(SPMD);
701 void insertStaticMemberDIE(const MDNode *StaticMD, DIE *Die) {
702 MDStaticMemberNodeToDieMap.insert(std::make_pair(StaticMD, Die));
704 DIE *getStaticMemberDIE(const MDNode *StaticMD) {
705 return MDStaticMemberNodeToDieMap.lookup(StaticMD);
707 void insertDIEEntryWorklist(DIE *Die, uint16_t Attribute, DIEEntry *Entry) {
708 DIEEntryWorklist.push_back(DIEEntryWorkItem(Die, Attribute, Entry));
711 /// \brief Emit all Dwarf sections that should come prior to the
715 /// \brief Emit all Dwarf sections that should come after the content.
718 /// \brief Gather pre-function debug information.
719 void beginFunction(const MachineFunction *MF);
721 /// \brief Gather and emit post-function debug information.
722 void endFunction(const MachineFunction *MF);
724 /// \brief Process beginning of an instruction.
725 void beginInstruction(const MachineInstr *MI);
727 /// \brief Process end of an instruction.
728 void endInstruction(const MachineInstr *MI);
730 /// \brief Add a DIE to the set of types that we're going to pull into
732 void addTypeUnitType(DIE *Die) { TypeUnits.push_back(Die); }
734 /// \brief Add a label so that arange data can be generated for it.
735 void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
737 /// \brief For symbols that have a size designated (e.g. common symbols),
738 /// this tracks that size.
739 void setSymbolSize(const MCSymbol *Sym, uint64_t Size) { SymSize[Sym] = Size;}
741 /// \brief Look up the source id with the given directory and source file
742 /// names. If none currently exists, create a new id and insert it in the
744 unsigned getOrCreateSourceID(StringRef DirName, StringRef FullName,
747 /// \brief Recursively Emits a debug information entry.
748 void emitDIE(DIE *Die, std::vector<DIEAbbrev *> *Abbrevs);
750 /// \brief Returns whether or not to limit some of our debug
751 /// output to the limitations of darwin gdb.
752 bool useDarwinGDBCompat() { return IsDarwinGDBCompat; }
754 // Experimental DWARF5 features.
756 /// \brief Returns whether or not to emit tables that dwarf consumers can
757 /// use to accelerate lookup.
758 bool useDwarfAccelTables() { return HasDwarfAccelTables; }
760 /// \brief Returns whether or not to change the current debug info for the
761 /// split dwarf proposal support.
762 bool useSplitDwarf() { return HasSplitDwarf; }
764 /// Returns the Dwarf Version.
765 unsigned getDwarfVersion() const { return DwarfVersion; }
767 /// Find the MDNode for the given scope reference.
768 template <typename T>
769 T resolve(DIRef<T> Ref) const {
770 return Ref.resolve(TypeIdentifierMap);
773 /// When we don't know whether the correct form is ref4 or ref_addr, we create
774 /// a worklist item and insert it to DIEEntryWorklist.
775 void addDIEEntry(DIE *Die, uint16_t Attribute, uint16_t Form,
778 /// isSubprogramContext - Return true if Context is either a subprogram
779 /// or another context nested inside a subprogram.
780 bool isSubprogramContext(const MDNode *Context);
783 } // End of namespace llvm