Panic handling in embedded mode

Hello,

I am incredibly exhausted by trying to debug my wasm code when all the output I get from crashes is "unreachable"

I could replace my own usage of fatalError and friends, but that does not help with stdlib crashes.

How can I get proper panic handling, similar to how rust does this

We don't have a fully customizable fatalError/trap system for embedded swift but this definitely is something we want to improve.

That said, you might want to try -assert-config Debug. This flag has helped me while debugging traps as it makes precondition messages actually be emitted (among other things).

1 Like

Thank you, that's not ideal because it outputs to putchar and not the error output but at least I can tell what's going on :slight_smile:

1 Like

Agreed, there's definitely more work needed, but I've also found this flag helpful for unblocking myself.

Does your code run in the browser? If so, you can get stack traces in browser developer tools and also use the debugging extension from SwiftWasm. If a crash is in Swift stdlib or runtime, you might need to build your own with release-debuginfo setting to be able to step through source code and possibly inspect variables.

It does, and I briefly looked into this kind of thing, but I am very annoyed by how Chrome installs itself and always auto starts in the background to access the network, so I'd probably rather work on my build system to cross compile natively and debug there

I'm developing on the browser build to avoid having to make my makefile even more complicated, but that's a bad idea in the first place