MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/TriangleMeshDistance / isDebuggerActive

Function isDebuggerActive

tests/catch.hpp:8219–8249  ·  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

8217 // Returns true if the current process is being debugged (either
8218 // running under the debugger or has a debugger attached post facto).
8219 bool isDebuggerActive(){
8220
8221 int mib[4];
8222 struct kinfo_proc info;
8223 std::size_t size;
8224
8225 // Initialize the flags so that, if sysctl fails for some bizarre
8226 // reason, we get a predictable result.
8227
8228 info.kp_proc.p_flag = 0;
8229
8230 // Initialize mib, which tells sysctl the info we want, in this case
8231 // we're looking for information about a specific process ID.
8232
8233 mib[0] = CTL_KERN;
8234 mib[1] = KERN_PROC;
8235 mib[2] = KERN_PROC_PID;
8236 mib[3] = getpid();
8237
8238 // Call sysctl.
8239
8240 size = sizeof(info);
8241 if( sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, nullptr, 0) != 0 ) {
8242 Catch::cerr() << "\n** Call to sysctl failed - unable to determine if debugger is active **\n" << std::endl;
8243 return false;
8244 }
8245
8246 // We're being debugged if the P_TRACED flag is set.
8247
8248 return ( (info.kp_proc.p_flag & P_TRACED) != 0 );
8249 }
8250 } // namespace Catch
8251
8252#elif defined(CATCH_PLATFORM_LINUX)

Callers 1

useColourOnPlatformFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected