ggjjj opened issue #9426:
https://github.com/bytecodealliance/wasm-tools/issues/1854
I am using a rust application that launches the wasmtime with debug_info() set to true and loads a WASM module that implements component module.
I use wasm-tools to get the module adapted to wasi by
wasm-tools component new ./target/wasm32-wasip1/debug/module1.wasm -o ./tests/data/wasm-modules/processor-module1-$(VERSION).wasm --adapt wasi_snapshot_preview1.reactor.wasmI also confirmed that the
wasm-tools objdump
to see that the debug_info information exists.now once I launch the debugger for the rust application, I am only able to step into a
call()
function and but not in the wasm module source code.is there any other step am I missing?
ggjjj commented on issue #9426:
Configuration of wasmtime engine
let mut engine_config = Config::new(); engine_config .debug_info(true) .cranelift_opt_level(OptLevel::None) .wasm_component_model(true);
ggjjj commented on issue #9426:
wasm-tools objdump
of the module1 in questionhttps://github.com/bytecodealliance/wasm-tools/issues/1854#issuecomment-2400748393
ggjjj edited issue #9426:
https://github.com/bytecodealliance/wasm-tools/issues/1854
I am using a rust application that launches the wasmtime with debug_info() set to true and loads a WASM module that implements component module.
I use wasm-tools to get the module adapted to wasi by
wasm-tools component new ./target/wasm32-wasip1/debug/module1.wasm -o ./tests/data/wasm-modules/processor-module1-$(VERSION).wasm --adapt wasi_snapshot_preview1.reactor.wasm
I also confirmed that the
wasm-tools objdump
to see that the debug_info information exists.now once I launch the debugger for the rust application, I am only able to step into a
call()
function and but not in the wasm module source code.is there any other step am I missing?
ggjjj commented on issue #9426:
Do I need to include this feature "debug-builtins" in wasmtime crate to enable the debug symbols?
ggjjj commented on issue #9426:
well adding the crate feature also did not help
alexcrichton commented on issue #9426:
Would you be able to share snippets of the component/embedding in question? Or perhaps a snippet using the
wasmtime
CLI? It sounds like you're doing everything right, so it may come down to the details as to why this isn't working
ggjjj commented on issue #9426:
Module Code
mod map_fah_to_cel { wit_bindgen::generate!({ path: "xxx", world "map-iml",}); // we also use some SDK elements for the exports impl exports::xx:xx::xx:xx for Module { fn process(message_input) -> message_output } export!(Module); }
ggjjj edited a comment on issue #9426:
Module Code
mod map_fah_to_cel { wit_bindgen::generate!({ path: "xxx", world "map-iml",}); // we also use some SDK elements for the exports impl exports::xx:xx::xx:xx for Module { fn process(message_input) -> message_output } export!(Module); }
ggjjj commented on issue #9426:
App code that launches the runtime and loads the module
fn main() { thread::scope(|scope| { /* * As wasm runtime & module have to be running on the same OS thread, * use new_current_thread() to build a tokio runtime with the current * thread scheduler selected. */ let runtime = runtime::Builder::new_current_thread() .enable_all() .build() .unwrap(); runtime.block_on(async_main(scope)); }); } async fn async_main(scope) { let mut engine_config = Config::new(); engine_config .debug_info(true) .cranelift_opt_level(OptLevel::None) .wasm_component_model(true); let wasm_file_name: &str = "../../tests/data/wasm-modules/processor-module1-v1.wasm"; { let wasm_component_info = &mut *wasm_component_info.lock(); wasm_component_info.insert_component(&wasm_module_id, wasm_file_name.to_owned()); } // insert_wasm_module() // call_map_fn() // wait for wasm device manager by join() }
ggjjj commented on issue #9426:
My goal is to step into the source code of
process()
when thecall_map_fn()
is executed.
ggjjj edited a comment on issue #9426:
App code that launches the runtime and loads the module
fn main() { thread::scope(|scope| { /* * As wasm runtime & module have to be running on the same OS thread, * use new_current_thread() to build a tokio runtime with the current * thread scheduler selected. */ let runtime = runtime::Builder::new_current_thread() .enable_all() .build() .unwrap(); runtime.block_on(async_main(scope)); }); } async fn async_main(scope) { let mut engine_config = Config::new(); engine_config .debug_info(true) .cranelift_opt_level(OptLevel::None) .wasm_component_model(true); let wasm_file_name: &str = "../../tests/data/wasm-modules/processor-module1-v1.wasm"; { let wasm_component_info = &mut *wasm_component_info.lock(); wasm_component_info.insert_component(&wasm_module_id, wasm_file_name.to_owned()); } // insert_wasm_module() // call_map_fn() // wait for wasm device manager by join() }
ggjjj edited a comment on issue #9426:
App code that launches the runtime and loads the module and I am debugging this app
fn main() { thread::scope(|scope| { /* * As wasm runtime & module have to be running on the same OS thread, * use new_current_thread() to build a tokio runtime with the current * thread scheduler selected. */ let runtime = runtime::Builder::new_current_thread() .enable_all() .build() .unwrap(); runtime.block_on(async_main(scope)); }); } async fn async_main(scope) { let mut engine_config = Config::new(); engine_config .debug_info(true) .cranelift_opt_level(OptLevel::None) .wasm_component_model(true); let wasm_file_name: &str = "../../tests/data/wasm-modules/processor-module1-v1.wasm"; { let wasm_component_info = &mut *wasm_component_info.lock(); wasm_component_info.insert_component(&wasm_module_id, wasm_file_name.to_owned()); } // insert_wasm_module() // call_map_fn() // wait for wasm device manager by join() }
fitzgen commented on issue #9426:
@ggjjj I appreciate that you provided some source code here, but it is incomplete and contains syntactical errors (eg no type on
async_main
's parameter).Could you provide a git repo containing a fully self contained example that we can simply clone as well as detailed steps reproduce with exactly that git repo? Something like the following:
Minimal test case: url-of-git-repo Steps to reproduce: * clone git repo * Run `cargo component build` inside the git repo * Run `lldb -- wasmtime run -g path/to/test.wasm` * step 5 times, until you reach the `foo` function Expected Results * You stepped through the `a.wasm::bar` function Actual Results * You never stepped through the `a.wasm::bar` function
The easier you can make it to reproduce the bug exactly, without needing to fix source code that doesn't build or infer steps that are implied but not explicitly described, the better we can help you and diagnose/resolve the bug that you are seeing.
Thanks!
ggjjj commented on issue #9426:
I understand but we are working on private code. so is there any way I can debug this further? @fitzgen
fitzgen commented on issue #9426:
Have you tried making a minimal reproducer that doesn't contain your private code?
ggjjj commented on issue #9426:
I am trying that. Is this the sample that you recommend?
ggjjj edited a comment on issue #9426:
I am trying that. Is this a sample that you recommend?
fitzgen commented on issue #9426:
If you can get that example to reproduce your issue, then that sounds great. If you can't get that example to reproduce your issue, then I'd suggest trying to make calls and link modules/components together in a similar shape as your private code in an effort to find something that will reproduce the bug.
ggjjj commented on issue #9426:
Sample tried -
https://github.com/bytecodealliance/wasmtime/tree/main/examples/component
Steps followed
- cargo build -p example-component-wasm --target wasm32-unknown-unknown
- cargo run --example component
I was succesfully able to step into source code in guest.rs
Next I switched to
wasm32-wasip1
targetSteps followed
- cargo build -p example-component-wasm --target wasm32-wasip1
- cargo run --example component
**Error: failed to decode world from module
Caused by:
0: module was not valid
1: failed to resolve importwasi_snapshot_preview1::fd_write
2: module requires an import interface named `wasi_snapshot_preview1**
ggjjj commented on issue #9426:
My goal was to convert the module to adapt to wasi-preview1
by
wasm-tools component new ./target/wasm32-wasip1/debug/guest.wasm -o ./target/wasm32-wasip1/debug/guest-wasi.wasm --adapt wasi_snapshot_preview1.reactor.wasm
But I couldn't get to this step
ggjjj edited a comment on issue #9426:
My goal was to convert the module to adapt to wasi-preview1
by
wasm-tools component new ./target/wasm32-wasip1/debug/guest.wasm -o ./target/wasm32-wasip1/debug/guest-wasi.wasm --adapt wasi_snapshot_preview1.reactor.wasm
and use guest-wasi.wasm to load in
main.rs
of component
But I couldn't get to this step
ggjjj commented on issue #9426:
I tried to use the guest-wasi.wasm in line53 of main.rs
let component = convert_to_component("target/wasm32-wasip1/debug/guest-wasi.wasm")?; while running it I got this error **Error: decoding a component is not supported**
ggjjj commented on issue #9426:
I used 25.0.2 snapshot file
https://github.com/bytecodealliance/wasmtime/releases/download/v25.0.2/wasi_snapshot_preview1.reactor.wasm
ggjjj edited a comment on issue #9426:
I tried to use the guest-wasi.wasm in line53 of main.rs
let component = convert_to_component("target/wasm32-wasip1/debug/guest-wasi.wasm")?;
while running it I got this error **Error: decoding a component is not supported**
ggjjj edited a comment on issue #9426:
I tried to use the guest-wasi.wasm in line53 of main.rs
let component = convert_to_component("target/wasm32-wasip1/debug/guest-wasi.wasm")?;
while running it, I got this error**Error: decoding a component is not supported**
ggjjj commented on issue #9426:
May I know why 26.0.0 is wasmtime version when only 25.0.2 is released?
ggjjj edited a comment on issue #9426:
I tried to use the guest-wasi.wasm in line53 of main.rs after the above
wasm-tools
command
let component = convert_to_component("target/wasm32-wasip1/debug/guest-wasi.wasm")?;
while running it, I got this error**Error: decoding a component is not supported**
ggjjj commented on issue #9426:
@fitzgen Hey Nick did you get a chance to look at this one?
alexcrichton commented on issue #9426:
@ggjjj it looks like there's a lot going on here with quite a few possibilities of what could be going wrong. We can try to piece together everything from the snippets of information you're posting but it'd be much more helpful to us as maintainers if you're able to do what Nick mentioned above with having a reproducible set of steps. It looks like you're trying a lot of things all at once and each thing is failing in different ways which may be unrelated to the original issue
ggjjj commented on issue #9426:
Agree and apologize for including some many of the methods I tried in once. ok let me start step by step.
Goal 1 - try the component example with wasm32-wasip1.
Minimal test case: url-of-git-repo
Steps to reproduce:
- clone git repo
- cargo build -p example-component-wasm --target wasm32-wasip1
- cargo run --example wasm32-wasip1
Expected Results
- Converted to 74.xxx
Actual Results
Error: failed to decode world from module
Caused by:
0: module was not valid
1: failed to resolve importwasi_snapshot_preview1::fd_write
2: module requires an import interface namedwasi_snapshot_preview1
ggjjj edited a comment on issue #9426:
Agree and apologize for including some many of the methods I tried in once. ok let me start step by step.
Goal 1 - try the component example with wasm32-wasip1.
Minimal test case: url-of-git-repo
Steps to reproduce:
- clone git repo
- cargo build -p example-component-wasm --target wasm32-wasip1
- cargo run --example wasm32-wasip1
Expected Results
- Converted to 74.xxx
Actual Results
Error: failed to decode world from module Caused by: 0: module was not valid 1: failed to resolve import `wasi_snapshot_preview1::fd_write` 2: module requires an import interface named `wasi_snapshot_preview1`
ggjjj edited a comment on issue #9426:
Agree and apologize for including some many of the methods I tried in once. ok let me start step by step.
Goal 1 - Try the component example with wasm32-wasip1.
Minimal test case: url-of-git-repo
Steps to reproduce:
- clone git repo
- cargo build -p example-component-wasm --target wasm32-wasip1
- cargo run --example wasm32-wasip1
Expected Results
- Converted to 74.xxx
Actual Results
Error: failed to decode world from module Caused by: 0: module was not valid 1: failed to resolve import `wasi_snapshot_preview1::fd_write` 2: module requires an import interface named `wasi_snapshot_preview1`
ggjjj commented on issue #9426:
@alexcrichton @fitzgen Is the above format okay? Is there any other information needed? Please advise
ggjjj commented on issue #9426:
I figured out what I was missing. Once I defined the wasibuilder, I was able to get it all to working and eventually step into the source code. Sample is somewhat closer to the app we have in house but it does create two threads
One thread is to create engine, linker, store and another thread is to extract and call component function. any thoughts on if that would affect the debug symbols to be lost in someway? @alexcrichton @fitzgen
alexcrichton commented on issue #9426:
@ggjjj from your comment above the error is happening because conversion to a component is a bit more subtle when the different target of
wasm32-wasip1
is used. Nowadays if you usewasm32-wasip2
the target automatically produces a component which is probably what we should update the example to be doing.any thoughts on if that would affect the debug symbols to be lost in someway?
Hm in theory no, having separate threads shouldn't affect anything. Were you able to get a reproduction we could poke around though?
ggjjj closed issue #9426:
https://github.com/bytecodealliance/wasm-tools/issues/1854
I am using a rust application that launches the wasmtime with debug_info() set to true and loads a WASM module that implements component module.
I use wasm-tools to get the module adapted to wasi by
wasm-tools component new ./target/wasm32-wasip1/debug/module1.wasm -o ./tests/data/wasm-modules/processor-module1-$(VERSION).wasm --adapt wasi_snapshot_preview1.reactor.wasm
I also confirmed that the
wasm-tools objdump
to see that the debug_info information exists.now once I launch the debugger for the rust application, I am only able to step into a
call()
function and but not in the wasm module source code.is there any other step am I missing?
ggjjj commented on issue #9426:
Looks it its not the separate threads its the wasmtime version. 24.0.0 did not work. 25.0.2 worked. Thanks for all the insights. closing the issue
Last updated: Dec 23 2024 at 13:07 UTC