[llvm-commits] CVS: llvm/include/llvm/CodeGen/DwarfWriter.h MachineDebugInfo.h

Jim Laskey jlaskey at apple.com
Wed Feb 22 11:02:23 PST 2006



Changes in directory llvm/include/llvm/CodeGen:

DwarfWriter.h updated: 1.23 -> 1.24
MachineDebugInfo.h updated: 1.16 -> 1.17
---
Log message:

Coordinate activities with llvm-gcc4 and dwarf.


---
Diffs of the changes:  (+64 -71)

 DwarfWriter.h      |   86 +++++++++++++++++++++--------------------------------
 MachineDebugInfo.h |   49 +++++++++++++++++-------------
 2 files changed, 64 insertions(+), 71 deletions(-)


Index: llvm/include/llvm/CodeGen/DwarfWriter.h
diff -u llvm/include/llvm/CodeGen/DwarfWriter.h:1.23 llvm/include/llvm/CodeGen/DwarfWriter.h:1.24
--- llvm/include/llvm/CodeGen/DwarfWriter.h:1.23	Mon Feb  6 09:33:21 2006
+++ llvm/include/llvm/CodeGen/DwarfWriter.h	Wed Feb 22 13:02:11 2006
@@ -34,12 +34,14 @@
   //
   class AsmPrinter;
   class CompileUnitDesc;
+  class DebugInfoDesc;
   class DIE;
-  class DwarfWriter; 
-  class DWContext;
+  class DwarfWriter;
+  class GlobalVariableDesc;
   class MachineDebugInfo;
   class MachineFunction;
   class Module;
+  class SubprogramDesc;
   class Type;
   
   //===--------------------------------------------------------------------===//
@@ -116,6 +118,7 @@
     unsigned getTag()                           const { return Tag; }
     unsigned getChildrenFlag()                  const { return ChildrenFlag; }
     const std::vector<DIEAbbrevData> &getData() const { return Data; }
+    void setChildrenFlag(unsigned CF)                 { ChildrenFlag = CF; }
 
     /// operator== - Used by UniqueVector to locate entry.
     ///
@@ -312,24 +315,21 @@
     unsigned AbbrevID;                    // Decribing abbreviation ID.
     unsigned Offset;                      // Offset in debug info section.
     unsigned Size;                        // Size of instance + children.
-    DWContext *Context;                   // Context for types and values.
     std::vector<DIE *> Children;          // Children DIEs.
     std::vector<DIEValue *> Values;       // Attributes values.
     
   public:
-    DIE(unsigned Tag, unsigned ChildrenFlag);
+    DIE(unsigned Tag);
     ~DIE();
     
     // Accessors
     unsigned   getAbbrevID()                   const { return AbbrevID; }
     unsigned   getOffset()                     const { return Offset; }
     unsigned   getSize()                       const { return Size; }
-    DWContext *getContext()                    const { return Context; }
     const std::vector<DIE *> &getChildren()    const { return Children; }
     const std::vector<DIEValue *> &getValues() const { return Values; }
     void setOffset(unsigned O)                 { Offset = O; }
     void setSize(unsigned S)                   { Size = S; }
-    void setContext(DWContext *C)              { Context = C; }
     
     /// SiblingOffset - Return the offset of the debug information entry's
     /// sibling.
@@ -376,40 +376,6 @@
   };
   
   //===--------------------------------------------------------------------===//
