Skip to content

Commit

Permalink
Make pdb-alt-path test more unwind-friendly for i686-pc-windows-msvc
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed Mar 14, 2024
1 parent e1c3a5a commit 0a094ba
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
6 changes: 3 additions & 3 deletions tests/run-make/pdb-alt-path/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 22 additions & 1 deletion tests/run-make/pdb-alt-path/main.rs
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 0a094ba

Please sign in to comment.