Skip to content

Commit

Permalink
Add a test that without debuginfo symbols still resolve
Browse files Browse the repository at this point in the history
Almost all platforms should still have some degree of symbolication
without debug symbols being present (aka the dynamic symbol table and
such), so add a test asserting that symbols do indeed come out in these
scenarios.

This test will likely need to be blacklisted for platforms over time,
but that's ok.
  • Loading branch information
alexcrichton committed Jun 3, 2019
1 parent f15a3e9 commit 2b8aae5
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ci/azure-test-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@ steps:
displayName: "Test backtrace (-default + dbghelp + std + verify-winapi)"
- bash: cd ./crates/cpp_smoke_test && cargo test
displayName: "Test cpp_smoke_test"
- bash: cd ./crates/without_debuginfo && cargo test
displayName: "Test without debuginfo"
- bash: cd ./crates/without_debuginfo && cargo test --features libbacktrace
displayName: "Test without debuginfo (libbacktrace)"
- bash: cd ./crates/without_debuginfo && cargo test --features 'libbacktrace coresymbolication'
displayName: "Test without debuginfo (coresymbolication)"
30 changes: 30 additions & 0 deletions crates/without_debuginfo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[package]
name = "without_debuginfo"
version = "0.1.0"
authors = ["Alex Crichton <[email protected]>"]
edition = "2018"

[dependencies.backtrace]
path = "../.."
default-features = false
features = [
# make sure a trace can be acquired
'libunwind',
'dbghelp',

# Allow fallback to dladdr
'dladdr',

# Yes, we have `std`
'std',
]

[profile.dev]
debug = false

[profile.test]
debug = false

[features]
libbacktrace = ['backtrace/libbacktrace']
coresymbolication = ['backtrace/coresymbolication']
1 change: 1 addition & 0 deletions crates/without_debuginfo/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// intentionally blank
19 changes: 19 additions & 0 deletions crates/without_debuginfo/tests/smoke.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#[test]
fn all_frames_have_symbols() {
println!("{:?}", backtrace::Backtrace::new());

let mut all_have_symbols = true;
backtrace::trace(|frame| {
let mut any = false;
backtrace::resolve_frame(frame, |sym| {
if sym.name().is_some() {
any = true;
}
});
if !any && !frame.ip().is_null() {
all_have_symbols = false;
}
true
});
assert!(all_have_symbols);
}

0 comments on commit 2b8aae5

Please sign in to comment.