[−][src]Function bugsalot::debugger::state
pub fn state() -> State
What is the current state of the debugger, with regards to this process? Attached? Detatched? Unknown?
Platforms
Platform | State | Notes |
---|---|---|
Windows | OK | |
Android | OK | |
Linux | OK | Some versions of Windows Subsystem for Linux incorrectly report Detatched |
FreeBSD | OK? | Untested |
NetBSD | OK? | Untested |
OS X | OK? | Untested |
iOS | OK? | Untested |
WASM | N/A | Returns Unknown . We could try to detect if devtools are open, but that's a browser specific mess, and you can usually get away with just invoking debugger; . That said, pull requests welcome. |
KNOWN BUGS:
- On some versions of Windows Subsystem for Linux,
TracerPid
may incorrectly be 0 when a debugger is attached, leading us to incorrectly reportDetatched
. If you encounter such a version, please file an issue that includes the result ofcat /proc/version
, so I can add version detection to reportUnknown
for affected versions.
Examples
use bugsalot::debugger; match debugger::state() { debugger::State::Detatched => println!("No debugger attached"), debugger::State::Attached => println!("A debugger is attached"), debugger::State::Unknown => println!("A debugger may or may not be attached"), } if cfg!(any(windows, target_os = "android", target_os = "linux")) { // Platform should be supported assert_ne!(debugger::state(), debugger::State::Unknown) } else if cfg!(any(target_arch = "wasm32")) { // Platform is *not* supported assert_eq!(debugger::state(), debugger::State::Unknown) } else { // Platform might be supported? Might not? }