test backtraces

This commit is contained in:
Jana Dönszelmann
2026-01-27 12:23:57 +01:00
parent d6db0ed612
commit b14799754e
4 changed files with 56 additions and 1 deletions
+1 -1
View File
@@ -117,7 +117,7 @@ fn predefine_without_aliases(
/// This is not a problem: instead of using LLVM aliases, we can just generate
/// a new function symbol (with target architecture!) which effectively comes down to:
///
/// ```rust,ignore
/// ```ignore (illustrative example)
/// fn alias_name(...args) {
/// original_name(...args)
/// }
@@ -0,0 +1,10 @@
//@ no-prefer-dynamic
//@ needs-unwind
//@ exec-env:RUST_BACKTRACE=1
#![crate_type = "rlib"]
#![feature(extern_item_impls)]
#[eii(eii1)]
pub fn decl1(x: u64) {
panic!("{}", x);
}
@@ -0,0 +1,35 @@
//@ no-prefer-dynamic
//@ aux-build: decl_with_default_panics.rs
//@ edition: 2021
//@ run-pass
//@ needs-unwind
//@ exec-env:RUST_BACKTRACE=1
//@ ignore-backends: gcc
// FIXME: linking on windows (speciifcally mingw) not yet supported, see tracking issue #125418
//@ ignore-windows
// A small test to make sure that unwinding works properly.
//
// Functions can have target-cpu applied. On apple-darwin this is super important,
// since you can have binaries which mix x86 and aarch64 code that are compatible
// with both architectures. So we can't just reject target_cpu on EIIs since apple
// puts them on by default. The problem: we generate aliases. And aliases cannot
// get target_cpu applied to them. So, instead we should, in the case of functions,
// generate a shim function. For statics aliases should keep working.
// However, to make this work properly,
// on LLVM we generate shim functions instead of function aliases.
// Little extra functions that look like
// ```
// function alias_symbol(*args) {return (tailcall) aliasee(*args);}
// ```
// This is a simple test to make sure that we can unwind through these,
// and that this wrapper function effectively doesn't show up in the trace.
#![feature(extern_item_impls)]
extern crate decl_with_default_panics;
fn main() {
let result = std::panic::catch_unwind(|| {
decl_with_default_panics::decl1(10);
});
assert!(result.is_err());
}
@@ -0,0 +1,10 @@
thread 'main' ($TID) panicked at $DIR/auxiliary/decl_with_default_panics.rs:14:5:
10
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_fmt
2: core::panicking::panic_display::<u64>
3: decl_with_default_panics::_::decl1
4: call_default_panics::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.