generated from EmbarkStudios/opensource-template
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add inital MacOS implementation (#17)
- Loading branch information
1 parent
556dd4d
commit 7049170
Showing
52 changed files
with
2,148 additions
and
545 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use mach2::{exception_types as et, mach_types as mt}; | ||
|
||
/// Information on the exception that caused the crash | ||
#[derive(Copy, Clone)] | ||
pub struct ExceptionInfo { | ||
/// The exception kind | ||
pub kind: et::exception_type_t, | ||
/// The exception code | ||
pub code: et::mach_exception_data_type_t, | ||
/// Optional subcode, typically only present for `EXC_BAD_ACCESS` exceptions | ||
pub subcode: Option<et::mach_exception_data_type_t>, | ||
} | ||
|
||
/// Mac crash context | ||
pub struct CrashContext { | ||
/// The process which crashed | ||
pub task: mt::task_t, | ||
/// The thread in the process that crashed | ||
pub thread: mt::thread_t, | ||
/// The thread that handled the exception. This may be useful to ignore. | ||
pub handler_thread: mt::thread_t, | ||
/// Optional exception information | ||
pub exception: Option<ExceptionInfo>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
cfg_if::cfg_if! { | ||
if #[cfg(target_arch = "x86_64")] { | ||
#[repr(C)] | ||
pub struct __jmp_buf([u64; 8]); | ||
} else if #[cfg(target_arch = "x86")] { | ||
#[repr(C)] | ||
pub struct __jmp_buf([u32; 6]); | ||
} else if #[cfg(target_arch = "arm")] { | ||
#[repr(C)] | ||
pub struct __jmp_buf([u64; 32]); | ||
} else if #[cfg(target_arch = "aarch64")] { | ||
#[repr(C)] | ||
pub struct __jmp_buf([u64; 22]); | ||
} | ||
} | ||
|
||
#[repr(C)] | ||
pub struct JmpBuf { | ||
/// CPU context | ||
__jmp_buf: __jmp_buf, | ||
/// Whether the signal mask was saved | ||
__fl: u32, | ||
/// Saved signal mask | ||
__ss: [u32; 32], | ||
} | ||
|
||
extern "C" { | ||
#[cfg_attr(target_env = "gnu", link_name = "__sigsetjmp")] | ||
pub fn sigsetjmp(jb: *mut JmpBuf, save_mask: i32) -> i32; | ||
pub fn siglongjmp(jb: *mut JmpBuf, val: i32) -> !; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.