Fix Windows targets has bad addresses in stacktrace
^KT-49240 Fixed Merge-request: KT-MR-6883 Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
This commit is contained in:
@@ -2760,6 +2760,11 @@ standaloneTest("stack_trace_inline") {
|
||||
outputChecker = { str -> str.split("\n").contains("0") }
|
||||
}
|
||||
|
||||
standaloneTest("kt-49240-stack-trace-completeness") {
|
||||
disabled = !supportsExceptions(project) || project.globalTestArgs.contains('-opt')
|
||||
source = "runtime/exceptions/kt-49240-stack-trace-completeness.kt"
|
||||
}
|
||||
|
||||
standaloneTest("stack_trace_out_of_bounds") {
|
||||
disabled = !supportsCoreSymbolication(project) || project.globalTestArgs.contains('-opt') || (project.testTarget == 'ios_arm64')
|
||||
flags = ['-g', '-Xg-generate-debug-trampoline=enable', '-Xbinary=stripDebugInfoFromNativeLibs=false']
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
import kotlin.text.Regex
|
||||
import kotlin.test.*
|
||||
|
||||
var inlinesCount = 0
|
||||
|
||||
fun exception() {
|
||||
error("FAIL!")
|
||||
}
|
||||
|
||||
fun main() {
|
||||
try {
|
||||
exception()
|
||||
}
|
||||
catch (e:Exception) {
|
||||
val stackTrace = e.getStackTrace().filter { "kfun:" in it }
|
||||
println("Kotlin part of call stack is:")
|
||||
for (entry in stackTrace)
|
||||
println(entry)
|
||||
println("Verifying...")
|
||||
val goldValues = arrayOf(
|
||||
"kfun:kotlin.Throwable#<init>(kotlin.String?){}",
|
||||
"kfun:kotlin.Exception#<init>(kotlin.String?){}",
|
||||
"kfun:kotlin.RuntimeException#<init>(kotlin.String?){}",
|
||||
"kfun:kotlin.IllegalStateException#<init>(kotlin.String?){}",
|
||||
"kfun:#exception(){}",
|
||||
"kfun:#main(){}",
|
||||
)
|
||||
assertEquals(goldValues.size, stackTrace.size)
|
||||
goldValues.zip(stackTrace).forEach { checkFrame(it.first, it.second) }
|
||||
println("Passed")
|
||||
}
|
||||
}
|
||||
|
||||
internal val regex = Regex("(kfun.+) \\+ (\\d+)")
|
||||
internal fun checkFrame(goldFunName: String, actualLine: String) {
|
||||
val findResult = regex.find(actualLine)
|
||||
|
||||
val (funName, offset) = findResult?.destructured ?: throw Error("Cannot find '$goldFunName + <int>' in $actualLine")
|
||||
assertEquals(goldFunName, funName)
|
||||
assertTrue(offset.toInt() > 0)
|
||||
}
|
||||
Reference in New Issue
Block a user