diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /library/backtrace/crates/debuglink | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/backtrace/crates/debuglink')
-rw-r--r-- | library/backtrace/crates/debuglink/Cargo.toml | 7 | ||||
-rw-r--r-- | library/backtrace/crates/debuglink/src/main.rs | 34 |
2 files changed, 41 insertions, 0 deletions
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); +} |