[K/N] More localized debug info rejection is supported

Sometimes plugins generate code with UNDEFINED_OFFSET debug info.
Probably, we can't control it, and just need to deal with it.

^KT-53667
This commit is contained in:
Pavel Kunyavskiy
2022-08-19 16:46:26 +02:00
committed by Space
parent 55e1061862
commit c279facc28
2 changed files with 8 additions and 12 deletions
@@ -1,6 +1,6 @@
/* /*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* that can be found in the LICENSE file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
package org.jetbrains.kotlin.backend.konan.llvm package org.jetbrains.kotlin.backend.konan.llvm
@@ -96,8 +96,8 @@ internal class DebugInfo internal constructor(override val context: Context):Con
*/ */
private val NO_SOURCE_FILE = "no source file" private val NO_SOURCE_FILE = "no source file"
private fun IrFileEntry.location(offset: Int, offsetToNumber: (Int) -> Int): Int { private fun IrFileEntry.location(offset: Int, offsetToNumber: (Int) -> Int): Int {
assert(offset != UNDEFINED_OFFSET)
// Part "name.isEmpty() || name == NO_SOURCE_FILE" is an awful hack, @minamoto, please fix properly. // Part "name.isEmpty() || name == NO_SOURCE_FILE" is an awful hack, @minamoto, please fix properly.
if (offset == UNDEFINED_OFFSET) return 0
if (offset == SYNTHETIC_OFFSET || name.isEmpty() || name == NO_SOURCE_FILE) return 1 if (offset == SYNTHETIC_OFFSET || name.isEmpty() || name == NO_SOURCE_FILE) return 1
// lldb uses 1-based unsigned integers, so 0 is "no-info". // lldb uses 1-based unsigned integers, so 0 is "no-info".
val result = offsetToNumber(offset) + 1 val result = offsetToNumber(offset) + 1
@@ -1,6 +1,6 @@
/* /*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* that can be found in the LICENSE file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
package org.jetbrains.kotlin.backend.konan.llvm package org.jetbrains.kotlin.backend.konan.llvm
@@ -2167,11 +2167,11 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
} }
private val IrElement.startLocation: LocationInfo? private val IrElement.startLocation: LocationInfo?
get() = if (!context.shouldContainLocationDebugInfo() || startOffset == UNDEFINED_OFFSET) null get() = if (!context.shouldContainLocationDebugInfo()) null
else currentCodeContext.location(startOffset) else currentCodeContext.location(startOffset)
private val IrElement.endLocation: LocationInfo? private val IrElement.endLocation: LocationInfo?
get() = if (!context.shouldContainLocationDebugInfo() || startOffset == UNDEFINED_OFFSET) null get() = if (!context.shouldContainLocationDebugInfo()) null
else currentCodeContext.location(endOffset) else currentCodeContext.location(endOffset)
//-------------------------------------------------------------------------// //-------------------------------------------------------------------------//
@@ -2974,11 +2974,7 @@ private fun Name.debugNameConversion(): Name = when(this) {
internal class LocationInfo(val scope: DIScopeOpaqueRef, internal class LocationInfo(val scope: DIScopeOpaqueRef,
val line: Int, val line: Int,
val column: Int, val column: Int,
val inlinedAt: LocationInfo? = null) { val inlinedAt: LocationInfo? = null)
init {
assert(line != 0)
}
}
internal fun Context.generateRuntimeConstantsModule() : LLVMModuleRef { internal fun Context.generateRuntimeConstantsModule() : LLVMModuleRef {
val llvmModule = LLVMModuleCreateWithNameInContext("constants", llvmContext)!! val llvmModule = LLVMModuleCreateWithNameInContext("constants", llvmContext)!!