Print stack trace for fatalError

+ 1. This should also be generalized to assert, precondition, etc. If there was a way for custom fatalError-like functions to also dump a stack trace, that would be great.

Is there even a way to display the call stack symbols in pure Swift without NSThread.callStackSymbols()?

···

On Dec 7, 2015, at 4:24 PM, Radoslaw Pietruszewski via swift-evolution <swift-evolution@swift.org> wrote:

+ 1. This should also be generalized to assert, precondition, etc. If there was a way for custom fatalError-like functions to also dump a stack trace, that would be great.
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Improvements to this area would be great. :-)

-Chris

···

On Dec 7, 2015, at 1:24 PM, Radoslaw Pietruszewski via swift-evolution <swift-evolution@swift.org> wrote:

+ 1. This should also be generalized to assert, precondition, etc. If there was a way for custom fatalError-like functions to also dump a stack trace, that would be great.

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.

···

On Dec 7, 2015, at 1:47 PM, Harlan Haskins via swift-evolution <swift-evolution@swift.org> wrote:

Is there even a way to display the call stack symbols in pure Swift without NSThread.callStackSymbols()?

--
Greg Parker gparker@apple.com Runtime Wrangler

Bumping because I'd hate to see this get buried. It's a big pain point right now not getting any information from a fatalError, assert, or precondition other than the message.

Is there anything technical preventing this?

Also some kind of name demangling would probably be necessary for this as well.

- Harlan

···

On Dec 7, 2015, at 4:47 PM, Harlan Haskins via swift-evolution <swift-evolution@swift.org> wrote:

Is there even a way to display the call stack symbols in pure Swift without NSThread.callStackSymbols()?

On Dec 7, 2015, at 4:24 PM, Radoslaw Pietruszewski via swift-evolution <swift-evolution@swift.org> wrote:

+ 1. This should also be generalized to assert, precondition, etc. If there was a way for custom fatalError-like functions to also dump a stack trace, that would be great.
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution