Live data from Hacker News

On-Crash Backtraces in Swift

swift.org

1–10 of 21 posts

Re: On-Crash Backtraces in Swift

#2
The best part of is that you can get all this goodness even without having Swift code in your codebase.

Just link your C++ (or whatever) project with The Swift runtime (swiftrt.o and libswiftCore.so), and there you have it without writing any Swift.

Re: On-Crash Backtraces in Swift

#3
post #2

The best part of is that you can get all this goodness even without having Swift code in your codebase. Just link your C++ (or whatever) project with The Swift runtime (swiftrt.o and libswiftCore.so), and there you have it without writing any Swift.

If you're on mac (where I assume the two are already available), what compiler flags need to be passed in to do this?

Re: On-Crash Backtraces in Swift

#4
post #2

The best part of is that you can get all this goodness even without having Swift code in your codebase. Just link your C++ (or whatever) project with The Swift runtime (swiftrt.o and libswiftCore.so), and there you have it without writing any Swift.

Looks like is already part of C++23 [0]. But if you must use an older C++, why link the entire Swift runtime rather than something GCC's builtin backtraces [1] or libbacktrace [2]?

[0] https://www.sandordargo.com/blog/2022/09/21/cpp23-stacktrace...

[1] https://www.gnu.org/software/libc/manual/html_node/Backtrace...

[2] https://github.com/ianlancetaylor/libbacktrace

Re: On-Crash Backtraces in Swift

#7
Hah that's funny, I recently ported the Swift compiler to a Debian package using the Ubuntu package (aside: why is Debian not supported, that baffles me, especially for Swift on Linux server? But Ubuntu is?).

I thought I did something wrong when the crash reported looked so different. I was unaware, that since the last time I did this (ubuntu->debian .deb), the compiler had changed its error reporting.

Props to the Swift team doing the good work, and please add a .deb to the binaries artefacts!

Re: On-Crash Backtraces in Swift

#8

> The backtracer also skips over system frames and Swift thunks by default. Boo! Show me my system frames! (Also, is this available in the Xcode toolchain yet?)

Part of Swift 5.9 which is in Xcode 15, so, I think so, but it's opt-in:

> This feature is also available on macOS but is disabled by default. To enable it, set SWIFT_BACKTRACE=enable=yes and sign your program with the com.apple.security.get-task-allow entitlement.

https://www.swift.org/blog/swift-5.9-released/

Re: On-Crash Backtraces in Swift

#9
post #2

The best part of is that you can get all this goodness even without having Swift code in your codebase. Just link your C++ (or whatever) project with The Swift runtime (swiftrt.o and libswiftCore.so), and there you have it without writing any Swift.

Looks like is already part of C++23 [0]. But if you must use an older C++, why link the entire Swift runtime rather than something GCC's builtin backtraces [1] or libbacktrace [2]? [0] https://www.sandordargo.com/blog/2022/09/21/cpp23-stacktrace... [1] https://www.gnu.org/software/libc/manual/html_node/Backtrace... [2] https://github.com/ianlancetaylor/libbacktrace

If you're on the Mac, your process is probably linking the Swift runtime anyway. Foundation.framework is being reimplemented in Swift, so if your process links Foundation (or even just CF), you've got the Swift runtime.
Post reply on HN