(&self, func: Cow<ir::Function>, context: &Context)
| 35 | } |
| 36 | |
| 37 | fn run(&self, func: Cow<ir::Function>, context: &Context) -> anyhow::Result<()> { |
| 38 | let isa = context.isa.expect("unwind needs an ISA"); |
| 39 | let mut comp_ctx = cranelift_codegen::Context::for_function(func.into_owned()); |
| 40 | |
| 41 | let code = comp_ctx |
| 42 | .compile(isa, &mut Default::default()) |
| 43 | .expect("failed to compile function"); |
| 44 | |
| 45 | let mut text = String::new(); |
| 46 | match code.create_unwind_info(isa).expect("unwind info") { |
| 47 | Some(UnwindInfo::WindowsX64(info)) => { |
| 48 | let mut mem = vec![0; info.emit_size()]; |
| 49 | info.emit(&mut mem); |
| 50 | windowsx64::dump(&mut text, &mem); |
| 51 | } |
| 52 | Some(UnwindInfo::SystemV(info)) => { |
| 53 | let mut table = FrameTable::default(); |
| 54 | let cie = isa |
| 55 | .create_systemv_cie() |
| 56 | .expect("the ISA should support a System V CIE"); |
| 57 | |
| 58 | let cie_id = table.add_cie(cie); |
| 59 | table.add_fde(cie_id, info.to_fde(Address::Constant(0))); |
| 60 | |
| 61 | let mut eh_frame = EhFrame(EndianVec::new(LittleEndian)); |
| 62 | table.write_eh_frame(&mut eh_frame).unwrap(); |
| 63 | systemv::dump(&mut text, &eh_frame.0.into_vec(), isa.pointer_bytes()) |
| 64 | } |
| 65 | Some(ui) => { |
| 66 | anyhow::bail!("Unexpected unwind info type: {ui:?}"); |
| 67 | } |
| 68 | None => {} |
| 69 | } |
| 70 | |
| 71 | run_filecheck(&text, context) |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | mod windowsx64 { |
nothing calls this directly
no test coverage detected