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

Function coredump_has_stack

tests/all/coredump.rs:39–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

37#[test]
38#[cfg_attr(miri, ignore)]
39fn coredump_has_stack() -> Result<()> {
40 let _ = env_logger::try_init();
41 let mut config = Config::default();
42 config.coredump_on_trap(true);
43 let engine = Engine::new(&config).unwrap();
44 let mut store = Store::<()>::new(&engine, ());
45
46 let wat = r#"
47 (module
48 (func $a (export "a")
49 call $b
50 )
51 (func $b
52 call $c
53 )
54 (func $c
55 unreachable
56 )
57 )
58 "#;
59
60 let module = Module::new(store.engine(), wat)?;
61 let instance = Instance::new(&mut store, &module, &[])?;
62 let a_func = instance.get_typed_func::<(), ()>(&mut store, "a")?;
63
64 let e = a_func.call(&mut store, ()).unwrap_err();
65 let cd = e.downcast_ref::<WasmCoreDump>().unwrap();
66 assert_eq!(cd.frames().len(), 3);
67 assert_eq!(cd.frames()[0].func_name().unwrap(), "c");
68 assert_eq!(cd.frames()[1].func_name().unwrap(), "b");
69 assert_eq!(cd.frames()[2].func_name().unwrap(), "a");
70 let _ = cd.serialize(&mut store, "stack");
71 Ok(())
72}
73
74#[test]
75#[cfg_attr(miri, ignore)]

Callers

nothing calls this directly

Calls 7

OkFunction · 0.85
coredump_on_trapMethod · 0.80
newFunction · 0.50
unwrapMethod · 0.45
engineMethod · 0.45
callMethod · 0.45
serializeMethod · 0.45

Tested by

no test coverage detected