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

Function parse_dwarf_info

tests/all/traps.rs:729–763  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

727
728#[test]
729fn parse_dwarf_info() -> Result<()> {
730 let wasm = rustc(
731 "
732 fn main() {
733 panic!();
734 }
735 ",
736 );
737 let mut config = Config::new();
738 config.wasm_backtrace_details(WasmBacktraceDetails::Enable);
739 let engine = Engine::new(&config)?;
740 let module = Module::new(&engine, &wasm)?;
741 let mut linker = Linker::new(&engine);
742 wasmtime_wasi::p1::add_to_linker_sync(&mut linker, |t| t)?;
743 let mut store = Store::new(&engine, wasmtime_wasi::WasiCtxBuilder::new().build_p1());
744 linker.module(&mut store, "", &module)?;
745 let run = linker.get_default(&mut store, "")?;
746 let trap = run.call(&mut store, &[], &mut []).unwrap_err();
747
748 let mut found = false;
749 let frames = trap.downcast_ref::<WasmBacktrace>().unwrap().frames();
750 for frame in frames {
751 for symbol in frame.symbols() {
752 if let Some(file) = symbol.file() {
753 if file.ends_with("input.rs") {
754 found = true;
755 assert!(symbol.name().unwrap().contains("main"));
756 assert_eq!(symbol.line(), Some(3));
757 }
758 }
759 }
760 }
761 assert!(found);
762 Ok(())
763}
764
765#[test]
766fn no_hint_even_with_dwarf_info() -> Result<()> {

Callers

nothing calls this directly

Calls 13

rustcFunction · 0.85
OkFunction · 0.85
build_p1Method · 0.80
newFunction · 0.50
add_to_linker_syncFunction · 0.50
moduleMethod · 0.45
get_defaultMethod · 0.45
callMethod · 0.45
framesMethod · 0.45
unwrapMethod · 0.45
symbolsMethod · 0.45

Tested by

no test coverage detected