std: Unsafe-wrap backtrace code held in-common
This commit is contained in:
parent
ed809e9b79
commit
e4d89bc802
1 changed files with 63 additions and 59 deletions
|
@ -1,4 +1,5 @@
|
|||
//! Common code for printing backtraces.
|
||||
#![forbid(unsafe_op_in_unsafe_fn)]
|
||||
|
||||
use crate::backtrace_rs::{self, BacktraceFmt, BytesOrWideString, PrintFmt};
|
||||
use crate::borrow::Cow;
|
||||
|
@ -62,6 +63,8 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt::
|
|||
// Start immediately if we're not using a short backtrace.
|
||||
let mut start = print_fmt != PrintFmt::Short;
|
||||
set_image_base();
|
||||
// SAFETY: we roll our own locking in this town
|
||||
unsafe {
|
||||
backtrace_rs::trace_unsynchronized(|frame| {
|
||||
if print_fmt == PrintFmt::Short && idx > MAX_NB_FRAMES {
|
||||
return false;
|
||||
|
@ -128,7 +131,8 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt::
|
|||
|
||||
idx += 1;
|
||||
res.is_ok()
|
||||
});
|
||||
})
|
||||
};
|
||||
res?;
|
||||
bt_fmt.finish()?;
|
||||
if print_fmt == PrintFmt::Short {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue