From c279facc2846fdf46f07c691a32af6b9b4da5506 Mon Sep 17 00:00:00 2001 From: Pavel Kunyavskiy Date: Fri, 19 Aug 2022 16:46:26 +0200 Subject: [PATCH] [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 --- .../kotlin/backend/konan/llvm/DebugUtils.kt | 6 +++--- .../kotlin/backend/konan/llvm/IrToBitcode.kt | 14 +++++--------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/DebugUtils.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/DebugUtils.kt index 8886bdd59c8..ea3c8545890 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/DebugUtils.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/DebugUtils.kt @@ -1,6 +1,6 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. + * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * 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 @@ -96,8 +96,8 @@ internal class DebugInfo internal constructor(override val context: Context):Con */ private val NO_SOURCE_FILE = "no source file" 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. + if (offset == UNDEFINED_OFFSET) return 0 if (offset == SYNTHETIC_OFFSET || name.isEmpty() || name == NO_SOURCE_FILE) return 1 // lldb uses 1-based unsigned integers, so 0 is "no-info". val result = offsetToNumber(offset) + 1 diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt index 95f8999b47d..3f14c41cc0c 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt @@ -1,6 +1,6 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. + * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * 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 @@ -2167,11 +2167,11 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map