From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- library/backtrace/crates/debuglink/Cargo.toml | 7 ++++++ library/backtrace/crates/debuglink/src/main.rs | 34 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 library/backtrace/crates/debuglink/Cargo.toml create mode 100644 library/backtrace/crates/debuglink/src/main.rs (limited to 'library/backtrace/crates/debuglink') diff --git a/library/backtrace/crates/debuglink/Cargo.toml b/library/backtrace/crates/debuglink/Cargo.toml new file mode 100644 index 000000000..6b55b1394 --- /dev/null +++ b/library/backtrace/crates/debuglink/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "debuglink" +version = "0.1.0" +edition = "2018" + +[dependencies] +backtrace = { path = "../.." } diff --git a/library/backtrace/crates/debuglink/src/main.rs b/library/backtrace/crates/debuglink/src/main.rs new file mode 100644 index 000000000..99265ae9a --- /dev/null +++ b/library/backtrace/crates/debuglink/src/main.rs @@ -0,0 +1,34 @@ +// Test that the debuginfo is being found by checking that the +// backtrace contains `main` and that the source filename uses +// the path given in the command line arguments. +// +// For dwz tests, this assumes that the path string will be moved into +// the dwz file. +fn main() { + let crate_dir = std::env::args().skip(1).next().unwrap(); + let expect = std::path::Path::new(&crate_dir).join("src/main.rs"); + + let bt = backtrace::Backtrace::new(); + println!("{:?}", bt); + + let mut found_main = false; + + for frame in bt.frames() { + let symbols = frame.symbols(); + if symbols.is_empty() { + continue; + } + + if let Some(name) = symbols[0].name() { + let name = format!("{:#}", name); + if name == "debuglink::main" { + found_main = true; + let filename = symbols[0].filename().unwrap(); + assert_eq!(filename, expect); + break; + } + } + } + + assert!(found_main); +} -- cgit v1.2.3