Stream: general

Topic: How can I debug wasmtime code ?


view this post on Zulip Naveen Davis Vallooran (Feb 29 2020 at 17:09):

I would like to debug when I execute wasmtime hello.wasm . excited to see the modules wasmtime is going through !

view this post on Zulip bjorn3 (Feb 29 2020 at 17:17):

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.

view this post on Zulip Naveen Davis Vallooran (Feb 29 2020 at 18:46):

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)

view this post on Zulip Till Schneidereit (Feb 29 2020 at 20:38):

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

view this post on Zulip bjorn3 (Feb 29 2020 at 20:40):

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)

view this post on Zulip bjorn3 (Feb 29 2020 at 20:44):

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.

view this post on Zulip Naveen Davis Vallooran (Mar 01 2020 at 02:58):

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)

view this post on Zulip Naveen Davis Vallooran (Mar 01 2020 at 02:59):

when debugging in gdb for the rustwasm.wasm , it's not catching the breakpoint at "catch_traps"

view this post on Zulip Naveen Davis Vallooran (Mar 01 2020 at 06:37):

I managed to debug in lldb. but sourcecode is listing in assembly. I wrote a rust program, but lldb shows as assembly..

view this post on Zulip bjorn3 (Mar 01 2020 at 08:27):

Did you compile the rust program with debuginfo?

view this post on Zulip Naveen Davis Vallooran (Mar 01 2020 at 15:16):

I built using cargo build --target=wasm32-wasi

view this post on Zulip Naveen Davis Vallooran (Mar 01 2020 at 15:22):

tried this one also : RUSTFLAGS=-g cargo build --target=wasm32-wasi . But did not work.. source code is listing as assembly

view this post on Zulip Yury Delendik (Mar 04 2020 at 14:32):

@Naveen Davis Vallooran did you have any luck with debugging? what version of rust you are using?

view this post on Zulip Yury Delendik (Mar 04 2020 at 17:35):

@Naveen Davis Vallooran can you trying something like https://gist.github.com/yurydelendik/92e707e4bd1569debac56a9517c6b9b6 ?

helloworld.rs debugging. GitHub Gist: instantly share code, notes, and snippets.

view this post on Zulip Joey Gouly (Mar 06 2020 at 14:55):

@Yury Delendik is gdb fine too?

view this post on Zulip Yury Delendik (Mar 06 2020 at 14:57):

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

view this post on Zulip Joey Gouly (Mar 06 2020 at 15:04):

@Yury Delendik and the 'Traps' in wasm, should they stop as breakpoints in gdb?

view this post on Zulip Yury Delendik (Mar 06 2020 at 15:05):

"'Traps' in wasm" ?

view this post on Zulip Yury Delendik (Mar 06 2020 at 15:07):

/me needs more info about 'Traps'

view this post on Zulip Joey Gouly (Mar 06 2020 at 15:07):

I see that CLIF has a Trap opcode, and it looks like wasmtime uses them for 'stack overflow' traps and some other issues

view this post on Zulip Yury Delendik (Mar 06 2020 at 15:09):

I saw LLDB stopping at signals, yes

view this post on Zulip Joey Gouly (Mar 06 2020 at 15:09):

Ok thanks

view this post on Zulip Yury Delendik (Mar 06 2020 at 15:11):

I need a specific test to see what is going on


Last updated: Dec 23 2024 at 13:07 UTC