Ejemplo n.º 1
0
 public DebugStructType(IStructType llvmType
                        , BitcodeModule module
                        , DIScope scope
                        , string name
                        , DIFile file
                        , uint line
                        , DebugInfoFlags debugFlags
                        , DIType derivedFrom
                        , IEnumerable <DIType> elements
                        , uint bitAlignment = 0
                        )
     : base(llvmType)
 {
     module.ValidateNotNull(nameof(module));
     DIType = module.DIBuilder
              .CreateStructType(scope
                                , name
                                , file
                                , line
                                , module.Layout.BitSizeOf(llvmType)
                                , bitAlignment
                                , debugFlags
                                , derivedFrom
                                , elements
                                );
 }
Ejemplo n.º 2
0
        /// <summary>Set the body of a type</summary>
        /// <param name="packed">Flag to indicate if the body elements are packed (e.g. no padding)</param>
        /// <param name="module">Module to contain the debug metadata for the type</param>
        /// <param name="scope">Scope containing this type</param>
        /// <param name="file">File containing the type</param>
        /// <param name="line">Line in <paramref name="file"/> for this type</param>
        /// <param name="debugFlags">Debug flags for this type</param>
        /// <param name="nativeElements">LLVM type of each element</param>
        /// <param name="debugElements">Descriptors for each element in the type</param>
        /// <param name="derivedFrom">Base type, if any for this type</param>
        /// <param name="bitSize">Total bit sice for this type or <see langword="null"/> to use default for target</param>
        /// <param name="bitAlignment">Alignment of the type in bits, 0 indicates default for taret</param>
        public void SetBody(bool packed
                            , BitcodeModule module
                            , DIScope scope
                            , DIFile file
                            , uint line
                            , DebugInfoFlags debugFlags
                            , IEnumerable <ITypeRef> nativeElements
                            , IEnumerable <DebugMemberInfo> debugElements
                            , DIType derivedFrom = null
                            , uint?bitSize       = null
                            , uint bitAlignment  = 0
                            )
        {
            DebugMembers = new ReadOnlyCollection <DebugMemberInfo>(debugElements as IList <DebugMemberInfo> ?? debugElements.ToList( ));
            SetBody(packed, nativeElements.ToArray());
            var memberTypes = from memberInfo in DebugMembers
                              select CreateMemberType(module, memberInfo);

            var concreteType = module.DIBuilder.CreateStructType(scope: scope
                                                                 , name: DIType.Name
                                                                 , file: file
                                                                 , line: line
                                                                 , bitSize: bitSize ?? module.Layout.BitSizeOf(NativeType)
                                                                 , bitAlign: bitAlignment
                                                                 , debugFlags: debugFlags
                                                                 , derivedFrom: derivedFrom
                                                                 , elements: memberTypes
                                                                 );

            DIType = concreteType;
        }
Ejemplo n.º 3
0
 /// <summary>Constructs a new <see cref="DebugPointerType"/></summary>
 /// <param name="llvmElementType">Native type of the pointee</param>
 /// <param name="module"><see cref="NativeModule"/> used for creating the pointer type and debug information</param>
 /// <param name="elementType">Debug type of the pointee</param>
 /// <param name="addressSpace">Target address space for the pointer [Default: 0]</param>
 /// <param name="name">Name of the type [Default: null]</param>
 /// <param name="alignment">Alignment of pointer</param>
 public DebugPointerType(ITypeRef llvmElementType, NativeModule module, DIType elementType, uint addressSpace = 0, string name = null, uint alignment = 0)
     : this(llvmElementType.VerifyArgNotNull(nameof(llvmElementType)).CreatePointerType(addressSpace)
            , module
            , elementType
            , name
            , alignment
            )
 {
 }
Ejemplo n.º 4
0
 public DebugPointerType(IPointerType llvmPtrType, NativeModule module, DIType elementType, string name = null, uint alignment = 0)
     : base(llvmPtrType)
 {
     module.VerifyArgNotNull(nameof(module));
     DIType = module.DIBuilder
              .CreatePointerType(elementType
                                 , name
                                 , module.Layout.BitSizeOf(llvmPtrType)
                                 , alignment
                                 );
 }