-  /// DWContext - Name context for types and values.
-  ///
-  class DWContext {
-  private:
-    DwarfWriter &DW;                    // DwarfWriter for global information.
-    DWContext *Parent;                  // Next context level searched.
-    DIE *Owner;                         // Owning debug information entry.
-    std::map<const Type *, DIE*> Types; // Named types in context.
-    std::map<std::string, DIE*> Variables;// Named variables in context.
-    
-  public:
-    DWContext(DwarfWriter &D, DWContext *P, DIE *O)
-    : DW(D)
-    , Parent(P)
-    , Owner(O)
-    , Types()
-    , Variables()
-    {
-      Owner->setContext(this);
-    }
-    ~DWContext() {}
-    
-    /// NewBasicType - Creates a new basic type, if necessary, then adds to the
-    /// context and owner.
-    DIE *NewBasicType(const Type *Ty, unsigned Size, unsigned Align);
-                                               
-    /// NewVariable - Creates a basic variable, if necessary, then adds to the
-    /// context and owner.
-    DIE *NewGlobalVariable(const std::string &Name,
-                           const std::string &MangledName,
-                           DIE *Type);
-  };
-
-  //===--------------------------------------------------------------------===//
   // DwarfWriter - Emits Dwarf debug and exception handling directives.
   //
   class DwarfWriter {
@@ -460,6 +426,15 @@
     ///
     UniqueVector<std::string> StringPool;
     
+    /// DescToDieMap - Tracks the mapping of debug informaton descriptors to
+    /// DIES.
+    std::map<DebugInfoDesc *, DIE *> DescToDieMap;
+    
+    /// TypeToDieMap - Type to DIEType map.
+    ///
+    // FIXME - Should not be needed.
+    std::map<Type *, DIE *> TypeToDieMap;
+    
     //===------------------------------------------------------------------===//
     // Properties to be set by the derived class ctor, used to configure the
     // Dwarf writer.
@@ -637,6 +612,11 @@
     ///
     DWLabel NewString(const std::string &String);
     
+    /// NewBasicType - Creates a new basic type if necessary, then adds to the
+    /// owner.
+    /// FIXME - Should never be needed.
+    DIE *NewBasicType(DIE *Owner, Type *Ty);
+
     /// NewGlobalType - Make the type visible globally using the given name.
     ///
     void NewGlobalType(const std::string &Name, DIE *Type);
@@ -644,20 +624,20 @@
     /// NewGlobalEntity - Make the entity visible globally using the given name.
     ///
     void NewGlobalEntity(const std::string &Name, DIE *Entity);
+
+private:
     
-    /// NewGlobalVariable - Add a new global variable DIE to the context.
+    /// NewGlobalVariable - Make a new global variable DIE.
     ///
-    void NewGlobalVariable(DWContext *Context,
-                           const std::string &Name,
-                           const std::string &MangledName,
-                           const Type *Ty,
-                           unsigned Size, unsigned Align);
+    DIE *NewGlobalVariable(GlobalVariableDesc *GVD);
 
-private:
+    /// NewSubprogram - Add a new subprogram DIE.
+    ///
+    DIE *NewSubprogram(SubprogramDesc *SPD);
 
     /// NewCompileUnit - Create new compile unit information.
     ///
-    DIE *NewCompileUnit(const CompileUnitDesc *CompileUnit);
+    DIE *NewCompileUnit(CompileUnitDesc *CompileUnit);
 
     /// EmitInitial - Emit initial Dwarf declarations.
     ///
@@ -669,7 +649,7 @@
     
     /// SizeAndOffsetDie - Compute the size and offset of a DIE.
     ///
-    unsigned SizeAndOffsetDie(DIE *Die, unsigned Offset) const;
+    unsigned SizeAndOffsetDie(DIE *Die, unsigned Offset);
 
     /// SizeAndOffsets - Compute the size and offset of all the DIEs.
     ///
@@ -723,10 +703,14 @@
     /// header file.
     void ConstructCompileUnitDIEs();
     
-    /// ConstructGlobalDIEs - Create DIEs for each of the externally visible global
-    /// variables.
+    /// ConstructGlobalDIEs - Create DIEs for each of the externally visible
+    /// global variables.
     void ConstructGlobalDIEs(Module &M);
 
+    /// ConstructSubprogramDIEs - Create DIEs for each of the externally visible
+    /// subprograms.
+    void ConstructSubprogramDIEs(Module &M);
+
     /// ShouldEmitDwarf - Returns true if Dwarf declarations should be made.
     /// When called it also checks to see if debug info is newly available.  if
     /// so the initial Dwarf headers are emitted.


Index: llvm/include/llvm/CodeGen/MachineDebugInfo.h
diff -u llvm/include/llvm/CodeGen/MachineDebugInfo.h:1.16 llvm/include/llvm/CodeGen/MachineDebugInfo.h:1.17
--- llvm/include/llvm/CodeGen/MachineDebugInfo.h:1.16	Mon Feb 13 10:56:43 2006
+++ llvm/include/llvm/CodeGen/MachineDebugInfo.h	Wed Feb 22 13:02:11 2006
@@ -310,18 +310,21 @@
 class GlobalVariableDesc : public GlobalDesc {
 private:
   GlobalVariable *Global;               // llvm global.
+  unsigned Line;                        // Source line number.
   
 public:
   GlobalVariableDesc();
 
   // Accessors.
   GlobalVariable *getGlobalVariable()        const { return Global; }
+  unsigned getLine()                         const { return Line; }
   void setGlobalVariable(GlobalVariable *GV)       { Global = GV; }
-  
+  void setLine(unsigned L)                         { Line = L; }
+ 
   // Implement isa/cast/dyncast.
   static bool classof(const GlobalVariableDesc *)  { return true; }
   static bool classof(const DebugInfoDesc *D) {
-    return D->getTag() == DI_TAG_global_variable;
+    return D->getTag() == DI_TAG_global_variable; 
   }
   
   /// ApplyToFields - Target the visitor to the fields of the
@@ -350,25 +353,12 @@
 /// subprogram/function.
 class SubprogramDesc : public GlobalDesc {
 private:
-  DebugInfoDesc *Context;               // Context debug descriptor.
-  std::string Name;                     // Subprogram name.
-  // FIXME - Use a descriptor.
-  GlobalVariable *TyDesc;               // Type debug descriptor.
-  bool IsStatic;                        // Is the subprogram a static.
-  bool IsDefinition;                    // Is the subprogram defined in context.
+  // FIXME - Other attributes
   
 public:
   SubprogramDesc();
   
   // Accessors
-  DebugInfoDesc *getContext()                const { return Context; }
-  const std::string &getName()               const { return Name; }
-  bool isStatic()                            const { return IsStatic; }
-  bool isDefinition()                        const { return IsDefinition; }
-  void setContext(DebugInfoDesc *C)                { Context = C; }
-  void setName(const std::string &N)               { Name = N; }
-  void setIsStatic(bool IS)                        { IsStatic = IS; }
-  void setIsDefinition(bool ID)                    { IsDefinition = ID; }
   // FIXME - Other getters/setters.
   
   // Implement isa/cast/dyncast.
@@ -604,10 +594,14 @@
   /// RecordSource - Register a source file with debug info. Returns an source
   /// ID.
   unsigned RecordSource(const std::string &Directory,
-                               const std::string &Source) {
+                        const std::string &Source) {
     unsigned DirectoryID = Directories.insert(Directory);
     return SourceFiles.insert(SourceFileInfo(DirectoryID, Source));
   }
+  unsigned RecordSource(const CompileUnitDesc *CompileUnit) {
+    return RecordSource(CompileUnit->getDirectory(),
+                        CompileUnit->getFileName());
+  }
   
   /// getDirectories - Return the UniqueVector of std::string representing
   /// directories.
@@ -634,10 +628,25 @@
   /// getCompileUnits - Return a vector of debug compile units.
   ///
   const UniqueVector<CompileUnitDesc *> getCompileUnits() const;
+  
+  /// getGlobalVariablesUsing - Return all of the GlobalVariables that use the
+  /// named GlobalVariable.
+  std::vector<GlobalVariable*>
+  getGlobalVariablesUsing(Module &M, const std::string &RootName);
+
+  /// getAnchoredDescriptors - Return a vector of anchored debug descriptors.
+  ///
+  template <class T>std::vector<T *> getAnchoredDescriptors(Module &M) {
+    T Desc;
+    std::vector<GlobalVariable *> Globals =
+                             getGlobalVariablesUsing(M, Desc.getAnchorString());
+    std::vector<T *> AnchoredDescs;
+    for (unsigned i = 0, N = Globals.size(); i < N; ++i) {
+      AnchoredDescs.push_back(static_cast<T *>(DR.Deserialize(Globals[i])));
+    }
 
-  /// getGlobalVariables - Return a vector of debug GlobalVariables.
-  ///
-  std::vector<GlobalVariableDesc *> getGlobalVariables(Module &M);
+    return AnchoredDescs;
+  }
 
 }; // End class MachineDebugInfo
 






More information about the llvm-commits mailing list