From 708bfdbd5f0cd98fe4c11d6fcf7e6651ff126a8f Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Sun, 16 Apr 2017 15:05:47 +0200 Subject: [PATCH] Generate line numbers for function call parameters Before this fix line numbers for function call arguments were not generated, so if argument was on another line than function call it was impossible to stop on argument line during debugging. Now line number for each argument is generated if necessary (another line than function call line). #KT-17144 Fixed --- .../codegen/CallBasedArgumentGenerator.java | 15 ----------- .../codegen/box/smap/simpleCallWithParams.kt | 26 +++++++++---------- .../custom/callWithCallInArguments.kt | 2 +- .../custom/multilineFunctionCall.kt | 2 +- .../lineNumber/custom/multilineInfixCall.kt | 2 +- .../lineNumber/custom/smapInlineAsArgument.kt | 2 +- .../custom/smapInlineAsInfixArgument.kt | 2 +- .../custom/smapInlineAsInlineArgument.kt | 2 +- .../debugger/tinyApp/outs/kt17144.out | 8 ++++++ .../tinyApp/src/stepping/custom/kt17144.kt | 18 +++++++++++++ .../debugger/KotlinSteppingTestGenerated.java | 6 +++++ 11 files changed, 51 insertions(+), 34 deletions(-) create mode 100644 idea/testData/debugger/tinyApp/outs/kt17144.out create mode 100644 idea/testData/debugger/tinyApp/src/stepping/custom/kt17144.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/CallBasedArgumentGenerator.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/CallBasedArgumentGenerator.java index c79cd34ee86..49ef24c6795 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/CallBasedArgumentGenerator.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/CallBasedArgumentGenerator.java @@ -51,21 +51,6 @@ public class CallBasedArgumentGenerator extends ArgumentGenerator { "Value parameters and their types mismatch in sizes: " + valueParameters.size() + " != " + valueParameterTypes.size(); } - - @NotNull - @Override - public DefaultCallArgs generate( - @NotNull List valueArgumentsByIndex, - @NotNull List valueArgs, - @Nullable CallableDescriptor calleeDescriptor - ) { - boolean shouldMarkLineNumbers = this.codegen.isShouldMarkLineNumbers(); - this.codegen.setShouldMarkLineNumbers(false); - DefaultCallArgs defaultArgs = super.generate(valueArgumentsByIndex, valueArgs, calleeDescriptor); - this.codegen.setShouldMarkLineNumbers(shouldMarkLineNumbers); - return defaultArgs; - } - @Override protected void generateExpression(int i, @NotNull ExpressionValueArgument argument) { ValueParameterDescriptor parameter = valueParameters.get(i); diff --git a/compiler/testData/codegen/box/smap/simpleCallWithParams.kt b/compiler/testData/codegen/box/smap/simpleCallWithParams.kt index 8c0830bc26e..473fa927e1b 100644 --- a/compiler/testData/codegen/box/smap/simpleCallWithParams.kt +++ b/compiler/testData/codegen/box/smap/simpleCallWithParams.kt @@ -5,8 +5,8 @@ package test fun testProperLineNumberAfterInline(): String { var exceptionCount = 0; try { - checkEquals(test(), - "12") + fail(inlineFun(), + "12") } catch(e: AssertionError) { val entry = (e as java.lang.Throwable).getStackTrace()!!.get(1) @@ -18,8 +18,8 @@ fun testProperLineNumberAfterInline(): String { } try { - checkEquals("12", - test()) + fail("12", + inlineFun()) } catch(e: AssertionError) { val entry = e.stackTrace!![1] @@ -36,13 +36,13 @@ fun testProperLineNumberAfterInline(): String { fun testProperLineForOtherParameters(): String { var exceptionCount = 0; try { - checkEquals(test(), - fail()) + fail(inlineFun(), + fail()) } catch(e: AssertionError) { val entry = e.stackTrace!![1] val actual = "${entry.getFileName()}:${entry.getLineNumber()}" - if ("simpleCallWithParams.kt:39" != actual) { + if ("simpleCallWithParams.kt:40" != actual) { return "fail 3: ${actual}" } exceptionCount++ @@ -50,8 +50,8 @@ fun testProperLineForOtherParameters(): String { } try { - checkEquals(fail(), - test()) + fail(fail(), + inlineFun()) } catch(e: AssertionError) { val entry = e.stackTrace!![1] @@ -63,7 +63,7 @@ fun testProperLineForOtherParameters(): String { } try { - checkEquals(fail(), test()) + fail(fail(), inlineFun()) } catch(e: AssertionError) { val entry = e.stackTrace!![1] @@ -75,7 +75,7 @@ fun testProperLineForOtherParameters(): String { } try { - checkEquals(fail(), test()) + fail(fail(), inlineFun()) } catch(e: AssertionError) { val entry = e.stackTrace!![1] @@ -97,11 +97,11 @@ fun box(): String { return testProperLineForOtherParameters() } -public fun checkEquals(p1: String, p2: String) { +public fun fail(p1: String, p2: String) { throw AssertionError("fail") } -inline fun test(): String { +inline fun inlineFun(): String { return "123" } diff --git a/compiler/testData/lineNumber/custom/callWithCallInArguments.kt b/compiler/testData/lineNumber/custom/callWithCallInArguments.kt index 9dc9de0af97..49258150d32 100644 --- a/compiler/testData/lineNumber/custom/callWithCallInArguments.kt +++ b/compiler/testData/lineNumber/custom/callWithCallInArguments.kt @@ -14,4 +14,4 @@ fun foo() { } -// 2 1 5 8 9 15 +// 2 1 5 8 9 +10 +11 10 9 15 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/multilineFunctionCall.kt b/compiler/testData/lineNumber/custom/multilineFunctionCall.kt index 27d9e201d60..b3e9bd9eb1e 100644 --- a/compiler/testData/lineNumber/custom/multilineFunctionCall.kt +++ b/compiler/testData/lineNumber/custom/multilineFunctionCall.kt @@ -7,4 +7,4 @@ fun foo() { fun foo(i: Int) { } -// 2 5 8 +// 2 +3 2 5 8 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/multilineInfixCall.kt b/compiler/testData/lineNumber/custom/multilineInfixCall.kt index 8669cb4fde5..b4a8f145ecd 100644 --- a/compiler/testData/lineNumber/custom/multilineInfixCall.kt +++ b/compiler/testData/lineNumber/custom/multilineInfixCall.kt @@ -6,4 +6,4 @@ fun foo() { infix fun Int.foo(i: Int) { } -// 2 4 7 +// 2 3 2 4 7 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/smapInlineAsArgument.kt b/compiler/testData/lineNumber/custom/smapInlineAsArgument.kt index 28b99f79ca5..caadb200911 100644 --- a/compiler/testData/lineNumber/custom/smapInlineAsArgument.kt +++ b/compiler/testData/lineNumber/custom/smapInlineAsArgument.kt @@ -18,4 +18,4 @@ fun fail() : String { throw AssertionError("fail") } -// 2 22 2 5 23 5 7 10 14 18 \ No newline at end of file +// 2 22 3 2 5 6 23 5 7 10 14 18 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/smapInlineAsInfixArgument.kt b/compiler/testData/lineNumber/custom/smapInlineAsInfixArgument.kt index c6b5e1f03f5..3a07f084958 100644 --- a/compiler/testData/lineNumber/custom/smapInlineAsInfixArgument.kt +++ b/compiler/testData/lineNumber/custom/smapInlineAsInfixArgument.kt @@ -16,4 +16,4 @@ fun fail() : String { throw AssertionError("fail") } -// 1 4 20 4 7 21 7 9 12 16 \ No newline at end of file +// 1 4 20 5 4 7 8 21 7 9 12 16 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/smapInlineAsInlineArgument.kt b/compiler/testData/lineNumber/custom/smapInlineAsInlineArgument.kt index 7ec73dc0b4f..b0ecaf77bb8 100644 --- a/compiler/testData/lineNumber/custom/smapInlineAsInlineArgument.kt +++ b/compiler/testData/lineNumber/custom/smapInlineAsInlineArgument.kt @@ -18,4 +18,4 @@ fun fail() : String { throw AssertionError("fail") } -// 2 22 2 23 5 24 5 25 7 10 14 18 \ No newline at end of file +// 2 22 3 2 23 5 6 24 5 25 7 10 14 18 \ No newline at end of file diff --git a/idea/testData/debugger/tinyApp/outs/kt17144.out b/idea/testData/debugger/tinyApp/outs/kt17144.out new file mode 100644 index 00000000000..24ecfa9ca9c --- /dev/null +++ b/idea/testData/debugger/tinyApp/outs/kt17144.out @@ -0,0 +1,8 @@ +LineBreakpoint created at kt17144.kt:9 +Run Java +Connected to the target VM +kt17144.kt:9 +Disconnected from the target VM + +Process finished with exit code 0 +foo diff --git a/idea/testData/debugger/tinyApp/src/stepping/custom/kt17144.kt b/idea/testData/debugger/tinyApp/src/stepping/custom/kt17144.kt new file mode 100644 index 00000000000..22b297afb18 --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/stepping/custom/kt17144.kt @@ -0,0 +1,18 @@ +package kt17144 + +fun main(args: Array) { + val a = true + 1 + when (a) { + true -> { + println("foo") + //Breakpoint! + 1 + } + else -> { + println("bar") + 2 + } + } +} + +//RESUME: 1 \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java index 5df51f26893..dba69fa7975 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java @@ -1088,6 +1088,12 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest { doCustomTest(fileName); } + @TestMetadata("kt17144.kt") + public void testKt17144() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/custom/kt17144.kt"); + doCustomTest(fileName); + } + @TestMetadata("kt17295.kt") public void testKt17295() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/custom/kt17295.kt");