[codegeneration][debug info] enchance debugger behaviour for paramterless when

- generates tramboline like a11b07f6c3 on -Xg-generate-when-marker=enable
- fixes issue KT-33364
This commit is contained in:
Vasily Levchenko
2021-05-31 13:09:41 +02:00
parent 70924f6c15
commit bebede9e4f
5 changed files with 24 additions and 0 deletions
@@ -178,6 +178,15 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
null
}
})
putIfNotNull(GENERATE_WHEN_MARKER, when (val it = arguments.generateWhenMarkerString) {
"enable" -> true
"disable" -> false
null -> null
else -> {
configuration.report(ERROR, "Unsupported -Xg-generate-when-marker= value: $it. Possible values are 'enable'/'disable'")
null
}
})
put(STATIC_FRAMEWORK, selectFrameworkType(configuration, arguments, outputKind))
put(OVERRIDE_CLANG_OPTIONS, arguments.clangOptions.toNonNullList())
put(ALLOCATION_MODE, arguments.allocator)
@@ -171,6 +171,12 @@ class K2NativeCompilerArguments : CommonCompilerArguments() {
description = """generates marker of inlined function body on call site to make debugger breakpoint resolution more accurate"""
)
var generateInlinedFunctionMarkerString: String? = null
@Argument(
value = "-Xg-generate-when-marker",
valueDescription = "{disable|enable}",
description = """generates marker of when to make debugger breakpoint resolution more accurate"""
)
var generateWhenMarkerString: String? = null
@Argument(
@@ -44,6 +44,7 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
val lightDebug: Boolean = configuration.get(KonanConfigKeys.LIGHT_DEBUG)
?: target.family.isAppleFamily // Default is true for Apple targets.
val generateInlinedBodyTrampoline = debug && configuration.get(KonanConfigKeys.GENERATE_INLINED_FUNCTION_BODY_MARKER) ?: false
val generateWhenTrampoline = debug && configuration.get(KonanConfigKeys.GENERATE_WHEN_MARKER) ?: false
val memoryModel: MemoryModel get() = configuration.get(KonanConfigKeys.MEMORY_MODEL)!!
val destroyRuntimeMode: DestroyRuntimeMode get() = configuration.get(KonanConfigKeys.DESTROY_RUNTIME_MODE)!!
@@ -58,6 +58,8 @@ class KonanConfigKeys {
= CompilerConfigurationKey.create("add light debug information")
val GENERATE_INLINED_FUNCTION_BODY_MARKER: CompilerConfigurationKey<Boolean?>
= CompilerConfigurationKey.create("generates inlined function body marker on call site")
val GENERATE_WHEN_MARKER: CompilerConfigurationKey<Boolean?>
= CompilerConfigurationKey.create("generates when marker on call site")
val LINKER_ARGS: CompilerConfigurationKey<List<String>>
= CompilerConfigurationKey.create("additional linker arguments")
val LIST_PHASES: CompilerConfigurationKey<Boolean>
@@ -1177,6 +1177,12 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
val whenEmittingContext = WhenEmittingContext(expression)
val generationContext = (currentCodeContext.functionScope() as? FunctionScope)?.functionGenerationContext
.takeIf { context.config.generateWhenTrampoline }
generationContext?.basicBlock("when", expression.startLocation)?.let {
generationContext.br(it)
generationContext.positionAtEnd(it)
}
expression.branches.forEach {
val bbNext = if (it == expression.branches.last())
null