Debugger: Gracefully handle debugger exceptions we can't do anything reasonable with (EA-128154, EA-139473)

This commit is contained in:
Yan Zhulanow
2019-07-24 17:48:58 +09:00
parent 70745f233f
commit 17c3406097
4 changed files with 44 additions and 26 deletions
@@ -25,8 +25,6 @@ class KotlinCoroutinesAsyncStackTraceProvider : KotlinCoroutinesAsyncStackTraceP
private companion object {
const val DEBUG_METADATA_KT = "kotlin.coroutines.jvm.internal.DebugMetadataKt"
private val LOG = Logger.getInstance(this::class.java)
tailrec fun findBaseContinuationSuperSupertype(type: ClassType): ClassType? {
if (type.name() == "kotlin.coroutines.jvm.internal.BaseContinuationImpl") {
return type
@@ -37,25 +35,7 @@ class KotlinCoroutinesAsyncStackTraceProvider : KotlinCoroutinesAsyncStackTraceP
}
override fun getAsyncStackTrace(stackFrame: JavaStackFrame, suspendContext: SuspendContextImpl): List<StackFrameItem>? {
return try {
getAsyncStackTraceSafe(stackFrame.stackFrameProxy, suspendContext)
} catch (e: Exception) {
handleException(e)
null
}
}
private fun handleException(e: Exception) {
when (if (e is EvaluateException) e.cause ?: e else e) {
is ObjectCollectedException, is IncompatibleThreadStateException, is VMDisconnectedException -> {}
else -> {
if (e is EvaluateException) {
LOG.debug("Cannot evaluate async stack trace", e)
} else {
throw e
}
}
}
return hopelessAware { getAsyncStackTraceSafe(stackFrame.stackFrameProxy, suspendContext) }
}
fun getAsyncStackTraceSafe(frameProxy: StackFrameProxyImpl, suspendContext: SuspendContextImpl): List<StackFrameItem>? {
@@ -284,7 +284,7 @@ class KotlinPositionManager(private val myDebugProcess: DebugProcess) : MultiReq
val psiFile = sourcePosition.file
if (psiFile is KtFile) {
if (!ProjectRootsUtil.isInProjectOrLibSource(psiFile)) return emptyList()
return DebuggerClassNameProvider(myDebugProcess).getClassesForPosition(sourcePosition)
return hopelessAware { DebuggerClassNameProvider(myDebugProcess).getClassesForPosition(sourcePosition) } ?: emptyList()
}
if (psiFile is ClsFileImpl) {