20 #if defined(ION_PLATFORM_LINUX) || defined(ION_PLATFORM_ANDROID) || \
21 defined(ION_PLATFORM_GENERIC_ARM)
27 #include <sys/types.h>
29 #elif defined(ION_PLATFORM_MAC) || defined(ION_PLATFORM_IOS)
33 #include <sys/sysctl.h>
34 #include <sys/types.h>
36 #elif defined(ION_PLATFORM_WINDOWS)
46 #if defined(ION_PLATFORM_LINUX) || defined(ION_PLATFORM_ANDROID) || \
47 defined(ION_PLATFORM_GENERIC_ARM)
55 int fd = open(
"/proc/self/status", O_RDONLY);
59 const ssize_t len = read(fd, buf,
sizeof(buf));
62 const char *
const kTracerPid =
"TracerPid:\t";
64 const char *p = strstr(buf, kTracerPid);
66 rc = (strncmp(p + strlen(kTracerPid),
"0\n", 2) != 0);
73 #elif defined(ION_PLATFORM_MAC) || defined(ION_PLATFORM_IOS)
83 struct kinfo_proc info;
88 info.kp_proc.p_flag = 0;
94 mib[2] = KERN_PROC_PID;
101 static_cast<u_int>(
sizeof(mib) /
sizeof(*mib)),
109 return (info.kp_proc.p_flag & P_TRACED) != 0;
112 #elif defined(ION_PLATFORM_WINDOWS)
115 return ::IsDebuggerPresent() ?
true :
false;
129 #if defined(ION_PLATFORM_LINUX) || defined(ION_PLATFORM_ANDROID) || \
130 defined(ION_PLATFORM_MAC) || defined(ION_PLATFORM_IOS) || \
131 defined(ION_PLATFORM_GENERIC_ARM)
133 #elif defined(ION_PLATFORM_WINDOWS)
bool IsDebuggerAttached()
Don't break on unsupported platforms.
void Break()
If a debugger is attached, this function interrupts the program execution and causes any attached deb...
void BreakOrAbort()
Calls Break() if running in a debugger, abort() otherwise.