11use std:: collections:: HashMap ;
2- #[ cfg( all( target_os = "linux" , feature = "unwind" ) ) ]
3- use std:: collections:: HashSet ;
4- #[ cfg( all( target_os = "linux" , feature = "unwind" ) ) ]
5- use std:: iter:: FromIterator ;
62use std:: path:: Path ;
73
84use anyhow:: { Context , Error , Result } ;
95use remoteprocess:: { Pid , Process , ProcessMemory , Tid } ;
106
117use crate :: config:: { Config , LockingStrategy } ;
12- #[ cfg( feature = "unwind" ) ]
8+ #[ cfg( all ( feature = "unwind" , target_os = "linux" , target_arch = "x86_64" ) ) ]
139use crate :: native_stack_trace:: NativeStack ;
1410use crate :: python_bindings:: {
1511 v2_7_15, v3_10_0, v3_11_0, v3_12_0, v3_3_7, v3_5_5, v3_6_6, v3_7_0, v3_8_0, v3_9_5,
@@ -31,7 +27,7 @@ pub struct PythonSpy {
3127 pub interpreter_address : usize ,
3228 pub threadstate_address : usize ,
3329 pub config : Config ,
34- #[ cfg( feature = "unwind" ) ]
30+ #[ cfg( all ( feature = "unwind" , target_os = "linux" , target_arch = "x86_64" ) ) ]
3531 pub native : Option < NativeStack > ,
3632 pub short_filenames : HashMap < String , Option < String > > ,
3733 pub python_thread_ids : HashMap < u64 , Tid > ,
@@ -64,7 +60,7 @@ impl PythonSpy {
6460 // lets us figure out which thread has the GIL
6561 let threadstate_address = get_threadstate_address ( & python_info, & version, config) ?;
6662
67- #[ cfg( feature = "unwind" ) ]
63+ #[ cfg( all ( feature = "unwind" , target_os = "linux" , target_arch = "x86_64" ) ) ]
6864 let native = if config. native {
6965 Some ( NativeStack :: new (
7066 pid,
@@ -81,7 +77,7 @@ impl PythonSpy {
8177 version,
8278 interpreter_address,
8379 threadstate_address,
84- #[ cfg( feature = "unwind" ) ]
80+ #[ cfg( all ( feature = "unwind" , target_os = "linux" , target_arch = "x86_64" ) ) ]
8581 native,
8682 #[ cfg( target_os = "linux" ) ]
8783 dockerized : python_info. dockerized ,
@@ -288,7 +284,7 @@ impl PythonSpy {
288284 }
289285
290286 // Merge in the native stack frames if necessary
291- #[ cfg( feature = "unwind" ) ]
287+ #[ cfg( all ( feature = "unwind" , target_os = "linux" , target_arch = "x86_64" ) ) ]
292288 {
293289 if self . config . native {
294290 if let Some ( native) = self . native . as_mut ( ) {
@@ -386,7 +382,10 @@ impl PythonSpy {
386382 Ok ( None )
387383 }
388384
389- #[ cfg( all( target_os = "linux" , not( feature = "unwind" ) ) ) ]
385+ #[ cfg( all(
386+ target_os = "linux" ,
387+ not( all( feature = "unwind" , target_arch = "x86_64" ) )
388+ ) ) ]
390389 fn _get_os_thread_id < I : InterpreterState > (
391390 & mut self ,
392391 _python_thread_id : u64 ,
@@ -395,12 +394,14 @@ impl PythonSpy {
395394 Ok ( None )
396395 }
397396
398- #[ cfg( all( target_os = "linux" , feature = "unwind" ) ) ]
397+ #[ cfg( all( target_os = "linux" , feature = "unwind" , target_arch = "x86_64" ) ) ]
399398 fn _get_os_thread_id < I : InterpreterState > (
400399 & mut self ,
401400 python_thread_id : u64 ,
402401 interp : & I ,
403402 ) -> Result < Option < Tid > , Error > {
403+ use std:: collections:: HashSet ;
404+
404405 // in nonblocking mode, we can't get the threadid reliably (method here requires reading the RBX
405406 // register which requires a ptrace attach). fallback to heuristic thread activity here
406407 if self . config . blocking == LockingStrategy :: NonBlocking {
@@ -446,6 +447,8 @@ impl PythonSpy {
446447 Ok ( pthread_id) => {
447448 if pthread_id != 0 {
448449 self . python_thread_ids . insert ( pthread_id, threadid) ;
450+ } else if self . config . native {
451+ panic ! ( "Native stack traces not supported on this platform" ) ;
449452 }
450453 }
451454 Err ( e) => {
@@ -480,12 +483,12 @@ impl PythonSpy {
480483 Ok ( None )
481484 }
482485
483- #[ cfg( all( target_os = "linux" , feature = "unwind" ) ) ]
486+ #[ cfg( all( target_os = "linux" , feature = "unwind" , target_arch = "x86_64" ) ) ]
484487 pub fn _get_pthread_id (
485488 & self ,
486489 unwinder : & remoteprocess:: Unwinder ,
487490 thread : & remoteprocess:: Thread ,
488- threadids : & HashSet < u64 > ,
491+ threadids : & std :: collections :: HashSet < u64 > ,
489492 ) -> Result < u64 , Error > {
490493 let mut pthread_id = 0 ;
491494
0 commit comments