1
1
use backtrace:: Frame ;
2
2
use std:: thread;
3
3
4
+ fn get_actual_fn_pointer ( fp : usize ) -> usize {
5
+ // On AIX, the function name references a function descriptor.
6
+ // A function descriptor is consisted of (See https://reviews.llvm.org/D62532)
7
+ // * The address of the entry point of the function.
8
+ // * The TOC base address for the function.
9
+ // * The environment pointer.
10
+ // Deref `fp` directly so that we can get the address of `fp`'s
11
+ // entry point in text section.
12
+ if cfg ! ( target_os = "aix" ) {
13
+ unsafe {
14
+ let actual_fn_entry = * ( fp as * const usize ) ;
15
+ actual_fn_entry
16
+ }
17
+ } else {
18
+ fp
19
+ }
20
+ }
21
+
4
22
#[ test]
5
23
// FIXME: shouldn't ignore this test on i686-msvc, unsure why it's failing
6
24
#[ cfg_attr( all( target_arch = "x86" , target_env = "msvc" ) , ignore) ]
@@ -20,7 +38,7 @@ fn smoke_test_frames() {
20
38
// Various platforms have various bits of weirdness about their
21
39
// backtraces. To find a good starting spot let's search through the
22
40
// frames
23
- let target = frame_4 as usize ;
41
+ let target = get_actual_fn_pointer ( frame_4 as usize ) ;
24
42
let offset = v
25
43
. iter ( )
26
44
. map ( |frame| frame. symbol_address ( ) as usize )
@@ -39,39 +57,39 @@ fn smoke_test_frames() {
39
57
40
58
assert_frame (
41
59
frames. next ( ) . unwrap ( ) ,
42
- frame_4 as usize ,
60
+ get_actual_fn_pointer ( frame_4 as usize ) ,
43
61
"frame_4" ,
44
62
"tests/smoke.rs" ,
45
63
start_line + 6 ,
46
64
9 ,
47
65
) ;
48
66
assert_frame (
49
67
frames. next ( ) . unwrap ( ) ,
50
- frame_3 as usize ,
68
+ get_actual_fn_pointer ( frame_3 as usize ) ,
51
69
"frame_3" ,
52
70
"tests/smoke.rs" ,
53
71
start_line + 3 ,
54
72
52 ,
55
73
) ;
56
74
assert_frame (
57
75
frames. next ( ) . unwrap ( ) ,
58
- frame_2 as usize ,
76
+ get_actual_fn_pointer ( frame_2 as usize ) ,
59
77
"frame_2" ,
60
78
"tests/smoke.rs" ,
61
79
start_line + 2 ,
62
80
52 ,
63
81
) ;
64
82
assert_frame (
65
83
frames. next ( ) . unwrap ( ) ,
66
- frame_1 as usize ,
84
+ get_actual_fn_pointer ( frame_1 as usize ) ,
67
85
"frame_1" ,
68
86
"tests/smoke.rs" ,
69
87
start_line + 1 ,
70
88
52 ,
71
89
) ;
72
90
assert_frame (
73
91
frames. next ( ) . unwrap ( ) ,
74
- smoke_test_frames as usize ,
92
+ get_actual_fn_pointer ( smoke_test_frames as usize ) ,
75
93
"smoke_test_frames" ,
76
94
"" ,
77
95
0 ,
0 commit comments