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 "llvm/ADT/DenseMap.h"
20 #include "llvm/ADT/FoldingSet.h"
21 #include "llvm/ADT/SetVector.h"
22 #include "llvm/ADT/SmallPtrSet.h"
23 #include "llvm/ADT/StringMap.h"
24 #include "llvm/ADT/MapVector.h"
25 #include "llvm/CodeGen/AsmPrinter.h"
26 #include "llvm/CodeGen/LexicalScopes.h"
27 #include "llvm/DebugInfo.h"
28 #include "llvm/MC/MachineLocation.h"
29 #include "llvm/Support/Allocator.h"
30 #include "llvm/Support/DebugLoc.h"
35 class DwarfCompileUnit;
39 class MachineFrameInfo;
40 class MachineModuleInfo;
43 class MCObjectFileInfo;
49 //===----------------------------------------------------------------------===//
50 /// \brief This class is used to record source line correspondence.
52 unsigned Line; // Source line number.
53 unsigned Column; // Source column.
54 unsigned SourceID; // Source ID number.
55 MCSymbol *Label; // Label in code ID number.
57 SrcLineInfo(unsigned L, unsigned C, unsigned S, MCSymbol *label)
58 : Line(L), Column(C), SourceID(S), Label(label) {}
61 unsigned getLine() const { return Line; }
62 unsigned getColumn() const { return Column; }
63 unsigned getSourceID() const { return SourceID; }
64 MCSymbol *getLabel() const { return Label; }
67 /// \brief This struct describes location entries emitted in the .debug_loc
69 class DotDebugLocEntry {
70 // Begin and end symbols for the address range that this location is valid.
71 const MCSymbol *Begin;
74 // Type of entry that this represents.
81 enum EntryType EntryKind;
85 const ConstantFP *CFP;
86 const ConstantInt *CIP;
89 // The location in the machine frame.
92 // The variable to which this location entry corresponds.
93 const MDNode *Variable;
95 // Whether this location has been merged.
99 DotDebugLocEntry() : Begin(0), End(0), Variable(0), Merged(false) {
102 DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, MachineLocation &L,
104 : Begin(B), End(E), Loc(L), Variable(V), Merged(false) {
106 EntryKind = E_Location;
108 DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, int64_t i)
109 : Begin(B), End(E), Variable(0), Merged(false) {
111 EntryKind = E_Integer;
113 DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, const ConstantFP *FPtr)
114 : Begin(B), End(E), Variable(0), Merged(false) {
115 Constants.CFP = FPtr;
116 EntryKind = E_ConstantFP;
118 DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E,
119 const ConstantInt *IPtr)
120 : Begin(B), End(E), Variable(0), Merged(false) {
121 Constants.CIP = IPtr;
122 EntryKind = E_ConstantInt;
125 /// \brief Empty entries are also used as a trigger to emit temp label. Such
126 /// labels are referenced is used to find debug_loc offset for a given DIE.
127 bool isEmpty() { return Begin == 0 && End == 0; }
128 bool isMerged() { return Merged; }
129 void Merge(DotDebugLocEntry *Next) {
130 if (!(Begin && Loc == Next->Loc && End == Next->Begin))
135 bool isLocation() const { return EntryKind == E_Location; }
136 bool isInt() const { return EntryKind == E_Integer; }
137 bool isConstantFP() const { return EntryKind == E_ConstantFP; }
138 bool isConstantInt() const { return EntryKind == E_ConstantInt; }
139 int64_t getInt() const { return Constants.Int; }
140 const ConstantFP *getConstantFP() const { return Constants.CFP; }
141 const ConstantInt *getConstantInt() const { return Constants.CIP; }
142 const MDNode *getVariable() const { return Variable; }
143 const MCSymbol *getBeginSym() const { return Begin; }
144 const MCSymbol *getEndSym() const { return End; }
145 MachineLocation getLoc() const { return Loc; }
148 //===----------------------------------------------------------------------===//
149 /// \brief This class is used to track local variable information.
151 DIVariable Var; // Variable Descriptor.
152 DIE *TheDIE; // Variable DIE.
153 unsigned DotDebugLocOffset; // Offset in DotDebugLocEntries.
154 DbgVariable *AbsVar; // Corresponding Abstract variable, if any.
155 const MachineInstr *MInsn; // DBG_VALUE instruction of the variable.
160 // AbsVar may be NULL.
161 DbgVariable(DIVariable V, DbgVariable *AV, DwarfDebug *DD)
162 : Var(V), TheDIE(0), DotDebugLocOffset(~0U), AbsVar(AV), MInsn(0),
163 FrameIndex(~0), DD(DD) {}
166 DIVariable getVariable() const { return Var; }
167 void setDIE(DIE *D) { TheDIE = D; }
168 DIE *getDIE() const { return TheDIE; }
169 void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; }
170 unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; }
171 StringRef getName() const { return Var.getName(); }
172 DbgVariable *getAbstractVariable() const { return AbsVar; }
173 const MachineInstr *getMInsn() const { return MInsn; }
174 void setMInsn(const MachineInstr *M) { MInsn = M; }
175 int getFrameIndex() const { return FrameIndex; }
176 void setFrameIndex(int FI) { FrameIndex = FI; }
177 // Translate tag to proper Dwarf tag.
178 uint16_t getTag() const {
179 if (Var.getTag() == dwarf::DW_TAG_arg_variable)
180 return dwarf::DW_TAG_formal_parameter;
182 return dwarf::DW_TAG_variable;
184 /// \brief Return true if DbgVariable is artificial.
185 bool isArtificial() const {
186 if (Var.isArtificial())
188 if (getType().isArtificial())
193 bool isObjectPointer() const {
194 if (Var.isObjectPointer())
196 if (getType().isObjectPointer())
201 bool variableHasComplexAddress() const {
202 assert(Var.isVariable() && "Invalid complex DbgVariable!");
203 return Var.hasComplexAddress();
205 bool isBlockByrefVariable() const {
206 assert(Var.isVariable() && "Invalid complex DbgVariable!");
207 return Var.isBlockByrefVariable();
209 unsigned getNumAddrElements() const {
210 assert(Var.isVariable() && "Invalid complex DbgVariable!");
211 return Var.getNumAddrElements();
213 uint64_t getAddrElement(unsigned i) const { return Var.getAddrElement(i); }
214 DIType getType() const;
217 /// resolve - Look in the DwarfDebug map for the MDNode that
218 /// corresponds to the reference.
219 template <typename T> T resolve(DIRef<T> Ref) const;
222 /// \brief Collects and handles information specific to a particular
223 /// collection of units. This collection represents all of the units
224 /// that will be ultimately output into a single object file.
226 // Target of Dwarf emission, used for sizing of abbreviations.
229 // Used to uniquely define abbreviations.
230 FoldingSet<DIEAbbrev> AbbreviationsSet;
232 // A list of all the unique abbreviations in use.
233 std::vector<DIEAbbrev *> Abbreviations;
235 // A pointer to all units in the section.
236 SmallVector<DwarfUnit *, 1> CUs;
238 // Collection of strings for this unit and assorted symbols.
239 // A String->Symbol mapping of strings used by indirect
241 typedef StringMap<std::pair<MCSymbol *, unsigned>, BumpPtrAllocator &>
244 unsigned NextStringPoolNumber;
245 std::string StringPref;
247 struct AddressPoolEntry {
250 AddressPoolEntry(unsigned Number, bool TLS) : Number(Number), TLS(TLS) {}
252 // Collection of addresses for this unit and assorted labels.
253 // A Symbol->unsigned mapping of addresses used by indirect
255 typedef DenseMap<const MCSymbol *, AddressPoolEntry> AddrPool;
256 AddrPool AddressPool;
257 unsigned NextAddrPoolNumber;
260 DwarfFile(AsmPrinter *AP, const char *Pref, BumpPtrAllocator &DA)
261 : Asm(AP), StringPool(DA), NextStringPoolNumber(0), StringPref(Pref),
262 AddressPool(), NextAddrPoolNumber(0) {}
266 const SmallVectorImpl<DwarfUnit *> &getUnits() { return CUs; }
268 /// \brief Compute the size and offset of a DIE given an incoming Offset.
269 unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
271 /// \brief Compute the size and offset of all the DIEs.
272 void computeSizeAndOffsets();
274 /// \brief Define a unique number for the abbreviation.
275 void assignAbbrevNumber(DIEAbbrev &Abbrev);
277 /// \brief Add a unit to the list of CUs.
278 void addUnit(DwarfUnit *CU) { CUs.push_back(CU); }
280 /// \brief Emit all of the units to the section listed with the given
281 /// abbreviation section.
282 void emitUnits(DwarfDebug *DD, const MCSection *ASection,
283 const MCSymbol *ASectionSym);
285 /// \brief Emit a set of abbreviations to the specific section.
286 void emitAbbrevs(const MCSection *);
288 /// \brief Emit all of the strings to the section given.
289 void emitStrings(const MCSection *StrSection, const MCSection *OffsetSection,
290 const MCSymbol *StrSecSym);
292 /// \brief Emit all of the addresses to the section given.
293 void emitAddresses(const MCSection *AddrSection);
295 /// \brief Returns the entry into the start of the pool.
296 MCSymbol *getStringPoolSym();
298 /// \brief Returns an entry into the string pool with the given
300 MCSymbol *getStringPoolEntry(StringRef Str);
302 /// \brief Returns the index into the string pool with the given
304 unsigned getStringPoolIndex(StringRef Str);
306 /// \brief Returns the string pool.
307 StrPool *getStringPool() { return &StringPool; }
309 /// \brief Returns the index into the address pool with the given
311 unsigned getAddrPoolIndex(const MCSymbol *Sym, bool TLS = false);
313 /// \brief Returns the address pool.
314 AddrPool *getAddrPool() { return &AddressPool; }
317 /// \brief Helper used to pair up a symbol and its DWARF compile unit.
319 SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
321 DwarfCompileUnit *CU;
324 /// \brief Collects and handles dwarf debug information.
325 class DwarfDebug : public AsmPrinterHandler {
326 // Target of Dwarf emission.
329 // Collected machine module information.
330 MachineModuleInfo *MMI;
332 // All DIEValues are allocated through this allocator.
333 BumpPtrAllocator DIEValueAllocator;
335 // Handle to the compile unit used for the inline extension handling,
336 // this is just so that the DIEValue allocator has a place to store
337 // the particular elements.
338 // FIXME: Store these off of DwarfDebug instead?
339 DwarfCompileUnit *FirstCU;
341 // Maps MDNode with its corresponding DwarfCompileUnit.
342 MapVector<const MDNode *, DwarfCompileUnit *> CUMap;
344 // Maps subprogram MDNode with its corresponding DwarfCompileUnit.
345 DenseMap<const MDNode *, DwarfCompileUnit *> SPMap;
347 // Maps a CU DIE with its corresponding DwarfCompileUnit.
348 DenseMap<const DIE *, DwarfCompileUnit *> CUDieMap;
350 /// Maps MDNodes for type sysstem with the corresponding DIEs. These DIEs can
351 /// be shared across CUs, that is why we keep the map here instead
352 /// of in DwarfCompileUnit.
353 DenseMap<const MDNode *, DIE *> MDTypeNodeToDieMap;
355 // Stores the current file ID for a given compile unit.
356 DenseMap<unsigned, unsigned> FileIDCUMap;
357 // Source id map, i.e. CUID, source filename and directory,
358 // separated by a zero byte, mapped to a unique id.
359 StringMap<unsigned, BumpPtrAllocator &> SourceIdMap;
361 // List of all labels used in aranges generation.
362 std::vector<SymbolCU> ArangeLabels;
364 // Size of each symbol emitted (for those symbols that have a specific size).
365 DenseMap<const MCSymbol *, uint64_t> SymSize;
367 // Provides a unique id per text section.
368 typedef DenseMap<const MCSection *, SmallVector<SymbolCU, 8> > SectionMapType;
369 SectionMapType SectionMap;
371 // List of arguments for current function.
372 SmallVector<DbgVariable *, 8> CurrentFnArguments;
374 LexicalScopes LScopes;
376 // Collection of abstract subprogram DIEs.
377 DenseMap<const MDNode *, DIE *> AbstractSPDies;
379 // Collection of dbg variables of a scope.
380 typedef DenseMap<LexicalScope *, SmallVector<DbgVariable *, 8> >
382 ScopeVariablesMap ScopeVariables;
384 // Collection of abstract variables.
385 DenseMap<const MDNode *, DbgVariable *> AbstractVariables;
387 // Collection of DotDebugLocEntry.
388 SmallVector<DotDebugLocEntry, 4> DotDebugLocEntries;
390 // Collection of subprogram DIEs that are marked (at the end of the module)
392 SmallPtrSet<DIE *, 4> InlinedSubprogramDIEs;
394 // This is a collection of subprogram MDNodes that are processed to
396 SmallPtrSet<const MDNode *, 16> ProcessedSPNodes;
398 // Maps instruction with label emitted before instruction.
399 DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn;
401 // Maps instruction with label emitted after instruction.
402 DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn;
404 // Every user variable mentioned by a DBG_VALUE instruction in order of
406 SmallVector<const MDNode *, 8> UserVariables;
408 // For each user variable, keep a list of DBG_VALUE instructions in order.
409 // The list can also contain normal instructions that clobber the previous
411 typedef DenseMap<const MDNode *, SmallVector<const MachineInstr *, 4> >
413 DbgValueHistoryMap DbgValues;
415 // Previous instruction's location information. This is used to determine
416 // label location to indicate scope boundries in dwarf debug info.
417 DebugLoc PrevInstLoc;
420 // This location indicates end of function prologue and beginning of function
422 DebugLoc PrologEndLoc;
424 // If nonnull, stores the current machine function we're processing.
425 const MachineFunction *CurFn;
427 // If nonnull, stores the current machine instruction we're processing.
428 const MachineInstr *CurMI;
430 // Section Symbols: these are assembler temporary labels that are emitted at
431 // the beginning of each supported dwarf section. These are used to form
432 // section offsets and are created by EmitSectionLabels.
433 MCSymbol *DwarfInfoSectionSym, *DwarfAbbrevSectionSym;
434 MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym;
435 MCSymbol *DwarfDebugLocSectionSym, *DwarfLineSectionSym, *DwarfAddrSectionSym;
436 MCSymbol *FunctionBeginSym, *FunctionEndSym;
437 MCSymbol *DwarfInfoDWOSectionSym, *DwarfAbbrevDWOSectionSym;
438 MCSymbol *DwarfStrDWOSectionSym;
439 MCSymbol *DwarfGnuPubNamesSectionSym, *DwarfGnuPubTypesSectionSym;
441 // As an optimization, there is no need to emit an entry in the directory
442 // table for the same directory as DW_AT_comp_dir.
443 StringRef CompilationDir;
445 // Counter for assigning globally unique IDs for ranges.
446 unsigned GlobalRangeCount;
448 // Holder for the file specific debug information.
449 DwarfFile InfoHolder;
451 // Holders for the various debug information flags that we might need to
452 // have exposed. See accessor functions below for description.
454 // Holder for imported entities.
455 typedef SmallVector<std::pair<const MDNode *, const MDNode *>, 32>
457 ImportedEntityMap ScopesWithImportedEntities;
459 // Map from MDNodes for user-defined types to the type units that describe
461 DenseMap<const MDNode *, const DwarfTypeUnit *> DwarfTypeUnits;
463 // Whether to emit the pubnames/pubtypes sections.
464 bool HasDwarfPubSections;
466 // Whether or not to use AT_ranges for compilation units.
469 // Whether we emitted a function into a section other than the default
471 bool UsedNonDefaultText;
473 // Version of dwarf we're emitting.
474 unsigned DwarfVersion;
476 // Maps from a type identifier to the actual MDNode.
477 DITypeIdentifierMap TypeIdentifierMap;
479 // DWARF5 Experimental Options
480 bool HasDwarfAccelTables;
483 // Separated Dwarf Variables
484 // In general these will all be for bits that are left in the
485 // original object file, rather than things that are meant
486 // to be in the .dwo sections.
488 // Holder for the skeleton information.
489 DwarfFile SkeletonHolder;
491 void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
493 const SmallVectorImpl<DwarfUnit *> &getUnits() {
494 return InfoHolder.getUnits();
497 /// \brief Find abstract variable associated with Var.
498 DbgVariable *findAbstractVariable(DIVariable &Var, DebugLoc Loc);
500 /// \brief Find DIE for the given subprogram and attach appropriate
501 /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
502 /// variables in this scope then create and insert DIEs for these
504 DIE *updateSubprogramScopeDIE(DwarfCompileUnit *SPCU, DISubprogram SP);
506 /// \brief A helper function to check whether the DIE for a given Scope is
507 /// going to be null.
508 bool isLexicalScopeDIENull(LexicalScope *Scope);
510 /// \brief A helper function to construct a RangeSpanList for a given
512 void addScopeRangeList(DwarfCompileUnit *TheCU, DIE *ScopeDIE,
513 const SmallVectorImpl<InsnRange> &Range);
515 /// \brief Construct new DW_TAG_lexical_block for this scope and
516 /// attach DW_AT_low_pc/DW_AT_high_pc labels.
517 DIE *constructLexicalScopeDIE(DwarfCompileUnit *TheCU, LexicalScope *Scope);
519 /// \brief This scope represents inlined body of a function. Construct
520 /// DIE to represent this concrete inlined copy of the function.
521 DIE *constructInlinedScopeDIE(DwarfCompileUnit *TheCU, LexicalScope *Scope);
523 /// \brief Construct a DIE for this scope.
524 DIE *constructScopeDIE(DwarfCompileUnit *TheCU, LexicalScope *Scope);
525 /// A helper function to create children of a Scope DIE.
526 DIE *createScopeChildrenDIE(DwarfCompileUnit *TheCU, LexicalScope *Scope,
527 SmallVectorImpl<DIE *> &Children);
529 /// \brief Emit initial Dwarf sections with a label at the start of each one.
530 void emitSectionLabels();
532 /// \brief Compute the size and offset of a DIE given an incoming Offset.
533 unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
535 /// \brief Compute the size and offset of all the DIEs.
536 void computeSizeAndOffsets();
538 /// \brief Attach DW_AT_inline attribute with inlined subprogram DIEs.
539 void computeInlinedDIEs();
541 /// \brief Collect info for variables that were optimized out.
542 void collectDeadVariables();
544 /// \brief Finish off debug information after all functions have been
546 void finalizeModuleInfo();
548 /// \brief Emit labels to close any remaining sections that have been left
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 inline info using custom format.
600 void emitDebugInlineInfo();
602 /// DWARF 5 Experimental Split Dwarf Emitters
604 /// \brief Initialize common features of skeleton units.
605 void initSkeletonUnit(const DwarfUnit *U, DIE *Die, DwarfUnit *NewU);
607 /// \brief Construct the split debug info compile unit for the debug info
609 DwarfCompileUnit *constructSkeletonCU(const DwarfCompileUnit *CU);
611 /// \brief Construct the split debug info compile unit for the debug info
613 DwarfTypeUnit *constructSkeletonTU(DwarfTypeUnit *TU);
615 /// \brief Emit the debug info dwo section.
616 void emitDebugInfoDWO();
618 /// \brief Emit the debug abbrev dwo section.
619 void emitDebugAbbrevDWO();
621 /// \brief Emit the debug str dwo section.
622 void emitDebugStrDWO();
624 /// Flags to let the linker know we have emitted new style pubnames. Only
625 /// emit it here if we don't have a skeleton CU for split dwarf.
626 void addGnuPubAttributes(DwarfUnit *U, DIE *D) const;
628 /// \brief Create new DwarfCompileUnit for the given metadata node with tag
629 /// DW_TAG_compile_unit.
630 DwarfCompileUnit *constructDwarfCompileUnit(DICompileUnit DIUnit);
632 /// \brief Construct subprogram DIE.
633 void constructSubprogramDIE(DwarfCompileUnit *TheCU, const MDNode *N);
635 /// \brief Construct imported_module or imported_declaration DIE.
636 void constructImportedEntityDIE(DwarfCompileUnit *TheCU, const MDNode *N);
638 /// \brief Construct import_module DIE.
639 void constructImportedEntityDIE(DwarfCompileUnit *TheCU, const MDNode *N,
642 /// \brief Construct import_module DIE.
643 void constructImportedEntityDIE(DwarfCompileUnit *TheCU,
644 const DIImportedEntity &Module, DIE *Context);
646 /// \brief Register a source line with debug info. Returns the unique
647 /// label that was emitted and which provides correspondence to the
648 /// source line list.
649 void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
652 /// \brief Indentify instructions that are marking the beginning of or
653 /// ending of a scope.
654 void identifyScopeMarkers();
656 /// \brief If Var is an current function argument that add it in
657 /// CurrentFnArguments list.
658 bool addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope);
660 /// \brief Populate LexicalScope entries with variables' info.
661 void collectVariableInfo(SmallPtrSet<const MDNode *, 16> &ProcessedVars);
663 /// \brief Collect variable information from the side table maintained
665 void collectVariableInfoFromMMITable(SmallPtrSet<const MDNode *, 16> &P);
667 /// \brief Ensure that a label will be emitted before MI.
668 void requestLabelBeforeInsn(const MachineInstr *MI) {
669 LabelsBeforeInsn.insert(std::make_pair(MI, (MCSymbol *)0));
672 /// \brief Return Label preceding the instruction.
673 MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
675 /// \brief Ensure that a label will be emitted after MI.
676 void requestLabelAfterInsn(const MachineInstr *MI) {
677 LabelsAfterInsn.insert(std::make_pair(MI, (MCSymbol *)0));
680 /// \brief Return Label immediately following the instruction.
681 MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
684 //===--------------------------------------------------------------------===//
685 // Main entry points.
687 DwarfDebug(AsmPrinter *A, Module *M);
689 void insertDIE(const MDNode *TypeMD, DIE *Die) {
690 MDTypeNodeToDieMap.insert(std::make_pair(TypeMD, Die));
692 DIE *getDIE(const MDNode *TypeMD) {
693 return MDTypeNodeToDieMap.lookup(TypeMD);
696 /// \brief Emit all Dwarf sections that should come prior to the
700 /// \brief Emit all Dwarf sections that should come after the content.
703 /// \brief Gather pre-function debug information.
704 void beginFunction(const MachineFunction *MF);
706 /// \brief Gather and emit post-function debug information.
707 void endFunction(const MachineFunction *MF);
709 /// \brief Process beginning of an instruction.
710 void beginInstruction(const MachineInstr *MI);
712 /// \brief Process end of an instruction.
713 void endInstruction();
715 /// \brief Add a DIE to the set of types that we're going to pull into
717 void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
718 DIE *Die, DICompositeType CTy);
720 /// \brief Add a label so that arange data can be generated for it.
721 void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
723 /// \brief For symbols that have a size designated (e.g. common symbols),
724 /// this tracks that size.
725 void setSymbolSize(const MCSymbol *Sym, uint64_t Size) {
729 /// \brief Look up the source id with the given directory and source file
730 /// names. If none currently exists, create a new id and insert it in the
732 unsigned getOrCreateSourceID(StringRef DirName, StringRef FullName,
735 /// \brief Recursively Emits a debug information entry.
736 void emitDIE(DIE *Die);
738 // Experimental DWARF5 features.
740 /// \brief Returns whether or not to emit tables that dwarf consumers can
741 /// use to accelerate lookup.
742 bool useDwarfAccelTables() { return HasDwarfAccelTables; }
744 /// \brief Returns whether or not to change the current debug info for the
745 /// split dwarf proposal support.
746 bool useSplitDwarf() { return HasSplitDwarf; }
748 /// \brief Returns whether or not to use AT_ranges for compilation units.
749 bool useCURanges() { return HasCURanges; }
751 /// Returns the Dwarf Version.
752 unsigned getDwarfVersion() const { return DwarfVersion; }
754 /// Find the MDNode for the given reference.
755 template <typename T> T resolve(DIRef<T> Ref) const {
756 return Ref.resolve(TypeIdentifierMap);
759 /// isSubprogramContext - Return true if Context is either a subprogram
760 /// or another context nested inside a subprogram.
761 bool isSubprogramContext(const MDNode *Context);
763 } // End of namespace llvm