Files
rust/src/libstd/sys/cloudabi/mod.rs
T
Alex Crichton d1040fe329 std: Depend on backtrace crate from crates.io
This commit removes all in-tree support for generating backtraces in
favor of depending on the `backtrace` crate on crates.io. This resolves
a very longstanding piece of duplication where the standard library has
long contained the ability to generate a backtrace on panics, but the
code was later extracted and duplicated on crates.io with the
`backtrace` crate. Since that fork each implementation has seen various
improvements one way or another, but typically `backtrace`-the-crate has
lagged behind libstd in one way or another.

The goal here is to remove this duplication of a fairly critical piece
of code and ensure that there's only one source of truth for generating
backtraces between the standard library and the crate on crates.io.
Recently I've been working to bring the `backtrace` crate on crates.io
up to speed with the support in the standard library which includes:

* Support for `StackWalkEx` on MSVC to recover inline frames with
  debuginfo.
* Using `libbacktrace` by default on MinGW targets.
* Supporting `libbacktrace` on OSX as an option.
* Ensuring all the requisite support in `backtrace`-the-crate compiles
  with `#![no_std]`.
* Updating the `libbacktrace` implementation in `backtrace`-the-crate to
  initialize the global state with the correct filename where necessary.

After reviewing the code in libstd the `backtrace` crate should be at
exact feature parity with libstd today. The backtraces generated should
have the same symbols and same number of frames in general, and there's
not known divergence from libstd currently.

Note that one major difference between libstd's backtrace support and
the `backtrace` crate is that on OSX the crates.io crate enables the
`coresymbolication` feature by default. This feature, however, uses
private internal APIs that aren't published for OSX. While they provide
more accurate backtraces this isn't appropriate for libstd distributed
as a binary, so libstd's dependency on the `backtrace` crate explicitly
disables this feature and forces OSX to use `libbacktrace` as a
symbolication strategy.

The long-term goal of this refactoring is to eventually move us towards
a world where we can drop `libbacktrace` entirely and simply use Gimli
and the surrounding crates for backtrace support. That's still aways off
but hopefully will much more easily enabled by having the source of
truth for backtraces live in crates.io!

Procedurally if we go forward with this I'd like to transfer the
`backtrace-rs` crate to the rust-lang GitHub organization as well, but I
figured I'd hold off on that until we get closer to merging.
2019-05-25 17:09:45 -07:00

67 lines
2.0 KiB
Rust

use crate::io::ErrorKind;
use crate::mem;
#[path = "../unix/alloc.rs"]
pub mod alloc;
pub mod args;
#[path = "../unix/cmath.rs"]
pub mod cmath;
pub mod condvar;
pub mod io;
#[path = "../unix/memchr.rs"]
pub mod memchr;
pub mod mutex;
pub mod os;
pub mod rwlock;
pub mod stack_overflow;
pub mod stdio;
pub mod thread;
#[path = "../unix/thread_local.rs"]
pub mod thread_local;
pub mod time;
pub use crate::sys_common::os_str_bytes as os_str;
mod abi;
mod shims;
pub use self::shims::*;
#[allow(dead_code)]
pub fn init() {}
pub fn decode_error_kind(errno: i32) -> ErrorKind {
match errno {
x if x == abi::errno::ACCES as i32 => ErrorKind::PermissionDenied,
x if x == abi::errno::ADDRINUSE as i32 => ErrorKind::AddrInUse,
x if x == abi::errno::ADDRNOTAVAIL as i32 => ErrorKind::AddrNotAvailable,
x if x == abi::errno::AGAIN as i32 => ErrorKind::WouldBlock,
x if x == abi::errno::CONNABORTED as i32 => ErrorKind::ConnectionAborted,
x if x == abi::errno::CONNREFUSED as i32 => ErrorKind::ConnectionRefused,
x if x == abi::errno::CONNRESET as i32 => ErrorKind::ConnectionReset,
x if x == abi::errno::EXIST as i32 => ErrorKind::AlreadyExists,
x if x == abi::errno::INTR as i32 => ErrorKind::Interrupted,
x if x == abi::errno::INVAL as i32 => ErrorKind::InvalidInput,
x if x == abi::errno::NOENT as i32 => ErrorKind::NotFound,
x if x == abi::errno::NOTCONN as i32 => ErrorKind::NotConnected,
x if x == abi::errno::PERM as i32 => ErrorKind::PermissionDenied,
x if x == abi::errno::PIPE as i32 => ErrorKind::BrokenPipe,
x if x == abi::errno::TIMEDOUT as i32 => ErrorKind::TimedOut,
_ => ErrorKind::Other,
}
}
pub unsafe fn abort_internal() -> ! {
core::intrinsics::abort();
}
pub use libc::strlen;
pub fn hashmap_random_keys() -> (u64, u64) {
unsafe {
let mut v = mem::uninitialized();
libc::arc4random_buf(&mut v as *mut _ as *mut libc::c_void, mem::size_of_val(&v));
v
}
}