[coroutine][debugger] refactoring being done

X-view approach added for review, thread groups added
This commit is contained in:
Vladimir Ilmov
2019-11-20 13:17:17 +03:00
committed by Vladimir Ilmov
parent 7f0437da68
commit 61c5ef61cc
43 changed files with 2302 additions and 1486 deletions
@@ -18,6 +18,7 @@ import com.intellij.debugger.jdi.VirtualMachineProxyImpl
import com.intellij.openapi.project.Project
import com.sun.jdi.*
import com.sun.jdi.request.EventRequest
import org.jetbrains.kotlin.idea.debugger.hopelessAware
import org.jetbrains.org.objectweb.asm.Type
class ExecutionContext(val evaluationContext: EvaluationContextImpl, val frameProxy: StackFrameProxyImpl) {
@@ -100,4 +101,65 @@ class ExecutionContext(val evaluationContext: EvaluationContextImpl, val framePr
@Suppress("DEPRECATION")
DebuggerUtilsEx.keep(reference, evaluationContext)
}
}
fun findClassSafe(className: String): ClassType? =
hopelessAware { findClass(className) as? ClassType }
fun invokeMethodAsString(instance: ObjectReference, methodName: String): String? =
(findAndInvoke(instance, instance.referenceType(), methodName, "()Ljava/lang/String;") as? StringReference)?.value() ?: null
fun invokeMethodAsInt(instance: ObjectReference, methodName: String): Int? =
(findAndInvoke(instance, instance.referenceType(), methodName, "()I") as? IntegerValue)?.value() ?: null
fun invokeMethodAsObject(type: ClassType, methodName: String, vararg params: Value): ObjectReference? =
invokeMethodAsObject(type, methodName, null, *params)
fun invokeMethodAsObject(type: ClassType, methodName: String, methodSignature: String?, vararg params: Value): ObjectReference? =
findAndInvoke(type, methodName, methodSignature, *params) as? ObjectReference
fun invokeMethodAsObject(instance: ObjectReference, methodName: String, vararg params: Value): ObjectReference? =
invokeMethodAsObject(instance, methodName, null, *params)
fun invokeMethodAsObject(instance: ObjectReference, methodName: String, methodSignature: String?, vararg params: Value): ObjectReference? =
findAndInvoke(instance, methodName, methodSignature, *params) as? ObjectReference
fun invokeMethodAsObject(instance: ObjectReference, method: Method, vararg params: Value): ObjectReference? =
invokeMethod(instance, method, params.asList()) as? ObjectReference
fun invokeMethodAsVoid(type: ClassType, methodName: String, methodSignature: String? = null, vararg params: Value = emptyArray()) =
findAndInvoke(type, methodName, methodSignature, *params)
fun invokeMethodAsVoid(instance: ObjectReference, methodName: String, methodSignature: String? = null, vararg params: Value = emptyArray()) =
findAndInvoke(instance, methodName, methodSignature, *params)
fun invokeMethodAsArray(instance: ClassType, methodName: String, methodSignature: String, vararg params: Value): ArrayReference? =
findAndInvoke(instance, methodName, methodSignature, *params) as? ArrayReference
private fun findAndInvoke(ref: ObjectReference, type: ReferenceType, name: String, methodSignature: String, vararg params: Value): Value? {
val method = type.methodsByName(name, methodSignature).single()
return invokeMethod(ref, method, params.asList())
}
/**
* static method invocation
*/
fun findAndInvoke(type: ClassType, name: String, methodSignature: String? = null, vararg params: Value): Value? {
val method =
if (methodSignature is String)
type.methodsByName(name, methodSignature).single()
else
type.methodsByName(name).single()
return invokeMethod(type, method, params.asList())
}
fun findAndInvoke(instance: ObjectReference, name: String, methodSignature: String? = null, vararg params: Value): Value? {
val type = instance.referenceType()
val method =
if (methodSignature is String)
type.methodsByName(name, methodSignature).single()
else
type.methodsByName(name).single()
return invokeMethod(instance, method, params.asList())
}
}