I would like to debug when I execute wasmtime hello.wasm . excited to see the modules wasmtime is going through !
If you run wasmtime with -g
, it will produce debuginfo for the jitted wasm module, if the wasm module contained debuginfo. If you run wasmtime itself in gdb or lldb, it will find the debuginfo produced by wasmtime and make the wasm module debuggable as if it was a native executable.
I am getting into wasmtime debug mode using gdb.. not able to see where wasmtime is calling the module..
gdb) n
34 in src/libstd/rt.rs
(gdb) n
40 in src/libstd/rt.rs
(gdb) n
41 in src/libstd/rt.rs
(gdb) n
44 in src/libstd/rt.rs
(gdb) n
48 in src/libstd/rt.rs
(gdb) n
[New Thread 0x7ffff6ec4700 (LWP 15929)]
[New Thread 0x7ffff6cc3700 (LWP 15930)]
[New Thread 0x7ffff6ac2700 (LWP 15931)]
[New Thread 0x7ffff68c1700 (LWP 15932)]
[New Thread 0x7ffff66c0700 (LWP 15933)]
Hello World
54 in src/libstd/rt.rs
(gdb)
Unfortunately debugging with gdb doesn't quite work yet. The DWARF debug info format that gdb and lldb both use is quite underspecified, so there are differences in interpretation. Since the content compiled to Wasm is produced by LLVM, it's much easier to make things work in LLVM's debugger, too
n(ext)
skips over calls instead of stepping into them like step
. This means that you skip over everything except for the content of the first function executed in every rust program (in this case wasmtime)
You may want to set a breakpoint at catch_traps
(rbreak catch_traps
with gdb or break set -r catch_traps
with lldb), as this is pretty much the last wasmtime function called before the jitted wasm code is executed.
hardtime to make it work again..
naveen@naveen-Inspiron-7352:~/rustprojects$ lldb -- wasmtime -g rustwasm.wasm
(lldb) target create "wasmtime"
error: '/home/naveen/rustprojects/wasmtime' doesn't contain any 'host' platform architectures: x86_64, i386
(lldb) file rustwasm.wasm
error: '/home/naveen/rustprojects/rustwasm.wasm' doesn't contain any 'host' platform architectures: x86_64, i386
(lldb)
when debugging in gdb for the rustwasm.wasm , it's not catching the breakpoint at "catch_traps"
I managed to debug in lldb. but sourcecode is listing in assembly. I wrote a rust program, but lldb shows as assembly..
Did you compile the rust program with debuginfo?
I built using cargo build --target=wasm32-wasi
tried this one also : RUSTFLAGS=-g cargo build --target=wasm32-wasi . But did not work.. source code is listing as assembly
@Naveen Davis Vallooran did you have any luck with debugging? what version of rust you are using?
@Naveen Davis Vallooran can you trying something like https://gist.github.com/yurydelendik/92e707e4bd1569debac56a9517c6b9b6 ?
@Yury Delendik is gdb fine too?
I was going to check that in a day or two. Last time I checked, about year or so, it is possible to set breakpoints on specific line
@Yury Delendik and the 'Traps' in wasm, should they stop as breakpoints in gdb?
"'Traps' in wasm" ?
/me needs more info about 'Traps'
I see that CLIF has a Trap opcode, and it looks like wasmtime uses them for 'stack overflow' traps and some other issues
I saw LLDB stopping at signals, yes
Ok thanks
I need a specific test to see what is going on
Last updated: Nov 22 2024 at 16:03 UTC