[WIP] Readable exceptions StackTraces#937
Conversation
|
First of all, thanks because this indeed solves a very real problem. On the other hand, this only solves the problem from a specific angle, and I wish we could try to address the shortcoming from a more generic perspective. In other words, since this is useful for debugging, we could try to see if we could take a similar approach using gimli to parse the DWARF sections, this way we would get relevant stack traces for all languages. for somewhat prior art, wazero introduced this a few years ago... using the built-in DWARF parser that comes with the Go stdlib, an equivalent for which unfortunately is not part of the JDK regardless, we might be able to keep all these experiments in a separate module if we provide a sufficiently generic interface (i.e. maybe not just string -> string, maybe trace->trace? thinking aloud here...) HTH |
I started a branch at: https://github.com/chirino/chicory/tree/source-maps It compiles the rust DWARF parser to WASM and just use it as byte code compiled chicory module. Should I resurrect that branch? Maybe some parts of it can be use by this one. |
8d068ce to
7c41613
Compare
Always welcome @chirino we need those experiments to keep going!
Looking for ideas here, interpreter and compiler are getting the function id in very different ways, and the interpreter is accessing a lot of private state to do so 😓 but it would be a perfect approach if applicable! |
|
I think the current structure is fine in the short term as it's an improvement on the user experience. Long term, It's a little weird to have guest language specific debugging code in this project. There could perhaps be some separate debugging submodule that handles DWARF in a generic way like @evacchi suggests. But i don't think it's required to do all that to get the change out. |
Cargo project names are incorrect, we haven't noticed because we never looked at those 😅 Noticed in #937 , it reduces the diff.
57786bc to
0ea8982
Compare
andreaTP
left a comment
There was a problem hiding this comment.
Done an iteration attempting to extract a "generic enough" API, I'm keeping rustc-demangle at the moment as it is a demonstration of the design with the interpreter and compiler implementations.
When we are convinced that the design is good enough I'll remove rustc-demangle as it can live in another repository.
| private final ExecutionListener listener; | ||
| private final Exports fluentExports; | ||
|
|
||
| private final Optional<BiFunction<Instance, Integer, List<StackTraceElement>>> |
There was a problem hiding this comment.
I extracted all the callback logic into this callback, we can move to a class or interface if preferable.
| var instance = | ||
| Instance.builder(CountVowels.load()) | ||
| .withMachineFactory(CountVowels::create) | ||
| .withExceptionConverter(demanglerExceptionConverter(debugModule)) |
There was a problem hiding this comment.
This is where the new design shines, we can inject the debugging logic using a different WasmModule.
|
Closing in favor of #943 |
Opening for visibility and to receive very much needed feedback.
The problem
Currently the StackTraces produced when we reach an unreachable statement are useless, the current output is masking all the useful information in the interpreter, and referring to generated functions in the compiler.
Wasmtime does a much better job, for example:
With this PR the output of Chicory becomes:
Open questions
rustc-demangle: where should it live? in this repo, in a separate one(e.g. under roastedroot), or should we try to push the changes up to the rust library or rebundle it ourself and call it a day?