@@ -26,8 +26,26 @@ pub mod _internal {
26
26
#[ doc( hidden) ]
27
27
pub use super :: _internal_once as _once;
28
28
29
+ #[ cfg( not( feature = "no_cache_debugger" ) ) ]
29
30
pub fn _is_debugger_present ( ) -> bool {
30
- pub use :: dbg_breakpoint:: { is_debugger_present, DebuggerPresence } ;
31
+ use :: core:: sync:: atomic:: { AtomicBool , Ordering } ;
32
+
33
+ static DEBUGGER_CHECKED : AtomicBool = AtomicBool :: new ( false ) ;
34
+ static DEBUGGER_ATTACHED : AtomicBool = AtomicBool :: new ( false ) ;
35
+
36
+ if !DEBUGGER_CHECKED . swap ( true , Ordering :: Relaxed ) {
37
+ DEBUGGER_ATTACHED . swap ( check_debugger ( ) , Ordering :: Relaxed ) ;
38
+ }
39
+
40
+ DEBUGGER_ATTACHED . load ( Ordering :: Relaxed )
41
+ }
42
+ #[ cfg( feature = "no_cache_debugger" ) ]
43
+ pub fn _is_debugger_present ( ) -> bool {
44
+ check_debugger ( )
45
+ }
46
+
47
+ fn check_debugger ( ) -> bool {
48
+ use :: dbg_breakpoint:: { is_debugger_present, DebuggerPresence } ;
31
49
32
50
let Some ( DebuggerPresence :: Detected ) = is_debugger_present ( ) else {
33
51
return false ;
@@ -52,10 +70,7 @@ macro_rules! breakpoint {
52
70
( ) => { } ;
53
71
}
54
72
#[ macro_export]
55
- #[ cfg( all(
56
- any( target_arch = "x86" , target_arch = "x86_64" ) ,
57
- debug_assertions
58
- ) ) ]
73
+ #[ cfg( all( any( target_arch = "x86" , target_arch = "x86_64" ) , debug_assertions) ) ]
59
74
macro_rules! breakpoint {
60
75
( ) => {
61
76
if $crate:: _internal:: _is_debugger_present( ) {
@@ -66,10 +81,7 @@ macro_rules! breakpoint {
66
81
} ;
67
82
}
68
83
#[ macro_export]
69
- #[ cfg( all(
70
- target_arch = "aarch64" ,
71
- debug_assertions
72
- ) ) ]
84
+ #[ cfg( all( target_arch = "aarch64" , debug_assertions) ) ]
73
85
macro_rules! breakpoint {
74
86
( ) => {
75
87
if $crate:: _internal:: _is_debugger_present( ) {
@@ -81,11 +93,7 @@ macro_rules! breakpoint {
81
93
}
82
94
#[ macro_export]
83
95
#[ cfg( all(
84
- not( any(
85
- target_arch = "x86" ,
86
- target_arch = "x86_64" ,
87
- target_arch = "aarch64" ,
88
- ) ) ,
96
+ not( any( target_arch = "x86" , target_arch = "x86_64" , target_arch = "aarch64" , ) ) ,
89
97
debug_assertions
90
98
) ) ]
91
99
macro_rules! breakpoint {
0 commit comments