On-Crash Backtraces in Swift

The new Swift 5.9 release contains a number of helpful, new features for debugging code, including an out-of-process, interactive crash handler to inspect crashes in real time, the ability to trigger the debugger for just-in-time debugging, along with concurrency-aware backtracing to make it easier to understand control flow in a program that uses structured concurrency.

swift.org/blog/swift-5.9-backtraces/

Swift 5.9 enhances debugging with an out-of-process crash handler that provides detailed backtraces, interactive inspection, and just-in-time debugging, improving on the limited crash messages of prior versions.

When a program crashes, it displays a backtrace with source code snippets, supports async frames for structured concurrency, and allows pausing for up to 30 seconds to interact or attach a debugger.

The backtracer skips system frames, demangles Swift and C++ names, and offers configurable options like frame limits for readability, enabled by default on Linux and optionally on macOS, with no current Windows support.

Users can control settings via the SWIFT_BACKTRACE environment variable, and the interactive prompt offers commands like backtrace, memory, and debug for deeper analysis.


Category:

Tag:

Year: