Debugger: Handle exceptions in async stack trace handler more gracefully (EA-141924)
This commit is contained in:
+16
-2
@@ -15,6 +15,7 @@ import com.intellij.debugger.jdi.GeneratedLocation
|
|||||||
import com.intellij.debugger.jdi.StackFrameProxyImpl
|
import com.intellij.debugger.jdi.StackFrameProxyImpl
|
||||||
import com.intellij.debugger.memory.utils.StackFrameItem
|
import com.intellij.debugger.memory.utils.StackFrameItem
|
||||||
import com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl
|
import com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl
|
||||||
|
import com.intellij.openapi.diagnostic.Logger
|
||||||
import com.intellij.xdebugger.frame.XNamedValue
|
import com.intellij.xdebugger.frame.XNamedValue
|
||||||
import com.sun.jdi.*
|
import com.sun.jdi.*
|
||||||
import org.jetbrains.kotlin.codegen.coroutines.CONTINUATION_VARIABLE_NAME
|
import org.jetbrains.kotlin.codegen.coroutines.CONTINUATION_VARIABLE_NAME
|
||||||
@@ -24,6 +25,8 @@ class KotlinCoroutinesAsyncStackTraceProvider : KotlinCoroutinesAsyncStackTraceP
|
|||||||
private companion object {
|
private companion object {
|
||||||
const val DEBUG_METADATA_KT = "kotlin.coroutines.jvm.internal.DebugMetadataKt"
|
const val DEBUG_METADATA_KT = "kotlin.coroutines.jvm.internal.DebugMetadataKt"
|
||||||
|
|
||||||
|
private val LOG = Logger.getInstance(this::class.java)
|
||||||
|
|
||||||
tailrec fun findBaseContinuationSuperSupertype(type: ClassType): ClassType? {
|
tailrec fun findBaseContinuationSuperSupertype(type: ClassType): ClassType? {
|
||||||
if (type.name() == "kotlin.coroutines.jvm.internal.BaseContinuationImpl") {
|
if (type.name() == "kotlin.coroutines.jvm.internal.BaseContinuationImpl") {
|
||||||
return type
|
return type
|
||||||
@@ -34,10 +37,21 @@ class KotlinCoroutinesAsyncStackTraceProvider : KotlinCoroutinesAsyncStackTraceP
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getAsyncStackTrace(stackFrame: JavaStackFrame, suspendContext: SuspendContextImpl): List<StackFrameItem>? {
|
override fun getAsyncStackTrace(stackFrame: JavaStackFrame, suspendContext: SuspendContextImpl): List<StackFrameItem>? {
|
||||||
return getAsyncStackTrace(stackFrame.stackFrameProxy, suspendContext)
|
return try {
|
||||||
|
getAsyncStackTraceSafe(stackFrame.stackFrameProxy, suspendContext)
|
||||||
|
} catch (e: ObjectCollectedException) {
|
||||||
|
null
|
||||||
|
} catch (e: IncompatibleThreadStateException) {
|
||||||
|
null
|
||||||
|
} catch (e: VMDisconnectedException) {
|
||||||
|
null
|
||||||
|
} catch (e: EvaluateException) {
|
||||||
|
LOG.debug("Cannot evaluate async stack trace", e)
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAsyncStackTrace(frameProxy: StackFrameProxyImpl, suspendContext: SuspendContextImpl): List<StackFrameItem>? {
|
fun getAsyncStackTraceSafe(frameProxy: StackFrameProxyImpl, suspendContext: SuspendContextImpl): List<StackFrameItem>? {
|
||||||
val location = frameProxy.location()
|
val location = frameProxy.location()
|
||||||
if (!location.isInKotlinSources()) {
|
if (!location.isInKotlinSources()) {
|
||||||
return null
|
return null
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ abstract class AbstractAsyncStackTraceTest : KotlinDebuggerTestBase() {
|
|||||||
val frameProxy = this.frameProxy
|
val frameProxy = this.frameProxy
|
||||||
if (frameProxy != null) {
|
if (frameProxy != null) {
|
||||||
try {
|
try {
|
||||||
val stackTrace = asyncStackTraceProvider.getAsyncStackTrace(frameProxy, this)
|
val stackTrace = asyncStackTraceProvider.getAsyncStackTraceSafe(frameProxy, this)
|
||||||
if (stackTrace != null && stackTrace.isNotEmpty()) {
|
if (stackTrace != null && stackTrace.isNotEmpty()) {
|
||||||
print(renderAsyncStackTrace(stackTrace), ProcessOutputTypes.SYSTEM)
|
print(renderAsyncStackTrace(stackTrace), ProcessOutputTypes.SYSTEM)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user