Skip to content

Commit 2b8aae5

Browse files
committed
Add a test that without debuginfo symbols still resolve
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.
1 parent f15a3e9 commit 2b8aae5

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

ci/azure-test-all.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,7 @@ steps:
4141
displayName: "Test backtrace (-default + dbghelp + std + verify-winapi)"
4242
- bash: cd ./crates/cpp_smoke_test && cargo test
4343
displayName: "Test cpp_smoke_test"
44-
- bash: cd ./crates/without_debuginfo && cargo test
45-
displayName: "Test without debuginfo"
44+
- bash: cd ./crates/without_debuginfo && cargo test --features libbacktrace
45+
displayName: "Test without debuginfo (libbacktrace)"
46+
- bash: cd ./crates/without_debuginfo && cargo test --features 'libbacktrace coresymbolication'
47+
displayName: "Test without debuginfo (coresymbolication)"

crates/without_debuginfo/Cargo.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[package]
2+
name = "without_debuginfo"
3+
version = "0.1.0"
4+
authors = ["Alex Crichton <[email protected]>"]
5+
edition = "2018"
6+
7+
[dependencies.backtrace]
8+
path = "../.."
9+
default-features = false
10+
features = [
11+
# make sure a trace can be acquired
12+
'libunwind',
13+
'dbghelp',
14+
15+
# Allow fallback to dladdr
16+
'dladdr',
17+
18+
# Yes, we have `std`
19+
'std',
20+
]
21+
22+
[profile.dev]
23+
debug = false
24+
25+
[profile.test]
26+
debug = false
27+
28+
[features]
29+
libbacktrace = ['backtrace/libbacktrace']
30+
coresymbolication = ['backtrace/coresymbolication']

crates/without_debuginfo/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// intentionally blank
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#[test]
2+
fn all_frames_have_symbols() {
3+
println!("{:?}", backtrace::Backtrace::new());
4+
5+
let mut all_have_symbols = true;
6+
backtrace::trace(|frame| {
7+
let mut any = false;
8+
backtrace::resolve_frame(frame, |sym| {
9+
if sym.name().is_some() {
10+
any = true;
11+
}
12+
});
13+
if !any && !frame.ip().is_null() {
14+
all_have_symbols = false;
15+
}
16+
true
17+
});
18+
assert!(all_have_symbols);
19+
}

0 commit comments

Comments
 (0)