Skip to content

Commit 31a3228

Browse files
committed
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
1 parent bb5aa64 commit 31a3228

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

.github/workflows/main.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,16 @@ jobs:
5959
- run: cargo build
6060
- run: cargo test
6161
- run: cargo test --features "gimli-symbolize"
62+
- run: cargo test --features "libbacktrace"
63+
- run: cargo test --features "libbacktrace gimli-symbolize"
6264
- run: cargo test --features "serialize-rustc"
6365
- run: cargo test --features "serialize-serde"
6466
- run: cargo test --features "verify-winapi"
6567
- run: cargo test --features "cpp_demangle"
6668
- run: cargo test --no-default-features
6769
- run: cargo test --no-default-features --features "libbacktrace"
6870
- run: cargo test --no-default-features --features "gimli-symbolize"
71+
- run: cargo test --no-default-features --features "gimli-symbolize libbacktrace"
6972
- run: cargo test --no-default-features --features "libbacktrace std"
7073
- run: cargo test --no-default-features --features "gimli-symbolize std"
7174
- run: cargo test --no-default-features --features "std"
@@ -182,5 +185,5 @@ jobs:
182185
with:
183186
submodules: true
184187
- name: Install Rust
185-
run: rustup update 1.32.0 && rustup default 1.32.0
188+
run: rustup update 1.40.0 && rustup default 1.40.0
186189
- run: cargo build

Cargo.toml

+8-7
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,26 @@ features = ['read_core', 'elf', 'macho', 'pe']
4949
winapi = { version = "0.3.3", optional = true }
5050

5151
[features]
52-
# By default libstd support and libbacktrace is used to symbolize addresses.
53-
default = ["std", "libbacktrace"]
52+
# By default libstd support and gimli-symbolize is used to symbolize addresses.
53+
default = ["std", "gimli-symbolize"]
5454

5555
# Include std support. This enables types like `Backtrace`.
5656
std = []
5757

5858
#=======================================
5959
# Methods of resolving symbols
6060
#
61-
# - libbacktrace: this feature activates the `backtrace-sys` dependency,
62-
# building the libbacktrace library found in gcc repos. This is the historical
63-
# default for the `backtrace` crate.
6461
# - gimli-symbolize: use the `gimli-rs/addr2line` crate to symbolicate
6562
# addresses into file, line, and name using DWARF debug information.
63+
# - libbacktrace: this feature activates the `backtrace-sys` dependency,
64+
# building the libbacktrace library found in gcc repos.
6665
#
6766
# Note that MSVC unconditionally uses the dbghelp library to symbolize and won't
68-
# be affected by feature selection here.
69-
libbacktrace = ["backtrace-sys/backtrace-sys"]
67+
# be affected by feature selection here. Also note that it's highly unlikely you
68+
# want to configure this. If you're having trouble getting backtraces it's
69+
# likely best to open an issue.
7070
gimli-symbolize = ["addr2line", "object", "std"]
71+
libbacktrace = ["backtrace-sys/backtrace-sys"]
7172

7273
#=======================================
7374
# Methods of serialization

src/symbolize/gimli.rs

-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ cfg_if::cfg_if! {
282282
use self::elf::Object;
283283

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

src/symbolize/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ cfg_if::cfg_if! {
463463
unsafe fn clear_symbol_cache_imp() {}
464464
} else if #[cfg(all(
465465
feature = "gimli-symbolize",
466+
any(unix, windows),
466467
not(target_os = "emscripten"),
467468
))] {
468469
mod gimli;

0 commit comments

Comments
 (0)