This commit is contained in:
nora 2023-06-13 13:28:26 +02:00
parent 2875f34693
commit d1e561c665
7 changed files with 157 additions and 81 deletions

View file

@ -1,31 +1,30 @@
#![no_std]
#![allow(dead_code)]
use std::sync::atomic::AtomicPtr;
use core::sync::atomic::AtomicPtr;
macro_rules! trace {
($($tt:tt)*) => {
eprintln!("UWUWIND TRACE | uwuwind/{}:{}: {}", file!(), line!(), format_args!($($tt)*));
};
}
// Get the macros into our local prelude.
#[macro_use]
mod stdext;
pub mod uw;
mod arch;
mod dwarf;
mod identify;
mod walk;
#[allow(nonstandard_style)]
pub unsafe extern "C" fn _UnwindRaiseException(
exception_object: *mut uw::_Unwind_Exception,
) -> uw::_Unwind_Reason_Code {
println!("someone raised an exception with addr {exception_object:p}");
trace!("someone raised an exception with addr {exception_object:p}");
crate::dwarf::dwarf_info(arch::get_rip() as _);
// walk::fp::walk();
std::process::abort();
stdext::abort();
}
// This is normally provided by the language runtime through the unwind info block.
@ -33,6 +32,6 @@ pub unsafe extern "C" fn _UnwindRaiseException(
static PERSONALITY_ROUTINE: AtomicPtr<()> = AtomicPtr::new(core::ptr::null_mut());
pub unsafe fn set_personality_routine(routine: uw::PersonalityRoutine) {
let ptr: *mut () = std::mem::transmute(routine);
PERSONALITY_ROUTINE.store(ptr, std::sync::atomic::Ordering::Relaxed);
let ptr: *mut () = core::mem::transmute(routine);
PERSONALITY_ROUTINE.store(ptr, core::sync::atomic::Ordering::Relaxed);
}