179db395d38327d3b8e6e9647909a84d7282b386
[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
199 // A String->Symbol mapping of strings used by indirect
200 // references.
201 typedef StringMap<std::pair<MCSymbol*, unsigned>,
202                   BumpPtrAllocator&> StrPool;
203
204 // A Symbol->unsigned mapping of addresses used by indirect
205 // references.
206 typedef DenseMap<const MCExpr *, unsigned> AddrPool;
207
208 /// \brief Collects and handles information specific to a particular
209 /// collection of units.
210 class DwarfUnits {
211   // Target of Dwarf emission, used for sizing of abbreviations.
212   AsmPrinter *Asm;
213
214   // Used to uniquely define abbreviations.
215   FoldingSet<DIEAbbrev> *AbbreviationsSet;
216
217   // A list of all the unique abbreviations in use.
218   std::vector<DIEAbbrev *> *Abbreviations;
219
220   // A pointer to all units in the section.
221   SmallVector<CompileUnit *, 1> CUs;
222
223   // Collection of strings for this unit and assorted symbols.
224   StrPool StringPool;
225   unsigned NextStringPoolNumber;
226   std::string StringPref;
227
228   // Collection of addresses for this unit and assorted labels.
229   AddrPool AddressPool;
230   unsigned NextAddrPoolNumber;
231
232 public:
233   DwarfUnits(AsmPrinter *AP, FoldingSet<DIEAbbrev> *AS,
234              std::vector<DIEAbbrev *> *A, const char *Pref,
235              BumpPtrAllocator &DA) :
236     Asm(AP), AbbreviationsSet(AS), Abbreviations(A),
237     StringPool(DA), NextStringPoolNumber(0), StringPref(Pref),
238     AddressPool(), NextAddrPoolNumber(0) {}
239
240   /// \brief Compute the size and offset of a DIE given an incoming Offset.
241   unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
242
243   /// \brief Compute the size and offset of all the DIEs.
244   void computeSizeAndOffsets();
245
246   /// \brief Define a unique number for the abbreviation.
247   void assignAbbrevNumber(DIEAbbrev &Abbrev);
248
249   /// \brief Add a unit to the list of CUs.
250   void addUnit(CompileUnit *CU) { CUs.push_back(CU); }
251
252   /// \brief Emit all of the units to the section listed with the given
253   /// abbreviation section.
254   void emitUnits(DwarfDebug *, const MCSection *, const MCSection *,
255                  const MCSymbol *);
256
257   /// \brief Emit all of the strings to the section given.
258   void emitStrings(const MCSection *, const MCSection *, const MCSymbol *);
259
260   /// \brief Emit all of the addresses to the section given.
261   void emitAddresses(const MCSection *);
262
263   /// \brief Returns the entry into the start of the pool.
264   MCSymbol *getStringPoolSym();
265
266   /// \brief Returns an entry into the string pool with the given
267   /// string text.
268   MCSymbol *getStringPoolEntry(StringRef Str);
269
270   /// \brief Returns the index into the string pool with the given
271   /// string text.
272   unsigned getStringPoolIndex(StringRef Str);
273
274   /// \brief Returns the string pool.
275   StrPool *getStringPool() { return &StringPool; }
276
277   /// \brief Returns the index into the address pool with the given
278   /// label/symbol.
279   unsigned getAddrPoolIndex(const MCExpr *);
280   unsigned getAddrPoolIndex(const MCSymbol *);
281
282   /// \brief Returns the address pool.
283   AddrPool *getAddrPool() { return &AddressPool; }
284
285   /// \brief for a given compile unit DIE, returns offset from beginning of
286   /// debug info.
287   unsigned getCUOffset(DIE *Die);
288 };
289
290 /// \brief Collects and handles dwarf debug information.
291 class DwarfDebug {
292   // Target of Dwarf emission.
293   AsmPrinter *Asm;
294
295   // Collected machine module information.
296   MachineModuleInfo *MMI;
297
298   // All DIEValues are allocated through this allocator.
299   BumpPtrAllocator DIEValueAllocator;
300
301   //===--------------------------------------------------------------------===//
302   // Attribute used to construct specific Dwarf sections.
303   //
304
305   CompileUnit *FirstCU;
306
307   // Maps MDNode with its corresponding CompileUnit.
308   DenseMap <const MDNode *, CompileUnit *> CUMap;
309
310   // Maps subprogram MDNode with its corresponding CompileUnit.
311   DenseMap <const MDNode *, CompileUnit *> SPMap;
312
313   // Used to uniquely define abbreviations.
314   FoldingSet<DIEAbbrev> AbbreviationsSet;
315
316   // A list of all the unique abbreviations in use.
317   std::vector<DIEAbbrev *> Abbreviations;
318
319   // Stores the current file ID for a given compile unit.
320   DenseMap <unsigned, unsigned> FileIDCUMap;
321   // Source id map, i.e. CUID, source filename and directory,
322   // separated by a zero byte, mapped to a unique id.
323   StringMap<unsigned, BumpPtrAllocator&> SourceIdMap;
324
325   // Provides a unique id per text section.
326   SetVector<const MCSection*> SectionMap;
327
328   // List of Arguments (DbgValues) for current function.
329   SmallVector<DbgVariable *, 8> CurrentFnArguments;
330
331   LexicalScopes LScopes;
332
333   // Collection of abstract subprogram DIEs.
334   DenseMap<const MDNode *, DIE *> AbstractSPDies;
335
336   // Collection of dbg variables of a scope.
337   typedef DenseMap<LexicalScope *,
338                    SmallVector<DbgVariable *, 8> > ScopeVariablesMap;
339   ScopeVariablesMap ScopeVariables;
340
341   // Collection of abstract variables.
342   DenseMap<const MDNode *, DbgVariable *> AbstractVariables;
343
344   // Collection of DotDebugLocEntry.
345   SmallVector<DotDebugLocEntry, 4> DotDebugLocEntries;
346
347   // Collection of subprogram DIEs that are marked (at the end of the module)
348   // as DW_AT_inline.
349   SmallPtrSet<DIE *, 4> InlinedSubprogramDIEs;
350
351   // Keep track of inlined functions and their location.  This
352   // information is used to populate the debug_inlined section.
353   typedef std::pair<const MCSymbol *, DIE *> InlineInfoLabels;
354   typedef DenseMap<const MDNode *,
355                    SmallVector<InlineInfoLabels, 4> > InlineInfoMap;
356   InlineInfoMap InlineInfo;
357   SmallVector<const MDNode *, 4> InlinedSPNodes;
358
359   // This is a collection of subprogram MDNodes that are processed to
360   // create DIEs.
361   SmallPtrSet<const MDNode *, 16> ProcessedSPNodes;
362
363   // Maps instruction with label emitted before instruction.
364   DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn;
365
366   // Maps instruction with label emitted after instruction.
367   DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn;
368
369   // Every user variable mentioned by a DBG_VALUE instruction in order of
370   // appearance.
371   SmallVector<const MDNode*, 8> UserVariables;
372
373   // For each user variable, keep a list of DBG_VALUE instructions in order.
374   // The list can also contain normal instructions that clobber the previous
375   // DBG_VALUE.
376   typedef DenseMap<const MDNode*, SmallVector<const MachineInstr*, 4> >
377     DbgValueHistoryMap;
378   DbgValueHistoryMap DbgValues;
379
380   SmallVector<const MCSymbol *, 8> DebugRangeSymbols;
381
382   // Previous instruction's location information. This is used to determine
383   // label location to indicate scope boundries in dwarf debug info.
384   DebugLoc PrevInstLoc;
385   MCSymbol *PrevLabel;
386
387   // This location indicates end of function prologue and beginning of function
388   // body.
389   DebugLoc PrologEndLoc;
390
391   // Section Symbols: these are assembler temporary labels that are emitted at
392   // the beginning of each supported dwarf section.  These are used to form
393   // section offsets and are created by EmitSectionLabels.
394   MCSymbol *DwarfInfoSectionSym, *DwarfAbbrevSectionSym;
395   MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym;
396   MCSymbol *DwarfDebugLocSectionSym, *DwarfLineSectionSym, *DwarfAddrSectionSym;
397   MCSymbol *FunctionBeginSym, *FunctionEndSym;
398   MCSymbol *DwarfAbbrevDWOSectionSym, *DwarfStrDWOSectionSym;
399
400   // As an optimization, there is no need to emit an entry in the directory
401   // table for the same directory as DW_AT_comp_dir.
402   StringRef CompilationDir;
403
404   // Counter for assigning globally unique IDs for CUs.
405   unsigned GlobalCUIndexCount;
406
407   // Holder for the file specific debug information.
408   DwarfUnits InfoHolder;
409
410   // Holders for the various debug information flags that we might need to
411   // have exposed. See accessor functions below for description.
412
413   // Whether or not we're emitting info for older versions of gdb on darwin.
414   bool IsDarwinGDBCompat;
415
416   // Holder for imported entities.
417   typedef SmallVector<std::pair<const MDNode *, const MDNode *>, 32>
418     ImportedEntityMap;
419   ImportedEntityMap ScopesWithImportedEntities;
420
421   // DWARF5 Experimental Options
422   bool HasDwarfAccelTables;
423   bool HasSplitDwarf;
424
425   unsigned DwarfVersion;
426
427   // Separated Dwarf Variables
428   // In general these will all be for bits that are left in the
429   // original object file, rather than things that are meant
430   // to be in the .dwo sections.
431
432   // The CUs left in the original object file for separated debug info.
433   SmallVector<CompileUnit *, 1> SkeletonCUs;
434
435   // Used to uniquely define abbreviations for the skeleton emission.
436   FoldingSet<DIEAbbrev> SkeletonAbbrevSet;
437
438   // A list of all the unique abbreviations in use.
439   std::vector<DIEAbbrev *> SkeletonAbbrevs;
440
441   // Holder for the skeleton information.
442   DwarfUnits SkeletonHolder;
443
444 private:
445
446   void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
447
448   /// \brief Find abstract variable associated with Var.
449   DbgVariable *findAbstractVariable(DIVariable &Var, DebugLoc Loc);
450
451   /// \brief Find DIE for the given subprogram and attach appropriate
452   /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
453   /// variables in this scope then create and insert DIEs for these
454   /// variables.
455   DIE *updateSubprogramScopeDIE(CompileUnit *SPCU, const MDNode *SPNode);
456
457   /// \brief Construct new DW_TAG_lexical_block for this scope and
458   /// attach DW_AT_low_pc/DW_AT_high_pc labels.
459   DIE *constructLexicalScopeDIE(CompileUnit *TheCU, LexicalScope *Scope);
460
461   /// \brief This scope represents inlined body of a function. Construct
462   /// DIE to represent this concrete inlined copy of the function.
463   DIE *constructInlinedScopeDIE(CompileUnit *TheCU, LexicalScope *Scope);
464
465   /// \brief Construct a DIE for this scope.
466   DIE *constructScopeDIE(CompileUnit *TheCU, LexicalScope *Scope);
467
468   /// \brief Emit initial Dwarf sections with a label at the start of each one.
469   void emitSectionLabels();
470
471   /// \brief Compute the size and offset of a DIE given an incoming Offset.
472   unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
473
474   /// \brief Compute the size and offset of all the DIEs.
475   void computeSizeAndOffsets();
476
477   /// \brief Attach DW_AT_inline attribute with inlined subprogram DIEs.
478   void computeInlinedDIEs();
479
480   /// \brief Collect info for variables that were optimized out.
481   void collectDeadVariables();
482
483   /// \brief Finish off debug information after all functions have been
484   /// processed.
485   void finalizeModuleInfo();
486
487   /// \brief Emit labels to close any remaining sections that have been left
488   /// open.
489   void endSections();
490
491   /// \brief Emit a set of abbreviations to the specific section.
492   void emitAbbrevs(const MCSection *, std::vector<DIEAbbrev*> *);
493
494   /// \brief Emit the debug info section.
495   void emitDebugInfo();
496
497   /// \brief Emit the abbreviation section.
498   void emitAbbreviations();
499
500   /// \brief Emit the last address of the section and the end of
501   /// the line matrix.
502   void emitEndOfLineMatrix(unsigned SectionEnd);
503
504   /// \brief Emit visible names into a hashed accelerator table section.
505   void emitAccelNames();
506
507   /// \brief Emit objective C classes and categories into a hashed
508   /// accelerator table section.
509   void emitAccelObjC();
510
511   /// \brief Emit namespace dies into a hashed accelerator table.
512   void emitAccelNamespaces();
513
514   /// \brief Emit type dies into a hashed accelerator table.
515   void emitAccelTypes();
516
517   /// \brief Emit visible names into a debug pubnames section.
518   void emitDebugPubnames();
519
520   /// \brief Emit visible types into a debug pubtypes section.
521   void emitDebugPubTypes();
522
523   /// \brief Emit visible names into a debug str section.
524   void emitDebugStr();
525
526   /// \brief Emit visible names into a debug loc section.
527   void emitDebugLoc();
528
529   /// \brief Emit visible names into a debug aranges section.
530   void emitDebugARanges();
531
532   /// \brief Emit visible names into a debug ranges section.
533   void emitDebugRanges();
534
535   /// \brief Emit visible names into a debug macinfo section.
536   void emitDebugMacInfo();
537
538   /// \brief Emit inline info using custom format.
539   void emitDebugInlineInfo();
540
541   /// DWARF 5 Experimental Split Dwarf Emitters
542
543   /// \brief Construct the split debug info compile unit for the debug info
544   /// section.
545   CompileUnit *constructSkeletonCU(const MDNode *);
546
547   /// \brief Emit the local split abbreviations.
548   void emitSkeletonAbbrevs(const MCSection *);
549
550   /// \brief Emit the debug info dwo section.
551   void emitDebugInfoDWO();
552
553   /// \brief Emit the debug abbrev dwo section.
554   void emitDebugAbbrevDWO();
555
556   /// \brief Emit the debug str dwo section.
557   void emitDebugStrDWO();
558
559   /// \brief Create new CompileUnit for the given metadata node with tag
560   /// DW_TAG_compile_unit.
561   CompileUnit *constructCompileUnit(const MDNode *N);
562
563   /// \brief Construct subprogram DIE.
564   void constructSubprogramDIE(CompileUnit *TheCU, const MDNode *N);
565
566   /// \brief Construct imported_module or imported_declaration DIE.
567   void constructImportedEntityDIE(CompileUnit *TheCU, const MDNode *N);
568
569   /// \brief Construct import_module DIE.
570   void constructImportedEntityDIE(CompileUnit *TheCU, const MDNode *N,
571                                   DIE *Context);
572
573   /// \brief Construct import_module DIE.
574   void constructImportedEntityDIE(CompileUnit *TheCU,
575                                   const DIImportedEntity &Module,
576                                   DIE *Context);
577
578   /// \brief Register a source line with debug info. Returns the unique
579   /// label that was emitted and which provides correspondence to the
580   /// source line list.
581   void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
582                         unsigned Flags);
583
584   /// \brief Indentify instructions that are marking the beginning of or
585   /// ending of a scope.
586   void identifyScopeMarkers();
587
588   /// \brief If Var is an current function argument that add it in
589   /// CurrentFnArguments list.
590   bool addCurrentFnArgument(const MachineFunction *MF,
591                             DbgVariable *Var, LexicalScope *Scope);
592
593   /// \brief Populate LexicalScope entries with variables' info.
594   void collectVariableInfo(const MachineFunction *,
595                            SmallPtrSet<const MDNode *, 16> &ProcessedVars);
596
597   /// \brief Collect variable information from the side table maintained
598   /// by MMI.
599   void collectVariableInfoFromMMITable(const MachineFunction * MF,
600                                        SmallPtrSet<const MDNode *, 16> &P);
601
602   /// \brief Ensure that a label will be emitted before MI.
603   void requestLabelBeforeInsn(const MachineInstr *MI) {
604     LabelsBeforeInsn.insert(std::make_pair(MI, (MCSymbol*)0));
605   }
606
607   /// \brief Return Label preceding the instruction.
608   MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
609
610   /// \brief Ensure that a label will be emitted after MI.
611   void requestLabelAfterInsn(const MachineInstr *MI) {
612     LabelsAfterInsn.insert(std::make_pair(MI, (MCSymbol*)0));
613   }
614
615   /// \brief Return Label immediately following the instruction.
616   MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
617
618 public:
619   //===--------------------------------------------------------------------===//
620   // Main entry points.
621   //
622   DwarfDebug(AsmPrinter *A, Module *M);
623   ~DwarfDebug();
624
625   /// \brief Emit all Dwarf sections that should come prior to the
626   /// content.
627   void beginModule();
628
629   /// \brief Emit all Dwarf sections that should come after the content.
630   void endModule();
631
632   /// \brief Gather pre-function debug information.
633   void beginFunction(const MachineFunction *MF);
634
635   /// \brief Gather and emit post-function debug information.
636   void endFunction(const MachineFunction *MF);
637
638   /// \brief Process beginning of an instruction.
639   void beginInstruction(const MachineInstr *MI);
640
641   /// \brief Process end of an instruction.
642   void endInstruction(const MachineInstr *MI);
643
644   /// \brief Look up the source id with the given directory and source file
645   /// names. If none currently exists, create a new id and insert it in the
646   /// SourceIds map.
647   unsigned getOrCreateSourceID(StringRef DirName, StringRef FullName,
648                                unsigned CUID);
649
650   /// \brief Recursively Emits a debug information entry.
651   void emitDIE(DIE *Die, std::vector<DIEAbbrev *> *Abbrevs);
652
653   /// \brief Returns whether or not to limit some of our debug
654   /// output to the limitations of darwin gdb.
655   bool useDarwinGDBCompat() { return IsDarwinGDBCompat; }
656
657   // Experimental DWARF5 features.
658
659   /// \brief Returns whether or not to emit tables that dwarf consumers can
660   /// use to accelerate lookup.
661   bool useDwarfAccelTables() { return HasDwarfAccelTables; }
662
663   /// \brief Returns whether or not to change the current debug info for the
664   /// split dwarf proposal support.
665   bool useSplitDwarf() { return HasSplitDwarf; }
666
667   /// Returns the Dwarf Version.
668   unsigned getDwarfVersion() const { return DwarfVersion; }
669 };
670 } // End of namespace llvm
671
672 #endif