mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
std: Unsafe-wrap backtrace code held in-common
This commit is contained in:
parent
ed809e9b79
commit
e4d89bc802
@ -1,4 +1,5 @@
|
|||||||
//! Common code for printing backtraces.
|
//! Common code for printing backtraces.
|
||||||
|
#![forbid(unsafe_op_in_unsafe_fn)]
|
||||||
|
|
||||||
use crate::backtrace_rs::{self, BacktraceFmt, BytesOrWideString, PrintFmt};
|
use crate::backtrace_rs::{self, BacktraceFmt, BytesOrWideString, PrintFmt};
|
||||||
use crate::borrow::Cow;
|
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.
|
// Start immediately if we're not using a short backtrace.
|
||||||
let mut start = print_fmt != PrintFmt::Short;
|
let mut start = print_fmt != PrintFmt::Short;
|
||||||
set_image_base();
|
set_image_base();
|
||||||
|
// SAFETY: we roll our own locking in this town
|
||||||
|
unsafe {
|
||||||
backtrace_rs::trace_unsynchronized(|frame| {
|
backtrace_rs::trace_unsynchronized(|frame| {
|
||||||
if print_fmt == PrintFmt::Short && idx > MAX_NB_FRAMES {
|
if print_fmt == PrintFmt::Short && idx > MAX_NB_FRAMES {
|
||||||
return false;
|
return false;
|
||||||
@ -128,7 +131,8 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt::
|
|||||||
|
|
||||||
idx += 1;
|
idx += 1;
|
||||||
res.is_ok()
|
res.is_ok()
|
||||||
});
|
})
|
||||||
|
};
|
||||||
res?;
|
res?;
|
||||||
bt_fmt.finish()?;
|
bt_fmt.finish()?;
|
||||||
if print_fmt == PrintFmt::Short {
|
if print_fmt == PrintFmt::Short {
|
||||||
|
Loading…
Reference in New Issue
Block a user