pub fn break_if_attached() {
    #[cfg(windows)] unsafe {
        if crate::ffi::win32::IsDebuggerPresent() != 0 {
            crate::ffi::win32::DebugBreak();
        }
        return;
    }

    #[cfg(all(target_arch = "wasm32", feature = "wasm-bindgen"))] {
        // XXX: Do we maybe want to cache this function somewhere at some point?
        let _ = js_sys::eval("debugger;");
        //js_sys::Function::new_no_args("debugger;").call0(&wasm_bindgen::prelude::JsValue::UNDEFINED);
        return;
    }

    #[cfg(all(target_arch = "wasm32", feature = "stdweb"))] {
        use stdweb0::js;
        js! { debugger; };
        return;
    }

    // For stable, signals tend to work.  Probably.  Maybe.  Although I recall the best signals (e.g. continuable after
    // a debugger attaches).  `std::intrinsics::breakpoint` is also an option, but it's perma-unstable (nightly only)
    // and adding the required feature to lib.rs for nightly only would require:
    // ```
    // #![rustc::attr(nightly, feature(core_intrinsics))]
    // ```
    // Which is *also* unstable, and thus nightly only, defeating the whole point.  Lame!  Other signals possibly worth
    // using include SIGILL, SIGSTOP, or SIGSEGV, depending on what exact debugger behavior... although SIGTRAP seems
    // like the "correct" signal.  https://en.wikipedia.org/wiki/Signal_(IPC)
    #[cfg(unix)] {
        if state() == State::Attached {
            #[link(name = "c")] extern "C" { fn raise(signum: i32) -> i32; }
            const SIGTRAP : i32 = 5;
            unsafe { raise(SIGTRAP); }
        }
        return;
    }
}
// We'd strongly prefer if the debugger showed us the call site, not this function.
We'd strongly prefer if the debugger showed us the call site, not this function.
We ' d strongly prefer if the debugger showed us the call site not this function .
pub fn break_if_attached() {
    #[cfg(windows)] unsafe {
        if crate::ffi::win32::IsDebuggerPresent() != 0 {
            crate::ffi::win32::DebugBreak();
        }
        return;
    }
    #[cfg(all(target_arch = "wasm32", feature = "wasm-bindgen"))] {
        // XXX: Do we maybe want to cache this function somewhere at some point?
        let _ = js_sys::eval("debugger;");
        //js_sys::Function::new_no_args("debugger;").call0(&wasm_bindgen::prelude::JsValue::UNDEFINED);
        return;
    }
    #[cfg(all(target_arch = "wasm32", feature = "stdweb"))] {
        use stdweb0::js;
        js! { debugger; };
        return;
    }
    // For stable, signals tend to work.  Probably.  Maybe.  Although I recall the best signals (e.g. continuable after
    // a debugger attaches).  `std::intrinsics::breakpoint` is also an option, but it's perma-unstable (nightly only)
    // and adding the required feature to lib.rs for nightly only would require:
    // ```
    // #![rustc::attr(nightly, feature(core_intrinsics))]
    // ```
    // Which is *also* unstable, and thus nightly only, defeating the whole point.  Lame!  Other signals possibly worth
    // using include SIGILL, SIGSTOP, or SIGSEGV, depending on what exact debugger behavior... although SIGTRAP seems
    // like the "correct" signal.  https://en.wikipedia.org/wiki/Signal_(IPC)
    #[cfg(unix)] {
        if state() == State::Attached {
            #[link(name = "c")] extern "C" { fn raise(signum: i32) -> i32; }
            const SIGTRAP : i32 = 5;
            unsafe { raise(SIGTRAP); }
        }
        return;
    }
}
pub fn break_if_attached ( ) { # [ cfg ( windows ) ] unsafe { if crate :: ffi :: win32 :: IsDebuggerPresent ( ) != 0 { crate :: ffi :: win32 :: DebugBreak ( ) ; } return ; } # [ cfg ( all ( target_arch " " feature " " ) ) ] { // XXX: Do we maybe want to cache this function somewhere at some point? let _ = js_sys :: eval ( " " ) ; //js_sys::Function::new_no_args("debugger;").call0(&wasm_bindgen::prelude::JsValue::UNDEFINED); return ; } # [ cfg ( all ( target_arch " " feature " " ) ) ] { use stdweb0 :: js ; js ! { debugger } ; return ; } // For stable, signals tend to work.  Probably.  Maybe.  Although I recall the best signals (e.g. continuable after // a debugger attaches).  `std::intrinsics::breakpoint` is also an option, but it's perma-unstable (nightly only) // and adding the required feature to lib.rs for nightly only would require: // ``` // #![rustc::attr(nightly, feature(core_intrinsics))] // ``` // Which is *also* unstable, and thus nightly only, defeating the whole point.  Lame!  Other signals possibly worth // using include SIGILL, SIGSTOP, or SIGSEGV, depending on what exact debugger behavior... although SIGTRAP seems // like the "correct" signal.  https://en.wikipedia.org/wiki/Signal_(IPC) # [ cfg ( unix ) ] { if state ( ) == State :: Attached { # [ link ( name " " ) ] extern " " { fn raise ( signum : i32 ) -> i32 ; } const SIGTRAP : i32 = 5 ; unsafe { raise ( SIGTRAP ) ; } } return ; } }
We'd strongly prefer if the debugger showed us the call site, not this function.
We ' d strongly prefer if the debugger showed us the call site not this function .