()
| 786 | #[tokio::test] |
| 787 | #[cfg_attr(miri, ignore)] |
| 788 | async fn breakpoint_events() -> wasmtime::Result<()> { |
| 789 | let _ = env_logger::try_init(); |
| 790 | |
| 791 | let (module, mut store) = get_module_and_store( |
| 792 | |config| { |
| 793 | config.wasm_exceptions(true); |
| 794 | }, |
| 795 | r#" |
| 796 | (module |
| 797 | (func (export "main") (param i32 i32) (result i32) |
| 798 | local.get 0 |
| 799 | local.get 1 |
| 800 | i32.add)) |
| 801 | "#, |
| 802 | )?; |
| 803 | |
| 804 | debug_event_checker!( |
| 805 | D, store, |
| 806 | { 0 ; |
| 807 | wasmtime::DebugEvent::Breakpoint => { |
| 808 | let stack = store.debug_exit_frames().next().unwrap(); |
| 809 | assert_eq!(stack.num_locals(&mut store).unwrap(), 2); |
| 810 | assert_eq!(stack.local(&mut store, 0).unwrap().unwrap_i32(), 1); |
| 811 | assert_eq!(stack.local(&mut store, 1).unwrap().unwrap_i32(), 2); |
| 812 | let (func, pc) = stack.wasm_function_index_and_pc(&mut store).unwrap().unwrap(); |
| 813 | assert_eq!(func.as_u32(), 0); |
| 814 | assert_eq!(pc.raw(), 0x28); |
| 815 | let stack = stack.parent(&mut store).unwrap(); |
| 816 | assert!(stack.is_none()); |
| 817 | } |
| 818 | } |
| 819 | ); |
| 820 | |
| 821 | let (handler, counter) = D::new_and_counter(); |
| 822 | store.set_debug_handler(handler); |
| 823 | store |
| 824 | .edit_breakpoints() |
| 825 | .unwrap() |
| 826 | .add_breakpoint(&module, ModulePC::new(0x28))?; |
| 827 | |
| 828 | let instance = Instance::new_async(&mut store, &module, &[]).await?; |
| 829 | let func = instance.get_func(&mut store, "main").unwrap(); |
| 830 | let mut results = [Val::I32(0)]; |
| 831 | func.call_async(&mut store, &[Val::I32(1), Val::I32(2)], &mut results) |
| 832 | .await?; |
| 833 | assert_eq!(counter.load(Ordering::Relaxed), 1); |
| 834 | assert_eq!(results[0].unwrap_i32(), 3); |
| 835 | |
| 836 | let breakpoints = store.breakpoints().unwrap().collect::<Vec<_>>(); |
| 837 | assert_eq!(breakpoints.len(), 1); |
| 838 | assert!(Module::same(&breakpoints[0].module, &module)); |
| 839 | assert_eq!(breakpoints[0].pc, ModulePC::new(0x28)); |
| 840 | |
| 841 | store |
| 842 | .edit_breakpoints() |
| 843 | .unwrap() |
| 844 | .remove_breakpoint(&module, ModulePC::new(0x28))?; |
| 845 | func.call_async(&mut store, &[Val::I32(1), Val::I32(2)], &mut results) |
nothing calls this directly
no test coverage detected