From 3edd6b52cf5afee33acdbc4f3d41165ccc48949a Mon Sep 17 00:00:00 2001 From: Natalia Ukhorskaya Date: Wed, 18 Jun 2014 11:11:56 +0400 Subject: [PATCH] Evaluate expression: test cache using logger --- .../evaluate/KotlinEvaluateExpressionCache.kt | 6 ++- .../debugger/tinyApp/outs/abstractFunCall.out | 1 + .../testData/debugger/tinyApp/outs/arrays.out | 9 ++++ .../tinyApp/outs/classFromAnotherPackage.out | 2 + .../debugger/tinyApp/outs/classObjectVal.out | 2 + .../debugger/tinyApp/outs/clearCache.out | 12 +++++ .../debugger/tinyApp/outs/collections.out | 11 +++++ .../debugger/tinyApp/outs/dependentOnFile.out | 8 ++++ .../debugger/tinyApp/outs/doubles.out | 1 + idea/testData/debugger/tinyApp/outs/enums.out | 1 + .../tinyApp/outs/extractLocalVariables.out | 4 ++ .../debugger/tinyApp/outs/extractThis.out | 3 ++ .../tinyApp/outs/extractVariablesFromCall.out | 4 ++ .../debugger/tinyApp/outs/imports.out | 4 ++ .../debugger/tinyApp/outs/insertInBlock.out | 1 + .../outs/multilineExpressionAtBreakpoint.out | 1 + .../debugger/tinyApp/outs/privateMember.out | 3 ++ .../debugger/tinyApp/outs/protectedMember.out | 3 ++ .../testData/debugger/tinyApp/outs/simple.out | 7 +++ .../testData/debugger/tinyApp/outs/stdlib.out | 7 +++ idea/testData/debugger/tinyApp/outs/vars.out | 2 + .../AbstractKotlinEvaluateExpressionTest.kt | 44 ++++++++++++++++--- 22 files changed, 130 insertions(+), 6 deletions(-) diff --git a/idea/src/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluateExpressionCache.kt b/idea/src/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluateExpressionCache.kt index 441e6776300..5af28367661 100644 --- a/idea/src/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluateExpressionCache.kt +++ b/idea/src/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluateExpressionCache.kt @@ -39,6 +39,7 @@ import org.jetbrains.jet.plugin.caches.resolve.JavaResolveExtension import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaClassImpl import org.jetbrains.jet.lang.resolve.java.JvmClassName import org.jetbrains.jet.codegen.AsmUtil +import org.apache.log4j.Logger class KotlinEvaluateExpressionCache(val project: Project) { @@ -49,6 +50,8 @@ class KotlinEvaluateExpressionCache(val project: Project) { }, false) class object { + private val LOG = Logger.getLogger(javaClass())!! + fun getInstance(project: Project) = ServiceManager.getService(project, javaClass())!! fun getOrCreateCompiledData( @@ -70,8 +73,9 @@ class KotlinEvaluateExpressionCache(val project: Project) { if (answer != null) return@synchronized answer val newCompiledData = create(codeFragment, sourcePosition) - cache.putValue(text, newCompiledData) + LOG.debug("Compile bytecode for ${codeFragment.getText()}") + cache.putValue(text, newCompiledData) return@synchronized newCompiledData } } diff --git a/idea/testData/debugger/tinyApp/outs/abstractFunCall.out b/idea/testData/debugger/tinyApp/outs/abstractFunCall.out index 4ec5a230c95..eef77767d00 100644 --- a/idea/testData/debugger/tinyApp/outs/abstractFunCall.out +++ b/idea/testData/debugger/tinyApp/outs/abstractFunCall.out @@ -2,6 +2,7 @@ LineBreakpoint created at abstractFunCall.kt:5 !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!;!RT_JAR! abstractFunCall.AbstractFunCallPackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' abstractFunCall.kt:4 +Compile bytecode for (1 as java.lang.Number).intValue() 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/arrays.out b/idea/testData/debugger/tinyApp/outs/arrays.out index f523f93f485..3f35b7c44b9 100644 --- a/idea/testData/debugger/tinyApp/outs/arrays.out +++ b/idea/testData/debugger/tinyApp/outs/arrays.out @@ -2,6 +2,15 @@ LineBreakpoint created at arrays.kt:5 !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!;!RT_JAR! arrays.ArraysPackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' arrays.kt:4 +Compile bytecode for array(1, 2).map { it.toString() } +Compile bytecode for array(1, 2, 101, 102).filter { it > 100 } +Compile bytecode for array(1, 2).none() +Compile bytecode for array(1, 2).count() +Compile bytecode for array(1, 2).size +Compile bytecode for array(1, 2).first() +Compile bytecode for array(1, 2).last() +Compile bytecode for intArray(1, 2).max() +Compile bytecode for array(1, 2).max() 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/classFromAnotherPackage.out b/idea/testData/debugger/tinyApp/outs/classFromAnotherPackage.out index e1153240cae..6dbcb1bcad4 100644 --- a/idea/testData/debugger/tinyApp/outs/classFromAnotherPackage.out +++ b/idea/testData/debugger/tinyApp/outs/classFromAnotherPackage.out @@ -2,6 +2,8 @@ LineBreakpoint created at classFromAnotherPackage.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!;!RT_JAR! classFromAnotherPackage.ClassFromAnotherPackagePackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' classFromAnotherPackage.kt:6 +Compile bytecode for MyJavaClass() +Compile bytecode for stepInto.MyJavaClass() 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/classObjectVal.out b/idea/testData/debugger/tinyApp/outs/classObjectVal.out index 67eb6a81afc..a347b06cd23 100644 --- a/idea/testData/debugger/tinyApp/outs/classObjectVal.out +++ b/idea/testData/debugger/tinyApp/outs/classObjectVal.out @@ -2,6 +2,8 @@ LineBreakpoint created at classObjectVal.kt:10 !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!;!RT_JAR! classObjectVal.ClassObjectValPackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' classObjectVal.kt:9 +Compile bytecode for coProp +Compile bytecode for MyClass.coProp 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/clearCache.out b/idea/testData/debugger/tinyApp/outs/clearCache.out index 4596499adcd..f5f1235bf62 100644 --- a/idea/testData/debugger/tinyApp/outs/clearCache.out +++ b/idea/testData/debugger/tinyApp/outs/clearCache.out @@ -20,26 +20,38 @@ LineBreakpoint created at clearCache.kt:189 !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!;!RT_JAR! clearCache.ClearCachePackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' clearCache.kt:11 +Compile bytecode for a clearCache.kt:19 +Compile bytecode for a clearCache.kt:30 +Compile bytecode for i clearCache.kt:30 clearCache.kt:41 +Compile bytecode for i clearCache.kt:41 clearCache.kt:51 +Compile bytecode for o.test() clearCache.kt:59 clearCache.kt:77 +Compile bytecode for c.size() clearCache.kt:85 clearCache.kt:94 clearCache.kt:104 clearCache.kt:112 +Compile bytecode for c.size() clearCache.kt:123 +Compile bytecode for c.get(0) clearCache.kt:132 clearCache.kt:142 +Compile bytecode for o.test() clearCache.kt:150 clearCache.kt:168 +Compile bytecode for obj.test() clearCache.kt:173 clearCache.kt:180 +Compile bytecode for o.test() clearCache.kt:188 +Compile bytecode for o.test() 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/collections.out b/idea/testData/debugger/tinyApp/outs/collections.out index 618a4970607..8215589597b 100644 --- a/idea/testData/debugger/tinyApp/outs/collections.out +++ b/idea/testData/debugger/tinyApp/outs/collections.out @@ -2,6 +2,17 @@ LineBreakpoint created at collections.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!;!RT_JAR! collections.CollectionsPackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' collections.kt:5 +Compile bytecode for arrayListOf(1, 2).map { it.toString() } +Compile bytecode for arrayListOf(1, 2, 101, 102).filter { it > 100 } +Compile bytecode for arrayListOf(1, 2).max() +Compile bytecode for arrayListOf(1, 2).count() +Compile bytecode for arrayListOf(1, 2).size +Compile bytecode for arrayListOf(1, 2).drop(1) +Compile bytecode for ar.map { if (it > 50) "big" else "small" } + .filter { it == "small" } + .size + +// RESULT: 2: I 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/dependentOnFile.out b/idea/testData/debugger/tinyApp/outs/dependentOnFile.out index 32f5a09bbfc..33361887a66 100644 --- a/idea/testData/debugger/tinyApp/outs/dependentOnFile.out +++ b/idea/testData/debugger/tinyApp/outs/dependentOnFile.out @@ -2,6 +2,14 @@ LineBreakpoint created at dependentOnFile.kt:5 !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!;!RT_JAR! dependentOnFile.DependentOnFilePackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' dependentOnFile.kt:4 +Compile bytecode for TestClass().testFun() +Compile bytecode for testFun() +Compile bytecode for TestObject.p +Compile bytecode for TestClass.p +Compile bytecode for 1.testExtFun() +Compile bytecode for testVal +Compile bytecode for 1.testExtVal +Compile bytecode for testDelVal 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/doubles.out b/idea/testData/debugger/tinyApp/outs/doubles.out index 7fc4417f6d8..9028781bd0b 100644 --- a/idea/testData/debugger/tinyApp/outs/doubles.out +++ b/idea/testData/debugger/tinyApp/outs/doubles.out @@ -2,6 +2,7 @@ LineBreakpoint created at doubles.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!;!RT_JAR! doubles.DoublesPackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' doubles.kt:6 +Compile bytecode for d1 + d2 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/enums.out b/idea/testData/debugger/tinyApp/outs/enums.out index 1c98f3af07a..9c475e903b1 100644 --- a/idea/testData/debugger/tinyApp/outs/enums.out +++ b/idea/testData/debugger/tinyApp/outs/enums.out @@ -2,6 +2,7 @@ LineBreakpoint created at enums.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!;!RT_JAR! enums.EnumsPackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' enums.kt:6 +Compile bytecode for A == MyEnum.A 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/extractLocalVariables.out b/idea/testData/debugger/tinyApp/outs/extractLocalVariables.out index fca8952e6a5..e8c4407ba13 100644 --- a/idea/testData/debugger/tinyApp/outs/extractLocalVariables.out +++ b/idea/testData/debugger/tinyApp/outs/extractLocalVariables.out @@ -2,6 +2,10 @@ LineBreakpoint created at extractLocalVariables.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!;!RT_JAR! extractLocalVariables.ExtractLocalVariablesPackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' extractLocalVariables.kt:6 +Compile bytecode for a +Compile bytecode for klass.f1(1) +Compile bytecode for args.size +Compile bytecode for klass.b 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/extractThis.out b/idea/testData/debugger/tinyApp/outs/extractThis.out index f308e1f8a66..fdbf81651b5 100644 --- a/idea/testData/debugger/tinyApp/outs/extractThis.out +++ b/idea/testData/debugger/tinyApp/outs/extractThis.out @@ -2,6 +2,9 @@ LineBreakpoint created at extractThis.kt:13 !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!;!RT_JAR! extractThis.ExtractThisPackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' extractThis.kt:12 +Compile bytecode for prop +Compile bytecode for this.prop +Compile bytecode for prop + a 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/extractVariablesFromCall.out b/idea/testData/debugger/tinyApp/outs/extractVariablesFromCall.out index ac9998a6ba8..77392f6796a 100644 --- a/idea/testData/debugger/tinyApp/outs/extractVariablesFromCall.out +++ b/idea/testData/debugger/tinyApp/outs/extractVariablesFromCall.out @@ -2,6 +2,10 @@ LineBreakpoint created at extractVariablesFromCall.kt:8 !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!;!RT_JAR! extractVariablesFromCall.ExtractVariablesFromCallPackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' extractVariablesFromCall.kt:7 +Compile bytecode for f1(a, s) +Compile bytecode for a.f2(s) +Compile bytecode for a f2 s +Compile bytecode for klass.f1(a, s) 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/imports.out b/idea/testData/debugger/tinyApp/outs/imports.out index 41c860627fb..f5d2f0980ef 100644 --- a/idea/testData/debugger/tinyApp/outs/imports.out +++ b/idea/testData/debugger/tinyApp/outs/imports.out @@ -2,6 +2,10 @@ LineBreakpoint created at imports.kt:10 !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!;!RT_JAR! imports.ImportsPackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' imports.kt:9 +Compile bytecode for Collections.emptyList() +Compile bytecode for ArrayList() +Compile bytecode for HashSet() +Compile bytecode for JHashMap() 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/insertInBlock.out b/idea/testData/debugger/tinyApp/outs/insertInBlock.out index 6936cb0ff92..88697b9114e 100644 --- a/idea/testData/debugger/tinyApp/outs/insertInBlock.out +++ b/idea/testData/debugger/tinyApp/outs/insertInBlock.out @@ -2,6 +2,7 @@ LineBreakpoint created at insertInBlock.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!;!RT_JAR! insertInBlock.InsertInBlockPackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' insertInBlock.kt:5 +Compile bytecode for 1 + 1 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/multilineExpressionAtBreakpoint.out b/idea/testData/debugger/tinyApp/outs/multilineExpressionAtBreakpoint.out index 03b028c046d..0393ae05b63 100644 --- a/idea/testData/debugger/tinyApp/outs/multilineExpressionAtBreakpoint.out +++ b/idea/testData/debugger/tinyApp/outs/multilineExpressionAtBreakpoint.out @@ -2,6 +2,7 @@ LineBreakpoint created at multilineExpressionAtBreakpoint.kt:5 !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!;!RT_JAR! multilineExpressionAtBreakpoint.MultilineExpressionAtBreakpointPackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' multilineExpressionAtBreakpoint.kt:4 +Compile bytecode for 1 + 1 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/privateMember.out b/idea/testData/debugger/tinyApp/outs/privateMember.out index beb563cb681..64268d1cda5 100644 --- a/idea/testData/debugger/tinyApp/outs/privateMember.out +++ b/idea/testData/debugger/tinyApp/outs/privateMember.out @@ -2,6 +2,9 @@ LineBreakpoint created at privateMember.kt:5 !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!;!RT_JAR! privateMember.PrivateMemberPackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' privateMember.kt:4 +Compile bytecode for MyClass().privateFun() +Compile bytecode for MyClass().privateVal +Compile bytecode for MyClass.PrivateClass().a 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/protectedMember.out b/idea/testData/debugger/tinyApp/outs/protectedMember.out index 9d9b6c38da6..35f56ba3f9f 100644 --- a/idea/testData/debugger/tinyApp/outs/protectedMember.out +++ b/idea/testData/debugger/tinyApp/outs/protectedMember.out @@ -2,6 +2,9 @@ LineBreakpoint created at protectedMember.kt:5 !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!;!RT_JAR! protectedMember.ProtectedMemberPackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' protectedMember.kt:4 +Compile bytecode for MyClass().protectedFun() +Compile bytecode for MyClass().protectedVal +Compile bytecode for MyClass.ProtectedClass().a 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/simple.out b/idea/testData/debugger/tinyApp/outs/simple.out index caf68a7723d..a50f76d0ce6 100644 --- a/idea/testData/debugger/tinyApp/outs/simple.out +++ b/idea/testData/debugger/tinyApp/outs/simple.out @@ -2,6 +2,13 @@ LineBreakpoint created at simple.kt:5 !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!;!RT_JAR! simple.SimplePackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' simple.kt:4 +Compile bytecode for 1 +Compile bytecode for 1 + 1 +Compile bytecode for val a = 1 +a + args.size + +// RESULT: 1: I + 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/stdlib.out b/idea/testData/debugger/tinyApp/outs/stdlib.out index 08dcedff6bc..dd798d2101e 100644 --- a/idea/testData/debugger/tinyApp/outs/stdlib.out +++ b/idea/testData/debugger/tinyApp/outs/stdlib.out @@ -2,6 +2,13 @@ LineBreakpoint created at stdlib.kt:5 !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!;!RT_JAR! stdlib.StdlibPackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' stdlib.kt:4 +Compile bytecode for array(100, 101) +Compile bytecode for array("a", "b", "c") +Compile bytecode for intArray(1, 2) +Compile bytecode for javaClass() +Compile bytecode for javaClass() +Compile bytecode for 100.toInt() +Compile bytecode for 100.toLong() 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/vars.out b/idea/testData/debugger/tinyApp/outs/vars.out index 764afeee9d0..0a19db7c231 100644 --- a/idea/testData/debugger/tinyApp/outs/vars.out +++ b/idea/testData/debugger/tinyApp/outs/vars.out @@ -2,6 +2,8 @@ LineBreakpoint created at vars.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!;!RT_JAR! vars.VarsPackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' vars.kt:6 +Compile bytecode for a +Compile bytecode for a += 1 Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' Process finished with exit code 0 diff --git a/idea/tests/org/jetbrains/jet/plugin/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt b/idea/tests/org/jetbrains/jet/plugin/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt index 18a53380877..d05f7197025 100644 --- a/idea/tests/org/jetbrains/jet/plugin/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt +++ b/idea/tests/org/jetbrains/jet/plugin/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt @@ -35,8 +35,40 @@ import com.sun.jdi.ObjectReference import org.jetbrains.jet.lang.psi.JetCodeFragment import java.util.Collections import com.intellij.debugger.engine.evaluation.EvaluateException +import com.intellij.execution.process.ProcessOutputTypes +import org.apache.log4j.AppenderSkeleton +import org.apache.log4j.spi.LoggingEvent +import org.apache.log4j.Level +import org.apache.log4j.Logger public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestCase() { + private val logger = Logger.getLogger(javaClass())!! + + private val appender = object : AppenderSkeleton() { + override fun append(event: LoggingEvent?) { + println(event?.getRenderedMessage(), ProcessOutputTypes.SYSTEM) + } + override fun close() {} + override fun requiresLayout() = false + } + + private var oldLogLevel: Level? = null + + override fun setUp() { + super.setUp() + + oldLogLevel = logger.getLevel() + logger.setLevel(Level.DEBUG) + logger.addAppender(appender) + } + + override fun tearDown() { + logger.setLevel(oldLogLevel) + logger.removeAppender(appender) + + super.tearDown() + } + fun doSingleBreakpointTest(path: String) { val file = File(path) val expressions = loadTestDirectivesPairs(file, "// EXPRESSION: ", "// RESULT: ") @@ -84,6 +116,8 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestC finish() } + + private fun checkExceptions(exceptions: MutableMap) { if (!exceptions.empty) { for (exc in exceptions.values()) { @@ -137,10 +171,10 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestC val evaluator = DebuggerInvocationUtil.commitAndRunReadAction(getProject()) { EvaluatorBuilderImpl.build(TextWithImportsImpl( - codeFragmentKind, - text, - JetCodeFragment.getImportsForElement(contextElement), - JetFileType.INSTANCE), + codeFragmentKind, + text, + JetCodeFragment.getImportsForElement(contextElement), + JetFileType.INSTANCE), contextElement, sourcePosition) } @@ -151,7 +185,7 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestC Assert.assertTrue("Evaluate expression returns wrong result for $text:\nexpected = $expectedResult\nactual = $actualResult\n", expectedResult == actualResult) } catch (e: EvaluateException) { - Assert.assertTrue("Evaluate expression throws wrong exception for $text:\nexpected = $expectedResult\nactual = ${e.getMessage()}\n", expectedResult == e.getMessage()) + Assert.assertTrue("Evaluate expression throws wrong exception for $text:\nexpected = $expectedResult\nactual = ${e.getMessage()}\n", expectedResult == e.getMessage()?.replaceFirst("id=[0-9]*", "id=ID")) } finally { resume(this)