[LLVMdev] DebugInfoBuilder?

Talin viridia at gmail.com
Thu May 22 18:58:18 PDT 2008


Evan Cheng wrote:
> I don't think so. Contribution welcome! :-) LLVM debugging support  
> isn't anywhere near where it needs to be.
>   
Well, here's a rough sketch of what I was thinking of:

class DebugInfoBuilder {
public:
    /// Constructor
    DebugInfoBuilder();

    /// Return the type defined by llvm.dbg.anchor.type
    StructType * GetAnchorType() const;
   
    /// Set the reference to the module where we will insert debugging 
information.
    /// Also defines the debug info types for the module and creates the 
initial anchors.
    void SetModule(Module * m);
   
    /// Emit a compile unit descriptor.
    GlobalVariable * CreateCompileUnitDescriptor(
        unsigned langId,
        const sys::Path & srcPath,
        const std::string & producer);

    /// Emit a subprogram descriptor.
    GlobalVariable * CreateSubProgramDescriptor(
        GlobalVariable * compileUnit,       /// Compile unit in which it 
is defined
        GlobalVariable * context,           /// Context in which it is 
defined
        const std::string & name,           /// Name of the subprogram
        const std::string & qualifiedName,  /// Fully-qualified name
        unsigned line,                      /// Line number
        GlobalVariable * typeDesc,          /// Type descriptor
        bool isStatic,                      /// True if this has static 
scope (internal to module)
        bool isDefined);                    /// True if this is not 
externally-defined.

    /// Create a type descriptor for a primitive type
    GlobalVariable * CreateBasicTypeDescriptor(
        GlobalVariable * compileUnit,
        GlobalVariable * context,
        std::string & name,
        unsigned line,
        unsigned sizeInBits,
        unsigned alignmentInBits,
        unsigned offsetInBits,
        unsigned typeEncoding);

    /// Create a type descriptor for an integer type
    GlobalVariable * CreateIntegerTypeDescriptor(
        std::string & name, const IntegerType * type, bool isSigned);

    /// Create a type descriptor for an character type
    GlobalVariable * CreateCharacterTypeDescriptor(
        std::string & name, const IntegerType * type, bool isSigned);

    /// Create a type descriptor for an floating-point type.
    GlobalVariable * CreateFloatTypeDescriptor(std::string & name, 
unsigned bitWidth);

    GlobalVariable * CreatePointerTypeDescriptor(
        GlobalVariable * compileUnit,       /// Compile unit in which 
type is defined
        GlobalVariable * context,           /// Context in which type is 
defined
        std::string & name,                 /// Name of the type
        GlobalVariable * referenceType,     /// Descriptor for what is 
pointed to
        const PointerType * type,           /// LLVM type of the pointer
        unsigned line);                     /// Line number of 
definition (0 if none)

    /// (etc... more to be added)
};





More information about the llvm-dev mailing list