CallStackSymbols
Formatted call stack symbols for iOS.
Installation
Supports Swift Package Manager.
Usage
Get current call stack symbols as DLADDR array.
let symbols = CallStackSymbols.current()
Thread.callStackSymbols
.
Parse raw string from let parser = CallStackSymbols.DLADDRParser()
let callStackSymbols = Thread.callStackSymbols
for callStackSymbol in callStackSymbols {
let dladdr = try parser.parse(input: callStackSymbol)
// ...
}
What is DLADDR?
DLADDR
is struct defined here.
This library internally call Thread.callStackSymbols
. Documentation of Thread.callStackSymbols
says Each element is an NSString object with a value in a format determined by the backtrace_symbols() function.
Information about backtrace_symbols()
can be seen by $ man backtrace_symbols
and manual says backtrace_symbols() attempts to transform a call stack obtained by backtrace() into an array of human-readable strings using dladdr().
Detail of dladdr()
can be seen by $ man dladdr
. The information treated by dladdr()
contains 2 set of name and address. The values returned value by Thread.callStackSymbols
cannot read as-is because raw value is array of string. So I defined struct DLADDR
and parse raw string into that formatted structure.