[codegen][debug] fix of KT-20207 (problem with accessing structs)
- removed artifacts of dwarf type generation, instead debugger will use runtime debugger functions - fixed variable offset calculation
This commit is contained in:
committed by
Vasily Levchenko
parent
b367a0d255
commit
82b2b76c09
+3
-4
@@ -504,14 +504,13 @@ internal class FunctionGenerationContext(val function: LLVMValueRef,
|
|||||||
call(context.llvm.enterFrameFunction, listOf(slots, Int32(slotCount).llvm))
|
call(context.llvm.enterFrameFunction, listOf(slots, Int32(slotCount).llvm))
|
||||||
}
|
}
|
||||||
addPhiIncoming(slotsPhi!!, prologueBb to slots)
|
addPhiIncoming(slotsPhi!!, prologueBb to slots)
|
||||||
val slotOffset = pointerSize * slotCount
|
|
||||||
memScoped {
|
memScoped {
|
||||||
slotToVariableLocation.forEach { slot, variable ->
|
slotToVariableLocation.forEach { slot, variable ->
|
||||||
val expr = longArrayOf(DwarfOp.DW_OP_minus.value,
|
val expr = longArrayOf(DwarfOp.DW_OP_plus.value,
|
||||||
slotOffset + runtime.pointerSize * slot.toLong()).toCValues()
|
runtime.pointerSize * slot.toLong()).toCValues()
|
||||||
DIInsertDeclaration(
|
DIInsertDeclaration(
|
||||||
builder = codegen.context.debugInfo.builder,
|
builder = codegen.context.debugInfo.builder,
|
||||||
value = slotsPhi,
|
value = slots,
|
||||||
localVariable = variable.localVariable,
|
localVariable = variable.localVariable,
|
||||||
location = variable.location,
|
location = variable.location,
|
||||||
bb = prologueBb,
|
bb = prologueBb,
|
||||||
|
|||||||
+1
-10
@@ -225,20 +225,11 @@ internal fun alignTo(value:Long, align:Long):Long = (value + align - 1) / align
|
|||||||
internal fun FunctionDescriptor.subroutineType(context: Context, llvmTargetData: LLVMTargetDataRef): DISubroutineTypeRef {
|
internal fun FunctionDescriptor.subroutineType(context: Context, llvmTargetData: LLVMTargetDataRef): DISubroutineTypeRef {
|
||||||
return memScoped {
|
return memScoped {
|
||||||
DICreateSubroutineType(context.debugInfo.builder, allocArrayOf(
|
DICreateSubroutineType(context.debugInfo.builder, allocArrayOf(
|
||||||
this@subroutineType.types.map { it.referenceOrValue(context, llvmTargetData) }),
|
this@subroutineType.types.map { it.diType(context, llvmTargetData) }),
|
||||||
this@subroutineType.types.size)!!
|
this@subroutineType.types.size)!!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
|
||||||
private fun KotlinType.referenceOrValue(context: Context, llvmTargetData: LLVMTargetDataRef):DITypeOpaqueRef {
|
|
||||||
val refType = this.dwarfType(context, llvmTargetData)
|
|
||||||
return if (KotlinBuiltIns.isPrimitiveType(this))
|
|
||||||
refType
|
|
||||||
else
|
|
||||||
dwarfPointerType(context, refType)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
private fun dwarfPointerType(context: Context, type: DITypeOpaqueRef) =
|
private fun dwarfPointerType(context: Context, type: DITypeOpaqueRef) =
|
||||||
DICreatePointerType(context.debugInfo.builder, type) as DITypeOpaqueRef
|
DICreatePointerType(context.debugInfo.builder, type) as DITypeOpaqueRef
|
||||||
|
|||||||
+2
-29
@@ -639,10 +639,8 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
using(ClassScope(declaration)) {
|
using(ClassScope(declaration)) {
|
||||||
debugClassDeclaration(declaration) {
|
declaration.declarations.forEach {
|
||||||
declaration.declarations.forEach {
|
it.acceptVoid(this)
|
||||||
it.acceptVoid(this)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1690,31 +1688,6 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
|||||||
//-------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------//
|
||||||
private fun IrElement.endColumn() = file().fileEntry.column(this.endOffset)
|
private fun IrElement.endColumn() = file().fileEntry.column(this.endOffset)
|
||||||
|
|
||||||
//-------------------------------------------------------------------------//
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
|
||||||
private fun debugClassDeclaration(declaration: IrClass, body: () -> Unit): Unit {
|
|
||||||
val doDebugInfo = context.shouldContainDebugInfo() && declaration.descriptor.isExported()
|
|
||||||
val classScope = currentCodeContext.classScope() as ClassScope
|
|
||||||
if (doDebugInfo) context.debugInfo.types[declaration.descriptor.defaultType] = classScope.scope!!
|
|
||||||
body()
|
|
||||||
memScoped {
|
|
||||||
if (doDebugInfo) context.debugInfo.types[declaration.descriptor.defaultType] = DICreateStructType(
|
|
||||||
refBuilder = context.debugInfo.builder,
|
|
||||||
scope = context.debugInfo.compilationModule as DIScopeOpaqueRef,
|
|
||||||
name = declaration.descriptor.typeInfoSymbolName,
|
|
||||||
file = file().file(),
|
|
||||||
lineNumber = declaration.startLine(),
|
|
||||||
sizeInBits = 64 /* TODO */,
|
|
||||||
alignInBits = 4 /* TODO */,
|
|
||||||
derivedFrom = null,
|
|
||||||
elements = classScope.members.toCValues(),
|
|
||||||
elementsCount = classScope.members.size.toLong(),
|
|
||||||
refPlace = context.debugInfo.types[declaration.descriptor.defaultType] as DICompositeTypeRef,
|
|
||||||
flags = 0
|
|
||||||
) as DITypeOpaqueRef
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------//
|
||||||
private fun debugFieldDeclaration(expression: IrField) {
|
private fun debugFieldDeclaration(expression: IrField) {
|
||||||
val scope = currentCodeContext.classScope() as? ClassScope ?: return
|
val scope = currentCodeContext.classScope() as? ClassScope ?: return
|
||||||
|
|||||||
Reference in New Issue
Block a user