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