@@ -8,69 +8,12 @@ pub use unwinding::custom_eh_frame_finder::{
88 EhFrameFinder , FrameInfo , FrameInfoKind , set_custom_eh_frame_finder,
99} ;
1010
11- #[ repr( C ) ]
12- #[ derive( Debug , Copy , Clone , PartialEq ) ]
13- pub enum _Unwind_Reason_Code {
14- _URC_NO_REASON = 0 ,
15- _URC_FOREIGN_EXCEPTION_CAUGHT = 1 ,
16- _URC_FATAL_PHASE2_ERROR = 2 ,
17- _URC_FATAL_PHASE1_ERROR = 3 ,
18- _URC_NORMAL_STOP = 4 ,
19- _URC_END_OF_STACK = 5 ,
20- _URC_HANDLER_FOUND = 6 ,
21- _URC_INSTALL_CONTEXT = 7 ,
22- _URC_CONTINUE_UNWIND = 8 ,
23- _URC_FAILURE = 9 , // used only by ARM EHABI
24- }
25- pub use _Unwind_Reason_Code:: * ;
11+ pub use crate :: types:: * ;
2612
27- pub type _Unwind_Exception_Class = u64 ;
28- pub type _Unwind_Word = * const u8 ;
2913pub type _Unwind_Ptr = * const u8 ;
30- pub type _Unwind_Trace_Fn =
31- extern "C" fn ( ctx : * mut _Unwind_Context , arg : * mut c_void ) -> _Unwind_Reason_Code ;
32-
33- pub const unwinder_private_data_size: usize = cfg_select ! {
34- target_arch = "x86" => 5 ,
35- all( target_arch = "x86_64" , not( any( target_os = "windows" , target_os = "cygwin" ) ) ) => 2 ,
36- all( target_arch = "x86_64" , any( target_os = "windows" , target_os = "cygwin" ) ) => 6 ,
37- all( target_arch = "arm" , not( target_vendor = "apple" ) ) => 20 ,
38- all( target_arch = "arm" , target_vendor = "apple" ) => 5 ,
39- all( target_arch = "aarch64" , target_pointer_width = "64" , not( target_os = "windows" ) ) => 2 ,
40- all( target_arch = "aarch64" , target_pointer_width = "64" , target_os = "windows" ) => 6 ,
41- all( target_arch = "aarch64" , target_pointer_width = "32" ) => 5 ,
42- target_arch = "m68k" => 2 ,
43- any( target_arch = "mips" , target_arch = "mips32r6" ) => 2 ,
44- target_arch = "csky" => 2 ,
45- any( target_arch = "mips64" , target_arch = "mips64r6" ) => 2 ,
46- any( target_arch = "powerpc" , target_arch = "powerpc64" ) => 2 ,
47- target_arch = "s390x" => 2 ,
48- any( target_arch = "sparc" , target_arch = "sparc64" ) => 2 ,
49- any( target_arch = "riscv64" , target_arch = "riscv32" ) => 2 ,
50- all( target_family = "wasm" , target_os = "emscripten" ) => 20 ,
51- all( target_arch = "wasm32" , any( target_os = "linux" , target_os = "wasi" ) ) => 2 ,
52- target_arch = "hexagon" => 5 ,
53- any( target_arch = "loongarch32" , target_arch = "loongarch64" ) => 2 ,
54- } ;
55-
56- #[ repr( C ) ]
57- pub struct _Unwind_Exception {
58- pub exception_class : _Unwind_Exception_Class ,
59- pub exception_cleanup : _Unwind_Exception_Cleanup_Fn ,
60- pub private : [ _Unwind_Word ; unwinder_private_data_size] ,
61- }
62-
63- // Check the size of _Unwind_Exception against the source of thruth when using the unwinding crate.
64- #[ cfg( target_os = "xous" ) ]
65- const _: ( ) = {
66- assert ! ( size_of:: <unwinding:: abi:: UnwindException >( ) == size_of:: <_Unwind_Exception>( ) ) ;
67- } ;
6814
6915pub enum _Unwind_Context { }
7016
71- pub type _Unwind_Exception_Cleanup_Fn =
72- Option < extern "C" fn ( unwind_code : _Unwind_Reason_Code , exception : * mut _Unwind_Exception ) > ;
73-
7417// FIXME: The `#[link]` attributes on `extern "C"` block marks those symbols declared in
7518// the block are reexported in dylib build of std. This is needed when build rustc with
7619// feature `llvm-libunwind`, as no other cdylib will provided those _Unwind_* symbols.
@@ -110,10 +53,10 @@ cfg_select! {
11053 pub type _Unwind_Action = c_int;
11154
11255 pub const _UA_SEARCH_PHASE: c_int = 1 ;
113- pub const _UA_CLEANUP_PHASE: c_int = 2 ;
114- pub const _UA_HANDLER_FRAME: c_int = 4 ;
56+ // pub const _UA_CLEANUP_PHASE: c_int = 2;
57+ // pub const _UA_HANDLER_FRAME: c_int = 4;
11558 pub const _UA_FORCE_UNWIND: c_int = 8 ;
116- pub const _UA_END_OF_STACK: c_int = 16 ;
59+ // pub const _UA_END_OF_STACK: c_int = 16;
11760
11861 #[ cfg_attr(
11962 all( feature = "llvm-libunwind" , any( target_os = "fuchsia" , target_os = "linux" ) ) ,
@@ -122,11 +65,9 @@ cfg_select! {
12265 unsafe extern "C" {
12366 pub fn _Unwind_GetGR( ctx: * mut _Unwind_Context, reg_index: c_int) -> _Unwind_Word;
12467 pub fn _Unwind_SetGR( ctx: * mut _Unwind_Context, reg_index: c_int, value: _Unwind_Word) ;
125- pub fn _Unwind_GetIP( ctx: * mut _Unwind_Context) -> _Unwind_Word;
12668 pub fn _Unwind_SetIP( ctx: * mut _Unwind_Context, value: _Unwind_Word) ;
12769 pub fn _Unwind_GetIPInfo( ctx: * mut _Unwind_Context, ip_before_insn: * mut c_int)
12870 -> _Unwind_Word;
129- pub fn _Unwind_FindEnclosingFunction( pc: * mut c_void) -> * mut c_void;
13071 }
13172
13273 }
@@ -213,12 +154,6 @@ cfg_select! {
213154 ( & raw mut value) as * mut c_void) ; }
214155 }
215156
216- pub unsafe fn _Unwind_GetIP( ctx: * mut _Unwind_Context)
217- -> _Unwind_Word {
218- let val = unsafe { _Unwind_GetGR( ctx, UNWIND_IP_REG ) } ;
219- val. map_addr( |v| v & !1 )
220- }
221-
222157 pub unsafe fn _Unwind_SetIP( ctx: * mut _Unwind_Context,
223158 value: _Unwind_Word) {
224159 // Propagate thumb bit to instruction pointer
@@ -232,45 +167,24 @@ cfg_select! {
232167 -> _Unwind_Word {
233168 unsafe {
234169 * ip_before_insn = 0 ;
235- _Unwind_GetIP( ctx)
170+ let val = unsafe { _Unwind_GetGR( ctx, UNWIND_IP_REG ) } ;
171+ val. map_addr( |v| v & !1 )
236172 }
237173 }
238-
239- // This function also doesn't exist on Android or ARM/Linux, so make it a no-op
240- pub unsafe fn _Unwind_FindEnclosingFunction( pc: * mut c_void) -> * mut c_void {
241- pc
242- }
243174 }
244175}
245176
246- cfg_select ! {
247- all( target_vendor = "apple" , not( target_os = "watchos" ) , target_arch = "arm" ) => {
248- // 32-bit ARM Apple (except for watchOS armv7k specifically) uses SjLj and
249- // does not provide _Unwind_Backtrace()
250- unsafe extern "C-unwind" {
251- pub fn _Unwind_SjLj_RaiseException( e: * mut _Unwind_Exception) -> _Unwind_Reason_Code;
252- }
253-
254- pub use _Unwind_SjLj_RaiseException as _Unwind_RaiseException;
255- }
256- _ => {
257- #[ cfg_attr(
258- all( feature = "llvm-libunwind" , any( target_os = "fuchsia" , target_os = "linux" ) ) ,
259- link( name = "unwind" , kind = "static" , modifiers = "-bundle" )
260- ) ]
261- unsafe extern "C-unwind" {
262- pub fn _Unwind_RaiseException( exception: * mut _Unwind_Exception) -> _Unwind_Reason_Code;
263- }
264- #[ cfg_attr(
265- all( feature = "llvm-libunwind" , any( target_os = "fuchsia" , target_os = "linux" ) ) ,
266- link( name = "unwind" , kind = "static" , modifiers = "-bundle" )
267- ) ]
268- unsafe extern "C" {
269- pub fn _Unwind_Backtrace( trace: _Unwind_Trace_Fn,
270- trace_argument: * mut c_void)
271- -> _Unwind_Reason_Code;
272- }
273- }
177+ #[ cfg_attr(
178+ all( feature = "llvm-libunwind" , any( target_os = "fuchsia" , target_os = "linux" ) ) ,
179+ link( name = "unwind" , kind = "static" , modifiers = "-bundle" )
180+ ) ]
181+ unsafe extern "C-unwind" {
182+ // 32-bit ARM Apple (except for watchOS armv7k specifically) uses SjLj
183+ #[ cfg_attr(
184+ all( target_vendor = "apple" , not( target_os = "watchos" ) , target_arch = "arm" ) ,
185+ link_name = "_Unwind_SjLj_RaiseException"
186+ ) ]
187+ pub fn _Unwind_RaiseException ( exception : * mut _Unwind_Exception ) -> _Unwind_Reason_Code ;
274188}
275189
276190cfg_select ! {
0 commit comments