()
| 1521 | #[tokio::test] |
| 1522 | #[cfg_attr(miri, ignore)] |
| 1523 | async fn component_module_relative_breakpoint_pcs() -> wasmtime::Result<()> { |
| 1524 | use wasmtime::component::{Component, Linker}; |
| 1525 | |
| 1526 | let _ = env_logger::try_init(); |
| 1527 | |
| 1528 | let m1_body = r#"(func (export "f1") (param i32 i32) (result i32) |
| 1529 | local.get 0 |
| 1530 | local.get 1 |
| 1531 | i32.add)"#; |
| 1532 | let m2_body = r#"(func (export "f2") (param i32 i32) (result i32) |
| 1533 | local.get 0 |
| 1534 | local.get 1 |
| 1535 | i32.mul)"#; |
| 1536 | |
| 1537 | let _m1_wasm = wat::parse_str(&format!("(module {m1_body})"))?; |
| 1538 | let _m2_wasm = wat::parse_str(&format!("(module {m2_body})"))?; |
| 1539 | |
| 1540 | let component_wat = format!( |
| 1541 | r#"(component |
| 1542 | (core module $m1 {m1_body}) |
| 1543 | (core instance $i1 (instantiate $m1)) |
| 1544 | (core module $m2 {m2_body}) |
| 1545 | (core instance $i2 (instantiate $m2)) |
| 1546 | (func (export "f1") (param "a" s32) (param "b" s32) (result s32) |
| 1547 | (canon lift (core func $i1 "f1"))) |
| 1548 | (func (export "f2") (param "a" s32) (param "b" s32) (result s32) |
| 1549 | (canon lift (core func $i2 "f2"))))"#, |
| 1550 | ); |
| 1551 | |
| 1552 | let mut config = Config::default(); |
| 1553 | config.guest_debug(true); |
| 1554 | let engine = Engine::new(&config)?; |
| 1555 | |
| 1556 | let component = Component::new(&engine, &component_wat)?; |
| 1557 | let linker: Linker<()> = Linker::new(&engine); |
| 1558 | let mut store = Store::new(&engine, ()); |
| 1559 | |
| 1560 | let instance = linker.instantiate_async(&mut store, &component).await?; |
| 1561 | |
| 1562 | let modules = store.debug_all_modules(); |
| 1563 | assert_eq!(modules.len(), 2); |
| 1564 | |
| 1565 | // The i32.add / i32.mul instruction is at module-relative offset |
| 1566 | // 0x26 in both modules. |
| 1567 | let breakpoint_pc = ModulePC::new(0x26); |
| 1568 | |
| 1569 | // Record breakpoint PCs seen in each event. |
| 1570 | let observed_pcs = Arc::new(Mutex::new(Vec::<(u32, u32)>::new())); |
| 1571 | let observed_pcs_clone = observed_pcs.clone(); |
| 1572 | |
| 1573 | #[derive(Clone)] |
| 1574 | struct D(Arc<Mutex<Vec<(u32, u32)>>>); |
| 1575 | impl DebugHandler for D { |
| 1576 | type Data = (); |
| 1577 | fn handle( |
| 1578 | &self, |
| 1579 | mut store: StoreContextMut<'_, ()>, |
| 1580 | _event: DebugEvent<'_>, |
nothing calls this directly
no test coverage detected