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