Add Throwable.getStackTraceAddresses() extension
To allow integration with third-party crash analytic tools.
This commit is contained in:
committed by
SvyatoslavScherbina
parent
931f577db4
commit
47e231efc1
@@ -34,6 +34,9 @@ public open class Throwable(open val message: String?, open val cause: Throwable
|
||||
|
||||
public fun getStackTrace(): Array<String> = stackTraceStrings
|
||||
|
||||
internal fun Throwable.getStackTraceAddressesInternal(): List<Long> =
|
||||
(0 until stackTrace.size).map { index -> stackTrace[index].toLong() }
|
||||
|
||||
public fun printStackTrace(): Unit = dumpStackTrace { println(it) }
|
||||
|
||||
internal fun dumpStackTrace(): String = buildString {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package kotlin.native
|
||||
|
||||
public fun Throwable.getStackTraceAddresses(): List<Long> =
|
||||
this.getStackTraceAddressesInternal()
|
||||
@@ -52,6 +52,9 @@ internal class NativePtrArray {
|
||||
@SymbolName("Kotlin_NativePtrArray_set")
|
||||
external public operator fun set(index: Int, value: NativePtr): Unit
|
||||
|
||||
val size: Int
|
||||
get() = getArrayLength()
|
||||
|
||||
@SymbolName("Kotlin_NativePtrArray_getArrayLength")
|
||||
external private fun getArrayLength(): Int
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user