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_13_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 > ,
@@ -65,7 +61,7 @@ impl PythonSpy {
6561 let threadstate_address =
6662 get_threadstate_address ( interpreter_address, & python_info, & version, config) ?;
6763
68- #[ cfg( feature = "unwind" ) ]
64+ #[ cfg( all ( feature = "unwind" , target_os = "linux" , target_arch = "x86_64" ) ) ]
6965 let native = if config. native {
7066 Some ( NativeStack :: new (
7167 pid,
@@ -82,7 +78,7 @@ impl PythonSpy {
8278 version,
8379 interpreter_address,
8480 threadstate_address,
85- #[ cfg( feature = "unwind" ) ]
81+ #[ cfg( all ( feature = "unwind" , target_os = "linux" , target_arch = "x86_64" ) ) ]
8682 native,
8783 #[ cfg( target_os = "linux" ) ]
8884 dockerized : python_info. dockerized ,
@@ -295,7 +291,7 @@ impl PythonSpy {
295291 }
296292
297293 // Merge in the native stack frames if necessary
298- #[ cfg( feature = "unwind" ) ]
294+ #[ cfg( all ( feature = "unwind" , target_os = "linux" , target_arch = "x86_64" ) ) ]
299295 {
300296 if self . config . native {
301297 if let Some ( native) = self . native . as_mut ( ) {
@@ -393,7 +389,10 @@ impl PythonSpy {
393389 Ok ( None )
394390 }
395391
396- #[ cfg( all( target_os = "linux" , not( feature = "unwind" ) ) ) ]
392+ #[ cfg( all(
393+ target_os = "linux" ,
394+ not( all( feature = "unwind" , target_arch = "x86_64" ) )
395+ ) ) ]
397396 fn _get_os_thread_id < I : InterpreterState > (
398397 & mut self ,
399398 _python_thread_id : u64 ,
@@ -402,12 +401,14 @@ impl PythonSpy {
402401 Ok ( None )
403402 }
404403
405- #[ cfg( all( target_os = "linux" , feature = "unwind" ) ) ]
404+ #[ cfg( all( target_os = "linux" , feature = "unwind" , target_arch = "x86_64" ) ) ]
406405 fn _get_os_thread_id < I : InterpreterState > (
407406 & mut self ,
408407 python_thread_id : u64 ,
409408 interp : & I ,
410409 ) -> Result < Option < Tid > , Error > {
410+ use std:: collections:: HashSet ;
411+
411412 // in nonblocking mode, we can't get the threadid reliably (method here requires reading the RBX
412413 // register which requires a ptrace attach). fallback to heuristic thread activity here
413414 if self . config . blocking == LockingStrategy :: NonBlocking {
@@ -453,6 +454,8 @@ impl PythonSpy {
453454 Ok ( pthread_id) => {
454455 if pthread_id != 0 {
455456 self . python_thread_ids . insert ( pthread_id, threadid) ;
457+ } else if self . config . native {
458+ panic ! ( "Native stack traces not supported on this platform" ) ;
456459 }
457460 }
458461 Err ( e) => {
@@ -487,12 +490,12 @@ impl PythonSpy {
487490 Ok ( None )
488491 }
489492
490- #[ cfg( all( target_os = "linux" , feature = "unwind" ) ) ]
493+ #[ cfg( all( target_os = "linux" , feature = "unwind" , target_arch = "x86_64" ) ) ]
491494 pub fn _get_pthread_id (
492495 & self ,
493496 unwinder : & remoteprocess:: Unwinder ,
494497 thread : & remoteprocess:: Thread ,
495- threadids : & HashSet < u64 > ,
498+ threadids : & std :: collections :: HashSet < u64 > ,
496499 ) -> Result < u64 , Error > {
497500 let mut pthread_id = 0 ;
498501
0 commit comments