Native: generate debug locations for catch parameters

^KT-50558 Fixed
This commit is contained in:
Svyatoslav Scherbina
2022-01-21 12:39:14 +03:00
committed by Space
parent d74418f575
commit a65b278f71
2 changed files with 40 additions and 4 deletions
@@ -1216,7 +1216,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
for (catch in catches) { for (catch in catches) {
fun genCatchBlock() { fun genCatchBlock() {
using(VariableScope()) { using(VariableScope()) {
currentCodeContext.genDeclareVariable(catch.catchParameter, exception, null) currentCodeContext.genDeclareVariable(catch.catchParameter, exception)
functionGenerationContext.generateFrameCheck() functionGenerationContext.generateFrameCheck()
evaluateExpressionAndJump(catch.result, success) evaluateExpressionAndJump(catch.result, success)
} }
@@ -1455,11 +1455,16 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
} }
} ?: evaluateExpression(it) } ?: evaluateExpression(it)
} }
currentCodeContext.genDeclareVariable( this.currentCodeContext.genDeclareVariable(variable, value)
variable, value, debugInfoIfNeeded(
(currentCodeContext.functionScope() as FunctionScope).declaration, variable))
} }
private fun CodeContext.genDeclareVariable(
variable: IrVariable,
value: LLVMValueRef?
) = genDeclareVariable(
variable, value, debugInfoIfNeeded(
(functionScope() as FunctionScope).declaration, variable))
//-------------------------------------------------------------------------// //-------------------------------------------------------------------------//
private fun evaluateTypeOperator(value: IrTypeOperatorCall): LLVMValueRef { private fun evaluateTypeOperator(value: IrTypeOperatorCall): LLVMValueRef {
@@ -126,6 +126,37 @@ class LldbTests {
> q > q
""") """)
@Test
fun `can inspect catch parameter`() = lldbTest("""
fun main() {
try {
throw Exception("message 1")
} catch (e1: Throwable) {
println(e1.message)
}
try {
throwError()
} catch (e2: Throwable) {
println(e2.message)
}
}
fun throwError() {
throw Error("message 2")
}
""", """
> b main.kt:5
> ${lldbCommandRunOrContinue()}
> fr var
(ObjHeader *) e1 = [..]
> b main.kt:11
> c
> fr var
(ObjHeader *) e2 = [..]
> q
""")
@Test @Test
fun `swift with kotlin static framework`() = lldbComplexTest { fun `swift with kotlin static framework`() = lldbComplexTest {
val aKtSrc = """ val aKtSrc = """