mbtmap

Crates.iombtmap
lib.rsmbtmap
version0.1.1
sourcesrc
created_at2024-10-09 08:26:57.083189
updated_at2024-10-09 11:40:41.760325
descriptionAttach source location to MoonBit traceback
homepage
repositoryhttps://github.com/NKID00/mbtmap
max_upload_size
id1402134
size34,585
NKID00 (NKID00)

documentation

README

MoonBit Source Mapper (mbtmap)

This tool filters traceback generated by moon run -g, automatically attaches source location resolved from sourcemap.

Install it with cargo install mbtmap, pass the location of source map and pipe stderr from moon run -g to it. For example on bash, use |&:

moon run -g src/bin/main.mbt |& mbtmap target/wasm-gc/debug/build/bin/bin.wasm.map
 RuntimeError: unreachable
-    at Option::unwrap|@moonbitlang/minimbt/closure.LowType|.fn/653 (wasm://wasm/001ac3c6:wasm-function[695]:0x112cd)
+    at Option::unwrap|@moonbitlang/minimbt/closure.LowType|.fn/653 (wasm://wasm/001ac3c6:wasm-function[695]:0x112cd /home/nkid00/.moon/lib/core/builtin/option.mbt:34:13)
-    at $moonbitlang/minimbt/wasm.emit_inst.fn/979 (wasm://wasm/001ac3c6:wasm-function[1073]:0x2a182)
+    at $moonbitlang/minimbt/wasm.emit_inst.fn/979 (wasm://wasm/001ac3c6:wasm-function[1073]:0x2a182 src/wasm/wasm.mbt:524:9)
-    at $moonbitlang/minimbt/wasm.emit_inst.fn/979 (wasm://wasm/001ac3c6:wasm-function[1073]:0x2a004)
+    at $moonbitlang/minimbt/wasm.emit_inst.fn/979 (wasm://wasm/001ac3c6:wasm-function[1073]:0x2a004 src/wasm/wasm.mbt:496:28)
-    at $moonbitlang/minimbt/wasm.emit_inst.fn/979 (wasm://wasm/001ac3c6:wasm-function[1073]:0x2a004)
+    at $moonbitlang/minimbt/wasm.emit_inst.fn/979 (wasm://wasm/001ac3c6:wasm-function[1073]:0x2a004 src/wasm/wasm.mbt:496:28)
-    at $moonbitlang/minimbt/wasm.emit_inst.fn/979 (wasm://wasm/001ac3c6:wasm-function[1073]:0x29c44)
+    at $moonbitlang/minimbt/wasm.emit_inst.fn/979 (wasm://wasm/001ac3c6:wasm-function[1073]:0x29c44 src/wasm/wasm.mbt:419:30)
 error: failed to run

Caveat if piping from moon run -g

If stdin of mbtmap is piped from moon run -g, the sourcemap may be stale after compilation and its content won't update before program and moon exit. Mbtmap will wait until stdin has been closed to try to make sure sourcemap has been freshly emitted and then resolve source locations. If this is not applicable or interactive is needed, pass -l option to mbtmap to fall back to line-buffered filter. This way, it is necessary to build and generate fresh sourcemap beforehand.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Commit count: 6

cargo fmt