From a635619cd208a01714176ab6bd9c4b03f856ff87 Mon Sep 17 00:00:00 2001 From: "Alexey.Merkulov" Date: Tue, 26 Nov 2024 20:06:58 +0100 Subject: [PATCH] [debugger] Fix a couple of cases with invalid statistics reporting IDEA-362361 (cherry picked from commit 7bdf1ca436e487c70eff2badde6f9531e3960e4b) IJ-CR-151042 GitOrigin-RevId: 098cf93fb08e99d71ab75ad7e19cfd336533d6b9 --- .../KotlinDebuggerEvaluatorStatisticsCollector.kt | 3 ++- .../idea/debugger/evaluate/KotlinEvaluatorBuilder.kt | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/kotlin/jvm-debugger/evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinDebuggerEvaluatorStatisticsCollector.kt b/plugins/kotlin/jvm-debugger/evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinDebuggerEvaluatorStatisticsCollector.kt index f3d0d7a882d6..f9a85d1759f4 100644 --- a/plugins/kotlin/jvm-debugger/evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinDebuggerEvaluatorStatisticsCollector.kt +++ b/plugins/kotlin/jvm-debugger/evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinDebuggerEvaluatorStatisticsCollector.kt @@ -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("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, diff --git a/plugins/kotlin/jvm-debugger/evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluatorBuilder.kt b/plugins/kotlin/jvm-debugger/evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluatorBuilder.kt index cd05c6808d40..f5c9ed9645e1 100644 --- a/plugins/kotlin/jvm-debugger/evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluatorBuilder.kt +++ b/plugins/kotlin/jvm-debugger/evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluatorBuilder.kt @@ -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 }