[codegeneration][debug info] generates marker of inlined function body on call site

- makes debuger breakpoint resolution more accurate
- restore expected behavior stack_trace_inline test
- fixes kt-33055
This commit is contained in:
Vasily Levchenko
2021-03-25 17:39:37 +01:00
committed by Space
parent 585e4254a0
commit a11b07f6c3
5 changed files with 26 additions and 1 deletions
@@ -169,6 +169,15 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
null
}
})
putIfNotNull(GENERATE_INLINED_FUNCTION_BODY_MARKER, when (val it = arguments.generateInlinedFunctionMarkerString) {
"enable" -> true
"disable" -> false
null -> null
else -> {
configuration.report(ERROR, "Unsupported -Xg-generate-inline-function-body-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)
@@ -165,6 +165,14 @@ class K2NativeCompilerArguments : CommonCompilerArguments() {
@Argument(value = "-Xg0", description = "Add light debug information. Deprecated option. Please use instead -Xadd-light-debug=enable")
var lightDebugDeprecated: Boolean = false
@Argument(
value = "-Xg-generate-inline-function-body-marker",
valueDescription = "{disable|enable}",
description = """generates marker of inlined function body on call site to make debugger breakpoint resolution more accurate"""
)
var generateInlinedFunctionMarkerString: String? = null
@Argument(
value = MAKE_CACHE,
valueDescription = "<path>",
@@ -43,6 +43,7 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
val debug: Boolean get() = configuration.getBoolean(KonanConfigKeys.DEBUG)
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 memoryModel: MemoryModel get() = configuration.get(KonanConfigKeys.MEMORY_MODEL)!!
val destroyRuntimeMode: DestroyRuntimeMode get() = configuration.get(KonanConfigKeys.DESTROY_RUNTIME_MODE)!!
@@ -56,6 +56,8 @@ class KonanConfigKeys {
= CompilerConfigurationKey.create("library version")
val LIGHT_DEBUG: CompilerConfigurationKey<Boolean?>
= 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 LINKER_ARGS: CompilerConfigurationKey<List<String>>
= CompilerConfigurationKey.create("additional linker arguments")
val LIST_PHASES: CompilerConfigurationKey<Boolean>
@@ -1823,11 +1823,16 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
}
//-------------------------------------------------------------------------//
private fun evaluateReturnableBlock(value: IrReturnableBlock): LLVMValueRef {
context.log{"evaluateReturnableBlock : ${value.statements.forEach { ir2string(it) }}"}
val returnableBlockScope = ReturnableBlockScope(value)
val generationContext = (currentCodeContext.functionScope() as? FunctionScope)?.functionGenerationContext
.takeIf { context.config.generateInlinedBodyTrampoline }
generationContext?.basicBlock("inline", value.startLocation)?.let {
generationContext.br(it)
generationContext.positionAtEnd(it)
}
using(returnableBlockScope) {
using(VariableScope()) {
value.statements.forEach {