Bool Panic_GetBreakOnPanic(void) { Bool shouldBreak = FALSE; switch (panicState.breakOnPanic) { case PanicBreakLevel_Never: break; case PanicBreakLevel_IfDebuggerAttached: #ifdef _WIN32 { typedef BOOL (*pfnIsDebuggerPresent)(void); HMODULE kernelLibrary = Win32U_LoadLibrary("kernel32.dll"); if (kernelLibrary != NULL) { pfnIsDebuggerPresent IsDebuggerPresentFn = (pfnIsDebuggerPresent) GetProcAddress(kernelLibrary, "IsDebuggerPresent"); if (IsDebuggerPresentFn != NULL) { shouldBreak = IsDebuggerPresentFn(); } FreeLibrary(kernelLibrary); } } #else /* XXX: Linux experts? How do you know if you're being ptraced? */ #endif break; default: case PanicBreakLevel_Always: shouldBreak = TRUE; break; } return shouldBreak; }
Bool Panic_GetBreakOnPanic(void) { Bool shouldBreak = FALSE; switch (panicState.breakOnPanic) { case PanicBreakLevel_Never: break; case PanicBreakLevel_IfDebuggerAttached: #ifdef _WIN32 { typedef BOOL (*pfnIsDebuggerPresent)(void); HMODULE kernelLibrary = Win32U_LoadLibrary("kernel32.dll"); if (kernelLibrary != NULL) { pfnIsDebuggerPresent IsDebuggerPresentFn = (pfnIsDebuggerPresent) GetProcAddress(kernelLibrary, "IsDebuggerPresent"); if (IsDebuggerPresentFn != NULL) { shouldBreak = IsDebuggerPresentFn(); } FreeLibrary(kernelLibrary); } } #else /* * This case is handled by Panic_BreakOnPanic for Posix as there is no * portable way to know if we're being debugged other than actually * trapping into the debugger. */ #endif break; default: case PanicBreakLevel_Always: shouldBreak = TRUE; break; } return shouldBreak; }