Debugger: Support synchronized blocks and functions in evaluator (KT-11888)

This commit is contained in:
Yan Zhulanow
2019-04-16 20:15:20 +03:00
parent 55bbcc4601
commit ee0daae2ab
5 changed files with 49 additions and 0 deletions
@@ -20,6 +20,7 @@ import com.sun.jdi.ArrayReference
import com.sun.jdi.ArrayType
import com.sun.jdi.ClassLoaderReference
import com.sun.jdi.Value
import jdk.internal.org.objectweb.asm.Opcodes
import org.jetbrains.kotlin.idea.debugger.evaluate.ExecutionContext
import org.jetbrains.org.objectweb.asm.ClassReader
import org.jetbrains.org.objectweb.asm.Label
@@ -63,6 +64,7 @@ interface ClassLoadingAdapter {
private fun analyzeClass(classToLoad: ClassToLoad, info: ClassInfoForEvaluator): ClassInfoForEvaluator {
val classNode = ClassNode().apply { ClassReader(classToLoad.bytes).accept(this, 0) }
val methodToRun = classNode.methods.single { it.name == GENERATED_FUNCTION_NAME }
val visitedLabels = hashSetOf<Label>()
@@ -78,6 +80,11 @@ interface ClassLoadingAdapter {
is TableSwitchInsnNode, is LookupSwitchInsnNode -> {
return info.copy(containsCodeUnsupportedInEval4J = true)
}
is InsnNode -> {
if (insn.opcode == Opcodes.MONITORENTER || insn.opcode == Opcodes.MONITOREXIT) {
return info.copy(containsCodeUnsupportedInEval4J = true)
}
}
}
val nextInsn = insn.next ?: return info