Debugger: Do not disable breakpoints on evaluation (KT-12242)
This commit is contained in:
+26
-27
@@ -330,7 +330,19 @@ class KotlinEvaluator(val codeFragment: KtCodeFragment, private val sourcePositi
|
||||
val thread = context.suspendContext.thread?.threadReference?.takeIf { it.isSuspended }
|
||||
?: error("Can not find a thread to run evaluation on")
|
||||
|
||||
val eval = JDIEval(vm, classLoader, thread, context.invokePolicy)
|
||||
val eval = object : JDIEval(vm, classLoader, thread, context.invokePolicy) {
|
||||
override fun jdiInvokeStaticMethod(type: ClassType, method: Method, args: List<Value?>, invokePolicy: Int): Value? {
|
||||
return context.invokeMethod(type, method, args)
|
||||
}
|
||||
|
||||
override fun jdiInvokeStaticMethod(type: InterfaceType, method: Method, args: List<Value?>, invokePolicy: Int): Value? {
|
||||
return context.invokeMethod(type, method, args)
|
||||
}
|
||||
|
||||
override fun jdiInvokeMethod(obj: ObjectReference, method: Method, args: List<Value?>, policy: Int): Value? {
|
||||
return context.invokeMethod(obj, method, args, ObjectReference.INVOKE_NONVIRTUAL)
|
||||
}
|
||||
}
|
||||
interpreterLoop(mainMethod, makeInitialFrame(mainMethod, args.map { it.asValue() }), eval)
|
||||
}
|
||||
}
|
||||
@@ -347,22 +359,20 @@ class KotlinEvaluator(val codeFragment: KtCodeFragment, private val sourcePositi
|
||||
.filter { !it.isMainClass }
|
||||
.forEach { context.findClass(it.className, classLoader) }
|
||||
|
||||
return context.vm.virtualMachine.executeWithBreakpointsDisabled {
|
||||
for (parameterType in compiledData.mainMethodSignature.parameterTypes) {
|
||||
context.findClass(parameterType, classLoader)
|
||||
}
|
||||
|
||||
val variableFinder = VariableFinder(context)
|
||||
val args = calculateMainMethodCallArguments(variableFinder, compiledData, status)
|
||||
|
||||
val result = block(args)
|
||||
|
||||
for (wrapper in variableFinder.refWrappers) {
|
||||
updateLocalVariableValue(variableFinder.evaluatorValueConverter, wrapper)
|
||||
}
|
||||
|
||||
return@executeWithBreakpointsDisabled result
|
||||
for (parameterType in compiledData.mainMethodSignature.parameterTypes) {
|
||||
context.findClass(parameterType, classLoader)
|
||||
}
|
||||
|
||||
val variableFinder = VariableFinder(context)
|
||||
val args = calculateMainMethodCallArguments(variableFinder, compiledData, status)
|
||||
|
||||
val result = block(args)
|
||||
|
||||
for (wrapper in variableFinder.refWrappers) {
|
||||
updateLocalVariableValue(variableFinder.evaluatorValueConverter, wrapper)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
private fun updateLocalVariableValue(converter: EvaluatorValueConverter, ref: VariableFinder.RefWrapper) {
|
||||
@@ -465,17 +475,6 @@ class KotlinEvaluator(val codeFragment: KtCodeFragment, private val sourcePositi
|
||||
}
|
||||
}
|
||||
|
||||
private fun <T> VirtualMachine.executeWithBreakpointsDisabled(block: () -> T): T {
|
||||
val allRequests = eventRequestManager().breakpointRequests() + eventRequestManager().classPrepareRequests()
|
||||
|
||||
try {
|
||||
allRequests.forEach { it.disable() }
|
||||
return block()
|
||||
} finally {
|
||||
allRequests.forEach { it.enable() }
|
||||
}
|
||||
}
|
||||
|
||||
private fun isSpecialException(th: Throwable): Boolean {
|
||||
return when (th) {
|
||||
is ClassNotPreparedException,
|
||||
|
||||
Reference in New Issue
Block a user