1 //===-- llvm/CodeGen/DwarfWriter.h - Dwarf Framework ------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains support for writing Dwarf debug and exception info into
11 // asm files. For Details on the Dwarf 3 specfication see DWARF Debugging
12 // Information Format V.3 reference manual http://dwarf.freestandards.org ,
14 // The role of the Dwarf Writer class is to extract information from the
15 // MachineModuleInfo object, organize it in Dwarf form and then emit it into asm
16 // the current asm file using data and high level Dwarf directives.
18 //===----------------------------------------------------------------------===//
20 #ifndef LLVM_CODEGEN_DWARFWRITER_H
21 #define LLVM_CODEGEN_DWARFWRITER_H
23 #include "llvm/Pass.h"
30 class MachineModuleInfo;
31 class MachineFunction;
42 //===----------------------------------------------------------------------===//
43 // DwarfWriter - Emits Dwarf debug and exception handling directives.
46 class DwarfWriter : public ImmutablePass {
48 /// DD - Provides the DwarfWriter debug implementation.
52 /// DE - Provides the DwarfWriter exception implementation.
57 static char ID; // Pass identification, replacement for typeid
60 virtual ~DwarfWriter();
62 //===--------------------------------------------------------------------===//
66 /// BeginModule - Emit all Dwarf sections that should come prior to the
68 void BeginModule(Module *M, MachineModuleInfo *MMI, raw_ostream &OS,
69 AsmPrinter *A, const TargetAsmInfo *T);
71 /// EndModule - Emit all Dwarf sections that should come after the content.
75 /// BeginFunction - Gather pre-function debug information. Assumes being
76 /// emitted immediately after the function entry point.
77 void BeginFunction(MachineFunction *MF);
79 /// EndFunction - Gather and emit post-function debug information.
81 void EndFunction(MachineFunction *MF);
83 /// ValidDebugInfo - Return true if V represents valid debug info value.
84 bool ValidDebugInfo(Value *V, bool FastISel);
86 /// RecordSourceLine - Register a source line with debug info. Returns a
87 /// unique label ID used to generate a label and provide correspondence to
88 /// the source line list.
89 unsigned RecordSourceLine(unsigned Line, unsigned Col, unsigned Src);
91 /// getOrCreateSourceID - Look up the source id with the given directory and
92 /// source file names. If none currently exists, create a new id and insert it
93 /// in the SourceIds map. This can update DirectoryIds and SourceFileIds maps
95 unsigned getOrCreateSourceID(const std::string &DirName,
96 const std::string &FileName);
98 /// RecordRegionStart - Indicate the start of a region.
99 unsigned RecordRegionStart(GlobalVariable *V);
101 /// RecordRegionEnd - Indicate the end of a region.
102 unsigned RecordRegionEnd(GlobalVariable *V);
104 /// getRecordSourceLineCount - Count source lines.
105 unsigned getRecordSourceLineCount();
107 /// RecordVariable - Indicate the declaration of a local variable.
109 void RecordVariable(GlobalVariable *GV, unsigned FrameIndex,
110 const MachineInstr *MI);
112 /// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
114 bool ShouldEmitDwarfDebug() const;
116 //// RecordInlinedFnStart - Indicate the start of a inlined function.
117 void RecordInlinedFnStart(Instruction *I, DISubprogram &SP, unsigned LabelID,
118 unsigned Src, unsigned Line, unsigned Col);
120 /// RecordInlinedFnEnd - Indicate the end of inlined subroutine.
121 unsigned RecordInlinedFnEnd(DISubprogram &SP);
123 /// RecordVariableScope - Record scope for the variable declared by
124 /// DeclareMI. DeclareMI must describe TargetInstrInfo::DECLARE.
125 void RecordVariableScope(DIVariable &DV, const MachineInstr *DeclareMI);
129 } // end llvm namespace