Skip to content

Commit acd2e87

Browse files
committed
test backtraces
1 parent 14a98da commit acd2e87

4 files changed

Lines changed: 56 additions & 1 deletion

File tree

compiler/rustc_codegen_llvm/src/mono_item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
125125
/// This is not a problem: instead of using LLVM aliases, we can just generate
126126
/// a new function symbol (with target architecture!) which effectively comes down to:
127127
///
128-
/// ```rust,ignore
128+
/// ```ignore (illustrative example)
129129
/// fn alias_name(...args) {
130130
/// original_name(...args)
131131
/// }
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//@ no-prefer-dynamic
2+
//@ needs-unwind
3+
//@ exec-env:RUST_BACKTRACE=1
4+
#![crate_type = "rlib"]
5+
#![feature(extern_item_impls)]
6+
7+
#[eii(eii1)]
8+
pub fn decl1(x: u64) {
9+
panic!("{}", x);
10+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//@ no-prefer-dynamic
2+
//@ aux-build: decl_with_default_panics.rs
3+
//@ edition: 2021
4+
//@ run-pass
5+
//@ needs-unwind
6+
//@ exec-env:RUST_BACKTRACE=1
7+
//@ ignore-backends: gcc
8+
// FIXME: linking on windows (speciifcally mingw) not yet supported, see tracking issue #125418
9+
//@ ignore-windows
10+
// A small test to make sure that unwinding works properly.
11+
//
12+
// Functions can have target-cpu applied. On apple-darwin this is super important,
13+
// since you can have binaries which mix x86 and aarch64 code that are compatible
14+
// with both architectures. So we can't just reject target_cpu on EIIs since apple
15+
// puts them on by default. The problem: we generate aliases. And aliases cannot
16+
// get target_cpu applied to them. So, instead we should, in the case of functions,
17+
// generate a shim function. For statics aliases should keep working.
18+
// However, to make this work properly,
19+
// on LLVM we generate shim functions instead of function aliases.
20+
// Little extra functions that look like
21+
// ```
22+
// function alias_symbol(*args) {return (tailcall) aliasee(*args);}
23+
// ```
24+
// This is a simple test to make sure that we can unwind through these,
25+
// and that this wrapper function effectively doesn't show up in the trace.
26+
#![feature(extern_item_impls)]
27+
28+
extern crate decl_with_default_panics;
29+
30+
fn main() {
31+
let result = std::panic::catch_unwind(|| {
32+
decl_with_default_panics::decl1(10);
33+
});
34+
assert!(result.is_err());
35+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
thread 'main' ($TID) panicked at $DIR/auxiliary/decl_with_default_panics.rs:14:5:
3+
10
4+
stack backtrace:
5+
0: __rustc::rust_begin_unwind
6+
1: core::panicking::panic_fmt
7+
2: core::panicking::panic_display::<u64>
8+
3: decl_with_default_panics::_::decl1
9+
4: call_default_panics::main
10+
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

0 commit comments

Comments
 (0)