MCPcopy Create free account
hub / github.com/RenderKit/oidn / isDebuggerActive

Function isDebuggerActive

external/catch.hpp:10409–10438  ·  view source on GitHub ↗

Returns true if the current process is being debugged (either running under the debugger or has a debugger attached post facto).

Source from the content-addressed store, hash-verified

10407 // Returns true if the current process is being debugged (either
10408 // running under the debugger or has a debugger attached post facto).
10409 bool isDebuggerActive(){
10410 int mib[4];
10411 struct kinfo_proc info;
10412 std::size_t size;
10413
10414 // Initialize the flags so that, if sysctl fails for some bizarre
10415 // reason, we get a predictable result.
10416
10417 info.kp_proc.p_flag = 0;
10418
10419 // Initialize mib, which tells sysctl the info we want, in this case
10420 // we're looking for information about a specific process ID.
10421
10422 mib[0] = CTL_KERN;
10423 mib[1] = KERN_PROC;
10424 mib[2] = KERN_PROC_PID;
10425 mib[3] = getpid();
10426
10427 // Call sysctl.
10428
10429 size = sizeof(info);
10430 if( sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, nullptr, 0) != 0 ) {
10431 Catch::cerr() << "\n** Call to sysctl failed - unable to determine if debugger is active **\n" << std::endl;
10432 return false;
10433 }
10434
10435 // We're being debugged if the P_TRACED flag is set.
10436
10437 return ( (info.kp_proc.p_flag & P_TRACED) != 0 );
10438 }
10439 #else
10440 bool isDebuggerActive() {
10441 // We need to find another way to determine this for non-appleclang compilers on macOS

Callers 1

useColourOnPlatformFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected