diff --git a/idea/testData/debugger/tinyApp/customLibrary/simpleLibFile/simpleLibFile.kt b/idea/testData/debugger/tinyApp/customLibrary/simpleLibFile/simpleLibFile.kt new file mode 100644 index 00000000000..dccf55fc28e --- /dev/null +++ b/idea/testData/debugger/tinyApp/customLibrary/simpleLibFile/simpleLibFile.kt @@ -0,0 +1,5 @@ +package customLib.simpleLibFile + +public fun foo() { + val a = 1 +} diff --git a/idea/testData/debugger/tinyApp/outs/customLibClassName.out b/idea/testData/debugger/tinyApp/outs/customLibClassName.out index 64b36270fa3..96be829709a 100644 --- a/idea/testData/debugger/tinyApp/outs/customLibClassName.out +++ b/idea/testData/debugger/tinyApp/outs/customLibClassName.out @@ -2,6 +2,7 @@ LineBreakpoint created at 1.kt:3 LineBreakpoint created at 1.kt:3 LineBreakpoint created at 1.kt:3 LineBreakpoint created at 1.kt:3 +LineBreakpoint created at simpleLibFile.kt:3 !JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !APP_PATH!\classes;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! customLibClassName.CustomLibClassNamePackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' 1.kt:3 @@ -12,6 +13,8 @@ Compile bytecode for 1 + 2 Compile bytecode for 1 + 3 1.kt:3 Compile bytecode for 1 + 4 +simpleLibFile.kt:3 +Compile bytecode for 1 + 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/outs/stdlibDelegatedProperty.out b/idea/testData/debugger/tinyApp/outs/stdlibDelegatedProperty.out deleted file mode 100644 index 979dc1afcc0..00000000000 --- a/idea/testData/debugger/tinyApp/outs/stdlibDelegatedProperty.out +++ /dev/null @@ -1,8 +0,0 @@ -LineBreakpoint created at Delegation.kt:48 -!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !APP_PATH!\classes;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! stdlibDelegatedProperty.StdlibDelegatedPropertyPackage -Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' -Delegation.kt:48 -Compile bytecode for value.toString() -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/stdlibRange.out b/idea/testData/debugger/tinyApp/outs/stdlibRange.out deleted file mode 100644 index 10adbf52e0a..00000000000 --- a/idea/testData/debugger/tinyApp/outs/stdlibRange.out +++ /dev/null @@ -1,8 +0,0 @@ -LineBreakpoint created at Ranges.kt:7 -!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !APP_PATH!\classes;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! stdlibRange.StdlibRangePackage -Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' -Ranges.kt:7 -Compile bytecode for start <= item -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/stdlibSlice.out b/idea/testData/debugger/tinyApp/outs/stdlibSlice.out deleted file mode 100644 index 3bbaaf353ea..00000000000 --- a/idea/testData/debugger/tinyApp/outs/stdlibSlice.out +++ /dev/null @@ -1,8 +0,0 @@ -LineBreakpoint created at StringsJVM.kt:163 -!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !APP_PATH!\classes;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! stdlibSlice.StdlibSlicePackage -Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' -StringsJVM.kt:163 -Compile bytecode for range.start -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/stepIntoSpecificKotlinClasses.out b/idea/testData/debugger/tinyApp/outs/stepIntoSpecificKotlinClasses.out index fd81d4e7941..4b864c62ac6 100644 --- a/idea/testData/debugger/tinyApp/outs/stepIntoSpecificKotlinClasses.out +++ b/idea/testData/debugger/tinyApp/outs/stepIntoSpecificKotlinClasses.out @@ -4,7 +4,7 @@ Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socke stepIntoSpecificKotlinClasses.kt:7 MyJavaClass.java:11 stepIntoSpecificKotlinClasses.kt:7 -Intrinsics.class:17 +Intrinsics.class stepIntoSpecificKotlinClasses.kt:7 stepIntoSpecificKotlinClasses.kt:8 Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' diff --git a/idea/testData/debugger/tinyApp/outs/stepIntoStdlib.out b/idea/testData/debugger/tinyApp/outs/stepIntoStdlib.out index b303ff9dfc6..f2f842bec75 100644 --- a/idea/testData/debugger/tinyApp/outs/stepIntoStdlib.out +++ b/idea/testData/debugger/tinyApp/outs/stepIntoStdlib.out @@ -2,7 +2,8 @@ LineBreakpoint created at stepIntoStdlib.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 !APP_PATH!\classes;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! stepIntoStdlib.StepIntoStdlibPackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' stepIntoStdlib.kt:5 -KotlinPackage.class:-1 +KotlinPackage.class +_Mapping.kt 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/multipleBreakpoints/library/customLibClassName.kt b/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/library/customLibClassName.kt index 943312bef5d..505388bc9d6 100644 --- a/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/library/customLibClassName.kt +++ b/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/library/customLibClassName.kt @@ -5,6 +5,7 @@ fun main(args: Array) { customLib.twoFunDifferentSignature.twoFunDifferentSignatureFun() customLib.property.foo customLib.breakpointOnLocalProperty.breakpointOnLocalPropertyFun() + customLib.simpleLibFile.foo() } // ADDITIONAL_BREAKPOINT: 1.kt:public fun oneFunSameFileNameFun(): Int { @@ -21,4 +22,8 @@ fun main(args: Array) { // ADDITIONAL_BREAKPOINT: 1.kt:public fun breakpointOnLocalPropertyFun(): Int { // EXPRESSION: 1 + 4 -// RESULT: 5: I \ No newline at end of file +// RESULT: 5: I + +// ADDITIONAL_BREAKPOINT: simpleLibFile.kt:public fun foo() { +// EXPRESSION: 1 + 5 +// RESULT: 6: I \ No newline at end of file diff --git a/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/library/stdlibDelegatedProperty.kt b/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/library/stdlibDelegatedProperty.kt deleted file mode 100644 index 788623d710f..00000000000 --- a/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/library/stdlibDelegatedProperty.kt +++ /dev/null @@ -1,15 +0,0 @@ -package stdlibDelegatedProperty - -import kotlin.properties.Delegates - -var prop: Int by Delegates.notNull() - -fun main(args: Array) { - prop = 3 - val a = prop -} - -// ADDITIONAL_BREAKPOINT: Delegation.kt:public override fun set(thisRef: Any?, desc: PropertyMetadata, value: T) { - -// EXPRESSION: value.toString() -// RESULT: "3": Ljava/lang/String; \ No newline at end of file diff --git a/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/library/stdlibRange.kt b/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/library/stdlibRange.kt deleted file mode 100644 index 047b03ee0b1..00000000000 --- a/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/library/stdlibRange.kt +++ /dev/null @@ -1,14 +0,0 @@ -package stdlibRange - -fun main(args: Array) { - A().rangeTo(A()).contains(A()) -} - -class A: Comparable { - override fun compareTo(other: A) = 0 -} - -// ADDITIONAL_BREAKPOINT: Ranges.kt:override fun contains(item: T): Boolean { - -// EXPRESSION: start <= item -// RESULT: 1: Z \ No newline at end of file diff --git a/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/library/stdlibSlice.kt b/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/library/stdlibSlice.kt deleted file mode 100644 index e71e6af4354..00000000000 --- a/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/library/stdlibSlice.kt +++ /dev/null @@ -1,11 +0,0 @@ -package stdlibSlice - -fun main(args: Array) { - val c: CharSequence = "CharSequence" - c.slice(0..1) -} - -// ADDITIONAL_BREAKPOINT: StringsJVM.kt:CharSequence.slice(range: IntRange): CharSequence - -// EXPRESSION: range.start -// RESULT: 0: I \ No newline at end of file diff --git a/idea/testData/debugger/tinyApp/src/filters/stepIntoStdlib.kt b/idea/testData/debugger/tinyApp/src/filters/stepIntoStdlib.kt index 215f361775f..ec4c16ec2f6 100644 --- a/idea/testData/debugger/tinyApp/src/filters/stepIntoStdlib.kt +++ b/idea/testData/debugger/tinyApp/src/filters/stepIntoStdlib.kt @@ -7,4 +7,5 @@ fun main(args: Array) { val b = 1 } +// REPEAT: 2 // TRACING_FILTERS_ENABLED: false diff --git a/idea/tests/org/jetbrains/jet/plugin/debugger/KotlinDebuggerTestBase.kt b/idea/tests/org/jetbrains/jet/plugin/debugger/KotlinDebuggerTestBase.kt index 943c37b5299..7764db4b63d 100644 --- a/idea/tests/org/jetbrains/jet/plugin/debugger/KotlinDebuggerTestBase.kt +++ b/idea/tests/org/jetbrains/jet/plugin/debugger/KotlinDebuggerTestBase.kt @@ -19,6 +19,11 @@ package org.jetbrains.jet.plugin.debugger import com.intellij.debugger.engine.DebugProcessImpl import com.intellij.debugger.engine.SuspendContextImpl import com.intellij.debugger.engine.MethodFilter +import org.jetbrains.jet.plugin.refactoring.runReadAction +import com.intellij.debugger.impl.PositionUtil +import com.intellij.execution.process.ProcessOutputTypes +import com.intellij.openapi.roots.libraries.LibraryUtil +import org.jetbrains.jet.plugin.JetJdkAndLibraryProjectDescriptor abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() { @@ -41,7 +46,28 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() { } protected fun SuspendContextImpl.printContext() { - printContext(this) + runReadAction { (): Unit -> + if (this.getFrameProxy() == null) { + return@runReadAction println("Context thread is null", ProcessOutputTypes.SYSTEM) + } + + val sourcePosition = PositionUtil.getSourcePosition(this) + if (sourcePosition == null) { + return@runReadAction println("SourcePosition is null", ProcessOutputTypes.SYSTEM) + } + + val virtualFile = sourcePosition.getFile().getVirtualFile() + if (virtualFile == null) { + return@runReadAction println("VirtualFile for position is null", ProcessOutputTypes.SYSTEM) + } + + val isInStdlib = LibraryUtil.findLibraryEntry(virtualFile, getProject())?.getPresentableName() == JetJdkAndLibraryProjectDescriptor.LIBRARY_NAME + if (isInStdlib) { + return@runReadAction println(virtualFile.getName(), ProcessOutputTypes.SYSTEM) + } + + println(virtualFile.getName() + ":" + sourcePosition.getLine(), ProcessOutputTypes.SYSTEM) + } } protected fun finish() { diff --git a/idea/tests/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java index 9e4923aa0b2..0148807d378 100644 --- a/idea/tests/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java @@ -375,24 +375,6 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat doMultipleBreakpointsTest(fileName); } - @TestMetadata("stdlibDelegatedProperty.kt") - public void testStdlibDelegatedProperty() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/library/stdlibDelegatedProperty.kt"); - doMultipleBreakpointsTest(fileName); - } - - @TestMetadata("stdlibRange.kt") - public void testStdlibRange() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/library/stdlibRange.kt"); - doMultipleBreakpointsTest(fileName); - } - - @TestMetadata("stdlibSlice.kt") - public void testStdlibSlice() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/library/stdlibSlice.kt"); - doMultipleBreakpointsTest(fileName); - } - } }