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

Function breakpoints_in_inlined_code

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

Source from the content-addressed store, hash-verified

922#[tokio::test]
923#[cfg_attr(miri, ignore)]
924async fn breakpoints_in_inlined_code() -> wasmtime::Result<()> {
925 let _ = env_logger::try_init();
926
927 let (module, mut store) = get_module_and_store(
928 |config| {
929 config.wasm_exceptions(true);
930 config.compiler_inlining(Inlining::Yes);
931 },
932 r#"
933 (module
934 (func $f (export "f") (param i32 i32) (result i32)
935 local.get 0
936 local.get 1
937 i32.add)
938
939 (func (export "main") (param i32 i32) (result i32)
940 local.get 0
941 local.get 1
942 call $f))
943 "#,
944 )?;
945
946 debug_event_checker!(
947 D, store,
948 { 0 ;
949 wasmtime::DebugEvent::Breakpoint => {}
950 },
951 { 1 ;
952 wasmtime::DebugEvent::Breakpoint => {}
953 }
954 );
955
956 let (handler, counter) = D::new_and_counter();
957 store.set_debug_handler(handler);
958 store
959 .edit_breakpoints()
960 .unwrap()
961 .add_breakpoint(&module, ModulePC::new(0x2d))?; // `i32.add` in `$f`.
962
963 let instance = Instance::new_async(&mut store, &module, &[]).await?;
964 let func_main = instance.get_func(&mut store, "main").unwrap();
965 let func_f = instance.get_func(&mut store, "f").unwrap();
966 let mut results = [Val::I32(0)];
967 // Breakpoint in `$f` should have been hit in `main` even if it
968 // was inlined.
969 func_main
970 .call_async(&mut store, &[Val::I32(1), Val::I32(2)], &mut results)
971 .await?;
972 assert_eq!(counter.load(Ordering::Relaxed), 1);
973 assert_eq!(results[0].unwrap_i32(), 3);
974
975 // Breakpoint in `$f` should be hit when called directly, too.
976 func_f
977 .call_async(&mut store, &[Val::I32(1), Val::I32(2)], &mut results)
978 .await?;
979 assert_eq!(counter.load(Ordering::Relaxed), 2);
980 assert_eq!(results[0].unwrap_i32(), 3);
981

Callers

nothing calls this directly

Calls 11

get_module_and_storeFunction · 0.85
OkFunction · 0.85
compiler_inliningMethod · 0.80
set_debug_handlerMethod · 0.80
edit_breakpointsMethod · 0.80
newFunction · 0.50
wasm_exceptionsMethod · 0.45
add_breakpointMethod · 0.45
unwrapMethod · 0.45
get_funcMethod · 0.45
call_asyncMethod · 0.45

Tested by

no test coverage detected