Debugger: Hide call-site 'this' in inline functions in Kotlin variables mode (KT-30610)

This commit is contained in:
Yan Zhulanow
2019-03-27 22:02:00 +03:00
parent 6dcaa64793
commit b7ea4ccc7e
8 changed files with 59 additions and 7 deletions
@@ -111,6 +111,24 @@ class KotlinStackFrame(frame: StackFrameProxyImpl) : JavaStackFrame(StackFrameDe
return true
}
return removeCallSiteThisInInlineFunction(evaluationContext, children)
}
private fun removeCallSiteThisInInlineFunction(evaluationContext: EvaluationContextImpl, children: XValueChildrenList): Boolean {
val frameProxy = evaluationContext.frameProxy
val variables = frameProxy?.safeVisibleVariables() ?: return false
val inlineDepth = VariableFinder.getInlineDepth(variables)
val declarationSiteThis = variables.firstOrNull { v ->
val name = v.name()
name.endsWith(INLINE_FUN_VAR_SUFFIX) && name.dropInlineSuffix() == AsmUtil.INLINE_DECLARATION_SITE_THIS
}
if (inlineDepth > 0 && declarationSiteThis != null) {
ExistingInstanceThis.find(children)?.remove()
return true
}
return false
}
@@ -75,10 +75,7 @@ class VariableFinder(private val context: ExecutionContext) {
return EvaluateExceptionUtil.createEvaluateException(message)
}
// org.jetbrains.kotlin.codegen.inline.MethodInliner.prepareNode
private const val OUTER_THIS_FOR_INLINE = AsmUtil.THIS + '_'
val inlinedThisRegex = getLocalVariableNameRegexInlineAware(OUTER_THIS_FOR_INLINE)
val inlinedThisRegex = getLocalVariableNameRegexInlineAware(AsmUtil.INLINE_DECLARATION_SITE_THIS)
private fun getCapturedVariableNameRegex(capturedName: String): Regex {
val escapedName = Regex.escape(capturedName)