From 0a094bae28a00117b99262621ff22876796d2885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20W=C3=B6rister?= Date: Thu, 14 Mar 2024 11:03:15 +0100 Subject: [PATCH] Make pdb-alt-path test more unwind-friendly for i686-pc-windows-msvc --- tests/run-make/pdb-alt-path/Makefile | 6 +++--- tests/run-make/pdb-alt-path/main.rs | 23 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/tests/run-make/pdb-alt-path/Makefile b/tests/run-make/pdb-alt-path/Makefile index 5795dae97c253..7a0ae3bf2ef0d 100644 --- a/tests/run-make/pdb-alt-path/Makefile +++ b/tests/run-make/pdb-alt-path/Makefile @@ -10,9 +10,9 @@ all: # Test that backtraces still can find debuginfo by checking that they contain symbol names and # source locations. - RUST_BACKTRACE="full" $(TMPDIR)/my_crate_name.exe &> $(TMPDIR)/backtrace.txt || exit 0 - $(CGREP) "my_crate_name::main" < $(TMPDIR)/backtrace.txt - $(CGREP) "pdb-alt-path\\main.rs:2" < $(TMPDIR)/backtrace.txt + $(TMPDIR)/my_crate_name.exe &> $(TMPDIR)/backtrace.txt + $(CGREP) "my_crate_name::fn_in_backtrace" < $(TMPDIR)/backtrace.txt + $(CGREP) "main.rs:15" < $(TMPDIR)/backtrace.txt # Test that explicitly passed `-Clink-arg=/PDBALTPATH:...` is respected $(RUSTC) main.rs -g --crate-name my_crate_name --crate-type bin -Clink-arg=/PDBALTPATH:abcdefg.pdb -Cforce-frame-pointers diff --git a/tests/run-make/pdb-alt-path/main.rs b/tests/run-make/pdb-alt-path/main.rs index e95109fd08a3b..d38d540fbc257 100644 --- a/tests/run-make/pdb-alt-path/main.rs +++ b/tests/run-make/pdb-alt-path/main.rs @@ -1,3 +1,24 @@ +// The various #[inline(never)] annotations and std::hint::black_box calls are +// an attempt to make unwinding as non-flaky as possible on i686-pc-windows-msvc. + +#[inline(never)] +fn generate_backtrace(x: &u32) { + std::hint::black_box(x); + let bt = std::backtrace::Backtrace::force_capture(); + println!("{}", bt); + std::hint::black_box(x); +} + +#[inline(never)] +fn fn_in_backtrace(x: &u32) { + std::hint::black_box(x); + generate_backtrace(x); + std::hint::black_box(x); +} + fn main() { - panic!("backtrace please"); + let x = &41; + std::hint::black_box(x); + fn_in_backtrace(x); + std::hint::black_box(x); }