`dx`: Print human readable traceback
Feature Request
During development I ran into a panic which printed the following error:
15:52:43 [web] panicked at library/std/src/sys/pal/wasm/../unsupported/time.rs:13:9:
time not implemented on this platform
Stack:
__wbg_get_imports/imports.wbg.__wbg_new_6b2318b8eabfc63e/<@http://192.168.1.249:8080/wasm/seat-route.js:1369:21
logError@http://192.168.1.249:8080/wasm/seat-route.js:151:18
__wbg_get_imports/imports.wbg.__wbg_new_6b2318b8eabfc63e@http://192.168.1.249:8080/wasm/seat-route.js:1368:66
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[17392]:0x2b10c8
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[9820]:0x262601
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[2941]:0x1906c4
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[12970]:0x28b63a
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[3379]:0x1a7db2
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[4694]:0x1e1b50
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[17723]:0x2b20fc
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[13150]:0x28d513
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[13153]:0x28d59c
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[11606]:0x27b7a6
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[986]:0xdf57d
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[3817]:0x1bcbba
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[2559]:0x17884b
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[11059]:0x274663
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[5278]:0x1f7128
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[6069]:0x210b32
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[3800]:0x1bbf4f
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[2567]:0x17908d
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[11304]:0x277999
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[5347]:0x1f96ca
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[334]:0x25e36
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[403]:0x505ed
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[2065]:0x154e97
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[5621]:0x2029b7
@http://192.168.1.249:8080/wasm/seat-route_bg.wasm:wasm-function[12894]:0x28a982
_ZN12wasm_bindgen7convert8closures1_1_6invoke17hef5f8e094bdda1d0E@http://192.168.1.249:8080/wasm/seat-route.js:304:10
real@http://192.168.1.249:8080/wasm/seat-route.js:174:20
This only tells where the panic happened but if this location is within library code it is entirely unhelpful.
Instead, dx could turn such a traceback to actual file:function:line-number on the fly, removing the need to do this manually. (Hopefully, I didn't just miss an option or tool that already does this.)
Implement Suggestion
I'm not familiar at all with this code base, but one approach could be to:
- Before printing a log message to the user,
dxcould detect whether it contains a traceback. - If it does, before printing, it should translate any
*.wasm:*:{addr}into{file}:{function}:{line-number}by querying the appropriate.wasmfile. This could also be a new CLI option (to turn it off).
I'm open to make a PR, but would need some guidance.
This should be supported with dwarf symbols in dev builds. In release mode, the symbols could be stripped for smaller binary sizes depending on your profile configuration. Cargo can also work with split debuginfo in a separate file, but that may not be supported in the CLI for assets, and hot reloading or the other tools dioxus uses internally like wasm bindgen and wasm opt
You need this chrome extension installed for dwarf debugging support in the browser: https://chromewebstore.google.com/detail/cc++-devtools-support-dwa/pdcpmagijalfljmkmjngeonclgbbannb?pli=1. I would love to auto-detect and warn about this in the CLI if we could
This should be supported with dwarf symbols in dev builds. In release mode, the symbols could be stripped for smaller binary sizes depending on your profile configuration. Cargo can also work with split debuginfo in a separate file, but that may not be supported in the CLI for assets, and hot reloading or the other tools dioxus uses internally like wasm bindgen and wasm opt
Yes, exactly. With debug symbols enabled this info is already available just not used by dx or whatever prints this backtrace. My workaround was to use wasm-tools (specifically wasm-tools addr2line) to turn the addresses into source locations.
Now instead of manually doing this, one approach could be to in dx:
- Search for lines with the format
@{...}/{file_name}.wasm:{...}:{addr}. - For any matches, query the debug symbols of
{file_name}.wasmand translate the address{addr}into its source location.
You need this chrome extension installed for dwarf debugging support in the browser: https://chromewebstore.google.com/detail/cc++-devtools-support-dwa/pdcpmagijalfljmkmjngeonclgbbannb?pli=1. I would love to auto-detect and warn about this in the CLI if we could
That's good to know.