From 2dd7470cdc38b7712093113cf4b1043dc09dcd7a Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Mon, 1 Aug 2016 15:51:59 +0300 Subject: [PATCH] Better search for inlined strings in strata: there might me several file mappings to the same file (KT-12896) #KT-12896 In Progress --- .../debugger/NoStrataPositionManagerHelper.kt | 4 ++-- .../tinyApp/outs/dexInlineInClass.out | 8 +++++++ .../tinyApp/outs/dexInlineInObject.out | 8 +++++++ .../outs/dexInlineInObjectSameFile.out | 10 ++++++++ .../debugger/tinyApp/outs/inlineInObject.out | 10 ++++++++ .../custom/dexInlineInObjectSameFile.kt | 15 ++++++++++++ .../src/stepping/custom/inlineInObject.kt | 15 ++++++++++++ .../stepOver/dexInlineInClass.Other.kt | 11 +++++++++ .../src/stepping/stepOver/dexInlineInClass.kt | 7 ++++++ .../stepOver/dexInlineInObject.Other.kt | 11 +++++++++ .../stepping/stepOver/dexInlineInObject.kt | 7 ++++++ .../debugger/KotlinSteppingTestGenerated.java | 24 +++++++++++++++++++ 12 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 idea/testData/debugger/tinyApp/outs/dexInlineInClass.out create mode 100644 idea/testData/debugger/tinyApp/outs/dexInlineInObject.out create mode 100644 idea/testData/debugger/tinyApp/outs/dexInlineInObjectSameFile.out create mode 100644 idea/testData/debugger/tinyApp/outs/inlineInObject.out create mode 100644 idea/testData/debugger/tinyApp/src/stepping/custom/dexInlineInObjectSameFile.kt create mode 100644 idea/testData/debugger/tinyApp/src/stepping/custom/inlineInObject.kt create mode 100644 idea/testData/debugger/tinyApp/src/stepping/stepOver/dexInlineInClass.Other.kt create mode 100644 idea/testData/debugger/tinyApp/src/stepping/stepOver/dexInlineInClass.kt create mode 100644 idea/testData/debugger/tinyApp/src/stepping/stepOver/dexInlineInObject.Other.kt create mode 100644 idea/testData/debugger/tinyApp/src/stepping/stepOver/dexInlineInObject.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/NoStrataPositionManagerHelper.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/NoStrataPositionManagerHelper.kt index 44299ef8bb0..6abdbeadb22 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/NoStrataPositionManagerHelper.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/NoStrataPositionManagerHelper.kt @@ -81,8 +81,8 @@ private fun inlinedLinesNumbers( val smap = smapData.kotlinStrata ?: return listOf() - val mappingToInlinedFile = smap.fileMappings.firstOrNull() { it.name == inlineFileName } ?: return listOf() - return mappingToInlinedFile.lineMappings.map { it.mapSourceToDest(inlineLineNumber) } + val mappingsToInlinedFile = smap.fileMappings.filter() { it.name == inlineFileName } + return mappingsToInlinedFile.flatMap { it.lineMappings.map { it.mapSourceToDest(inlineLineNumber) } } } @Volatile var emulateDexDebugInTests: Boolean = false diff --git a/idea/testData/debugger/tinyApp/outs/dexInlineInClass.out b/idea/testData/debugger/tinyApp/outs/dexInlineInClass.out new file mode 100644 index 00000000000..ac6ace8655f --- /dev/null +++ b/idea/testData/debugger/tinyApp/outs/dexInlineInClass.out @@ -0,0 +1,8 @@ +LineBreakpoint created at dexInlineInClass.Other.kt:6 +!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! dexInlineInClass.DexInlineInClassKt +Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' +dexInlineInClass.Other.kt:6 +dexInlineInClass.Other.kt:7 +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/dexInlineInObject.out b/idea/testData/debugger/tinyApp/outs/dexInlineInObject.out new file mode 100644 index 00000000000..5c3db39b53a --- /dev/null +++ b/idea/testData/debugger/tinyApp/outs/dexInlineInObject.out @@ -0,0 +1,8 @@ +LineBreakpoint created at dexInlineInObject.Other.kt:6 +!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! dexInlineInObject.DexInlineInObjectKt +Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' +dexInlineInObject.Other.kt:6 +dexInlineInObject.Other.kt:7 +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/dexInlineInObjectSameFile.out b/idea/testData/debugger/tinyApp/outs/dexInlineInObjectSameFile.out new file mode 100644 index 00000000000..daf6af3cfc0 --- /dev/null +++ b/idea/testData/debugger/tinyApp/outs/dexInlineInObjectSameFile.out @@ -0,0 +1,10 @@ +LineBreakpoint created at dexInlineInObjectSameFile.kt:5 +LineBreakpoint created at dexInlineInObjectSameFile.kt:11 +!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! dexInlineInObjectSameFile.DexInlineInObjectSameFileKt +Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' +dexInlineInObjectSameFile.kt:5 +dexInlineInObjectSameFile.kt:11 +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/inlineInObject.out b/idea/testData/debugger/tinyApp/outs/inlineInObject.out new file mode 100644 index 00000000000..6d6003c49a3 --- /dev/null +++ b/idea/testData/debugger/tinyApp/outs/inlineInObject.out @@ -0,0 +1,10 @@ +LineBreakpoint created at inlineInObject.kt:5 +LineBreakpoint created at inlineInObject.kt:11 +!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! inlineInObject.InlineInObjectKt +Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' +inlineInObject.kt:5 +inlineInObject.kt:11 +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/stepping/custom/dexInlineInObjectSameFile.kt b/idea/testData/debugger/tinyApp/src/stepping/custom/dexInlineInObjectSameFile.kt new file mode 100644 index 00000000000..ff17972f20d --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/stepping/custom/dexInlineInObjectSameFile.kt @@ -0,0 +1,15 @@ +package dexInlineInObjectSameFile + +fun main(args: Array) { + //Breakpoint! + OtherWithInline.one() +} + +object OtherWithInline { + inline fun one() { + //Breakpoint! + println() + } +} + +// RESUME: 1 \ No newline at end of file diff --git a/idea/testData/debugger/tinyApp/src/stepping/custom/inlineInObject.kt b/idea/testData/debugger/tinyApp/src/stepping/custom/inlineInObject.kt new file mode 100644 index 00000000000..07b42bcfd3c --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/stepping/custom/inlineInObject.kt @@ -0,0 +1,15 @@ +package inlineInObject + +fun main(args: Array) { + //Breakpoint! + OtherWithInline.one() +} + +object OtherWithInline { + inline fun one() { + //Breakpoint! + println() + } +} + +// RESUME: 1 \ No newline at end of file diff --git a/idea/testData/debugger/tinyApp/src/stepping/stepOver/dexInlineInClass.Other.kt b/idea/testData/debugger/tinyApp/src/stepping/stepOver/dexInlineInClass.Other.kt new file mode 100644 index 00000000000..9219980b479 --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/stepping/stepOver/dexInlineInClass.Other.kt @@ -0,0 +1,11 @@ +package dexInlineInClass.other + +class TestDexInlineInClass { + inline fun inlineFun() { + // Breakpoint 1 + some() + some() + } + + fun some() {} +} diff --git a/idea/testData/debugger/tinyApp/src/stepping/stepOver/dexInlineInClass.kt b/idea/testData/debugger/tinyApp/src/stepping/stepOver/dexInlineInClass.kt new file mode 100644 index 00000000000..e87ef8d5570 --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/stepping/stepOver/dexInlineInClass.kt @@ -0,0 +1,7 @@ +package dexInlineInClass + +fun main(args: Array) { + dexInlineInClass.other.TestDexInlineInClass().inlineFun() +} + +// ADDITIONAL_BREAKPOINT: dexInlineInClass.Other.kt: Breakpoint 1 \ No newline at end of file diff --git a/idea/testData/debugger/tinyApp/src/stepping/stepOver/dexInlineInObject.Other.kt b/idea/testData/debugger/tinyApp/src/stepping/stepOver/dexInlineInObject.Other.kt new file mode 100644 index 00000000000..9a9caffc7f1 --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/stepping/stepOver/dexInlineInObject.Other.kt @@ -0,0 +1,11 @@ +package dexInlineInObject.other + +object TestDexInlineInObject { + inline fun inlineFun() { + // Breakpoint 1 + some() + some() + } + + fun some() {} +} diff --git a/idea/testData/debugger/tinyApp/src/stepping/stepOver/dexInlineInObject.kt b/idea/testData/debugger/tinyApp/src/stepping/stepOver/dexInlineInObject.kt new file mode 100644 index 00000000000..f2796f7c8ff --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/stepping/stepOver/dexInlineInObject.kt @@ -0,0 +1,7 @@ +package dexInlineInObject + +fun main(args: Array) { + dexInlineInObject.other.TestDexInlineInObject.inlineFun() +} + +// ADDITIONAL_BREAKPOINT: dexInlineInObject.Other.kt: Breakpoint 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 36a09ce5272..630c2de0437 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java @@ -373,6 +373,18 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/debugger/tinyApp/src/stepping/stepOver"), Pattern.compile("^([^.]+)\\.kt$"), true); } + @TestMetadata("dexInlineInClass.kt") + public void testDexInlineInClass() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/dexInlineInClass.kt"); + doStepOverTest(fileName); + } + + @TestMetadata("dexInlineInObject.kt") + public void testDexInlineInObject() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/dexInlineInObject.kt"); + doStepOverTest(fileName); + } + @TestMetadata("dexStopInInlineFun.kt") public void testDexStopInInlineFun() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/dexStopInInlineFun.kt"); @@ -577,6 +589,12 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest { doCustomTest(fileName); } + @TestMetadata("dexInlineInObjectSameFile.kt") + public void testDexInlineInObjectSameFile() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/custom/dexInlineInObjectSameFile.kt"); + doCustomTest(fileName); + } + @TestMetadata("dexManyFilesWithInlineCalls1.kt") public void testDexManyFilesWithInlineCalls1() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/custom/dexManyFilesWithInlineCalls1.kt"); @@ -625,6 +643,12 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest { doCustomTest(fileName); } + @TestMetadata("inlineInObject.kt") + public void testInlineInObject() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/custom/inlineInObject.kt"); + doCustomTest(fileName); + } + @TestMetadata("severalFunLiterals.kt") public void testSeveralFunLiterals() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/custom/severalFunLiterals.kt");