Skip to main content

wasmtime/runtime/vm/traphandlers/
coredump_enabled.rs

1use super::CallThreadState;
2use crate::prelude::*;
3use crate::runtime::vm::{Backtrace, VMStoreContext};
4use wasm_encoder::CoreDumpValue;
5
6/// A WebAssembly Coredump
7#[derive(Debug)]
8pub struct CoreDumpStack {
9    /// The backtrace containing the stack frames for the CoreDump
10    pub bt: Backtrace,
11
12    /// The locals for each frame in the backtrace.
13    ///
14    /// This is not currently implemented.
15    pub locals: Vec<Vec<CoreDumpValue>>,
16
17    /// The operands for each stack frame
18    ///
19    /// This is not currently implemented.
20    pub operand_stack: Vec<Vec<CoreDumpValue>>,
21}
22
23impl CallThreadState {
24    pub(super) fn capture_coredump(
25        &self,
26        vm_store_context: *const VMStoreContext,
27        trap_pc_and_fp: Option<(usize, usize)>,
28    ) -> Option<CoreDumpStack> {
29        if !self.capture_coredump {
30            return None;
31        }
32        let bt = unsafe {
33            Backtrace::new_with_trap_state(vm_store_context, self.unwinder, self, trap_pc_and_fp)
34        };
35
36        Some(CoreDumpStack {
37            bt,
38            locals: vec![],
39            operand_stack: vec![],
40        })
41    }
42}