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