[swift-evolution] Print stack trace for fatalError
Greg Parker
gparker at apple.com
Wed Dec 9 00:25:08 CST 2015
> On Dec 7, 2015, at 1:47 PM, Harlan Haskins via swift-evolution <swift-evolution at swift.org> wrote:
>
> Is there even a way to display the call stack symbols in pure Swift without NSThread.callStackSymbols()?
backtrace(3) and backtrace_symbols(3) should work on OS X. I expect other platforms have equivalents. Calling them from Swift would probably be unpleasant, but the right place to implement this is in stdlib/public/runtime/Errors.cpp.
Be warned that you may not like the results.
First, you'll need to demangle Swift and C++ symbols if you want something human-readable.
Second, on some platforms any backtrace collected in-process will be missing lots of symbol names. For example, on current iOS you would see "<redacted>" for most frames inside the system frameworks. The symbol names can be recovered, but you need to record additional data to make that work. In iOS crash logs the additional data required is the "Binary Images" section. Recording that data and recovering the symbol names is easy for a debugger or crash reporter, but would be hard for Swift to do.
--
Greg Parker gparker at apple.com Runtime Wrangler
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151208/9c45f0f4/attachment.html>
More information about the swift-evolution
mailing list