pub mod jmp;
mod signal;
mod state;
use crate::Error;
#[derive(Copy, Clone)]
#[repr(i32)]
#[allow(overflowing_literals)]
pub enum ExceptionCode {
Abort = 0x40000015, Fpe = -1073741676, Illegal = -1073741795, Segv = -1073741819, StackOverflow = -1073741571, Trap = -2147483645, InvalidParameter = -1073741811, Purecall = -1073741787, User = 0xcca11ed, HeapCorruption = 0xc0000374, }
pub struct CrashHandler;
#[allow(clippy::unused_self)]
impl CrashHandler {
pub fn attach(on_crash: Box<dyn crate::CrashEvent>) -> Result<Self, Error> {
state::attach(on_crash)?;
Ok(Self)
}
#[inline]
pub fn detach(self) {
state::detach();
}
pub fn simulate_exception(&self, exception_code: Option<i32>) -> crate::CrashEventResult {
unsafe { state::simulate_exception(exception_code) }
}
}
impl Drop for CrashHandler {
fn drop(&mut self) {
state::detach();
}
}