Implement support to debug inlined functions.
[oota-llvm.git] / include / llvm / CodeGen / DwarfWriter.h
1 //===-- llvm/CodeGen/DwarfWriter.h - Dwarf 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 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 ,
13 //
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.
17 // 
18 //===----------------------------------------------------------------------===//
19
20 #ifndef LLVM_CODEGEN_DWARFWRITER_H
21 #define LLVM_CODEGEN_DWARFWRITER_H
22
23 #include "llvm/Pass.h"
24 #include "llvm/Target/TargetMachine.h"
25
26 namespace llvm {
27
28 class AsmPrinter;
29 class DwarfDebug;
30 class DwarfException;
31 class MachineModuleInfo;
32 class MachineFunction;
33 class MachineInstr;
34 class Value;
35 class Module;
36 class MDNode;
37 class MCAsmInfo;
38 class raw_ostream;
39 class Instruction;
40 class DICompileUnit;
41 class DISubprogram;
42 class DIVariable;
43
44 //===----------------------------------------------------------------------===//
45 // DwarfWriter - Emits Dwarf debug and exception handling directives.
46 //
47
48 class DwarfWriter : public ImmutablePass {
49 private:
50   /// DD - Provides the DwarfWriter debug implementation.
51   ///
52   DwarfDebug *DD;
53
54   /// DE - Provides the DwarfWriter exception implementation.
55   ///
56   DwarfException *DE;
57
58 public:
59   static char ID; // Pass identification, replacement for typeid
60
61   DwarfWriter();
62   virtual ~DwarfWriter();
63
64   //===--------------------------------------------------------------------===//
65   // Main entry points.
66   //
67   
68   /// BeginModule - Emit all Dwarf sections that should come prior to the
69   /// content.
70   void BeginModule(Module *M, MachineModuleInfo *MMI, raw_ostream &OS,
71                    AsmPrinter *A, const MCAsmInfo *T);
72   
73   /// EndModule - Emit all Dwarf sections that should come after the content.
74   ///
75   void EndModule();
76   
77   /// BeginFunction - Gather pre-function debug information.  Assumes being 
78   /// emitted immediately after the function entry point.
79   void BeginFunction(MachineFunction *MF);
80   
81   /// EndFunction - Gather and emit post-function debug information.
82   ///
83   void EndFunction(MachineFunction *MF);
84
85   /// RecordSourceLine - Register a source line with debug info. Returns a
86   /// unique label ID used to generate a label and provide correspondence to
87   /// the source line list.
88   unsigned RecordSourceLine(unsigned Line, unsigned Col, MDNode *Scope);
89
90   /// RecordRegionStart - Indicate the start of a region.
91   unsigned RecordRegionStart(MDNode *N);
92
93   /// RecordRegionEnd - Indicate the end of a region.
94   unsigned RecordRegionEnd(MDNode *N);
95
96   /// getRecordSourceLineCount - Count source lines.
97   unsigned getRecordSourceLineCount();
98
99   /// RecordVariable - Indicate the declaration of  a local variable.
100   ///
101   void RecordVariable(MDNode *N, unsigned FrameIndex);
102
103   /// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
104   /// be emitted.
105   bool ShouldEmitDwarfDebug() const;
106
107   void BeginScope(const MachineInstr *MI, unsigned Label);
108   void EndScope(const MachineInstr *MI);
109 };
110
111 } // end llvm namespace
112
113 #endif