-
Notifications
You must be signed in to change notification settings - Fork 290
Emit backtrace in runtime error message. #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack some of my comments imply work possibly more than the code here, but I have to be Jiminy Cricket.
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
@codefromthecrypt thanks for the help!! |
@@ -28,4 +28,13 @@ func Test_trap(t *testing.T) { | |||
|
|||
_, _, err = store.CallFunction("test", "cause_panic") | |||
require.Error(t, err) | |||
|
|||
const expErrMsg = `wasm runtime error: unreachable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ❤️ this
great work |
This commit adds the parser of the "name" custom section[1], and starts emitting the backtrace of the program into the runtime error message by leveraging the function name informations stored in "name" custom section. Note that this is the minimal implementation -- the trace doesn't contain the original Wasm instruction address nor the source code info. The former can be implemented easily but the latter requires us to implement the Wasm DWARF format parser of .debug_* custom sections[2]. [1] https://webassembly.github.io/spec/core/appendix/custom.html#name-section [2] https://yurydelendik.github.io/webassembly-dwarf/ The following is the output from examples/trap_test.go: === RUN Test_trap panic: causing panic!!!!!!!!!! wasm runtime error: unreachable wasm backtrace: 0: runtime._panic 1: main.three 2: main.two 3: main.one 4: cause_panic
This commit adds the parser of the "name" custom section[1],
and starts emitting the backtrace of the program into the runtime error message
by leveraging the function name informations stored in "name" custom section.
Note that this is the minimal implementation -- the trace doesn't contain the
original Wasm instruction address nor the source code info. The former
can be implemented easily but the latter requires us to implement the Wasm
DWARF format parser of
.debug_*
custom sections[2].[1] https://webassembly.github.io/spec/core/appendix/custom.html#name-section
[2] https://yurydelendik.github.io/webassembly-dwarf/
This is similar to what I did to Proxy-Wasm C++ host: proxy-wasm/proxy-wasm-cpp-host#66
The following is the output from examples/trap_test.go:
As a comparison wasmtime emits like this: