I’m trying to detect when gdb is attached to my app and I’m using this in JNI code
long x = ptrace(PTRACE_TRACEME, 0, 1, 0); char buffer; sprintf(buffer, "ptrace = %ld", x); return (*env)->NewStringUTF(env, buffer);
x is always
-1 regardless of whether gdb is attached or not. Why is that? What can I do to figure out what I’m doing wrong?