From 31a3228d3e1c04e2bbc845d5beaa9181e12c4a9a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 12 May 2020 09:51:31 -0700 Subject: [PATCH] Switch to `gimli-symbolize` by default This commit switches this crate to using `gimli` by default for parsing DWARF debug information. This is a long time coming and brings a number of benefits: * Primarily, Rust is safe. The libbacktrace library has been plagued with segfaults ever since we first started using it. Gimli, however, is almost entirely safe code. This should make us much more resilient in the face of buggy debuginfo. * Secondarily, it means this library no longer needs a C compiler. Being an all-Rust crate generally makes it much easier to cross-compile, port, etc. * Finally, this paves the road for future improvements such as split-debuginfo support by default. The libbacktrace library hasn't really changed since we started using it years ago, and this gives us more control over what's used and how now. Closes #189 --- .github/workflows/main.yml | 5 ++++- Cargo.toml | 15 ++++++++------- src/symbolize/gimli.rs | 1 - src/symbolize/mod.rs | 1 + 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 37dbff82b..14a830dd6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -59,6 +59,8 @@ jobs: - run: cargo build - run: cargo test - run: cargo test --features "gimli-symbolize" + - run: cargo test --features "libbacktrace" + - run: cargo test --features "libbacktrace gimli-symbolize" - run: cargo test --features "serialize-rustc" - run: cargo test --features "serialize-serde" - run: cargo test --features "verify-winapi" @@ -66,6 +68,7 @@ jobs: - run: cargo test --no-default-features - run: cargo test --no-default-features --features "libbacktrace" - run: cargo test --no-default-features --features "gimli-symbolize" + - run: cargo test --no-default-features --features "gimli-symbolize libbacktrace" - run: cargo test --no-default-features --features "libbacktrace std" - run: cargo test --no-default-features --features "gimli-symbolize std" - run: cargo test --no-default-features --features "std" @@ -182,5 +185,5 @@ jobs: with: submodules: true - name: Install Rust - run: rustup update 1.32.0 && rustup default 1.32.0 + run: rustup update 1.40.0 && rustup default 1.40.0 - run: cargo build diff --git a/Cargo.toml b/Cargo.toml index 0a7cd8a45..6e97821d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,8 +49,8 @@ features = ['read_core', 'elf', 'macho', 'pe'] winapi = { version = "0.3.3", optional = true } [features] -# By default libstd support and libbacktrace is used to symbolize addresses. -default = ["std", "libbacktrace"] +# By default libstd support and gimli-symbolize is used to symbolize addresses. +default = ["std", "gimli-symbolize"] # Include std support. This enables types like `Backtrace`. std = [] @@ -58,16 +58,17 @@ std = [] #======================================= # Methods of resolving symbols # -# - libbacktrace: this feature activates the `backtrace-sys` dependency, -# building the libbacktrace library found in gcc repos. This is the historical -# default for the `backtrace` crate. # - gimli-symbolize: use the `gimli-rs/addr2line` crate to symbolicate # addresses into file, line, and name using DWARF debug information. +# - libbacktrace: this feature activates the `backtrace-sys` dependency, +# building the libbacktrace library found in gcc repos. # # Note that MSVC unconditionally uses the dbghelp library to symbolize and won't -# be affected by feature selection here. -libbacktrace = ["backtrace-sys/backtrace-sys"] +# be affected by feature selection here. Also note that it's highly unlikely you +# want to configure this. If you're having trouble getting backtraces it's +# likely best to open an issue. gimli-symbolize = ["addr2line", "object", "std"] +libbacktrace = ["backtrace-sys/backtrace-sys"] #======================================= # Methods of serialization diff --git a/src/symbolize/gimli.rs b/src/symbolize/gimli.rs index 36709761b..4205f5d84 100644 --- a/src/symbolize/gimli.rs +++ b/src/symbolize/gimli.rs @@ -282,7 +282,6 @@ cfg_if::cfg_if! { use self::elf::Object; fn native_libraries() -> Vec { - wut(); let mut ret = Vec::new(); unsafe { libc::dl_iterate_phdr(Some(callback), &mut ret as *mut _ as *mut _); diff --git a/src/symbolize/mod.rs b/src/symbolize/mod.rs index acb90e4f9..4a3d6abb5 100644 --- a/src/symbolize/mod.rs +++ b/src/symbolize/mod.rs @@ -463,6 +463,7 @@ cfg_if::cfg_if! { unsafe fn clear_symbol_cache_imp() {} } else if #[cfg(all( feature = "gimli-symbolize", + any(unix, windows), not(target_os = "emscripten"), ))] { mod gimli;