Ejemplo n.º 5
0
        /// <summary>Initializes a new instance of the <see cref="DebugStructType"/> class.</summary>
        /// <param name="module">Module to contain the debug meta data</param>
        /// <param name="nativeName">Name of the type in LLVM IR</param>
        /// <param name="scope">Debug scope for the structure</param>
        /// <param name="name">Source/debug name of the struct</param>
        /// <param name="file">File containing the definition of this type</param>
        /// <param name="line">line number this type is defined at</param>
        /// <param name="debugFlags">debug flags for this type</param>
        /// <param name="debugElements">Description of all the members of this structure</param>
        /// <param name="derivedFrom">Base type, if any for this type</param>
        /// <param name="packed">Indicates if this type is packed or not</param>
        /// <param name="bitSize">Total bit size for this type or <see langword="null"/> to use default for target</param>
        /// <param name="bitAlignment">Alignment of the type in bits, 0 indicates default for target</param>
        public DebugStructType(BitcodeModule module
                               , string nativeName
                               , DIScope scope
                               , string name
                               , DIFile file
                               , uint line
                               , DebugInfoFlags debugFlags
                               , IEnumerable <DebugMemberInfo> debugElements
                               , DIType derivedFrom = null
                               , bool packed        = false
                               , uint?bitSize       = null
                               , uint bitAlignment  = 0
                               )
        {
            module.ValidateNotNull(nameof(module));
            DebugMembers = new ReadOnlyCollection <DebugMemberInfo>(debugElements as IList <DebugMemberInfo> ?? debugElements.ToList( ));

            NativeType = module.Context.CreateStructType(nativeName, packed, debugElements.Select(e => e.DebugType).ToArray( ));

            // create a temp opaque type to act as scope for members
            // this is RAUW with the full struct once it is defined
            DIType = module.DIBuilder.CreateReplaceableCompositeType(Tag.StructureType
                                                                     , name
                                                                     , scope
                                                                     , file
                                                                     , line
                                                                     );

            var memberTypes = from memberInfo in DebugMembers
                              select CreateMemberType(module, memberInfo);

            var concreteType = module.DIBuilder.CreateStructType(scope: scope
                                                                 , name: name
                                                                 , file: file
                                                                 , line: line
                                                                 , bitSize: bitSize ?? module.Layout.BitSizeOf(NativeType)
                                                                 , bitAlign: bitAlignment
                                                                 , debugFlags: debugFlags
                                                                 , derivedFrom: derivedFrom
                                                                 , elements: memberTypes
                                                                 );

            // assignment performs RAUW
            DIType = concreteType;
        }
Ejemplo n.º 6
0
 /// <summary>Initializes a new instance of the <see cref="DebugArrayType"/> class.</summary>
 /// <param name="llvmType">Native LLVM type for the elements</param>
 /// <param name="module"><see cref="BitcodeModule"/> to use for the context of the debug information</param>
 /// <param name="elementType">Debug type of the array elements</param>
 /// <param name="count">Number of elements in the array</param>
 /// <param name="lowerBound"><see cref="LowerBound"/> value for the array indices [Default: 0]</param>
 public DebugArrayType(IArrayType llvmType, BitcodeModule module, DIType elementType, uint count, uint lowerBound = 0)
     : this(DebugType.Create(llvmType.ValidateNotNull(nameof(llvmType)).ElementType, elementType), module, count, lowerBound)
 {
 }
Ejemplo n.º 7
0
 /// <summary>Constructs a new <see cref="DebugArrayType"/></summary>
 /// <param name="llvmType">Native LLVM type for the elements</param>
 /// <param name="module"><see cref="NativeModule"/> to use for the context of the debug information</param>
 /// <param name="elementType">Debug type of the array elements</param>
 /// <param name="count">Number of elements in the array</param>
 /// <param name="lowerBound"><see cref="LowerBound"/> value for the array indices [Default: 0]</param>
 public DebugArrayType(IArrayType llvmType, NativeModule module, DIType elementType, uint count, uint lowerBound = 0)
     : this(DebugType.Create(llvmType.VerifyArgNotNull(nameof(llvmType)).ElementType, elementType), module, count, lowerBound)
 {
 }