crash_context/lib.rs
1//! This crate exposes a platform specific [`CrashContext`] which contains the
2//! details for a crash (signal, exception, etc). This crate is fairly minimal
3//! since the intended use case is to more easily share these crash details
4//! between different crates without requiring lots of dependencies, and is
5//! currently only really made for the purposes of the crates in this repo, and
6//! [minidump-writer](https://github.com/rust-minidump/minidump-writer).
7//!
8//! ## Linux/Android
9//!
10//! This crate also contains a portable implementation of [`getcontext`](
11//! https://man7.org/linux/man-pages/man3/getcontext.3.html), as not all libc
12//! implementations (notably `musl`) implement it as it has been deprecated from
13//! POSIX.
14//!
15//! ## Macos
16//!
17//! One major difference on Macos is that the details in the [`CrashContext`]
18//! cannot be transferred to another process via normal methods (eg. sockets)
19//! and must be sent via the criminally undocumented mach ports. This crate
20//! provides a `Client` and `Server` that can be used to send and receive a
21//! [`CrashContext`] across processes so that you don't have to suffer like I
22//! did.
23
24// crate-specific exceptions:
25#![allow(unsafe_code, nonstandard_style)]
26
27cfg_if::cfg_if! {
28 if #[cfg(any(target_os = "linux", target_os = "android"))] {
29 mod linux;
30 pub use linux::*;
31 } else if #[cfg(target_os = "windows")] {
32 mod windows;
33 pub use windows::*;
34 } else if #[cfg(target_os = "macos")] {
35 mod mac;
36 pub use mac::*;
37 }
38}