How to locate error messages source

Hi, I would like some advice on tracking down a runtime error message. It's literally just Encountered error: unsupported platform.

This is from compiling Ruff to wasi-p1. I've tried its verbose logging option, that didn't help. I've tried RUST_BACKTRACE=1 but since it's not a panic that doesn't help.

In languages with exceptions this is a lot easier since you can pretty much just start a debugger and break on throw (as long as the code isn't badly written and uses exceptions in normal operation).

But Rust doesn't have that and anyway I'm not sure how to attach a debugger to wasm (I'm running it with the wasmtime CLI).

The best I've got so far is to search grep.app, which leads me to suspect it's coming from the ignore crate (which is a shame since I don't see why that couldn't support WASI).

However that doesn't tell me where the error happens in the Rust code. Ruff is a huge codebase so it's not easy to narrow down. My current best option is printf debugging but since Ruff takes about 10s to compile that's quite painful too.

Is there a better option?

One thing that would really help would be a way to search the source code of all of Ruff's dependencies, and then I could do "find all usages" or something to work back. Is that possible? It seems like the source code for crates is probably not stored in target? Can I force it to do that?

It's a little hacky, but cargo vendor will fetch all your dependencies sources and let you easily search within them.

You can run Rust under most standard native (C/c++) debuggers, too, though the type visualizers are generally not particularly readable.

2 Likes

Ah perfect! Yeah I have no problem debugging native Rust, but this is WASM.

Oh right! Well, you can debug WASM in Chrome at least, though last I tried it was not particularly easy to get working well; hopefully it's a little better now?