From c5d788d0499566acac3a5b74750d9b4b14537e2f Mon Sep 17 00:00:00 2001 From: Natalia Ukhorskaya Date: Tue, 16 Feb 2016 15:30:51 +0300 Subject: [PATCH] Debugger: do not put breakpoints at lines from another file in case of inline function --- .../kotlin/idea/debugger/KotlinPositionManager.kt | 2 +- .../outs/inlineFunctionBreakpointAnotherFile.out | 7 +++++++ .../tinyApp/outs/stepIntoStdlibInlineFun2step.out | 2 +- .../inlineFunctionBreakpointAnotherFile.kt | 13 +++++++++++++ .../src/forTests/inlineFunctionWithBreakpoint.kt | 5 +++++ .../KotlinEvaluateExpressionTestGenerated.java | 6 ++++++ 6 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 idea/testData/debugger/tinyApp/outs/inlineFunctionBreakpointAnotherFile.out create mode 100644 idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/inlineFunctionBreakpointAnotherFile.kt create mode 100644 idea/testData/debugger/tinyApp/src/forTests/inlineFunctionWithBreakpoint.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinPositionManager.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinPositionManager.kt index 4fd18bf8fd9..1530320fca7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinPositionManager.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinPositionManager.kt @@ -299,7 +299,7 @@ class KotlinPositionManager(private val myDebugProcess: DebugProcess) : MultiReq try { val line = position.line + 1 val locations = if (myDebugProcess.virtualMachineProxy.versionHigher("1.4")) - type.locationsOfLine("Kotlin", null, line) + type.locationsOfLine("Kotlin", null, line).filter { it.sourceName("Kotlin") == position.file.name } else type.locationsOfLine(line) if (locations == null || locations.isEmpty()) throw NoDataException.INSTANCE diff --git a/idea/testData/debugger/tinyApp/outs/inlineFunctionBreakpointAnotherFile.out b/idea/testData/debugger/tinyApp/outs/inlineFunctionBreakpointAnotherFile.out new file mode 100644 index 00000000000..f431679b130 --- /dev/null +++ b/idea/testData/debugger/tinyApp/outs/inlineFunctionBreakpointAnotherFile.out @@ -0,0 +1,7 @@ +LineBreakpoint created at inlineFunctionWithBreakpoint.kt:4 +!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !OUTPUT_PATH!;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! inlineFunctionBreakpointAnotherFile.InlineFunctionBreakpointAnotherFileKt +Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' +inlineFunctionWithBreakpoint.kt:4 +Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' + +Process finished with exit code 0 diff --git a/idea/testData/debugger/tinyApp/outs/stepIntoStdlibInlineFun2step.out b/idea/testData/debugger/tinyApp/outs/stepIntoStdlibInlineFun2step.out index 45f3c8027df..c2d0a1400c9 100644 --- a/idea/testData/debugger/tinyApp/outs/stepIntoStdlibInlineFun2step.out +++ b/idea/testData/debugger/tinyApp/outs/stepIntoStdlibInlineFun2step.out @@ -1,9 +1,9 @@ LineBreakpoint created at functionInLibrary.kt:4 !JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !OUTPUT_PATH!;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! stepIntoStdlibInlineFun2step.StepIntoStdlibInlineFun2stepKt Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' -stepIntoStdlibInlineFun2step.kt:4 functionInLibrary.kt:4 functionInLibrary.kt:8 +stepIntoStdlibInlineFun2step.kt:5 Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' Process finished with exit code 0 diff --git a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/inlineFunctionBreakpointAnotherFile.kt b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/inlineFunctionBreakpointAnotherFile.kt new file mode 100644 index 00000000000..b7e14820c2e --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/inlineFunctionBreakpointAnotherFile.kt @@ -0,0 +1,13 @@ +package inlineFunctionBreakpointAnotherFile + +fun main(args: Array) { + val a1 = 1 + val a2 = 1 + val a3 = 1 + + inlineFunctionWithBreakpoint.myFun { + val a = 1 + } +} + +// ADDITIONAL_BREAKPOINT: inlineFunctionWithBreakpoint.kt:inline fun myFun \ No newline at end of file diff --git a/idea/testData/debugger/tinyApp/src/forTests/inlineFunctionWithBreakpoint.kt b/idea/testData/debugger/tinyApp/src/forTests/inlineFunctionWithBreakpoint.kt new file mode 100644 index 00000000000..3610fc8a761 --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/forTests/inlineFunctionWithBreakpoint.kt @@ -0,0 +1,5 @@ +package inlineFunctionWithBreakpoint + +inline fun myFun(f: (Int) -> Unit) { + f(1) +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java index ea863e55783..eee6ee31f9f 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java @@ -169,6 +169,12 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat doSingleBreakpointTest(fileName); } + @TestMetadata("inlineFunctionBreakpointAnotherFile.kt") + public void testInlineFunctionBreakpointAnotherFile() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/inlineFunctionBreakpointAnotherFile.kt"); + doSingleBreakpointTest(fileName); + } + @TestMetadata("inlineFunctionBreakpointVariants.kt") public void testInlineFunctionBreakpointVariants() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/inlineFunctionBreakpointVariants.kt");