DIBuilder
public final class DIBuilder
A DIBuilder is a helper object used to generate debugging information in
the form of LLVM metadata. A DIBuilder is usually paired with an
IRBuilder to allow for the generation of code and metadata in lock step.
-
The module this
DIBuilderis associated with.Declaration
Swift
public let module: Module -
Initializes a new
DIBuilderobject.Declaration
Swift
public init(module: Module, allowUnresolved: Bool = true)Parameters
moduleThe parent module.
allowUnresolvedIf true, when this DIBuilder is finalized it will collect unresolved nodes attached to the module in order to resolve cycles
-
Construct any deferred debug info descriptors.
Declaration
Swift
public func finalize()
-
Builds a call to a debug intrinsic for declaring a local variable and inserts it before a given instruction.
This intrinsic provides information about a local element (e.g. a variable) defined in some lexical scope. The variable does not have to be physically represented in the source.
Each variable may have at most one corresponding
llvm.dbg.declare. A variable declaration is not control-dependent: A variable is declared at most once, and that declaration remains in effect until the lifetime of that variable ends.lldb.dbg.declarecan make optimizing code that needs accurate debug info difficult because of these scoping constraints.Declaration
Swift
public func buildDeclare( of variable: IRValue, before: IRInstruction, metadata: LocalVariableMetadata, expr: ExpressionMetadata, location: DebugLocation )Parameters
variableThe IRValue of a variable to declare.
beforeThe instruction before which the intrinsic will be inserted.
metadataLocal variable metadata.
exprA “complex expression” that modifies the current variable declaration.
locationThe location of the variable in source.
-
Builds a call to a debug intrinsic for declaring a local variable and inserts it at the end of a given basic block.
This intrinsic provides information about a local element (e.g. a variable) defined in some lexical scope. The variable does not have to be physically represented in the source.
Each variable may have at most one corresponding
llvm.dbg.declare. A variable declaration is not control-dependent: A variable is declared at most once, and that declaration remains in effect until the lifetime of that variable ends.lldb.dbg.declarecan make optimizing code that needs accurate debug info difficult because of these scoping constraints.Declaration
Swift
public func buildDeclare( of variable: IRValue, atEndOf block: BasicBlock, metadata: LocalVariableMetadata, expr: ExpressionMetadata, location: DebugLocation )Parameters
variableThe IRValue of a variable to declare.
blockThe block in which the intrinsic will be placed.
metadataLocal variable metadata.
exprA “complex expression” that modifies the current variable declaration.
locationThe location of the variable in source.
-
Builds a call to a debug intrinsic for providing information about the value of a local variable and inserts it before a given instruction.
This intrinsic provides information to model the result of a source variable being set to a new value.
This intrinsic is built to describe the value of a source variable directly. That is, the source variable may be a value or an address, but the value for that variable provided to this intrinsic is considered without interpretation to be the value of the given variable.
Declaration
Swift
public func buildDbgValue( of value: IRValue, to metadata: LocalVariableMetadata, before: IRInstruction, expr: ExpressionMetadata, location: DebugLocation )Parameters
valueThe value to set the given variable to.
metadataMetadata for the given local variable.
beforeThe instruction before which the intrinsic will be inserted.
exprA “complex expression” that modifies the given value.
locationThe location of the variable assignment in source.
-
Builds a call to a debug intrinsic for providing information about the value of a local variable and inserts it before a given instruction.
This intrinsic provides information to model the result of a source variable being set to a new value.
This intrinsic is built to describe the value of a source variable directly. That is, the source variable may be a value or an address, but the value for that variable provided to this intrinsic is considered without interpretation to be the value of the given variable.
Declaration
Swift
public func buildDbgValue( of value: IRValue, to metadata: LocalVariableMetadata, atEndOf block: BasicBlock, expr: ExpressionMetadata, location: DebugLocation )Parameters
valueThe value to set the given variable to.
metadataMetadata for the given local variable.
blockThe block in which the intrinsic will be placed.
exprA “complex expression” that modifies the given value.
locationThe location of the variable assignment in source.
-
buildCompileUnit(for:in: kind: optimized: splitDebugInlining: debugInfoForProfiling: flags: runtimeVersion: splitDWARFPath: identity: sysRoot: sdkRoot: ) A CompileUnit provides an anchor for all debugging information generated during this instance of compilation.
Declaration
Swift
public func buildCompileUnit( for language: DWARFSourceLanguage, in file: FileMetadata, kind: DWARFEmissionKind, optimized: Bool = false, splitDebugInlining: Bool = false, debugInfoForProfiling: Bool = false, flags: [String] = [], runtimeVersion: Int = 0, splitDWARFPath: String = "", identity: String = "", sysRoot: String = "", sdkRoot: String = "" ) -> CompileUnitMetadataParameters
languageThe source programming language.
fileThe file descriptor for the source file.
kindThe kind of debug info to generate.
optimizedA flag that indicates whether optimization is enabled or not when compiling the source file. Defaults to
false.splitDebugInliningIf true, minimal debug info in the module is emitted to facilitate online symbolication and stack traces in the absence of .dwo/.dwp files when using Split DWARF.
debugInfoForProfilingA flag that indicates whether to emit extra debug information for profile collection.
flagsCommand line options that are embedded in debug info for use by third-party tools.
splitDWARFPathThe path to the split DWARF file.
identityThe identity of the tool that is compiling this source file.
sysRootThe Clang system root (the value of the
-isysrootthat’s passed to clang).sdkRootThe SDK root – on Darwin platforms, this is the last component of the sysroot.
Return Value
A value representing a compilation-unit level scope.
-
Create a file descriptor to hold debugging information for a file.
Global variables and top level functions would be defined using this context. File descriptors also provide context for source line correspondence.
Declaration
Swift
public func buildFile( named name: String, in directory: String ) -> FileMetadataParameters
nameThe name of the file.
directoryThe directory the file resides in.
Return Value
A value represending metadata about a given file.
-
Creates a new descriptor for a module with the specified parent scope.
Declaration
Swift
public func buildModule( named name: String, scope: DIScope, macros: [String] = [], includePath: String = "", includeSystemRoot: String = "" ) -> ModuleMetadataParameters
nameModule name.
scopeThe parent scope containing this module declaration.
macrosA list of -D macro definitions as they would appear on a command line.
includePathThe path to the module map file.
includeSystemRootThe Clang system root (value of -isysroot).
-
Creates a new descriptor for a namespace with the specified parent scope.
Declaration
Swift
public func buildNameSpace( named name: String, scope: DIScope, exportsSymbols: Bool ) -> NameSpaceMetadataParameters
nameNameSpace name.
scopeThe parent scope containing this module declaration.
exportsSymbolsWhether or not the namespace exports symbols, e.g. this is true of C++ inline namespaces.
-
buildFunction(named:linkageName: scope: file: line: scopeLine: type: flags: isLocal: isDefinition: isOptimized: ) Create a new descriptor for the specified subprogram.
Declaration
Swift
public func buildFunction( named name: String, linkageName: String, scope: DIScope, file: FileMetadata, line: Int, scopeLine: Int, type: DISubroutineType, flags: DIFlags, isLocal: Bool = true, isDefinition: Bool = true, isOptimized: Bool = false ) -> FunctionMetadataParameters
nameFunction name.
linkageNameMangled function name.
scopeFunction scope.
fileFile where this variable is defined.
lineLine number.
scopeLineSet to the beginning of the scope this starts
typeFunction type.
flagsFlags to emit DWARF attributes.
isLocalTrue if this function is not externally visible.
isDefinitionTrue if this is a function definition.
isOptimizedTrue if optimization is enabled.
-
Create a descriptor for a lexical block with the specified parent context.
Declaration
Swift
public func buildLexicalBlock( scope: DIScope, file: FileMetadata, line: Int, column: Int ) -> LexicalBlockMetadataParameters
scopeParent lexical block.
FileSource file.
lineThe line in the source file.
columnThe column in the source file.
-
Create a descriptor for a lexical block with a new file attached.
Declaration
Swift
public func buildLexicalBlockFile( scope: DIScope, file: FileMetadata, discriminator: Int ) -> LexicalBlockFileMetadataParameters
scopeLexical block.
fileSource file.
discriminatorDWARF path discriminator value.
-
Create a new descriptor for a local auto variable.
Declaration
Swift
public func buildLocalVariable( named name: String, scope: DIScope, file: FileMetadata, line: Int, type: DIType, alwaysPreserve: Bool = false, flags: DIFlags = [], alignment: Alignment ) -> LocalVariableMetadataParameters
nameVariable name.
scopeThe local scope the variable is declared in.
fileFile where this variable is defined.
lineLine number.
typeMetadata describing the type of the variable.
alwaysPreserveIf true, this descriptor will survive optimizations.
flagsFlags.
alignmentVariable alignment.
-
Create a new descriptor for a function parameter variable.
Declaration
Swift
public func buildParameterVariable( named name: String, index: Int, scope: DIScope, file: FileMetadata, line: Int, type: DIType, alwaysPreserve: Bool = false, flags: DIFlags = [] ) -> LocalVariableMetadataParameters
nameVariable name.
indexUnique argument number for this variable; starts at 1.
scopeThe local scope the variable is declared in.
fileFile where this variable is defined.
lineLine number.
typeMetadata describing the type of the variable.
alwaysPreserveIf true, this descriptor will survive optimizations.
flagsFlags.
-
Creates a new debug location that describes a source location.
Declaration
Swift
public func buildDebugLocation( at location : (line: Int, column: Int), in scope: DIScope, inlinedAt: DIScope? = nil ) -> DebugLocationParameters
locationThe location of the line and column for this information. If the location of the value is unknown, pass
(line: 0, column: 0).scopeThe scope this debug location resides in.
inlinedAtIf this location has been inlined somewhere, the scope in which it was inlined. Defaults to
nil.Return Value
A value representing a debug location.
-
Create subroutine type.
Declaration
Swift
public func buildSubroutineType( in file: FileMetadata, parameterTypes: [DIType], returnType: DIType? = nil, flags: DIFlags = [] ) -> DISubroutineTypeParameters
fileThe file in which the subroutine resides.
parameterTypesAn array of subroutine parameter types.
returnTypeThe return type of the function, if any.
flagsFlags to emit DWARF attributes.
-
Create a debugging information entry for an enumeration.
Declaration
Parameters
nameEnumeration name.
scopeScope in which this enumeration is defined.
fileFile where this member is defined.
lineLine number.
sizeMember size.
alignmentMember alignment.
elementsEnumeration elements.
numElementsNumber of enumeration elements.
underlyingTypeUnderlying type of a C++11/ObjC fixed enum.
-
Create a debugging information entry for a union.
Declaration
Parameters
nameUnion name.
scopeScope in which this union is defined.
fileFile where this member is defined.
lineLine number.
sizeMember size.
alignmentMember alignment.
flagsFlags to encode member attribute, e.g. private
elementsUnion elements.
runtimeVersionOptional parameter, Objective-C runtime version.
uniqueIDA unique identifier for the union.
-
Create a debugging information entry for an array.
Declaration
Parameters
elementTypeMetadata describing the type of the elements.
sizeThe total size of the array.
alignmentThe alignment of the array.
subscriptsA list of ranges of valid subscripts into the array. For unbounded arrays, pass the unchecked range
-1...0. -
Create a debugging information entry for a vector.
Declaration
Parameters
elementTypeMetadata describing the type of the elements.
sizeThe total size of the array.
alignmentThe alignment of the array.
subscriptsA list of ranges of valid subscripts into the array. For unbounded arrays, pass the unchecked range
-1...0. -
Create a debugging information entry for a DWARF unspecified type.
Some languages have constructs in which a type may be left unspecified or the absence of a type may be explicitly indicated. For example, C++ permits using the
autoreturn type specifier for the return type of a member function declaration. The actual return type is deduced based on the definition of the function, so it may not be known when the function is declared. The language implementation can provide an unspecified type entry with the nameautowhich can be referenced by the return type attribute of a function declaration entry. When the function is later defined, thesubprogramentry for the definition includes a reference to the actual return type.Declaration
Swift
public func buildUnspecifiedType(named name: String) -> DITypeParameters
nameThe name of the type
-
Create a debugging information entry for a basic type.
Declaration
Swift
public func buildBasicType( named name: String, encoding: DIAttributeTypeEncoding, flags: DIFlags, size: Size ) -> DITypeParameters
nameType name.
encodingThe basic type encoding
sizeSize of the type.
-
Create a debugging information entry for a pointer.
Declaration
Swift
public func buildPointerType( pointee: DIType, size: Size, alignment: Alignment, addressSpace: AddressSpace = .zero, name: String = "" ) -> DITypeParameters
pointeeType pointed by this pointer.
sizeThe size of the pointer value.
alignmentThe alignment of the pointer.
addressSpaceThe address space the pointer type reside in.
nameThe name of the pointer type.
-
buildStructType(named:scope: file: line: size: alignment: flags: baseType: elements: vtableHolder: runtimeVersion: uniqueID: ) Create a debugging information entry for a struct.
Declaration
Parameters
nameStruct name.
scopeScope in which this struct is defined.
fileFile where this member is defined.
lineLine number.
sizeThe total size of the struct and its members.
alignmentThe alignment of the struct.
flagsFlags to encode member attributes.
elementsStruct elements.
vtableHolderThe object containing the vtable for the struct.
runtimeVersionOptional parameter, Objective-C runtime version.
uniqueIdA unique identifier for the struct.
-
Create a debugging information entry for a member.
Declaration
Parameters
parentTypeParent type.
scopeMember scope.
nameMember name.
fileFile where this member is defined.
lineLine number.
sizeMember size.
alignmentMember alignment.
offsetMember offset.
flagsFlags to encode member attributes.
-
Create a debugging information entry for a C++ static data member.
Declaration
Swift
public func buildStaticMemberType( of parentType: DIType, scope: DIScope, name: String, file: FileMetadata, line: Int, alignment: Alignment, flags: DIFlags = [], initialValue: IRConstant? = nil ) -> DITypeParameters
parentTypeType of the static member.
scopeMember scope.
nameMember name.
fileFile where this member is declared.
lineLine number.
alignmentMember alignment.
flagsFlags to encode member attributes.
initialValueConstant initializer of the member.
-
Create a debugging information entry for a pointer to member.
Declaration
Parameters
pointeeType pointed to by this pointer.
baseTypeType for which this pointer points to members of.
sizeSize.
alignmentAlignment.
flagsFlags.
-
Create C++11 nullptr type.
Declaration
Swift
public func buildNullPtrType() -> DIType -
Create a debugging information entry for a typedef.
Declaration
Swift
public func buildTypedef( of type: DIType, name: String, alignment: Alignment, scope: DIScope, file: FileMetadata, line: Int ) -> DITypeParameters
typeOriginal type.
nameTypedef name.
alignmentAlignment of the type.
scopeThe surrounding context for the typedef.
fileFile where this type is defined.
lineLine number.
-
Create a debugging information entry to establish inheritance relationship between two types.
Declaration
Parameters
derivedOriginal type.
baseBase type. Ty is inherits from base.
baseOffsetBase offset.
virtualBasePointerOffsetVirtual base pointer offset.
flagsFlags to describe inheritance attribute, e.g. private
-
Create a permanent forward-declared type.
Declaration
Parameters
nameType name.
tagA unique tag for this type.
scopeType scope.
fileFile where this type is defined.
lineLine number where this type is defined.
sizeMember size.
alignmentMember alignment.
runtimeLanguageIndicates runtime version for languages like Objective-C.
uniqueIDA unique identifier for the type.
-
buildReplaceableCompositeType(named:tag: scope: file: line: size: alignment: flags: runtimeVersion: uniqueID: ) Create a temporary forward-declared type.
Declaration
Parameters
nameType name.
tagA unique tag for this type.
scopeType scope.
fileFile where this type is defined.
lineLine number where this type is defined. Objective-C.
sizeMember size.
alignmentMember alignment.
flagsFlags.
runtimeVersionIndicates runtime version for languages like
uniqueIDA unique identifier for the type.
-
Create a debugging information entry for a bit field member.
Declaration
Parameters
nameMember name.
typeParent type.
scopeMember scope.
fileFile where this member is defined.
lineLine number.
sizeMember size.
offsetMember offset.
storageOffsetMember storage offset.
flagsFlags to encode member attribute.
-
buildClassType(named:derivedFrom: scope: file: line: size: alignment: offset: flags: elements: vtableHolder: uniqueID: ) Create a debugging information entry for a class.
- name: Class name.
- baseType: Debug info of the base class of this type.
- scope: Scope in which this class is defined.
- file: File where this member is defined.
- line: Line number.
- size: Member size.
- alignment: Member alignment.
- offset: Member offset.
- flags: Flags to encode member attribute, e.g. private.
- elements: Class members.
- vtableHolder: Debug info of the base class that contains vtable
for this type. This is used in
DW_AT_containing_type. - uniqueID: A unique identifier for the type.
-
Create a descriptor for an imported module.
Declaration
Swift
public func buildImportedModule( in context: DIScope, namespace: NameSpaceMetadata, file: FileMetadata, line: Int ) -> ImportedEntityMetadataParameters
contextThe scope this module is imported into
namespaceThe namespace being imported here.
fileFile where the declaration is located.
lineLine number of the declaration.
-
Create a descriptor for an imported module.
Declaration
Swift
public func buildImportedModule( in context: DIScope, aliasee: ImportedEntityMetadata, file: FileMetadata, line: Int ) -> ImportedEntityMetadataParameters
contextThe scope this module is imported into.
aliaseeAn aliased namespace.
fileFile where the declaration is located.
lineLine number of the declaration.
-
Create a descriptor for an imported module.
Declaration
Swift
public func buildImportedModule( in context: DIScope, module: ModuleMetadata, file: FileMetadata, line: Int ) -> ImportedEntityMetadataParameters
contextThe scope this module is imported into.
moduleThe module being imported here
fileFile where the declaration is located.
lineLine number of the declaration.
-
Create a descriptor for an imported function.
Declaration
Swift
public func buildImportedDeclaration( in context: DIScope, declaration: IRMetadata, file: FileMetadata, line: Int, name: String = "" ) -> ImportedEntityMetadataParameters
contextThe scope this module is imported into.
declarationThe declaration (or definition) of a function, type, or variable.
fileFile where the declaration is located.
lineLine number of the declaration.
nameThe name of the imported declaration.
-
Create a debugging information entry for Objective-C instance variable.
Declaration
Swift
public func buildObjCIVar( for property: ObjectiveCPropertyMetadata, name: String, type: DIType, file: FileMetadata, line: Int, size: Size, alignment: Alignment, offset: Size, flags: DIFlags = [] ) -> DITypeParameters
propertyThe property associated with this ivar.
nameMember name.
typeType.
fileFile where this member is defined.
lineLine number.
sizeMember size.
alignmentMember alignment.
offsetMember offset.
flagsFlags to encode member attributes.
-
Create a debugging information entry for Objective-C property.
Declaration
Swift
public func buildObjCProperty( named name: String, type: DIType, file: FileMetadata, line: Int, getter: String, setter: String, propertyAttributes: ObjectiveCPropertyAttribute ) -> ObjectiveCPropertyMetadataParameters
nameProperty name.
typeType.
fileFile where this property is defined.
lineLine number.
getterName of the Objective C property getter selector.
setterName of the Objective C property setter selector.
propertyAttributesObjective C property attributes.
-
Create a new descriptor for the specified variable which has a complex address expression for its address.
Declaration
Swift
public func buildExpression(_ expression: [DWARFExpression]) -> ExpressionMetadataParameters
expressionAn array of complex address operations.
-
Create a new descriptor for the specified variable that does not have an address, but does have a constant value.
Declaration
Swift
public func buildConstantExpresion(_ value: Int) -> ExpressionMetadataParameters
valueThe constant value.
-
buildGlobalExpression(named:linkageName: type: scope: file: line: isLocal: expression: declaration: alignment: ) Create a new descriptor for the specified variable.
Declaration
Swift
public func buildGlobalExpression( named name: String, linkageName: String, type: DIType, scope: DIScope, file: FileMetadata, line: Int, isLocal: Bool = true, expression: ExpressionMetadata? = nil, declaration: IRMetadata? = nil, alignment: Alignment ) -> ExpressionMetadataParameters
nameName of the variable.
linkageNameMangled name of the variable.
typeVariable Type.
scopeVariable scope.
fileFile where this variable is defined.
lineLine number.
isLocalBoolean flag indicate whether this variable is externally visible or not.
expressionThe location of the global relative to the attached GlobalVariable.
declarationReference to the corresponding declaration.
alignmentVariable alignment
DIBuilder Class Reference