Make pdb-alt-path test more unwind-friendly for i686-pc-windows-msvc

This commit is contained in:
Michael Wörister 2024-03-14 11:03:15 +01:00
parent e1c3a5a7aa
commit 0a094bae28
2 changed files with 26 additions and 5 deletions

View File

@ -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

View File

@ -1,3 +1,24 @@
fn main() {
panic!("backtrace please");
// 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() {
let x = &41;
std::hint::black_box(x);
fn_in_backtrace(x);
std::hint::black_box(x);
}