Evaluate expression: switch off breakpoints during eval4j run

This commit is contained in:
Natalia Ukhorskaya
2014-09-23 12:52:56 +04:00
parent e1c7ad50d6
commit 8ad18df3fa
4 changed files with 34 additions and 0 deletions
@@ -161,6 +161,9 @@ class KotlinEvaluator(val codeFragment: JetCodeFragment,
val args = context.getArgumentsForEval4j(compiledData.parameters.getParameterNames(), Type.getArgumentTypes(desc))
return object : MethodNode(Opcodes.ASM5, access, name, desc, signature, exceptions) {
override fun visitEnd() {
val breakpoints = virtualMachine.eventRequestManager().breakpointRequests()
breakpoints?.forEach { it.disable() }
resultValue = interpreterLoop(
this,
makeInitialFrame(this, args),
@@ -169,6 +172,8 @@ class KotlinEvaluator(val codeFragment: JetCodeFragment,
context.getSuspendContext().getThread()?.getThreadReference()!!,
context.getSuspendContext().getInvokePolicy())
)
breakpoints?.forEach { it.enable() }
}
}
}
@@ -0,0 +1,9 @@
LineBreakpoint created at methodWithBreakpoint.kt:5
LineBreakpoint created at methodWithBreakpoint.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!;!CUSTOM_LIBRARY!;!RT_JAR! methodWithBreakpoint.MethodWithBreakpointPackage
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
methodWithBreakpoint.kt:4
Compile bytecode for foo()
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
Process finished with exit code 0
@@ -0,0 +1,14 @@
package methodWithBreakpoint
fun main(args: Array<String>) {
//Breakpoint!
args.size
}
fun foo(): Int {
//Breakpoint!
return 1
}
// EXPRESSION: foo()
// RESULT: 1: I
@@ -144,6 +144,12 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat
doSingleBreakpointTest(fileName);
}
@TestMetadata("methodWithBreakpoint.kt")
public void testMethodWithBreakpoint() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/methodWithBreakpoint.kt");
doSingleBreakpointTest(fileName);
}
@TestMetadata("multilineExpressionAtBreakpoint.kt")
public void testMultilineExpressionAtBreakpoint() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/multilineExpressionAtBreakpoint.kt");