From f15a3e9017e785a9e71c04b05f36694e57993fb4 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 3 Jun 2019 08:44:24 -0700 Subject: [PATCH 1/2] Move aux crates in a `crates` directory Just an internal refactoring before more are added. --- .gitmodules | 2 +- Cargo.toml | 2 +- ci/azure-test-all.yml | 4 +++- {backtrace-sys => crates/backtrace-sys}/Cargo.toml | 0 {backtrace-sys => crates/backtrace-sys}/LICENSE-APACHE | 0 {backtrace-sys => crates/backtrace-sys}/LICENSE-MIT | 0 {backtrace-sys => crates/backtrace-sys}/build.rs | 0 {backtrace-sys => crates/backtrace-sys}/src/lib.rs | 0 {backtrace-sys => crates/backtrace-sys}/src/libbacktrace | 0 {cpp_smoke_test => crates/cpp_smoke_test}/Cargo.toml | 2 +- {cpp_smoke_test => crates/cpp_smoke_test}/build.rs | 0 {cpp_smoke_test => crates/cpp_smoke_test}/cpp/trampoline.cpp | 0 {cpp_smoke_test => crates/cpp_smoke_test}/src/lib.rs | 0 {cpp_smoke_test => crates/cpp_smoke_test}/tests/smoke.rs | 0 14 files changed, 6 insertions(+), 4 deletions(-) rename {backtrace-sys => crates/backtrace-sys}/Cargo.toml (100%) rename {backtrace-sys => crates/backtrace-sys}/LICENSE-APACHE (100%) rename {backtrace-sys => crates/backtrace-sys}/LICENSE-MIT (100%) rename {backtrace-sys => crates/backtrace-sys}/build.rs (100%) rename {backtrace-sys => crates/backtrace-sys}/src/lib.rs (100%) rename {backtrace-sys => crates/backtrace-sys}/src/libbacktrace (100%) rename {cpp_smoke_test => crates/cpp_smoke_test}/Cargo.toml (74%) rename {cpp_smoke_test => crates/cpp_smoke_test}/build.rs (100%) rename {cpp_smoke_test => crates/cpp_smoke_test}/cpp/trampoline.cpp (100%) rename {cpp_smoke_test => crates/cpp_smoke_test}/src/lib.rs (100%) rename {cpp_smoke_test => crates/cpp_smoke_test}/tests/smoke.rs (100%) diff --git a/.gitmodules b/.gitmodules index 8fc4effc3..7d41369fa 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "backtrace-sys/src/libbacktrace"] - path = backtrace-sys/src/libbacktrace + path = crates/backtrace-sys/src/libbacktrace url = https://github.com/rust-lang-nursery/libbacktrace diff --git a/Cargo.toml b/Cargo.toml index 17a60018b..88f257569 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ autotests = true [dependencies] cfg-if = "0.1.6" rustc-demangle = "0.1.4" -backtrace-sys = { path = "backtrace-sys", version = "0.1.17", optional = true } +backtrace-sys = { path = "crates/backtrace-sys", version = "0.1.17", optional = true } libc = { version = "0.2.45", default-features = false } core = { version = "1.0.0", optional = true, package = 'rustc-std-workspace-core' } compiler_builtins = { version = '0.1.2', optional = true } diff --git a/ci/azure-test-all.yml b/ci/azure-test-all.yml index 6f2d192be..a95a03a3f 100644 --- a/ci/azure-test-all.yml +++ b/ci/azure-test-all.yml @@ -39,5 +39,7 @@ steps: displayName: "Test backtrace (-default + dbghelp + std)" - bash: cargo test --no-default-features --features 'dbghelp std verify-winapi' displayName: "Test backtrace (-default + dbghelp + std + verify-winapi)" - - bash: cd ./cpp_smoke_test && cargo test + - bash: cd ./crates/cpp_smoke_test && cargo test displayName: "Test cpp_smoke_test" + - bash: cd ./crates/without_debuginfo && cargo test + displayName: "Test without debuginfo" diff --git a/backtrace-sys/Cargo.toml b/crates/backtrace-sys/Cargo.toml similarity index 100% rename from backtrace-sys/Cargo.toml rename to crates/backtrace-sys/Cargo.toml diff --git a/backtrace-sys/LICENSE-APACHE b/crates/backtrace-sys/LICENSE-APACHE similarity index 100% rename from backtrace-sys/LICENSE-APACHE rename to crates/backtrace-sys/LICENSE-APACHE diff --git a/backtrace-sys/LICENSE-MIT b/crates/backtrace-sys/LICENSE-MIT similarity index 100% rename from backtrace-sys/LICENSE-MIT rename to crates/backtrace-sys/LICENSE-MIT diff --git a/backtrace-sys/build.rs b/crates/backtrace-sys/build.rs similarity index 100% rename from backtrace-sys/build.rs rename to crates/backtrace-sys/build.rs diff --git a/backtrace-sys/src/lib.rs b/crates/backtrace-sys/src/lib.rs similarity index 100% rename from backtrace-sys/src/lib.rs rename to crates/backtrace-sys/src/lib.rs diff --git a/backtrace-sys/src/libbacktrace b/crates/backtrace-sys/src/libbacktrace similarity index 100% rename from backtrace-sys/src/libbacktrace rename to crates/backtrace-sys/src/libbacktrace diff --git a/cpp_smoke_test/Cargo.toml b/crates/cpp_smoke_test/Cargo.toml similarity index 74% rename from cpp_smoke_test/Cargo.toml rename to crates/cpp_smoke_test/Cargo.toml index f0551f101..3bcfb6cf8 100644 --- a/cpp_smoke_test/Cargo.toml +++ b/crates/cpp_smoke_test/Cargo.toml @@ -8,4 +8,4 @@ build = "build.rs" gcc = "0.3.43" [dependencies] -"backtrace" = { path = "..", features = ["cpp_demangle"] } +backtrace = { path = "../..", features = ["cpp_demangle"] } diff --git a/cpp_smoke_test/build.rs b/crates/cpp_smoke_test/build.rs similarity index 100% rename from cpp_smoke_test/build.rs rename to crates/cpp_smoke_test/build.rs diff --git a/cpp_smoke_test/cpp/trampoline.cpp b/crates/cpp_smoke_test/cpp/trampoline.cpp similarity index 100% rename from cpp_smoke_test/cpp/trampoline.cpp rename to crates/cpp_smoke_test/cpp/trampoline.cpp diff --git a/cpp_smoke_test/src/lib.rs b/crates/cpp_smoke_test/src/lib.rs similarity index 100% rename from cpp_smoke_test/src/lib.rs rename to crates/cpp_smoke_test/src/lib.rs diff --git a/cpp_smoke_test/tests/smoke.rs b/crates/cpp_smoke_test/tests/smoke.rs similarity index 100% rename from cpp_smoke_test/tests/smoke.rs rename to crates/cpp_smoke_test/tests/smoke.rs From 0f7946faf9e96d165185331e48fc0a1bd46a3adc Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 3 Jun 2019 08:51:19 -0700 Subject: [PATCH 2/2] 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. --- ci/azure-test-all.yml | 2 +- crates/without_debuginfo/Cargo.toml | 14 ++++++++++++++ crates/without_debuginfo/src/lib.rs | 1 + crates/without_debuginfo/tests/smoke.rs | 19 +++++++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 crates/without_debuginfo/Cargo.toml create mode 100644 crates/without_debuginfo/src/lib.rs create mode 100644 crates/without_debuginfo/tests/smoke.rs diff --git a/ci/azure-test-all.yml b/ci/azure-test-all.yml index a95a03a3f..73405a149 100644 --- a/ci/azure-test-all.yml +++ b/ci/azure-test-all.yml @@ -3,7 +3,7 @@ steps: submodules: true - template: azure-install-rust.yml - - bash: cargo build --manifest-path backtrace-sys/Cargo.toml + - bash: cargo build --manifest-path crates/backtrace-sys/Cargo.toml displayName: "Build backtrace-sys" - bash: cargo build displayName: "Build backtrace" diff --git a/crates/without_debuginfo/Cargo.toml b/crates/without_debuginfo/Cargo.toml new file mode 100644 index 000000000..10ee0c235 --- /dev/null +++ b/crates/without_debuginfo/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "without_debuginfo" +version = "0.1.0" +authors = ["Alex Crichton "] +edition = "2018" + +[dependencies] +backtrace = { path = "../.." } + +[profile.dev] +debug = false + +[profile.test] +debug = false diff --git a/crates/without_debuginfo/src/lib.rs b/crates/without_debuginfo/src/lib.rs new file mode 100644 index 000000000..65e2cc340 --- /dev/null +++ b/crates/without_debuginfo/src/lib.rs @@ -0,0 +1 @@ +// intentionally blank diff --git a/crates/without_debuginfo/tests/smoke.rs b/crates/without_debuginfo/tests/smoke.rs new file mode 100644 index 000000000..85be656c2 --- /dev/null +++ b/crates/without_debuginfo/tests/smoke.rs @@ -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); +}