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;
43 //===----------------------------------------------------------------------===//
44 // DwarfWriter - Emits Dwarf debug and exception handling directives.
47 class DwarfWriter : public ImmutablePass {
49 /// DD - Provides the DwarfWriter debug implementation.
53 /// DE - Provides the DwarfWriter exception implementation.
58 static char ID; // Pass identification, replacement for typeid
61 virtual ~DwarfWriter();
63 //===--------------------------------------------------------------------===//
67 /// BeginModule - Emit all Dwarf sections that should come prior to the
69 void BeginModule(Module *M, MachineModuleInfo *MMI, raw_ostream &OS,
70 AsmPrinter *A, const TargetAsmInfo *T);
72 /// EndModule - Emit all Dwarf sections that should come after the content.
76 /// BeginFunction - Gather pre-function debug information. Assumes being
77 /// emitted immediately after the function entry point.
78 void BeginFunction(MachineFunction *MF);
80 /// EndFunction - Gather and emit post-function debug information.
82 void EndFunction(MachineFunction *MF);
84 /// ValidDebugInfo - Return true if V represents valid debug info value.
85 bool ValidDebugInfo(Value *V, CodeGenOpt::Level OptLevel);
87 /// RecordSourceLine - Register a source line with debug info. Returns a
88 /// unique label ID used to generate a label and provide correspondence to
89 /// the source line list.
90 unsigned RecordSourceLine(unsigned Line, unsigned Col, unsigned Src);
92 /// getOrCreateSourceID - Look up the source id with the given directory and
93 /// source file names. If none currently exists, create a new id and insert it
94 /// in the SourceIds map. This can update DirectoryIds and SourceFileIds maps
96 unsigned getOrCreateSourceID(const std::string &DirName,
97 const std::string &FileName);
99 /// RecordRegionStart - Indicate the start of a region.
100 unsigned RecordRegionStart(GlobalVariable *V);
102 /// RecordRegionEnd - Indicate the end of a region.
103 unsigned RecordRegionEnd(GlobalVariable *V);
105 /// getRecordSourceLineCount - Count source lines.
106 unsigned getRecordSourceLineCount();
108 /// RecordVariable - Indicate the declaration of a local variable.
110 void RecordVariable(GlobalVariable *GV, unsigned FrameIndex,
111 const MachineInstr *MI);
113 /// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
115 bool ShouldEmitDwarfDebug() const;
117 //// RecordInlinedFnStart - Indicate the start of a inlined function.
118 void RecordInlinedFnStart(Instruction *I, DISubprogram &SP, unsigned LabelID,
119 unsigned Src, unsigned Line, unsigned Col);
121 /// RecordInlinedFnEnd - Indicate the end of inlined subroutine.
122 unsigned RecordInlinedFnEnd(DISubprogram &SP);
124 /// RecordVariableScope - Record scope for the variable declared by
125 /// DeclareMI. DeclareMI must describe TargetInstrInfo::DECLARE.
126 void RecordVariableScope(DIVariable &DV, const MachineInstr *DeclareMI);
130 } // end llvm namespace