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

Function frame_iterator

crates/unwinder/src/stackwalk.rs:285–307  ·  view source on GitHub ↗

Wrap `FrameCursor` in a true iterator. This captures the `unwind` borrow for the duration of the iterator's lifetime. # Safety Safety conditions for this function are the same as for the [`FrameCursor::new`] function, plus the condition on `unwind` from the [`FrameCursor::advance`] method.

(
    unwind: &dyn Unwind,
    pc: usize,
    fp: usize,
    trampoline_fp: usize,
)

Source from the content-addressed store, hash-verified

283/// [`FrameCursor::new`] function, plus the condition on `unwind` from
284/// the [`FrameCursor::advance`] method.
285pub unsafe fn frame_iterator(
286 unwind: &dyn Unwind,
287 pc: usize,
288 fp: usize,
289 trampoline_fp: usize,
290) -> impl Iterator<Item = Frame> {
291 // SAFETY: our safety conditions include those of
292 // `FrameCursor::new`.
293 let mut cursor = unsafe { FrameCursor::new(pc, fp, trampoline_fp) };
294 core::iter::from_fn(move || {
295 if cursor.done() {
296 None
297 } else {
298 let frame = cursor.frame();
299 // SAFETY: `unwind` is associated with the stack as per
300 // our safety conditions.
301 unsafe {
302 cursor.advance(unwind);
303 }
304 Some(frame)
305 }
306 })
307}
308
309/// Walk through a contiguous sequence of Wasm frames starting with
310/// the frame at the given PC and FP and ending at

Callers 1

visit_framesFunction · 0.85

Calls 4

frameMethod · 0.80
advanceMethod · 0.80
newFunction · 0.50
doneMethod · 0.45

Tested by

no test coverage detected