Skip to content

Commit

Permalink
Switch to gimli-symbolize by default
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alexcrichton committed May 12, 2020
1 parent bb5aa64 commit 682df6a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Expand Up @@ -59,13 +59,16 @@ 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"
- run: cargo test --features "cpp_demangle"
- 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"
Expand Down
15 changes: 8 additions & 7 deletions Cargo.toml
Expand Up @@ -49,25 +49,26 @@ 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 = []

#=======================================
# 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
Expand Down
1 change: 0 additions & 1 deletion src/symbolize/gimli.rs
Expand Up @@ -282,7 +282,6 @@ cfg_if::cfg_if! {
use self::elf::Object;

fn native_libraries() -> Vec<Library> {
wut();
let mut ret = Vec::new();
unsafe {
libc::dl_iterate_phdr(Some(callback), &mut ret as *mut _ as *mut _);
Expand Down

0 comments on commit 682df6a

Please sign in to comment.