Skip to content

Disable backtraces on OSX #45760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/libbacktrace/configure
Original file line number Diff line number Diff line change
@@ -11844,9 +11844,6 @@ elf*) FORMAT_FILE="elf.lo" ;;
pecoff) FORMAT_FILE="pecoff.lo"
backtrace_supports_data=no
;;
macho*) FORMAT_FILE="macho.lo"
backtrace_supports_data=no
;;
*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not determine output file type" >&5
$as_echo "$as_me: WARNING: could not determine output file type" >&2;}
FORMAT_FILE="unknown.lo"
3 changes: 0 additions & 3 deletions src/libbacktrace/configure.ac
Original file line number Diff line number Diff line change
@@ -231,9 +231,6 @@ elf*) FORMAT_FILE="elf.lo" ;;
pecoff) FORMAT_FILE="pecoff.lo"
backtrace_supports_data=no
;;
macho*) FORMAT_FILE="macho.lo"
backtrace_supports_data=no
;;
*) AC_MSG_WARN([could not determine output file type])
FORMAT_FILE="unknown.lo"
backtrace_supported=no
6 changes: 0 additions & 6 deletions src/libbacktrace/filetype.awk
Original file line number Diff line number Diff line change
@@ -3,9 +3,3 @@
/\177ELF\002/ { if (NR == 1) { print "elf64"; exit } }
/\114\001/ { if (NR == 1) { print "pecoff"; exit } }
/\144\206/ { if (NR == 1) { print "pecoff"; exit } }
/\xFE\xED\xFA\xCE/ { if (NR == 1) { print "macho32"; exit } }
/\xCE\xFA\xED\xFE/ { if (NR == 1) { print "macho32"; exit } }
/\xFE\xED\xFA\xCF/ { if (NR == 1) { print "macho64"; exit } }
/\xCF\xFA\xED\xFE/ { if (NR == 1) { print "macho64"; exit } }
/\xCA\xFE\xBA\xBE/ { if (NR == 1) { print "macho-fat"; exit } }
/\xBE\xBA\xFE\xCA/ { if (NR == 1) { print "macho-fat"; exit } }
1,416 changes: 0 additions & 1,416 deletions src/libbacktrace/macho.c

This file was deleted.

2 changes: 1 addition & 1 deletion src/libstd/build.rs
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ use build_helper::{run, native_lib_boilerplate, BuildExpectation};
fn main() {
let target = env::var("TARGET").expect("TARGET was not set");
let host = env::var("HOST").expect("HOST was not set");
if cfg!(feature = "backtrace") && !target.contains("msvc") &&
if cfg!(feature = "backtrace") && !target.contains("apple") && !target.contains("msvc") &&
!target.contains("emscripten") && !target.contains("fuchsia") {
let _ = build_libbacktrace(&host, &target);
}
16 changes: 1 addition & 15 deletions src/libstd/sys/unix/backtrace/mod.rs
Original file line number Diff line number Diff line change
@@ -91,29 +91,15 @@ mod tracing;
// symbol resolvers:
mod printing;

#[cfg(not(target_os = "emscripten"))]
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "emscripten")))]
pub mod gnu {
use io;
use fs;
use libc::c_char;

#[cfg(not(any(target_os = "macos", target_os = "ios")))]
pub fn get_executable_filename() -> io::Result<(Vec<c_char>, fs::File)> {
Err(io::Error::new(io::ErrorKind::Other, "Not implemented"))
}

#[cfg(any(target_os = "macos", target_os = "ios"))]
pub fn get_executable_filename() -> io::Result<(Vec<c_char>, fs::File)> {
use env;
use os::unix::ffi::OsStrExt;

let filename = env::current_exe()?;
let file = fs::File::open(&filename)?;
let mut filename_cstr: Vec<_> = filename.as_os_str().as_bytes().iter()
.map(|&x| x as c_char).collect();
filename_cstr.push(0); // Null terminate
Ok((filename_cstr, file))
}
}

pub struct BacktraceContext;
8 changes: 8 additions & 0 deletions src/libstd/sys/unix/backtrace/printing/dladdr.rs
Original file line number Diff line number Diff line change
@@ -32,6 +32,14 @@ pub fn resolve_symname<F>(frame: Frame,
}
}

pub fn foreach_symbol_fileline<F>(_symbol_addr: Frame,
_f: F,
_: &BacktraceContext) -> io::Result<bool>
where F: FnMut(&[u8], libc::c_int) -> io::Result<()>
{
Ok(false)
}

#[repr(C)]
struct Dl_info {
dli_fname: *const libc::c_char,
41 changes: 10 additions & 31 deletions src/libstd/sys/unix/backtrace/printing/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014-2017 The Rust Project Developers. See the COPYRIGHT
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@@ -8,36 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

mod dladdr;
pub use self::imp::{foreach_symbol_fileline, resolve_symname};

use sys::backtrace::BacktraceContext;
use sys_common::backtrace::Frame;
use io;
#[cfg(any(target_os = "macos", target_os = "ios",
target_os = "emscripten"))]
#[path = "dladdr.rs"]
mod imp;

#[cfg(target_os = "emscripten")]
pub use self::dladdr::resolve_symname;

#[cfg(target_os = "emscripten")]
pub fn foreach_symbol_fileline<F>(_: Frame, _: F, _: &BacktraceContext) -> io::Result<bool>
where
F: FnMut(&[u8], ::libc::c_int) -> io::Result<()>
{
Ok(false)
}

#[cfg(not(target_os = "emscripten"))]
pub use sys_common::gnu::libbacktrace::foreach_symbol_fileline;

#[cfg(not(target_os = "emscripten"))]
pub fn resolve_symname<F>(frame: Frame, callback: F, bc: &BacktraceContext) -> io::Result<()>
where
F: FnOnce(Option<&str>) -> io::Result<()>
{
::sys_common::gnu::libbacktrace::resolve_symname(frame, |symname| {
if symname.is_some() {
callback(symname)
} else {
dladdr::resolve_symname(frame, callback, bc)
}
}, bc)
#[cfg(not(any(target_os = "macos", target_os = "ios",
target_os = "emscripten")))]
mod imp {
pub use sys_common::gnu::libbacktrace::{foreach_symbol_fileline, resolve_symname};
}
2 changes: 1 addition & 1 deletion src/libstd/sys_common/mod.rs
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ pub use sys::net;
pub mod net;

#[cfg(feature = "backtrace")]
#[cfg(any(all(unix, not(target_os = "emscripten")),
#[cfg(any(all(unix, not(any(target_os = "macos", target_os = "ios", target_os = "emscripten"))),
all(windows, target_env = "gnu"),
target_os = "redox"))]
pub mod gnu;
4 changes: 3 additions & 1 deletion src/test/run-pass/backtrace-debuginfo.rs
Original file line number Diff line number Diff line change
@@ -31,7 +31,9 @@ macro_rules! dump_and_die {
($($pos:expr),*) => ({
// FIXME(#18285): we cannot include the current position because
// the macro span takes over the last frame's file/line.
if cfg!(any(target_os = "android",
if cfg!(any(target_os = "macos",
target_os = "ios",
target_os = "android",
all(target_os = "linux", target_arch = "arm"),
target_os = "freebsd",
target_os = "dragonfly",