Compare commits
No commits in common. "978cc419f9db73a5fd115c1969809c4994869cb9" and "4adf2d434fdf7d3a9b5c976ae0f1299b36de5151" have entirely different histories.
978cc419f9
...
4adf2d434f
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "unwinding"
|
name = "unwinding"
|
||||||
version = "0.1.5"
|
version = "0.1.4"
|
||||||
authors = ["Gary Guo <gary@garyguo.net>"]
|
authors = ["Gary Guo <gary@garyguo.net>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
|
@ -137,7 +137,7 @@ binding! {
|
|||||||
extern "C-unwind" fn _Unwind_RaiseException(
|
extern "C-unwind" fn _Unwind_RaiseException(
|
||||||
exception: &mut UnwindException,
|
exception: &mut UnwindException,
|
||||||
) -> UnwindReasonCode;
|
) -> UnwindReasonCode;
|
||||||
extern "C-unwind" fn _Unwind_ForcedUnwind(
|
extern "C-unwind" fn _Unwind_ForceUnwind(
|
||||||
exception: &mut UnwindException,
|
exception: &mut UnwindException,
|
||||||
stop: UnwindStopFn,
|
stop: UnwindStopFn,
|
||||||
stop_arg: *mut c_void,
|
stop_arg: *mut c_void,
|
||||||
|
12
src/panic.rs
12
src/panic.rs
@ -8,15 +8,15 @@ pub use crate::panic_handler::*;
|
|||||||
use crate::panicking::Exception;
|
use crate::panicking::Exception;
|
||||||
|
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct RustPanic(Box<dyn Any + Send>, DropGuard);
|
struct RustPanic(Box<dyn Any + Send>, ForeignGuard);
|
||||||
|
|
||||||
struct DropGuard;
|
struct ForeignGuard;
|
||||||
|
|
||||||
impl Drop for DropGuard {
|
impl Drop for ForeignGuard {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
#[cfg(feature = "panic-handler")]
|
#[cfg(feature = "panic-handler")]
|
||||||
{
|
{
|
||||||
drop_panic();
|
foreign_exception();
|
||||||
}
|
}
|
||||||
core::intrinsics::abort();
|
core::intrinsics::abort();
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ unsafe impl Exception for RustPanic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn begin_panic(payload: Box<dyn Any + Send>) -> UnwindReasonCode {
|
pub fn begin_panic(payload: Box<dyn Any + Send>) -> UnwindReasonCode {
|
||||||
crate::panicking::begin_panic(RustPanic(payload, DropGuard))
|
crate::panicking::begin_panic(RustPanic(payload, ForeignGuard))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn catch_unwind<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>> {
|
pub fn catch_unwind<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>> {
|
||||||
@ -55,7 +55,7 @@ pub fn catch_unwind<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
|
|||||||
None => {
|
None => {
|
||||||
#[cfg(feature = "panic-handler")]
|
#[cfg(feature = "panic-handler")]
|
||||||
{
|
{
|
||||||
foreign_exception();
|
drop_panic();
|
||||||
}
|
}
|
||||||
core::intrinsics::abort();
|
core::intrinsics::abort();
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ pub extern "C-unwind" fn save_context() -> Context {
|
|||||||
mov [rax + 0x78], r15
|
mov [rax + 0x78], r15
|
||||||
mov rdx, [rsp]
|
mov rdx, [rsp]
|
||||||
mov [rax + 0x80], rdx
|
mov [rax + 0x80], rdx
|
||||||
/* stmxcsr [rax + 0x88] */
|
stmxcsr [rax + 0x88]
|
||||||
fnstcw [rax + 0x90]
|
fnstcw [rax + 0x90]
|
||||||
ret
|
ret
|
||||||
",
|
",
|
||||||
@ -95,7 +95,7 @@ pub unsafe extern "C" fn restore_context(ctx: &Context) -> ! {
|
|||||||
mov rsp, [rdi + 0x38]
|
mov rsp, [rdi + 0x38]
|
||||||
|
|
||||||
/* Restore callee-saved control registers */
|
/* Restore callee-saved control registers */
|
||||||
/* ldmxcsr [rdi + 0x88] */
|
ldmxcsr [rdi + 0x88]
|
||||||
fldcw [rdi + 0x90]
|
fldcw [rdi + 0x90]
|
||||||
|
|
||||||
/* Restore return address */
|
/* Restore return address */
|
||||||
|
@ -27,7 +27,7 @@ const fn next_value(x: usize) -> usize {
|
|||||||
|
|
||||||
impl<R: gimli::Reader> gimli::UnwindContextStorage<R> for StoreOnStack {
|
impl<R: gimli::Reader> gimli::UnwindContextStorage<R> for StoreOnStack {
|
||||||
type Rules = [(Register, RegisterRule<R>); next_value(MAX_REG_RULES)];
|
type Rules = [(Register, RegisterRule<R>); next_value(MAX_REG_RULES)];
|
||||||
type Stack = [UnwindTableRow<R, Self>; 2];
|
type Stack = [UnwindTableRow<R, Self>; 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "dwarf-expr")]
|
#[cfg(feature = "dwarf-expr")]
|
||||||
|
@ -217,7 +217,7 @@ fn raise_exception_phase2(
|
|||||||
|
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C-unwind" fn _Unwind_ForcedUnwind(
|
pub extern "C-unwind" fn _Unwind_ForceUnwind(
|
||||||
exception: &mut UnwindException,
|
exception: &mut UnwindException,
|
||||||
stop: UnwindStopFn,
|
stop: UnwindStopFn,
|
||||||
stop_arg: *mut c_void,
|
stop_arg: *mut c_void,
|
||||||
|
Loading…
Reference in New Issue
Block a user