[swift-users] Automatically dump stack trace on trap
Karl Pickett
karl.pickett at gmail.com
Tue Dec 22 18:32:23 CST 2015
Having stack traces on critical faults is an "enterprisey" feature that I
like. It would be nice if swift allowed customization of what happened on
a trap (like array out of bounds), so it dumped the thread's stack trace to
stderr before exiting.
I can simulate the desired behavior by installing a signal handler for
SIGILL, and launch a script that fires up a debugger which attaches to the
process and dumps the stack trace(s) before terminating it.
I wrote it in C pretty easily and it is here:
https://gist.github.com/kjpgit/9a1059a5960694767193
It's just a small pain to build and link the C code to each swift project.
So my question is, can I use pure swift code for the signal handling
instead of that C shim.
1) Does swift on linux support an atomic_fetch_add() equivalent out of the
box (or some other signal-safe serialization)
2) Any other concerns using swift code in a signal handler. I'd just be
using Glibc system calls, and any char data would be pre-allocated.
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20151222/7a6fe5e8/attachment.html>
More information about the swift-users
mailing list