legacy mode, win, fix layout code simulation

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2023-04-06 17:53:07 +08:00
parent 1bc0dd791e
commit ac74ed1914
3 changed files with 73 additions and 34 deletions

View File

@@ -4,11 +4,15 @@ pub mod linux;
#[cfg(target_os = "macos")]
pub mod macos;
#[cfg(not(debug_assertions))]
use crate::{config::Config, log};
#[cfg(not(debug_assertions))]
use std::process::exit;
#[cfg(not(debug_assertions))]
static mut GLOBAL_CALLBACK: Option<Box<dyn Fn()>> = None;
#[cfg(not(debug_assertions))]
extern "C" fn breakdown_signal_handler(sig: i32) {
let mut stack = vec![];
backtrace::trace(|frame| {
@@ -61,13 +65,13 @@ extern "C" fn breakdown_signal_handler(sig: i32) {
exit(0);
}
pub fn register_breakdown_handler<T>(_callback: T)
#[cfg(not(debug_assertions))]
pub fn register_breakdown_handler<T>(callback: T)
where
T: Fn() + 'static,
{
#[cfg(not(debug_assertions))]
unsafe {
GLOBAL_CALLBACK = Some(Box::new(_callback));
GLOBAL_CALLBACK = Some(Box::new(callback));
libc::signal(libc::SIGSEGV, breakdown_signal_handler as _);
}
}