c51b3ea84d783952d96f7659a0645900fc0beacd
[oota-llvm.git] / include / llvm / CodeGen / MachineDebugInfo.h
1 //===-- llvm/CodeGen/MachineDebugInfo.h -------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by James M. Laskey and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Collect debug information for a module.  This information should be in a
11 // neutral form that can be used by different debugging schemes.
12 //
13 // The organization of information is primarily clustered around the source
14 // compile units.  The main exception is source line correspondence where
15 // inlining may interleave code from various compile units.
16 //
17 // The following information can be retrieved from the MachineDebugInfo.
18 //
19 //  -- Source directories - Directories are uniqued based on their canonical
20 //     string and assigned a sequential numeric ID (base 1.)
21 //  -- Source files - Files are also uniqued based on their name and directory
22 //     ID.  A file ID is sequential number (base 1.)
23 //  -- Source line coorespondence - A vector of file ID, line#, column# triples.
24 //     A DEBUG_LOCATION instruction is generated  by the DAG Legalizer
25 //     corresponding to each entry in the source line list.  This allows a debug
26 //     emitter to generate labels referenced by debug information tables.
27 //
28 //===----------------------------------------------------------------------===//
29
30 #ifndef LLVM_CODEGEN_MACHINEDEBUGINFO_H
31 #define LLVM_CODEGEN_MACHINEDEBUGINFO_H
32
33 #include "llvm/Support/Dwarf.h"
34 #include "llvm/ADT/UniqueVector.h"
35 #include "llvm/GlobalValue.h"
36 #include "llvm/Pass.h"
37 #include "llvm/User.h"
38
39 #include <string>
40 #include <set>
41
42 namespace llvm {
43
44 //===----------------------------------------------------------------------===//
45 // Forward declarations.
46 class Constant;
47 class DebugInfoDesc;
48 class GlobalVariable;
49 class Module;
50 class PointerType;
51 class StructType;
52
53 //===----------------------------------------------------------------------===//
54 // Debug info constants.
55
56 enum {
57   LLVMDebugVersion = 1,                 // Current version of debug information.
58   DIInvalid = ~0U,                      // Invalid result indicator.
59   
60   // DebugInfoDesc type identifying tags.
61   DI_TAG_anchor = 0,
62   DI_TAG_compile_unit,
63   DI_TAG_global_variable,
64   DI_TAG_subprogram,
65   DI_TAG_basictype
66 };
67
68 //===----------------------------------------------------------------------===//
69 /// DIVisitor - Subclasses of this class apply steps to each of the fields in
70 /// the supplied DebugInfoDesc.
71 class DIVisitor {
72 public:
73   DIVisitor() {}
74   virtual ~DIVisitor() {}
75
76   /// ApplyToFields - Target the visitor to each field of the debug information
77   /// descriptor.
78   void ApplyToFields(DebugInfoDesc *DD);
79   
80   /// Apply - Subclasses override each of these methods to perform the
81   /// appropriate action for the type of field.
82   virtual void Apply(int &Field) = 0;
83   virtual void Apply(unsigned &Field) = 0;
84   virtual void Apply(uint64_t &Field) = 0;
85   virtual void Apply(bool &Field) = 0;
86   virtual void Apply(std::string &Field) = 0;
87   virtual void Apply(DebugInfoDesc *&Field) = 0;
88   virtual void Apply(GlobalVariable *&Field) = 0;
89 };
90
91 //===----------------------------------------------------------------------===//
92 /// DebugInfoDesc - This class is the base class for debug info descriptors.
93 ///
94 class DebugInfoDesc {
95 private:
96   unsigned Tag;                         // Content indicator.  Dwarf values are
97                                         // used but that does not limit use to
98                                         // Dwarf writers.
99   
100 protected:
101   DebugInfoDesc(unsigned T) : Tag(T) {}
102   
103 public:
104   virtual ~DebugInfoDesc() {}
105
106   // Accessors
107   unsigned getTag()          const { return Tag; }
108   
109   /// TagFromGlobal - Returns the Tag number from a debug info descriptor
110   /// GlobalVariable.  Return DIIValid if operand is not an unsigned int.
111   static unsigned TagFromGlobal(GlobalVariable *GV);
112
113   /// DescFactory - Create an instance of debug info descriptor based on Tag.
114   /// Return NULL if not a recognized Tag.
115   static DebugInfoDesc *DescFactory(unsigned Tag);
116   
117   /// getLinkage - get linkage appropriate for this type of descriptor.
118   ///
119   virtual GlobalValue::LinkageTypes getLinkage() const;
120     
121   //===--------------------------------------------------------------------===//
122   // Subclasses should supply the following static methods.
123   
124   // Implement isa/cast/dyncast.
125   static bool classof(const DebugInfoDesc *)  { return true; }
126   
127   //===--------------------------------------------------------------------===//
128   // Subclasses should supply the following virtual methods.
129   
130   /// ApplyToFields - Target the vistor to the fields of the descriptor.
131   ///
132   virtual void ApplyToFields(DIVisitor *Visitor);
133
134   /// getDescString - Return a string used to compose global names and labels.
135   ///
136   virtual const char *getDescString() const = 0;
137   
138   /// getTypeString - Return a string used to label this descriptor's type.
139   ///
140   virtual const char *getTypeString() const = 0;
141   
142 #ifndef NDEBUG
143   virtual void dump() = 0;
144 #endif
145 };
146
147
148 //===----------------------------------------------------------------------===//
149 /// AnchorDesc - Descriptors of this class act as markers for identifying
150 /// descriptors of certain groups.
151 class AnchorDesc : public DebugInfoDesc {
152 private:  
153   std::string Name;                     // Anchor type string.
154   
155 public:
156   AnchorDesc()
157   : DebugInfoDesc(DI_TAG_anchor)
158   , Name("")
159   {}
160   AnchorDesc(const std::string &N)
161   : DebugInfoDesc(DI_TAG_anchor)
162   , Name(N)
163   {}
164   
165   // Accessors
166   const std::string &getName() const { return Name; }
167
168   // Implement isa/cast/dyncast.
169   static bool classof(const AnchorDesc *) { return true; }
170   static bool classof(const DebugInfoDesc *D) {
171     return D->getTag() == DI_TAG_anchor;
172   }
173
174   /// getLinkage - get linkage appropriate for this type of descriptor.
175   ///
176   virtual GlobalValue::LinkageTypes getLinkage() const;
177
178   /// ApplyToFields - Target the visitor to the fields of the AnchorDesc.
179   ///
180   virtual void ApplyToFields(DIVisitor *Visitor);
181
182   /// getDescString - Return a string used to compose global names and labels.
183   ///
184   virtual const char *getDescString() const;
185     
186   /// getTypeString - Return a string used to label this descriptor's type.
187   ///
188   virtual const char *getTypeString() const;
189     
190 #ifndef NDEBUG
191   virtual void dump();
192 #endif
193 };
194
195 //===----------------------------------------------------------------------===//
196 /// AnchoredDesc - This class manages anchors for a variety of top level
197 /// descriptors.
198 class AnchoredDesc : public DebugInfoDesc {
199 private:  
200   AnchorDesc *Anchor;                   // Anchor for all descriptors of the
201                                         // same type.
202
203 protected:
204
205   AnchoredDesc(unsigned T);
206
207 public:  
208   // Accessors.
209   AnchorDesc *getAnchor() const { return Anchor; }
210   void setAnchor(AnchorDesc *A) { Anchor = A; }
211
212   //===--------------------------------------------------------------------===//
213   // Subclasses should supply the following virtual methods.
214   
215   /// ApplyToFields - Target the visitor to the fields of the AnchoredDesc.
216   ///
217   virtual void ApplyToFields(DIVisitor *Visitor);
218 };
219
220 //===----------------------------------------------------------------------===//
221 /// CompileUnitDesc - This class packages debug information associated with a 
222 /// source/header file.
223 class CompileUnitDesc : public AnchoredDesc {
224 private:  
225   unsigned DebugVersion;                // LLVM debug version when produced.
226   unsigned Language;                    // Language number (ex. DW_LANG_C89.)
227   std::string FileName;                 // Source file name.
228   std::string Directory;                // Source file directory.
229   std::string Producer;                 // Compiler string.
230   
231 public:
232   CompileUnitDesc();
233   
234   // Accessors
235   unsigned getDebugVersion()              const { return DebugVersion; }
236   unsigned getLanguage()                  const { return Language; }
237   const std::string &getFileName()        const { return FileName; }
238   const std::string &getDirectory()       const { return Directory; }
239   const std::string &getProducer()        const { return Producer; }
240   void setLanguage(unsigned L)                  { Language = L; }
241   void setFileName(const std::string &FN)       { FileName = FN; }
242   void setDirectory(const std::string &D)       { Directory = D; }
243   void setProducer(const std::string &P)        { Producer = P; }
244   
245   // FIXME - Need translation unit getter/setter.
246
247   // Implement isa/cast/dyncast.
248   static bool classof(const CompileUnitDesc *) { return true; }
249   static bool classof(const DebugInfoDesc *D) {
250     return D->getTag() == DI_TAG_compile_unit;
251   }
252   
253   /// DebugVersionFromGlobal - Returns the version number from a compile unit
254   /// GlobalVariable.  Return DIIValid if operand is not an unsigned int.
255   static unsigned DebugVersionFromGlobal(GlobalVariable *GV);
256   
257   /// ApplyToFields - Target the visitor to the fields of the CompileUnitDesc.
258   ///
259   virtual void ApplyToFields(DIVisitor *Visitor);
260
261   /// getDescString - Return a string used to compose global names and labels.
262   ///
263   virtual const char *getDescString() const;
264     
265   /// getTypeString - Return a string used to label this descriptor's type.
266   ///
267   virtual const char *getTypeString() const;
268   
269   /// getAnchorString - Return a string used to label this descriptor's anchor.
270   ///
271   virtual const char *getAnchorString() const;
272     
273 #ifndef NDEBUG
274   virtual void dump();
275 #endif
276 };
277
278 //===----------------------------------------------------------------------===//
279 /// TypeDesc - This class packages debug information associated with a type.
280 ///
281 class TypeDesc : public DebugInfoDesc {
282 private:
283   DebugInfoDesc *Context;               // Context debug descriptor.
284   std::string Name;                     // Type name.
285   uint64_t Size;                        // Type size.
286
287 protected:
288   TypeDesc(unsigned T);
289
290 public:
291   // Accessors
292   DebugInfoDesc *getContext()                const { return Context; }
293   const std::string &getName()               const { return Name; }
294   uint64_t getSize()                         const { return Size; }
295   void setContext(DebugInfoDesc *C)                { Context = C; }
296   void setName(const std::string &N)               { Name = N; }
297   void setSize(uint64_t S)                         { Size = S; }
298   
299   /// ApplyToFields - Target the visitor to the fields of the  TypeDesc.
300   ///
301   virtual void ApplyToFields(DIVisitor *Visitor);
302
303   /// getDescString - Return a string used to compose global names and labels.
304   ///
305   virtual const char *getDescString() const;
306
307   /// getTypeString - Return a string used to label this descriptor's type.
308   ///
309   virtual const char *getTypeString() const;
310   
311 #ifndef NDEBUG
312   virtual void dump();
313 #endif
314 };
315
316 //===----------------------------------------------------------------------===//
317 /// BasicTypeDesc - This class packages debug information associated with a
318 /// basic type (eg. int, bool, double.)
319 class BasicTypeDesc : public TypeDesc {
320 private:
321   unsigned Encoding;                    // Type encoding.
322   
323 public:
324   BasicTypeDesc();
325   
326   // Accessors
327   unsigned getEncoding()                     const { return Encoding; }
328   void setEncoding(unsigned E)                     { Encoding = E; }
329
330   // Implement isa/cast/dyncast.
331   static bool classof(const BasicTypeDesc *)  { return true; }
332   static bool classof(const DebugInfoDesc *D) {
333     return D->getTag() == DI_TAG_basictype;
334   }
335   
336   /// ApplyToFields - Target the visitor to the fields of the  BasicTypeDesc.
337   ///
338   virtual void ApplyToFields(DIVisitor *Visitor);
339
340 #ifndef NDEBUG
341   virtual void dump();
342 #endif
343 };
344
345 //===----------------------------------------------------------------------===//
346 /// GlobalDesc - This class is the base descriptor for global functions and
347 /// variables.
348 class GlobalDesc : public AnchoredDesc {
349 private:
350   DebugInfoDesc *Context;               // Context debug descriptor.
351   std::string Name;                     // Global name.
352   TypeDesc *TyDesc;                     // Type debug descriptor.
353   bool IsStatic;                        // Is the global a static.
354   bool IsDefinition;                    // Is the global defined in context.
355   
356 protected:
357   GlobalDesc(unsigned T);
358
359 public:
360   // Accessors
361   DebugInfoDesc *getContext()                const { return Context; }
362   const std::string &getName()               const { return Name; }
363   TypeDesc *getTypeDesc()                    const { return TyDesc; }
364   bool isStatic()                            const { return IsStatic; }
365   bool isDefinition()                        const { return IsDefinition; }
366   void setContext(DebugInfoDesc *C)                { Context = C; }
367   void setName(const std::string &N)               { Name = N; }
368   void setTypeDesc(TypeDesc *T)                    { TyDesc = T; }
369   void setIsStatic(bool IS)                        { IsStatic = IS; }
370   void setIsDefinition(bool ID)                    { IsDefinition = ID; }
371
372   /// ApplyToFields - Target the visitor to the fields of the GlobalDesc.
373   ///
374   virtual void ApplyToFields(DIVisitor *Visitor);
375 };
376
377 //===----------------------------------------------------------------------===//
378 /// GlobalVariableDesc - This class packages debug information associated with a
379 /// GlobalVariable.
380 class GlobalVariableDesc : public GlobalDesc {
381 private:
382   GlobalVariable *Global;               // llvm global.
383   unsigned Line;                        // Source line number.
384   
385 public:
386   GlobalVariableDesc();
387
388   // Accessors.
389   GlobalVariable *getGlobalVariable()        const { return Global; }
390   unsigned getLine()                         const { return Line; }
391   void setGlobalVariable(GlobalVariable *GV)       { Global = GV; }
392   void setLine(unsigned L)                         { Line = L; }
393  
394   // Implement isa/cast/dyncast.
395   static bool classof(const GlobalVariableDesc *)  { return true; }
396   static bool classof(const DebugInfoDesc *D) {
397     return D->getTag() == DI_TAG_global_variable; 
398   }
399   
400   /// ApplyToFields - Target the visitor to the fields of the
401   /// GlobalVariableDesc.
402   virtual void ApplyToFields(DIVisitor *Visitor);
403
404   /// getDescString - Return a string used to compose global names and labels.
405   ///
406   virtual const char *getDescString() const;
407
408   /// getTypeString - Return a string used to label this descriptor's type.
409   ///
410   virtual const char *getTypeString() const;
411   
412   /// getAnchorString - Return a string used to label this descriptor's anchor.
413   ///
414   virtual const char *getAnchorString() const;
415     
416 #ifndef NDEBUG
417   virtual void dump();
418 #endif
419 };
420
421 //===----------------------------------------------------------------------===//
422 /// SubprogramDesc - This class packages debug information associated with a
423 /// subprogram/function.
424 class SubprogramDesc : public GlobalDesc {
425 private:
426   // FIXME - Other attributes
427   
428 public:
429   SubprogramDesc();
430   
431   // Accessors
432   // FIXME - Other getters/setters.
433   
434   // Implement isa/cast/dyncast.
435   static bool classof(const SubprogramDesc *)  { return true; }
436   static bool classof(const DebugInfoDesc *D) {
437     return D->getTag() == DI_TAG_subprogram;
438   }
439   
440   /// ApplyToFields - Target the visitor to the fields of the  SubprogramDesc.
441   ///
442   virtual void ApplyToFields(DIVisitor *Visitor);
443
444   /// getDescString - Return a string used to compose global names and labels.
445   ///
446   virtual const char *getDescString() const;
447
448   /// getTypeString - Return a string used to label this descriptor's type.
449   ///
450   virtual const char *getTypeString() const;
451   
452   /// getAnchorString - Return a string used to label this descriptor's anchor.
453   ///
454   virtual const char *getAnchorString() const;
455     
456 #ifndef NDEBUG
457   virtual void dump();
458 #endif
459 };
460
461 //===----------------------------------------------------------------------===//
462 /// DIDeserializer - This class is responsible for casting GlobalVariables
463 /// into DebugInfoDesc objects.
464 class DIDeserializer {
465 private:
466   unsigned DebugVersion;                // Version of debug information in use.
467   std::map<GlobalVariable *, DebugInfoDesc *> GlobalDescs;
468                                         // Previously defined gloabls.
469   
470 public:
471   DIDeserializer() : DebugVersion(LLVMDebugVersion) {}
472   ~DIDeserializer() {}
473   
474   // Accessors
475   unsigned getDebugVersion() const { return DebugVersion; }
476   
477   /// Deserialize - Reconstitute a GlobalVariable into it's component
478   /// DebugInfoDesc objects.
479   DebugInfoDesc *Deserialize(Value *V);
480   DebugInfoDesc *Deserialize(GlobalVariable *GV);
481 };
482
483 //===----------------------------------------------------------------------===//
484 /// DISerializer - This class is responsible for casting DebugInfoDesc objects
485 /// into GlobalVariables.
486 class DISerializer {
487 private:
488   Module *M;                            // Definition space module.
489   PointerType *StrPtrTy;                // A "sbyte *" type.  Created lazily.
490   PointerType *EmptyStructPtrTy;        // A "{ }*" type.  Created lazily.
491   std::map<unsigned, StructType *> TagTypes;
492                                         // Types per Tag.  Created lazily.
493   std::map<DebugInfoDesc *, GlobalVariable *> DescGlobals;
494                                         // Previously defined descriptors.
495   std::map<const std::string, Constant *> StringCache;
496                                         // Previously defined strings.
497                                           
498 public:
499   DISerializer()
500   : M(NULL)
501   , StrPtrTy(NULL)
502   , EmptyStructPtrTy(NULL)
503   , TagTypes()
504   , DescGlobals()
505   , StringCache()
506   {}
507   ~DISerializer() {}
508   
509   // Accessors
510   Module *getModule()        const { return M; };
511   void setModule(Module *module)  { M = module; }
512
513   /// getStrPtrType - Return a "sbyte *" type.
514   ///
515   const PointerType *getStrPtrType();
516   
517   /// getEmptyStructPtrType - Return a "{ }*" type.
518   ///
519   const PointerType *getEmptyStructPtrType();
520   
521   /// getTagType - Return the type describing the specified descriptor (via
522   /// tag.)
523   const StructType *getTagType(DebugInfoDesc *DD);
524   
525   /// getString - Construct the string as constant string global.
526   ///
527   Constant *getString(const std::string &String);
528   
529   /// Serialize - Recursively cast the specified descriptor into a
530   /// GlobalVariable so that it can be serialized to a .bc or .ll file.
531   GlobalVariable *Serialize(DebugInfoDesc *DD);
532 };
533
534 //===----------------------------------------------------------------------===//
535 /// DIVerifier - This class is responsible for verifying the given network of
536 /// GlobalVariables are valid as DebugInfoDesc objects.
537 class DIVerifier {
538 private:
539   unsigned DebugVersion;                // Version of debug information in use.
540   std::set<GlobalVariable *> Visited;   // Tracks visits during recursion.
541   std::map<unsigned, unsigned> Counts;  // Count of fields per Tag type.
542
543   /// markVisited - Return true if the GlobalVariable hase been "seen" before.
544   /// Mark markVisited otherwise.
545   bool markVisited(GlobalVariable *GV);
546   
547 public:
548   DIVerifier() : DebugVersion(LLVMDebugVersion) {}
549   ~DIVerifier() {}
550   
551   /// Verify - Return true if the GlobalVariable appears to be a valid
552   /// serialization of a DebugInfoDesc.
553   bool Verify(Value *V);
554   bool Verify(GlobalVariable *GV);
555 };
556
557 //===----------------------------------------------------------------------===//
558 /// SourceLineInfo - This class is used to record source line correspondence.
559 ///
560 class SourceLineInfo {
561 private:
562   unsigned Line;                        // Source line number.
563   unsigned Column;                      // Source column.
564   unsigned SourceID;                    // Source ID number.
565
566 public:
567   SourceLineInfo(unsigned L, unsigned C, unsigned S)
568   : Line(L), Column(C), SourceID(S) {}
569   
570   // Accessors
571   unsigned getLine()     const { return Line; }
572   unsigned getColumn()   const { return Column; }
573   unsigned getSourceID() const { return SourceID; }
574 };
575
576 //===----------------------------------------------------------------------===//
577 /// SourceFileInfo - This class is used to track source information.
578 ///
579 class SourceFileInfo {
580 private:
581   unsigned DirectoryID;                 // Directory ID number.
582   std::string Name;                     // File name (not including directory.)
583   
584 public:
585   SourceFileInfo(unsigned D, const std::string &N) : DirectoryID(D), Name(N) {}
586             
587   // Accessors
588   unsigned getDirectoryID()    const { return DirectoryID; }
589   const std::string &getName() const { return Name; }
590
591   /// operator== - Used by UniqueVector to locate entry.
592   ///
593   bool operator==(const SourceFileInfo &SI) const {
594     return getDirectoryID() == SI.getDirectoryID() && getName() == SI.getName();
595   }
596
597   /// operator< - Used by UniqueVector to locate entry.
598   ///
599   bool operator<(const SourceFileInfo &SI) const {
600     return getDirectoryID() < SI.getDirectoryID() ||
601           (getDirectoryID() == SI.getDirectoryID() && getName() < SI.getName());
602   }
603 };
604
605 //===----------------------------------------------------------------------===//
606 /// MachineDebugInfo - This class contains debug information specific to a
607 /// module.  Queries can be made by different debugging schemes and reformated
608 /// for specific use.
609 ///
610 class MachineDebugInfo : public ImmutablePass {
611 private:
612   // Use the same serializer/deserializer/verifier for the module.
613   DIDeserializer DR;
614
615   // CompileUnits - Uniquing vector for compile units.
616   UniqueVector<CompileUnitDesc *> CompileUnits;
617   
618   // Directories - Uniquing vector for directories.
619   UniqueVector<std::string> Directories;
620                                          
621   // SourceFiles - Uniquing vector for source files.
622   UniqueVector<SourceFileInfo> SourceFiles;
623
624   // Lines - List of of source line correspondence.
625   std::vector<SourceLineInfo *> Lines;
626
627 public:
628   MachineDebugInfo();
629   ~MachineDebugInfo();
630   
631   /// doInitialization - Initialize the debug state for a new module.
632   ///
633   bool doInitialization();
634   
635   /// doFinalization - Tear down the debug state after completion of a module.
636   ///
637   bool doFinalization();
638   
639   /// getDescFor - Convert a Value to a debug information descriptor.
640   ///
641   // FIXME - use new Value type when available.
642   DebugInfoDesc *getDescFor(Value *V);
643   
644   /// Verify - Verify that a Value is debug information descriptor.
645   ///
646   bool Verify(Value *V);
647   
648   /// AnalyzeModule - Scan the module for global debug information.
649   ///
650   void AnalyzeModule(Module &M);
651   
652   /// hasInfo - Returns true if valid debug info is present.
653   ///
654   bool hasInfo() const { return !CompileUnits.empty(); }
655   
656   /// RecordLabel - Records location information and associates it with a
657   /// debug label.  Returns a unique label ID used to generate a label and 
658   /// provide correspondence to the source line list.
659   unsigned RecordLabel(unsigned Line, unsigned Column, unsigned Source) {
660     Lines.push_back(new SourceLineInfo(Line, Column, Source));
661     return Lines.size();
662   }
663   
664   /// RecordSource - Register a source file with debug info. Returns an source
665   /// ID.
666   unsigned RecordSource(const std::string &Directory,
667                         const std::string &Source) {
668     unsigned DirectoryID = Directories.insert(Directory);
669     return SourceFiles.insert(SourceFileInfo(DirectoryID, Source));
670   }
671   unsigned RecordSource(const CompileUnitDesc *CompileUnit) {
672     return RecordSource(CompileUnit->getDirectory(),
673                         CompileUnit->getFileName());
674   }
675   
676   /// getDirectories - Return the UniqueVector of std::string representing
677   /// directories.
678   const UniqueVector<std::string> &getDirectories() const {
679     return Directories;
680   }
681   
682   /// getSourceFiles - Return the UniqueVector of source files. 
683   ///
684   const UniqueVector<SourceFileInfo> &getSourceFiles() const {
685     return SourceFiles;
686   }
687   
688   /// getSourceLines - Return a vector of source lines.  Vector index + 1
689   /// equals label ID.
690   const std::vector<SourceLineInfo *> &getSourceLines() const {
691     return Lines;
692   }
693   
694   /// SetupCompileUnits - Set up the unique vector of compile units.
695   ///
696   void SetupCompileUnits(Module &M);
697
698   /// getCompileUnits - Return a vector of debug compile units.
699   ///
700   const UniqueVector<CompileUnitDesc *> getCompileUnits() const;
701   
702   /// getGlobalVariablesUsing - Return all of the GlobalVariables that use the
703   /// named GlobalVariable.
704   std::vector<GlobalVariable*>
705   getGlobalVariablesUsing(Module &M, const std::string &RootName);
706
707   /// getAnchoredDescriptors - Return a vector of anchored debug descriptors.
708   ///
709   template <class T>std::vector<T *> getAnchoredDescriptors(Module &M) {
710     T Desc;
711     std::vector<GlobalVariable *> Globals =
712                              getGlobalVariablesUsing(M, Desc.getAnchorString());
713     std::vector<T *> AnchoredDescs;
714     for (unsigned i = 0, N = Globals.size(); i < N; ++i) {
715       AnchoredDescs.push_back(static_cast<T *>(DR.Deserialize(Globals[i])));
716     }
717
718     return AnchoredDescs;
719   }
720
721 }; // End class MachineDebugInfo
722
723 } // End llvm namespace
724
725 #endif