LLVM API Documentation

DwarfWriter.h

Go to the documentation of this file.
00001 //===-- llvm/CodeGen/DwarfWriter.h - Dwarf Framework ------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file contains support for writing Dwarf debug and exception info into
00011 // asm files.  For Details on the Dwarf 3 specfication see DWARF Debugging
00012 // Information Format V.3 reference manual http://dwarf.freestandards.org ,
00013 //
00014 // The role of the Dwarf Writer class is to extract information from the
00015 // MachineModuleInfo object, organize it in Dwarf form and then emit it into asm
00016 // the current asm file using data and high level Dwarf directives.
00017 // 
00018 //===----------------------------------------------------------------------===//
00019 
00020 #ifndef LLVM_CODEGEN_DWARFWRITER_H
00021 #define LLVM_CODEGEN_DWARFWRITER_H
00022 
00023 #include "llvm/Pass.h"
00024 #include "llvm/Target/TargetMachine.h"
00025 
00026 namespace llvm {
00027 
00028 class AsmPrinter;
00029 class DwarfDebug;
00030 class DwarfException;
00031 class MachineModuleInfo;
00032 class MachineFunction;
00033 class MachineInstr;
00034 class Value;
00035 class Module;
00036 class GlobalVariable;
00037 class TargetAsmInfo;
00038 class raw_ostream;
00039 class Instruction;
00040 class DICompileUnit;
00041 class DISubprogram;
00042 class DIVariable;
00043 
00044 //===----------------------------------------------------------------------===//
00045 // DwarfWriter - Emits Dwarf debug and exception handling directives.
00046 //
00047 
00048 class DwarfWriter : public ImmutablePass {
00049 private:
00050   /// DD - Provides the DwarfWriter debug implementation.
00051   ///
00052   DwarfDebug *DD;
00053 
00054   /// DE - Provides the DwarfWriter exception implementation.
00055   ///
00056   DwarfException *DE;
00057 
00058 public:
00059   static char ID; // Pass identification, replacement for typeid
00060 
00061   DwarfWriter();
00062   virtual ~DwarfWriter();
00063 
00064   //===--------------------------------------------------------------------===//
00065   // Main entry points.
00066   //
00067   
00068   /// BeginModule - Emit all Dwarf sections that should come prior to the
00069   /// content.
00070   void BeginModule(Module *M, MachineModuleInfo *MMI, raw_ostream &OS,
00071                    AsmPrinter *A, const TargetAsmInfo *T);
00072   
00073   /// EndModule - Emit all Dwarf sections that should come after the content.
00074   ///
00075   void EndModule();
00076   
00077   /// BeginFunction - Gather pre-function debug information.  Assumes being 
00078   /// emitted immediately after the function entry point.
00079   void BeginFunction(MachineFunction *MF);
00080   
00081   /// EndFunction - Gather and emit post-function debug information.
00082   ///
00083   void EndFunction(MachineFunction *MF);
00084 
00085   /// RecordSourceLine - Register a source line with debug info. Returns a
00086   /// unique label ID used to generate a label and provide correspondence to
00087   /// the source line list.
00088   unsigned RecordSourceLine(unsigned Line, unsigned Col, DICompileUnit CU);
00089 
00090   /// RecordRegionStart - Indicate the start of a region.
00091   unsigned RecordRegionStart(GlobalVariable *V);
00092 
00093   /// RecordRegionEnd - Indicate the end of a region.
00094   unsigned RecordRegionEnd(GlobalVariable *V);
00095 
00096   /// getRecordSourceLineCount - Count source lines.
00097   unsigned getRecordSourceLineCount();
00098 
00099   /// RecordVariable - Indicate the declaration of  a local variable.
00100   ///
00101   void RecordVariable(GlobalVariable *GV, unsigned FrameIndex, 
00102                       const MachineInstr *MI);
00103 
00104   /// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
00105   /// be emitted.
00106   bool ShouldEmitDwarfDebug() const;
00107 
00108   //// RecordInlinedFnStart - Indicate the start of a inlined function.
00109   unsigned RecordInlinedFnStart(DISubprogram SP, DICompileUnit CU,
00110                                 unsigned Line, unsigned Col);
00111 
00112   /// RecordInlinedFnEnd - Indicate the end of inlined subroutine.
00113   unsigned RecordInlinedFnEnd(DISubprogram SP);
00114 
00115   /// RecordVariableScope - Record scope for the variable declared by
00116   /// DeclareMI. DeclareMI must describe TargetInstrInfo::DECLARE.
00117   void RecordVariableScope(DIVariable &DV, const MachineInstr *DeclareMI);
00118 };
00119 
00120 
00121 } // end llvm namespace
00122 
00123 #endif