DwarfWriter reading basic type information from llvm-gcc4 code.
[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 was developed by James M. Laskey and is distributed under the
6 // University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains support for writing Dwarf debug info into asm files.  For
11 // Details on the Dwarf 3 specfication see DWARF Debugging Information Format
12 // V.3 reference manual http://dwarf.freestandards.org ,
13 //
14 // The role of the Dwarf Writer class is to extract debug information from the
15 // MachineDebugInfo 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/ADT/UniqueVector.h"
24 #include "llvm/Support/DataTypes.h"
25
26 #include <iosfwd>
27 #include <string>
28
29
30 namespace llvm {
31   
32   //===--------------------------------------------------------------------===//
33   // Forward declarations.
34   //
35   class AsmPrinter;
36   class CompileUnitDesc;
37   class DebugInfoDesc;
38   class DIE;
39   class DwarfWriter;
40   class GlobalVariableDesc;
41   class MachineDebugInfo;
42   class MachineFunction;
43   class Module;
44   class SubprogramDesc;
45   class Type;
46   class TypeDesc;
47   
48   //===--------------------------------------------------------------------===//
49   // DWLabel - Labels are used to track locations in the assembler file.
50   // Labels appear in the form <prefix>debug_<Tag><Number>, where the tag is a
51   // category of label (Ex. location) and number is a value unique in that
52   // category.
53   class DWLabel {
54   public:
55     const char *Tag;                    // Label category tag. Should always be
56                                         // a staticly declared C string.
57     unsigned    Number;                 // Unique number.
58
59     DWLabel(const char *T, unsigned N) : Tag(T), Number(N) {}
60   };
61   
62   //===--------------------------------------------------------------------===//
63   // DIEAbbrevData - Dwarf abbreviation data, describes the one attribute of a
64   // Dwarf abbreviation.
65   class DIEAbbrevData {
66   private:
67     unsigned Attribute;                 // Dwarf attribute code.
68     unsigned Form;                      // Dwarf form code.
69     
70   public:
71     DIEAbbrevData(unsigned A, unsigned F)
72     : Attribute(A)
73     , Form(F)
74     {}
75     
76     // Accessors
77     unsigned getAttribute() const { return Attribute; }
78     unsigned getForm()      const { return Form; }
79     
80     /// operator== - Used by DIEAbbrev to locate entry.
81     ///
82     bool operator==(const DIEAbbrevData &DAD) const {
83       return Attribute == DAD.Attribute && Form == DAD.Form;
84     }
85
86     /// operator!= - Used by DIEAbbrev to locate entry.
87     ///
88     bool operator!=(const DIEAbbrevData &DAD) const {
89       return Attribute != DAD.Attribute || Form != DAD.Form;
90     }
91     
92     /// operator< - Used by DIEAbbrev to locate entry.
93     ///
94     bool operator<(const DIEAbbrevData &DAD) const {
95       return Attribute < DAD.Attribute ||
96             (Attribute == DAD.Attribute && Form < DAD.Form);
97     }
98   };
99   
100   //===--------------------------------------------------------------------===//
101   // DIEAbbrev - Dwarf abbreviation, describes the organization of a debug
102   // information object.
103   class DIEAbbrev {
104   private:
105     unsigned Tag;                       // Dwarf tag code.
106     unsigned ChildrenFlag;              // Dwarf children flag.
107     std::vector<DIEAbbrevData> Data;    // Raw data bytes for abbreviation.
108
109   public:
110   
111     DIEAbbrev(unsigned T, unsigned C)
112     : Tag(T)
113     , ChildrenFlag(C)
114     , Data()
115     {}
116     ~DIEAbbrev() {}
117     
118     // Accessors
119     unsigned getTag()                           const { return Tag; }
120     unsigned getChildrenFlag()                  const { return ChildrenFlag; }
121     const std::vector<DIEAbbrevData> &getData() const { return Data; }
122     void setChildrenFlag(unsigned CF)                 { ChildrenFlag = CF; }
123
124     /// operator== - Used by UniqueVector to locate entry.
125     ///
126     bool operator==(const DIEAbbrev &DA) const;
127
128     /// operator< - Used by UniqueVector to locate entry.
129     ///
130     bool operator<(const DIEAbbrev &DA) const;
131
132     /// AddAttribute - Adds another set of attribute information to the
133     /// abbreviation.
134     void AddAttribute(unsigned Attribute, unsigned Form) {
135       Data.push_back(DIEAbbrevData(Attribute, Form));
136     }
137     
138     /// Emit - Print the abbreviation using the specified Dwarf writer.
139     ///
140     void Emit(const DwarfWriter &DW) const; 
141         
142 #ifndef NDEBUG
143     void print(std::ostream &O);
144     void dump();
145 #endif
146   };
147
148   //===--------------------------------------------------------------------===//
149   // DIEValue - A debug information entry value.
150   //
151   class DIEValue {
152   public:
153     enum {
154       isInteger,
155       isString,
156       isLabel,
157       isAsIsLabel,
158       isDelta,
159       isEntry
160     };
161     
162     unsigned Type;                      // Type of the value
163     
164     DIEValue(unsigned T) : Type(T) {}
165     virtual ~DIEValue() {}
166     
167     // Implement isa/cast/dyncast.
168     static bool classof(const DIEValue *) { return true; }
169     
170     /// EmitValue - Emit value via the Dwarf writer.
171     ///
172     virtual void EmitValue(const DwarfWriter &DW, unsigned Form) const = 0;
173     
174     /// SizeOf - Return the size of a value in bytes.
175     ///
176     virtual unsigned SizeOf(const DwarfWriter &DW, unsigned Form) const = 0;
177   };
178
179   //===--------------------------------------------------------------------===//
180   // DWInteger - An integer value DIE.
181   // 
182   class DIEInteger : public DIEValue {
183   private:
184     uint64_t Integer;
185     
186   public:
187     DIEInteger(uint64_t I) : DIEValue(isInteger), Integer(I) {}
188
189     // Implement isa/cast/dyncast.
190     static bool classof(const DIEInteger *) { return true; }
191     static bool classof(const DIEValue *I)  { return I->Type == isInteger; }
192     
193     /// EmitValue - Emit integer of appropriate size.
194     ///
195     virtual void EmitValue(const DwarfWriter &DW, unsigned Form) const;
196     
197     /// SizeOf - Determine size of integer value in bytes.
198     ///
199     virtual unsigned SizeOf(const DwarfWriter &DW, unsigned Form) const;
200   };
201
202   //===--------------------------------------------------------------------===//
203   // DIEString - A string value DIE.
204   // 
205   struct DIEString : public DIEValue {
206     const std::string String;
207     
208     DIEString(const std::string &S) : DIEValue(isString), String(S) {}
209
210     // Implement isa/cast/dyncast.
211     static bool classof(const DIEString *) { return true; }
212     static bool classof(const DIEValue *S) { return S->Type == isString; }
213     
214     /// EmitValue - Emit string value.
215     ///
216     virtual void EmitValue(const DwarfWriter &DW, unsigned Form) const;
217     
218     /// SizeOf - Determine size of string value in bytes.
219     ///
220     virtual unsigned SizeOf(const DwarfWriter &DW, unsigned Form) const;
221   };
222
223   //===--------------------------------------------------------------------===//
224   // DIEDwarfLabel - A Dwarf internal label expression DIE.
225   //
226   struct DIEDwarfLabel : public DIEValue {
227     const DWLabel Label;
228     
229     DIEDwarfLabel(const DWLabel &L) : DIEValue(isLabel), Label(L) {}
230
231     // Implement isa/cast/dyncast.
232     static bool classof(const DIEDwarfLabel *)  { return true; }
233     static bool classof(const DIEValue *L) { return L->Type == isLabel; }
234     
235     /// EmitValue - Emit label value.
236     ///
237     virtual void EmitValue(const DwarfWriter &DW, unsigned Form) const;
238     
239     /// SizeOf - Determine size of label value in bytes.
240     ///
241     virtual unsigned SizeOf(const DwarfWriter &DW, unsigned Form) const;
242   };
243
244
245   //===--------------------------------------------------------------------===//
246   // DIEObjectLabel - A label to an object in code or data.
247   //
248   struct DIEObjectLabel : public DIEValue {
249     const std::string Label;
250     
251     DIEObjectLabel(const std::string &L) : DIEValue(isAsIsLabel), Label(L) {}
252
253     // Implement isa/cast/dyncast.
254     static bool classof(const DIEObjectLabel *) { return true; }
255     static bool classof(const DIEValue *L)    { return L->Type == isAsIsLabel; }
256     
257     /// EmitValue - Emit label value.
258     ///
259     virtual void EmitValue(const DwarfWriter &DW, unsigned Form) const;
260     
261     /// SizeOf - Determine size of label value in bytes.
262     ///
263     virtual unsigned SizeOf(const DwarfWriter &DW, unsigned Form) const;
264   };
265
266   //===--------------------------------------------------------------------===//
267   // DIEDelta - A simple label difference DIE.
268   // 
269   struct DIEDelta : public DIEValue {
270     const DWLabel LabelHi;
271     const DWLabel LabelLo;
272     
273     DIEDelta(const DWLabel &Hi, const DWLabel &Lo)
274     : DIEValue(isDelta), LabelHi(Hi), LabelLo(Lo) {}
275
276     // Implement isa/cast/dyncast.
277     static bool classof(const DIEDelta *)  { return true; }
278     static bool classof(const DIEValue *D) { return D->Type == isDelta; }
279     
280     /// EmitValue - Emit delta value.
281     ///
282     virtual void EmitValue(const DwarfWriter &DW, unsigned Form) const;
283     
284     /// SizeOf - Determine size of delta value in bytes.
285     ///
286     virtual unsigned SizeOf(const DwarfWriter &DW, unsigned Form) const;
287   };
288   
289   //===--------------------------------------------------------------------===//
290   // DIEntry - A pointer to a debug information entry.
291   // 
292   struct DIEntry : public DIEValue {
293     DIE *Entry;
294     
295     DIEntry(DIE *E) : DIEValue(isEntry), Entry(E) {}
296
297     // Implement isa/cast/dyncast.
298     static bool classof(const DIEntry *)   { return true; }
299     static bool classof(const DIEValue *E) { return E->Type == isEntry; }
300     
301     /// EmitValue - Emit delta value.
302     ///
303     virtual void EmitValue(const DwarfWriter &DW, unsigned Form) const;
304     
305     /// SizeOf - Determine size of delta value in bytes.
306     ///
307     virtual unsigned SizeOf(const DwarfWriter &DW, unsigned Form) const;
308   };
309   
310   //===--------------------------------------------------------------------===//
311   // DIE - A structured debug information entry.  Has an abbreviation which
312   // describes it's organization.
313   class DIE {
314   private:
315     DIEAbbrev *Abbrev;                    // Temporary buffer for abbreviation.
316     unsigned AbbrevID;                    // Decribing abbreviation ID.
317     unsigned Offset;                      // Offset in debug info section.
318     unsigned Size;                        // Size of instance + children.
319     std::vector<DIE *> Children;          // Children DIEs.
320     std::vector<DIEValue *> Values;       // Attributes values.
321     
322   public:
323     DIE(unsigned Tag);
324     ~DIE();
325     
326     // Accessors
327     unsigned   getAbbrevID()                   const { return AbbrevID; }
328     unsigned   getOffset()                     const { return Offset; }
329     unsigned   getSize()                       const { return Size; }
330     const std::vector<DIE *> &getChildren()    const { return Children; }
331     const std::vector<DIEValue *> &getValues() const { return Values; }
332     void setOffset(unsigned O)                 { Offset = O; }
333     void setSize(unsigned S)                   { Size = S; }
334     
335     /// SiblingOffset - Return the offset of the debug information entry's
336     /// sibling.
337     unsigned SiblingOffset() const { return Offset + Size; }
338
339     /// AddUInt - Add an unsigned integer attribute data and value.
340     ///
341     void AddUInt(unsigned Attribute, unsigned Form, uint64_t Integer);
342
343     /// AddSInt - Add an signed integer attribute data and value.
344     ///
345     void AddSInt(unsigned Attribute, unsigned Form, int64_t Integer);
346         
347     /// AddString - Add a std::string attribute data and value.
348     ///
349     void AddString(unsigned Attribute, unsigned Form,
350                    const std::string &String);
351         
352     /// AddLabel - Add a Dwarf label attribute data and value.
353     ///
354     void AddLabel(unsigned Attribute, unsigned Form, const DWLabel &Label);
355         
356     /// AddObjectLabel - Add a non-Dwarf label attribute data and value.
357     ///
358     void AddObjectLabel(unsigned Attribute, unsigned Form,
359                         const std::string &Label);
360         
361     /// AddDelta - Add a label delta attribute data and value.
362     ///
363     void AddDelta(unsigned Attribute, unsigned Form,
364                   const DWLabel &Hi, const DWLabel &Lo);
365         
366     ///  AddDIEntry - Add a DIE attribute data and value.
367     ///
368     void AddDIEntry(unsigned Attribute, unsigned Form, DIE *Entry);
369
370     /// Complete - Indicate that all attributes have been added and
371     /// ready to get an abbreviation ID.
372     ///
373     void Complete(DwarfWriter &DW);
374     
375     /// AddChild - Add a child to the DIE.
376     void AddChild(DIE *Child);
377   };
378   
379   //===--------------------------------------------------------------------===//
380   // DwarfWriter - Emits Dwarf debug and exception handling directives.
381   //
382   class DwarfWriter {
383   protected:
384   
385     //===------------------------------------------------------------------===//
386     // Core attributes used by the Dwarf  writer.
387     //
388     
389     //
390     /// O - Stream to .s file.
391     ///
392     std::ostream &O;
393
394     /// Asm - Target of Dwarf emission.
395     ///
396     AsmPrinter *Asm;
397     
398     /// DebugInfo - Collected debug information.
399     ///
400     MachineDebugInfo *DebugInfo;
401     
402     /// didInitial - Flag to indicate if initial emission has been done.
403     ///
404     bool didInitial;
405     
406     //===------------------------------------------------------------------===//
407     // Attributes used to construct specific Dwarf sections.
408     //
409     
410     /// CompileUnits - All the compile units involved in this build.  The index
411     /// of each entry in this vector corresponds to the sources in DebugInfo.
412     std::vector<DIE *> CompileUnits;
413
414     /// Abbreviations - A UniqueVector of TAG structure abbreviations.
415     ///
416     UniqueVector<DIEAbbrev> Abbreviations;
417     
418     /// GlobalTypes - A map of globally visible named types.
419     ///
420     std::map<std::string, DIE *> GlobalTypes;
421     
422     /// GlobalEntities - A map of globally visible named entities.
423     ///
424     std::map<std::string, DIE *> GlobalEntities;
425      
426     /// StringPool - A UniqueVector of strings used by indirect references.
427     ///
428     UniqueVector<std::string> StringPool;
429     
430     /// DescToDieMap - Tracks the mapping of debug informaton descriptors to
431     /// DIES.
432     std::map<DebugInfoDesc *, DIE *> DescToDieMap;
433     
434     /// TypeToDieMap - Type to DIEType map.
435     ///
436     // FIXME - Should not be needed.
437     std::map<Type *, DIE *> TypeToDieMap;
438     
439     //===------------------------------------------------------------------===//
440     // Properties to be set by the derived class ctor, used to configure the
441     // Dwarf writer.
442     //
443     
444     /// AddressSize - Size of addresses used in file.
445     ///
446     unsigned AddressSize;
447
448     /// hasLEB128 - True if target asm supports leb128 directives.
449     ///
450     bool hasLEB128; /// Defaults to false.
451     
452     /// hasDotLoc - True if target asm supports .loc directives.
453     ///
454     bool hasDotLoc; /// Defaults to false.
455     
456     /// hasDotFile - True if target asm supports .file directives.
457     ///
458     bool hasDotFile; /// Defaults to false.
459     
460     /// needsSet - True if target asm can't compute addresses on data
461     /// directives.
462     bool needsSet; /// Defaults to false.
463     
464     /// DwarfAbbrevSection - Section directive for Dwarf abbrev.
465     ///
466     const char *DwarfAbbrevSection; /// Defaults to ".debug_abbrev".
467
468     /// DwarfInfoSection - Section directive for Dwarf info.
469     ///
470     const char *DwarfInfoSection; /// Defaults to ".debug_info".
471
472     /// DwarfLineSection - Section directive for Dwarf info.
473     ///
474     const char *DwarfLineSection; /// Defaults to ".debug_line".
475     
476     /// DwarfFrameSection - Section directive for Dwarf info.
477     ///
478     const char *DwarfFrameSection; /// Defaults to ".debug_frame".
479     
480     /// DwarfPubNamesSection - Section directive for Dwarf info.
481     ///
482     const char *DwarfPubNamesSection; /// Defaults to ".debug_pubnames".
483     
484     /// DwarfPubTypesSection - Section directive for Dwarf info.
485     ///
486     const char *DwarfPubTypesSection; /// Defaults to ".debug_pubtypes".
487     
488     /// DwarfStrSection - Section directive for Dwarf info.
489     ///
490     const char *DwarfStrSection; /// Defaults to ".debug_str".
491
492     /// DwarfLocSection - Section directive for Dwarf info.
493     ///
494     const char *DwarfLocSection; /// Defaults to ".debug_loc".
495
496     /// DwarfARangesSection - Section directive for Dwarf info.
497     ///
498     const char *DwarfARangesSection; /// Defaults to ".debug_aranges".
499
500     /// DwarfRangesSection - Section directive for Dwarf info.
501     ///
502     const char *DwarfRangesSection; /// Defaults to ".debug_ranges".
503
504     /// DwarfMacInfoSection - Section directive for Dwarf info.
505     ///
506     const char *DwarfMacInfoSection; /// Defaults to ".debug_macinfo".
507
508     /// TextSection - Section directive for standard text.
509     ///
510     const char *TextSection; /// Defaults to ".text".
511     
512     /// DataSection - Section directive for standard data.
513     ///
514     const char *DataSection; /// Defaults to ".data".
515
516     //===------------------------------------------------------------------===//
517     // Emission and print routines
518     //
519
520 public:
521     /// getAddressSize - Return the size of a target address in bytes.
522     ///
523     unsigned getAddressSize() const { return AddressSize; }
524
525     /// PrintHex - Print a value as a hexidecimal value.
526     ///
527     void PrintHex(int Value) const;
528
529     /// EOL - Print a newline character to asm stream.  If a comment is present
530     /// then it will be printed first.  Comments should not contain '\n'.
531     void EOL(const std::string &Comment) const;
532                                           
533     /// EmitULEB128Bytes - Emit an assembler byte data directive to compose an
534     /// unsigned leb128 value.
535     void EmitULEB128Bytes(unsigned Value) const;
536     
537     /// EmitSLEB128Bytes - print an assembler byte data directive to compose a
538     /// signed leb128 value.
539     void EmitSLEB128Bytes(int Value) const;
540     
541     /// PrintULEB128 - Print a series of hexidecimal values (separated by
542     /// commas) representing an unsigned leb128 value.
543     void PrintULEB128(unsigned Value) const;
544
545     /// SizeULEB128 - Compute the number of bytes required for an unsigned
546     /// leb128 value.
547     static unsigned SizeULEB128(unsigned Value);
548     
549     /// PrintSLEB128 - Print a series of hexidecimal values (separated by
550     /// commas) representing a signed leb128 value.
551     void PrintSLEB128(int Value) const;
552     
553     /// SizeSLEB128 - Compute the number of bytes required for a signed leb128
554     /// value.
555     static unsigned SizeSLEB128(int Value);
556     
557     /// EmitInt8 - Emit a byte directive and value.
558     ///
559     void EmitInt8(int Value) const;
560
561     /// EmitInt16 - Emit a short directive and value.
562     ///
563     void EmitInt16(int Value) const;
564
565     /// EmitInt32 - Emit a long directive and value.
566     ///
567     void EmitInt32(int Value) const;
568     
569     /// EmitInt64 - Emit a long long directive and value.
570     ///
571     void EmitInt64(uint64_t Value) const;
572     
573     /// EmitString - Emit a string with quotes and a null terminator.
574     /// Special characters are emitted properly. (Eg. '\t')
575     void EmitString(const std::string &String) const;
576
577     /// PrintLabelName - Print label name in form used by Dwarf writer.
578     ///
579     void PrintLabelName(DWLabel Label) const {
580       PrintLabelName(Label.Tag, Label.Number);
581     }
582     void PrintLabelName(const char *Tag, unsigned Number) const;
583     
584     /// EmitLabel - Emit location label for internal use by Dwarf.
585     ///
586     void EmitLabel(DWLabel Label) const {
587       EmitLabel(Label.Tag, Label.Number);
588     }
589     void EmitLabel(const char *Tag, unsigned Number) const;
590     
591     /// EmitReference - Emit a reference to a label.
592     ///
593     void EmitReference(DWLabel Label) const {
594       EmitReference(Label.Tag, Label.Number);
595     }
596     void EmitReference(const char *Tag, unsigned Number) const;
597     void EmitReference(const std::string &Name) const;
598
599     /// EmitDifference - Emit the difference between two labels.  Some
600     /// assemblers do not behave with absolute expressions with data directives,
601     /// so there is an option (needsSet) to use an intermediary set expression.
602     void EmitDifference(DWLabel LabelHi, DWLabel LabelLo) const {
603       EmitDifference(LabelHi.Tag, LabelHi.Number, LabelLo.Tag, LabelLo.Number);
604     }
605     void EmitDifference(const char *TagHi, unsigned NumberHi,
606                         const char *TagLo, unsigned NumberLo) const;
607                                    
608     /// NewAbbreviation - Add the abbreviation to the Abbreviation vector.
609     ///  
610     unsigned NewAbbreviation(DIEAbbrev *Abbrev);
611     
612     /// NewString - Add a string to the constant pool and returns a label.
613     ///
614     DWLabel NewString(const std::string &String);
615     
616     /// NewBasicType - Creates a new basic type if necessary, then adds to the
617     /// owner.
618     /// FIXME - Should never be needed.
619     DIE *NewBasicType(DIE *Owner, Type *Ty);
620
621     /// NewGlobalType - Make the type visible globally using the given name.
622     ///
623     void NewGlobalType(const std::string &Name, DIE *Type);
624     
625     /// NewGlobalEntity - Make the entity visible globally using the given name.
626     ///
627     void NewGlobalEntity(const std::string &Name, DIE *Entity);
628
629 private:
630
631     /// NewType - Create a new type DIE.
632     ///
633     DIE *NewType(DIE *Unit, TypeDesc *TyDesc);
634     
635     /// NewCompileUnit - Create new compile unit DIE.
636     ///
637     DIE *NewCompileUnit(CompileUnitDesc *CompileUnit);
638     
639     /// NewGlobalVariable - Make a new global variable DIE.
640     ///
641     DIE *NewGlobalVariable(GlobalVariableDesc *GVD);
642
643     /// NewSubprogram - Add a new subprogram DIE.
644     ///
645     DIE *NewSubprogram(SubprogramDesc *SPD);
646
647     /// EmitInitial - Emit initial Dwarf declarations.
648     ///
649     void EmitInitial() const;
650     
651     /// EmitDIE - Recusively Emits a debug information entry.
652     ///
653     void EmitDIE(DIE *Die) const;
654     
655     /// SizeAndOffsetDie - Compute the size and offset of a DIE.
656     ///
657     unsigned SizeAndOffsetDie(DIE *Die, unsigned Offset);
658
659     /// SizeAndOffsets - Compute the size and offset of all the DIEs.
660     ///
661     void SizeAndOffsets();
662     
663     /// EmitDebugInfo - Emit the debug info section.
664     ///
665     void EmitDebugInfo() const;
666     
667     /// EmitAbbreviations - Emit the abbreviation section.
668     ///
669     void EmitAbbreviations() const;
670     
671     /// EmitDebugLines - Emit source line information.
672     ///
673     void EmitDebugLines() const;
674
675     /// EmitDebugFrame - Emit info into a debug frame section.
676     ///
677     void EmitDebugFrame();
678     
679     /// EmitDebugPubNames - Emit info into a debug pubnames section.
680     ///
681     void EmitDebugPubNames();
682     
683     /// EmitDebugPubTypes - Emit info into a debug pubtypes section.
684     ///
685     void EmitDebugPubTypes();
686     
687     /// EmitDebugStr - Emit info into a debug str section.
688     ///
689     void EmitDebugStr();
690     
691     /// EmitDebugLoc - Emit info into a debug loc section.
692     ///
693     void EmitDebugLoc();
694     
695     /// EmitDebugARanges - Emit info into a debug aranges section.
696     ///
697     void EmitDebugARanges();
698     
699     /// EmitDebugRanges - Emit info into a debug ranges section.
700     ///
701     void EmitDebugRanges();
702     
703     /// EmitDebugMacInfo - Emit info into a debug macinfo section.
704     ///
705     void EmitDebugMacInfo();
706     
707     /// ConstructCompileUnitDIEs - Create a compile unit DIE for each source and
708     /// header file.
709     void ConstructCompileUnitDIEs();
710     
711     /// ConstructGlobalDIEs - Create DIEs for each of the externally visible
712     /// global variables.
713     void ConstructGlobalDIEs(Module &M);
714
715     /// ConstructSubprogramDIEs - Create DIEs for each of the externally visible
716     /// subprograms.
717     void ConstructSubprogramDIEs(Module &M);
718
719     /// ShouldEmitDwarf - Returns true if Dwarf declarations should be made.
720     /// When called it also checks to see if debug info is newly available.  if
721     /// so the initial Dwarf headers are emitted.
722     bool ShouldEmitDwarf();
723   
724   public:
725     
726     DwarfWriter(std::ostream &OS, AsmPrinter *A);
727     virtual ~DwarfWriter();
728     
729     /// SetDebugInfo - Set DebugInfo when it's known that pass manager has
730     /// created it.  Set by the target AsmPrinter.
731     void SetDebugInfo(MachineDebugInfo *DI) { DebugInfo = DI; }
732
733     //===------------------------------------------------------------------===//
734     // Main entry points.
735     //
736     
737     /// BeginModule - Emit all Dwarf sections that should come prior to the
738     /// content.
739     void BeginModule(Module &M);
740     
741     /// EndModule - Emit all Dwarf sections that should come after the content.
742     ///
743     void EndModule(Module &M);
744     
745     /// BeginFunction - Gather pre-function debug information.
746     ///
747     void BeginFunction(MachineFunction &MF);
748     
749     /// EndFunction - Gather and emit post-function debug information.
750     ///
751     void EndFunction(MachineFunction &MF);
752   };
753
754 } // end llvm namespace
755
756 #endif