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"
24 #include "llvm/Target/TargetMachine.h"
31 class MachineModuleInfo;
32 class MachineFunction;
44 //===----------------------------------------------------------------------===//
45 // DwarfWriter - Emits Dwarf debug and exception handling directives.
48 class DwarfWriter : public ImmutablePass {
50 /// DD - Provides the DwarfWriter debug implementation.
54 /// DE - Provides the DwarfWriter exception implementation.
59 static char ID; // Pass identification, replacement for typeid
62 virtual ~DwarfWriter();
64 //===--------------------------------------------------------------------===//
68 /// BeginModule - Emit all Dwarf sections that should come prior to the
70 void BeginModule(Module *M, MachineModuleInfo *MMI, raw_ostream &OS,
71 AsmPrinter *A, const TargetAsmInfo *T);
73 /// EndModule - Emit all Dwarf sections that should come after the content.
77 /// BeginFunction - Gather pre-function debug information. Assumes being
78 /// emitted immediately after the function entry point.
79 void BeginFunction(MachineFunction *MF);
81 /// EndFunction - Gather and emit post-function debug information.
83 void EndFunction(MachineFunction *MF);
85 /// ValidDebugInfo - Return true if V represents valid debug info value.
86 bool ValidDebugInfo(Value *V, CodeGenOpt::Level OptLevel);
88 /// RecordSourceLine - Register a source line with debug info. Returns a
89 /// unique label ID used to generate a label and provide correspondence to
90 /// the source line list.
91 unsigned RecordSourceLine(unsigned Line, unsigned Col, DICompileUnit CU);
93 /// RecordRegionStart - Indicate the start of a region.
94 unsigned RecordRegionStart(GlobalVariable *V);
96 /// RecordRegionEnd - Indicate the end of a region.
97 unsigned RecordRegionEnd(GlobalVariable *V);
99 /// getRecordSourceLineCount - Count source lines.
100 unsigned getRecordSourceLineCount();
102 /// RecordVariable - Indicate the declaration of a local variable.
104 void RecordVariable(GlobalVariable *GV, unsigned FrameIndex,
105 const MachineInstr *MI);
107 /// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
109 bool ShouldEmitDwarfDebug() const;
111 //// RecordInlinedFnStart - Indicate the start of a inlined function.
112 void RecordInlinedFnStart(Instruction *I, DISubprogram &SP, unsigned LabelID,
113 DICompileUnit CU, unsigned Line, unsigned Col);
115 /// RecordInlinedFnEnd - Indicate the end of inlined subroutine.
116 unsigned RecordInlinedFnEnd(DISubprogram &SP);
118 /// RecordVariableScope - Record scope for the variable declared by
119 /// DeclareMI. DeclareMI must describe TargetInstrInfo::DECLARE.
120 void RecordVariableScope(DIVariable &DV, const MachineInstr *DeclareMI);
124 } // end llvm namespace