Move typedefs inside the class that they belong to.
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DwarfDebug.h
1 //===-- llvm/CodeGen/DwarfDebug.h - Dwarf Debug Framework ------*- C++ -*--===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains support for writing dwarf debug info into asm files.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef CODEGEN_ASMPRINTER_DWARFDEBUG_H__
15 #define CODEGEN_ASMPRINTER_DWARFDEBUG_H__
16
17 #include "DIE.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"
29
30 namespace llvm {
31
32 class CompileUnit;
33 class ConstantInt;
34 class ConstantFP;
35 class DbgVariable;
36 class MachineFrameInfo;
37 class MachineModuleInfo;
38 class MachineOperand;
39 class MCAsmInfo;
40 class DIEAbbrev;
41 class DIE;
42 class DIEBlock;
43 class DIEEntry;
44
45 //===----------------------------------------------------------------------===//
46 /// \brief This class is used to record source line correspondence.
47 class SrcLineInfo {
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.
52 public:
53   SrcLineInfo(unsigned L, unsigned C, unsigned S, MCSymbol *label)
54     : Line(L), Column(C), SourceID(S), Label(label) {}
55
56   // Accessors
57   unsigned getLine() const { return Line; }
58   unsigned getColumn() const { return Column; }
59   unsigned getSourceID() const { return SourceID; }
60   MCSymbol *getLabel() const { return Label; }
61 };
62
63 /// \brief This struct describes location entries emitted in the .debug_loc
64 /// section.
65 typedef struct DotDebugLocEntry {
66   const MCSymbol *Begin;
67   const MCSymbol *End;
68   MachineLocation Loc;
69   const MDNode *Variable;
70   bool Merged;
71   enum EntryType {
72     E_Location,
73     E_Integer,
74     E_ConstantFP,
75     E_ConstantInt
76   };
77   enum EntryType EntryKind;
78
79   union {
80     int64_t Int;
81     const ConstantFP *CFP;
82     const ConstantInt *CIP;
83   } Constants;
84   DotDebugLocEntry() : Begin(0), End(0), Variable(0), Merged(false) {
85     Constants.Int = 0;
86   }
87   DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, MachineLocation &L,
88                    const MDNode *V)
89       : Begin(B), End(E), Loc(L), Variable(V), Merged(false) {
90     Constants.Int = 0;
91     EntryKind = E_Location;
92   }
93   DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, int64_t i)
94       : Begin(B), End(E), Variable(0), Merged(false) {
95     Constants.Int = i;
96     EntryKind = E_Integer;
97   }
98   DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, const ConstantFP *FPtr)
99       : Begin(B), End(E), Variable(0), Merged(false) {
100     Constants.CFP = FPtr;
101     EntryKind = E_ConstantFP;
102   }
103   DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E,
104                    const ConstantInt *IPtr)
105       : Begin(B), End(E), Variable(0), Merged(false) {
106     Constants.CIP = IPtr;
107     EntryKind = E_ConstantInt;
108   }
109
110   /// \brief Empty entries are also used as a trigger to emit temp label. Such
111   /// labels are referenced is used to find debug_loc offset for a given DIE.
112   bool isEmpty() { return Begin == 0 && End == 0; }
113   bool isMerged() { return Merged; }
114   void Merge(DotDebugLocEntry *Next) {
115     if (!(Begin && Loc == Next->Loc && End == Next->Begin))
116       return;
117     Next->Begin = Begin;
118     Merged = true;
119   }
120   bool isLocation() const    { return EntryKind == E_Location; }
121   bool isInt() const         { return EntryKind == E_Integer; }
122   bool isConstantFP() const  { return EntryKind == E_ConstantFP; }
123   bool isConstantInt() const { return EntryKind == E_ConstantInt; }
124   int64_t getInt() const                    { return Constants.Int; }
125   const ConstantFP *getConstantFP() const   { return Constants.CFP; }
126   const ConstantInt *getConstantInt() const { return Constants.CIP; }
127 } DotDebugLocEntry;
128
129 //===----------------------------------------------------------------------===//
130 /// \brief This class is used to track local variable information.
131 class DbgVariable {
132   DIVariable Var;                    // Variable Descriptor.
133   DIE *TheDIE;                       // Variable DIE.
134   unsigned DotDebugLocOffset;        // Offset in DotDebugLocEntries.
135   DbgVariable *AbsVar;               // Corresponding Abstract variable, if any.
136   const MachineInstr *MInsn;         // DBG_VALUE instruction of the variable.
137   int FrameIndex;
138 public:
139   // AbsVar may be NULL.
140   DbgVariable(DIVariable V, DbgVariable *AV)
141     : Var(V), TheDIE(0), DotDebugLocOffset(~0U), AbsVar(AV), MInsn(0),
142       FrameIndex(~0) {}
143
144   // Accessors.
145   DIVariable getVariable()           const { return Var; }
146   void setDIE(DIE *D)                      { TheDIE = D; }
147   DIE *getDIE()                      const { return TheDIE; }
148   void setDotDebugLocOffset(unsigned O)    { DotDebugLocOffset = O; }
149   unsigned getDotDebugLocOffset()    const { return DotDebugLocOffset; }
150   StringRef getName()                const { return Var.getName(); }
151   DbgVariable *getAbstractVariable() const { return AbsVar; }
152   const MachineInstr *getMInsn()     const { return MInsn; }
153   void setMInsn(const MachineInstr *M)     { MInsn = M; }
154   int getFrameIndex()                const { return FrameIndex; }
155   void setFrameIndex(int FI)               { FrameIndex = FI; }
156   // Translate tag to proper Dwarf tag.
157   unsigned getTag()                  const {
158     if (Var.getTag() == dwarf::DW_TAG_arg_variable)
159       return dwarf::DW_TAG_formal_parameter;
160
161     return dwarf::DW_TAG_variable;
162   }
163   /// \brief Return true if DbgVariable is artificial.
164   bool isArtificial()                const {
165     if (Var.isArtificial())
166       return true;
167     if (getType().isArtificial())
168       return true;
169     return false;
170   }
171
172   bool isObjectPointer()             const {
173     if (Var.isObjectPointer())
174       return true;
175     if (getType().isObjectPointer())
176       return true;
177     return false;
178   }
179
180   bool variableHasComplexAddress()   const {
181     assert(Var.Verify() && "Invalid complex DbgVariable!");
182     return Var.hasComplexAddress();
183   }
184   bool isBlockByrefVariable()        const {
185     assert(Var.Verify() && "Invalid complex DbgVariable!");
186     return Var.isBlockByrefVariable();
187   }
188   unsigned getNumAddrElements()      const {
189     assert(Var.Verify() && "Invalid complex DbgVariable!");
190     return Var.getNumAddrElements();
191   }
192   uint64_t getAddrElement(unsigned i) const {
193     return Var.getAddrElement(i);
194   }
195   DIType getType() const;
196 };
197
198 /// \brief Collects and handles information specific to a particular
199 /// collection of units.
200 class DwarfUnits {
201   // Target of Dwarf emission, used for sizing of abbreviations.
202   AsmPrinter *Asm;
203
204   // Used to uniquely define abbreviations.
205   FoldingSet<DIEAbbrev> *AbbreviationsSet;
206
207   // A list of all the unique abbreviations in use.
208   std::vector<DIEAbbrev *> *Abbreviations;
209
210   // A pointer to all units in the section.
211   SmallVector<CompileUnit *, 1> CUs;
212
213   // Collection of strings for this unit and assorted symbols.
214   // A String->Symbol mapping of strings used by indirect
215   // references.
216   typedef StringMap<std::pair<MCSymbol*, unsigned>,
217                     BumpPtrAllocator&> StrPool;
218   StrPool StringPool;
219   unsigned NextStringPoolNumber;
220   std::string StringPref;
221
222   // Collection of addresses for this unit and assorted labels.
223   // A Symbol->unsigned mapping of addresses used by indirect
224   // references.
225   typedef DenseMap<const MCExpr *, unsigned> AddrPool;
226   AddrPool AddressPool;
227   unsigned NextAddrPoolNumber;
228
229 public:
230   DwarfUnits(AsmPrinter *AP, FoldingSet<DIEAbbrev> *AS,
231              std::vector<DIEAbbrev *> *A, const char *Pref,
232              BumpPtrAllocator &DA) :
233     Asm(AP), AbbreviationsSet(AS), Abbreviations(A),
234     StringPool(DA), NextStringPoolNumber(0), StringPref(Pref),
235     AddressPool(), NextAddrPoolNumber(0) {}
236
237   /// \brief Compute the size and offset of a DIE given an incoming Offset.
238   unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
239
240   /// \brief Compute the size and offset of all the DIEs.
241   void computeSizeAndOffsets();
242
243   /// \brief Define a unique number for the abbreviation.
244   void assignAbbrevNumber(DIEAbbrev &Abbrev);
245
246   /// \brief Add a unit to the list of CUs.
247   void addUnit(CompileUnit *CU) { CUs.push_back(CU); }
248
249   /// \brief Emit all of the units to the section listed with the given
250   /// abbreviation section.
251   void emitUnits(DwarfDebug *, const MCSection *, const MCSection *,
252                  const MCSymbol *);
253
254   /// \brief Emit all of the strings to the section given.
255   void emitStrings(const MCSection *, const MCSection *, const MCSymbol *);
256
257   /// \brief Emit all of the addresses to the section given.
258   void emitAddresses(const MCSection *);
259
260   /// \brief Returns the entry into the start of the pool.
261   MCSymbol *getStringPoolSym();
262
263   /// \brief Returns an entry into the string pool with the given
264   /// string text.
265   MCSymbol *getStringPoolEntry(StringRef Str);
266
267   /// \brief Returns the index into the string pool with the given
268   /// string text.
269   unsigned getStringPoolIndex(StringRef Str);
270
271   /// \brief Returns the string pool.
272   StrPool *getStringPool() { return &StringPool; }
273
274   /// \brief Returns the index into the address pool with the given
275   /// label/symbol.
276   unsigned getAddrPoolIndex(const MCExpr *);
277   unsigned getAddrPoolIndex(const MCSymbol *);
278
279   /// \brief Returns the address pool.
280   AddrPool *getAddrPool() { return &AddressPool; }
281
282   /// \brief for a given compile unit DIE, returns offset from beginning of
283   /// debug info.
284   unsigned getCUOffset(DIE *Die);
285 };
286
287 /// \brief Collects and handles dwarf debug information.
288 class DwarfDebug {
289   // Target of Dwarf emission.
290   AsmPrinter *Asm;
291
292   // Collected machine module information.
293   MachineModuleInfo *MMI;
294
295   // All DIEValues are allocated through this allocator.
296   BumpPtrAllocator DIEValueAllocator;
297
298   //===--------------------------------------------------------------------===//
299   // Attribute used to construct specific Dwarf sections.
300   //
301
302   CompileUnit *FirstCU;
303
304   // Maps MDNode with its corresponding CompileUnit.
305   DenseMap <const MDNode *, CompileUnit *> CUMap;
306
307   // Maps subprogram MDNode with its corresponding CompileUnit.
308   DenseMap <const MDNode *, CompileUnit *> SPMap;
309
310   // Used to uniquely define abbreviations.
311   FoldingSet<DIEAbbrev> AbbreviationsSet;
312
313   // A list of all the unique abbreviations in use.
314   std::vector<DIEAbbrev *> Abbreviations;
315
316   // Stores the current file ID for a given compile unit.
317   DenseMap <unsigned, unsigned> FileIDCUMap;
318   // Source id map, i.e. CUID, source filename and directory,
319   // separated by a zero byte, mapped to a unique id.
320   StringMap<unsigned, BumpPtrAllocator&> SourceIdMap;
321
322   // Provides a unique id per text section.
323   SetVector<const MCSection*> SectionMap;
324
325   // List of Arguments (DbgValues) for current function.
326   SmallVector<DbgVariable *, 8> CurrentFnArguments;
327
328   LexicalScopes LScopes;
329
330   // Collection of abstract subprogram DIEs.
331   DenseMap<const MDNode *, DIE *> AbstractSPDies;
332
333   // Collection of dbg variables of a scope.
334   typedef DenseMap<LexicalScope *,
335                    SmallVector<DbgVariable *, 8> > ScopeVariablesMap;
336   ScopeVariablesMap ScopeVariables;
337
338   // Collection of abstract variables.
339   DenseMap<const MDNode *, DbgVariable *> AbstractVariables;
340
341   // Collection of DotDebugLocEntry.
342   SmallVector<DotDebugLocEntry, 4> DotDebugLocEntries;
343
344   // Collection of subprogram DIEs that are marked (at the end of the module)
345   // as DW_AT_inline.
346   SmallPtrSet<DIE *, 4> InlinedSubprogramDIEs;
347
348   // Keep track of inlined functions and their location.  This
349   // information is used to populate the debug_inlined section.
350   typedef std::pair<const MCSymbol *, DIE *> InlineInfoLabels;
351   typedef DenseMap<const MDNode *,
352                    SmallVector<InlineInfoLabels, 4> > InlineInfoMap;
353   InlineInfoMap InlineInfo;
354   SmallVector<const MDNode *, 4> InlinedSPNodes;
355
356   // This is a collection of subprogram MDNodes that are processed to
357   // create DIEs.
358   SmallPtrSet<const MDNode *, 16> ProcessedSPNodes;
359
360   // Maps instruction with label emitted before instruction.
361   DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn;
362
363   // Maps instruction with label emitted after instruction.
364   DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn;
365
366   // Every user variable mentioned by a DBG_VALUE instruction in order of
367   // appearance.
368   SmallVector<const MDNode*, 8> UserVariables;
369
370   // For each user variable, keep a list of DBG_VALUE instructions in order.
371   // The list can also contain normal instructions that clobber the previous
372   // DBG_VALUE.
373   typedef DenseMap<const MDNode*, SmallVector<const MachineInstr*, 4> >
374     DbgValueHistoryMap;
375   DbgValueHistoryMap DbgValues;
376
377   SmallVector<const MCSymbol *, 8> DebugRangeSymbols;
378
379   // Previous instruction's location information. This is used to determine
380   // label location to indicate scope boundries in dwarf debug info.
381   DebugLoc PrevInstLoc;
382   MCSymbol *PrevLabel;
383
384   // This location indicates end of function prologue and beginning of function
385   // body.
386   DebugLoc PrologEndLoc;
387
388   // Section Symbols: these are assembler temporary labels that are emitted at
389   // the beginning of each supported dwarf section.  These are used to form
390   // section offsets and are created by EmitSectionLabels.
391   MCSymbol *DwarfInfoSectionSym, *DwarfAbbrevSectionSym;
392   MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym;
393   MCSymbol *DwarfDebugLocSectionSym, *DwarfLineSectionSym, *DwarfAddrSectionSym;
394   MCSymbol *FunctionBeginSym, *FunctionEndSym;
395   MCSymbol *DwarfAbbrevDWOSectionSym, *DwarfStrDWOSectionSym;
396
397   // As an optimization, there is no need to emit an entry in the directory
398   // table for the same directory as DW_AT_comp_dir.
399   StringRef CompilationDir;
400
401   // Counter for assigning globally unique IDs for CUs.
402   unsigned GlobalCUIndexCount;
403
404   // Holder for the file specific debug information.
405   DwarfUnits InfoHolder;
406
407   // Holders for the various debug information flags that we might need to
408   // have exposed. See accessor functions below for description.
409
410   // Whether or not we're emitting info for older versions of gdb on darwin.
411   bool IsDarwinGDBCompat;
412
413   // Holder for imported entities.
414   typedef SmallVector<std::pair<const MDNode *, const MDNode *>, 32>
415     ImportedEntityMap;
416   ImportedEntityMap ScopesWithImportedEntities;
417
418   // DWARF5 Experimental Options
419   bool HasDwarfAccelTables;
420   bool HasSplitDwarf;
421
422   unsigned DwarfVersion;
423
424   // Separated Dwarf Variables
425   // In general these will all be for bits that are left in the
426   // original object file, rather than things that are meant
427   // to be in the .dwo sections.
428
429   // The CUs left in the original object file for separated debug info.
430   SmallVector<CompileUnit *, 1> SkeletonCUs;
431
432   // Used to uniquely define abbreviations for the skeleton emission.
433   FoldingSet<DIEAbbrev> SkeletonAbbrevSet;
434
435   // A list of all the unique abbreviations in use.
436   std::vector<DIEAbbrev *> SkeletonAbbrevs;
437
438   // Holder for the skeleton information.
439   DwarfUnits SkeletonHolder;
440
441 private:
442
443   void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
444
445   /// \brief Find abstract variable associated with Var.
446   DbgVariable *findAbstractVariable(DIVariable &Var, DebugLoc Loc);
447
448   /// \brief Find DIE for the given subprogram and attach appropriate
449   /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
450   /// variables in this scope then create and insert DIEs for these
451   /// variables.
452   DIE *updateSubprogramScopeDIE(CompileUnit *SPCU, const MDNode *SPNode);
453
454   /// \brief Construct new DW_TAG_lexical_block for this scope and
455   /// attach DW_AT_low_pc/DW_AT_high_pc labels.
456   DIE *constructLexicalScopeDIE(CompileUnit *TheCU, LexicalScope *Scope);
457
458   /// \brief This scope represents inlined body of a function. Construct
459   /// DIE to represent this concrete inlined copy of the function.
460   DIE *constructInlinedScopeDIE(CompileUnit *TheCU, LexicalScope *Scope);
461
462   /// \brief Construct a DIE for this scope.
463   DIE *constructScopeDIE(CompileUnit *TheCU, LexicalScope *Scope);
464
465   /// \brief Emit initial Dwarf sections with a label at the start of each one.
466   void emitSectionLabels();
467
468   /// \brief Compute the size and offset of a DIE given an incoming Offset.
469   unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
470
471   /// \brief Compute the size and offset of all the DIEs.
472   void computeSizeAndOffsets();
473
474   /// \brief Attach DW_AT_inline attribute with inlined subprogram DIEs.
475   void computeInlinedDIEs();
476
477   /// \brief Collect info for variables that were optimized out.
478   void collectDeadVariables();
479
480   /// \brief Finish off debug information after all functions have been
481   /// processed.
482   void finalizeModuleInfo();
483
484   /// \brief Emit labels to close any remaining sections that have been left
485   /// open.
486   void endSections();
487
488   /// \brief Emit a set of abbreviations to the specific section.
489   void emitAbbrevs(const MCSection *, std::vector<DIEAbbrev*> *);
490
491   /// \brief Emit the debug info section.
492   void emitDebugInfo();
493
494   /// \brief Emit the abbreviation section.
495   void emitAbbreviations();
496
497   /// \brief Emit the last address of the section and the end of
498   /// the line matrix.
499   void emitEndOfLineMatrix(unsigned SectionEnd);
500
501   /// \brief Emit visible names into a hashed accelerator table section.
502   void emitAccelNames();
503
504   /// \brief Emit objective C classes and categories into a hashed
505   /// accelerator table section.
506   void emitAccelObjC();
507
508   /// \brief Emit namespace dies into a hashed accelerator table.
509   void emitAccelNamespaces();
510
511   /// \brief Emit type dies into a hashed accelerator table.
512   void emitAccelTypes();
513
514   /// \brief Emit visible names into a debug pubnames section.
515   void emitDebugPubnames();
516
517   /// \brief Emit visible types into a debug pubtypes section.
518   void emitDebugPubTypes();
519
520   /// \brief Emit visible names into a debug str section.
521   void emitDebugStr();
522
523   /// \brief Emit visible names into a debug loc section.
524   void emitDebugLoc();
525
526   /// \brief Emit visible names into a debug aranges section.
527   void emitDebugARanges();
528
529   /// \brief Emit visible names into a debug ranges section.
530   void emitDebugRanges();
531
532   /// \brief Emit visible names into a debug macinfo section.
533   void emitDebugMacInfo();
534
535   /// \brief Emit inline info using custom format.
536   void emitDebugInlineInfo();
537
538   /// DWARF 5 Experimental Split Dwarf Emitters
539
540   /// \brief Construct the split debug info compile unit for the debug info
541   /// section.
542   CompileUnit *constructSkeletonCU(const MDNode *);
543
544   /// \brief Emit the local split abbreviations.
545   void emitSkeletonAbbrevs(const MCSection *);
546
547   /// \brief Emit the debug info dwo section.
548   void emitDebugInfoDWO();
549
550   /// \brief Emit the debug abbrev dwo section.
551   void emitDebugAbbrevDWO();
552
553   /// \brief Emit the debug str dwo section.
554   void emitDebugStrDWO();
555
556   /// \brief Create new CompileUnit for the given metadata node with tag
557   /// DW_TAG_compile_unit.
558   CompileUnit *constructCompileUnit(const MDNode *N);
559
560   /// \brief Construct subprogram DIE.
561   void constructSubprogramDIE(CompileUnit *TheCU, const MDNode *N);
562
563   /// \brief Construct imported_module or imported_declaration DIE.
564   void constructImportedEntityDIE(CompileUnit *TheCU, const MDNode *N);
565
566   /// \brief Construct import_module DIE.
567   void constructImportedEntityDIE(CompileUnit *TheCU, const MDNode *N,
568                                   DIE *Context);
569
570   /// \brief Construct import_module DIE.
571   void constructImportedEntityDIE(CompileUnit *TheCU,
572                                   const DIImportedEntity &Module,
573                                   DIE *Context);
574
575   /// \brief Register a source line with debug info. Returns the unique
576   /// label that was emitted and which provides correspondence to the
577   /// source line list.
578   void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
579                         unsigned Flags);
580
581   /// \brief Indentify instructions that are marking the beginning of or
582   /// ending of a scope.
583   void identifyScopeMarkers();
584
585   /// \brief If Var is an current function argument that add it in
586   /// CurrentFnArguments list.
587   bool addCurrentFnArgument(const MachineFunction *MF,
588                             DbgVariable *Var, LexicalScope *Scope);
589
590   /// \brief Populate LexicalScope entries with variables' info.
591   void collectVariableInfo(const MachineFunction *,
592                            SmallPtrSet<const MDNode *, 16> &ProcessedVars);
593
594   /// \brief Collect variable information from the side table maintained
595   /// by MMI.
596   void collectVariableInfoFromMMITable(const MachineFunction * MF,
597                                        SmallPtrSet<const MDNode *, 16> &P);
598
599   /// \brief Ensure that a label will be emitted before MI.
600   void requestLabelBeforeInsn(const MachineInstr *MI) {
601     LabelsBeforeInsn.insert(std::make_pair(MI, (MCSymbol*)0));
602   }
603
604   /// \brief Return Label preceding the instruction.
605   MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
606
607   /// \brief Ensure that a label will be emitted after MI.
608   void requestLabelAfterInsn(const MachineInstr *MI) {
609     LabelsAfterInsn.insert(std::make_pair(MI, (MCSymbol*)0));
610   }
611
612   /// \brief Return Label immediately following the instruction.
613   MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
614
615 public:
616   //===--------------------------------------------------------------------===//
617   // Main entry points.
618   //
619   DwarfDebug(AsmPrinter *A, Module *M);
620   ~DwarfDebug();
621
622   /// \brief Emit all Dwarf sections that should come prior to the
623   /// content.
624   void beginModule();
625
626   /// \brief Emit all Dwarf sections that should come after the content.
627   void endModule();
628
629   /// \brief Gather pre-function debug information.
630   void beginFunction(const MachineFunction *MF);
631
632   /// \brief Gather and emit post-function debug information.
633   void endFunction(const MachineFunction *MF);
634
635   /// \brief Process beginning of an instruction.
636   void beginInstruction(const MachineInstr *MI);
637
638   /// \brief Process end of an instruction.
639   void endInstruction(const MachineInstr *MI);
640
641   /// \brief Look up the source id with the given directory and source file
642   /// names. If none currently exists, create a new id and insert it in the
643   /// SourceIds map.
644   unsigned getOrCreateSourceID(StringRef DirName, StringRef FullName,
645                                unsigned CUID);
646
647   /// \brief Recursively Emits a debug information entry.
648   void emitDIE(DIE *Die, std::vector<DIEAbbrev *> *Abbrevs);
649
650   /// \brief Returns whether or not to limit some of our debug
651   /// output to the limitations of darwin gdb.
652   bool useDarwinGDBCompat() { return IsDarwinGDBCompat; }
653
654   // Experimental DWARF5 features.
655
656   /// \brief Returns whether or not to emit tables that dwarf consumers can
657   /// use to accelerate lookup.
658   bool useDwarfAccelTables() { return HasDwarfAccelTables; }
659
660   /// \brief Returns whether or not to change the current debug info for the
661   /// split dwarf proposal support.
662   bool useSplitDwarf() { return HasSplitDwarf; }
663
664   /// Returns the Dwarf Version.
665   unsigned getDwarfVersion() const { return DwarfVersion; }
666 };
667 } // End of namespace llvm
668
669 #endif