MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / caught_exception_events

Function caught_exception_events

tests/all/debug.rs:648–696  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

646#[tokio::test]
647#[cfg_attr(miri, ignore)]
648async fn caught_exception_events() -> wasmtime::Result<()> {
649 let _ = env_logger::try_init();
650
651 let (module, mut store) = get_module_and_store(
652 |config| {
653 config.wasm_exceptions(true);
654 },
655 r#"
656 (module
657 (tag $t (param i32))
658 (func (export "main")
659 (block $b (result i32)
660 (try_table (catch $t $b)
661 call 1)
662 i32.const 0)
663 drop)
664 (func
665 (local $i i32)
666 (local.set $i (i32.const 100))
667 (throw $t (i32.const 42))))
668 "#,
669 )?;
670
671 debug_event_checker!(
672 D, store,
673 { 0 ;
674 wasmtime::DebugEvent::Exception(e) => {
675 assert_eq!(e.field(&mut store, 0).unwrap().unwrap_i32(), 42);
676 let stack = store.debug_exit_frames().next().unwrap();
677 assert_eq!(stack.num_locals(&mut store).unwrap(), 1);
678 assert_eq!(stack.local(&mut store, 0).unwrap().unwrap_i32(), 100);
679 let stack = stack.parent(&mut store).unwrap().unwrap();
680 let stack = stack.parent(&mut store).unwrap();
681 assert!(stack.is_none());
682 }
683 }
684 );
685
686 let (handler, counter) = D::new_and_counter();
687 store.set_debug_handler(handler);
688
689 let instance = Instance::new_async(&mut store, &module, &[]).await?;
690 let func = instance.get_func(&mut store, "main").unwrap();
691 let mut results = [];
692 func.call_async(&mut store, &[], &mut results).await?;
693 assert_eq!(counter.load(Ordering::Relaxed), 1);
694
695 Ok(())
696}
697
698#[tokio::test]
699#[cfg_attr(miri, ignore)]

Callers

nothing calls this directly

Calls 7

get_module_and_storeFunction · 0.85
OkFunction · 0.85
set_debug_handlerMethod · 0.80
wasm_exceptionsMethod · 0.45
unwrapMethod · 0.45
get_funcMethod · 0.45
call_asyncMethod · 0.45

Tested by

no test coverage detected