[debugger] Fix a couple of cases with invalid statistics reporting

IDEA-362361

(cherry picked from commit 7bdf1ca436e487c70eff2badde6f9531e3960e4b)


IJ-CR-151042

GitOrigin-RevId: 098cf93fb08e99d71ab75ad7e19cfd336533d6b9
This commit is contained in:
Alexey.Merkulov
2024-11-26 20:06:58 +01:00
committed by intellij-monorepo-bot
parent 4c5fca5bc6
commit a635619cd2
2 changed files with 9 additions and 2 deletions

View File

@@ -19,7 +19,7 @@ object KotlinDebuggerEvaluatorStatisticsCollector : CounterUsagesCollector() {
override fun getGroup(): EventLogGroup = GROUP
private val GROUP = EventLogGroup("kotlin.debugger.evaluator", 9)
private val GROUP = EventLogGroup("kotlin.debugger.evaluator", 10)
// fields
private val compilerField = EventFields.Enum<CompilerType>("compiler")
@@ -77,6 +77,7 @@ enum class StatisticsEvaluationResult {
COMPILER_INTERNAL_ERROR,
UNCLASSIFIED_COMPILATION_PROBLEM,
UNSUPPORTED_CALL, // Check KotlinEvaluator.calculateMainMethodCallArguments for examples
UNCLASSIFIED_EVALUATION_PROBLEM,
MISCOMPILED,
ERROR_DURING_PARSING_EXCEPTION,

View File

@@ -165,6 +165,7 @@ class KotlinEvaluator(val codeFragment: KtCodeFragment, private val sourcePositi
if (!hasCast && e.cause is ClassCastException) StatisticsEvaluationResult.MISCOMPILED
else StatisticsEvaluationResult.USER_EXCEPTION
e is EvaluateException && cause != null -> checkCauseOfEvaluateException(cause, hasCast)
e is EvaluateException -> StatisticsEvaluationResult.UNSUPPORTED_CALL
isSpecialException(e) -> StatisticsEvaluationResult.WRONG_JVM_STATE
else -> StatisticsEvaluationResult.UNCLASSIFIED_EVALUATION_PROBLEM
}
@@ -184,7 +185,7 @@ class KotlinEvaluator(val codeFragment: KtCodeFragment, private val sourcePositi
if (isApplicationInternalMode()) {
reportErrorWithAttachments(context, codeFragment, e,
prepareBytecodes(compiledData),
"Can't perform evaluation. Compiled by ${compiledData.compilerType} compiler")
"Can't perform evaluation: $errorType. Compiled by ${compiledData.compilerType} compiler")
}
}
throw e
@@ -196,6 +197,11 @@ class KotlinEvaluator(val codeFragment: KtCodeFragment, private val sourcePositi
try {
val exceptionFromCodeFragment = cause.exception()
val type = exceptionFromCodeFragment.type()
if (type.signature().equals("Ljava/lang/IllegalArgumentException;")) {
if (DebuggerUtils.tryExtractExceptionMessage(exceptionFromCodeFragment) == "argument type mismatch") {
return StatisticsEvaluationResult.MISCOMPILED
}
}
if (type.signature().startsWith("Ljava/lang/invoke/") || type.isSubTypeOrSame("java.lang.ReflectiveOperationException")) {
return StatisticsEvaluationResult.MISCOMPILED
}