Implemented printing stack trace
This commit is contained in:
parent
61d9923230
commit
b6561debb0
|
@ -7,9 +7,13 @@ expect class Thread() {
|
|||
|
||||
val current: Thread
|
||||
|
||||
fun printCurrentThreadStackTrace()
|
||||
|
||||
}
|
||||
|
||||
|
||||
val threadName: String
|
||||
|
||||
fun printStackTrace()
|
||||
|
||||
}
|
|
@ -11,6 +11,11 @@ actual class Thread(private val thread: NSThread) {
|
|||
actual val current: Thread
|
||||
get() = Thread(NSThread.currentThread)
|
||||
|
||||
|
||||
actual fun printCurrentThreadStackTrace() {
|
||||
Thread.current.printStackTrace()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,4 +35,13 @@ actual class Thread(private val thread: NSThread) {
|
|||
?: "Could not retrieve thread's name"
|
||||
}
|
||||
|
||||
|
||||
actual fun printStackTrace() {
|
||||
println("Stack trace of $threadName")
|
||||
|
||||
NSThread.callStackSymbols.forEach { callStackSymbol ->
|
||||
println(callStackSymbol)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -8,6 +8,11 @@ actual class Thread(private val thread: java.lang.Thread) : java.lang.Thread() {
|
|||
actual val current: Thread
|
||||
get() = Thread(currentThread())
|
||||
|
||||
|
||||
actual fun printCurrentThreadStackTrace() {
|
||||
Thread.current.printStackTrace()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,4 +22,13 @@ actual class Thread(private val thread: java.lang.Thread) : java.lang.Thread() {
|
|||
actual val threadName: String
|
||||
get() = thread.name
|
||||
|
||||
|
||||
actual fun printStackTrace() {
|
||||
println("Stack trace of $threadName")
|
||||
|
||||
thread.stackTrace.forEachIndexed { index, stackTraceElement ->
|
||||
println("[$index] $stackTraceElement")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue