[K/N] Add opt-in flag to use debug info from native libs

Unfortunately, llvm removes full debug info from module on any error.
Different version debug info in bitcode is not always compatible, also
it adds this debug info additional requirements on generated debug info.

So this feature is quite unstable and shouldn't be enabled by default,
although it has almost no downsides when worked correctly.
This commit is contained in:
Pavel Kunyavskiy
2021-08-25 16:56:08 +03:00
committed by Space
parent 18f1610442
commit 98e4d67900
9 changed files with 58 additions and 1 deletions
@@ -0,0 +1,37 @@
import kotlin.text.Regex
import kotlin.test.*
fun main() {
try {
val array = intArrayOf(1, 2, 3, 4)
println(array[4])
}
catch (e:Exception) {
val stackTrace = e.getStackTrace()
stackTrace.take(goldValues.size).forEach(::checkFrame)
}
}
internal val regex = Regex("^(\\d+)\\ +.*/(.*):(\\d+):.*$")
internal val goldValues = arrayOf(
"Throwable.kt" to null,
"Exceptions.kt" to null,
"Exceptions.kt" to null,
"Exceptions.kt" to null,
"Exceptions.kt" to null,
"RuntimeUtils.kt" to null,
"Arrays.cpp" to null,
"stack_trace_out_of_bounds.kt" to 7,
"stack_trace_out_of_bounds.kt" to 4,
"launcher.cpp" to null,
)
internal fun checkFrame(value:String) {
val (pos, file, line) = regex.find(value)!!.destructured
goldValues[pos.toInt()]?.let{
assertEquals(it.first, file)
if (it.second != null) {
assertEquals(it.second, line.toInt())
}
}
}