PT_DENY_ATTACH is an Apple-specific constant that can prevent debuggers (gdb, DTrace, etc.) from debugging your binary in kernel-level. Calling
ptrace(PT_DENY_ATTACH, 0, 0, 0);
will send a SEGFAULT to its tracing parent. Nevertheless, since ptrace has a well-defined address, a simple GDB macro is enough to break this:
break ptracecommands 1 return continueend
Nevertheless, since the ptrace is built inside the kernel, which the userspace interface only performs syscall 26, as long as your assembly code resembles
mov r0, #31mov r1, #0mov r2, #0mov r3, #0mov ip, #26svc #0x80
the PT_DENY_ATTACH will be installed and there is no way GDB can workaround it. The cracker can still use patching techniques to nop out the svn #0x80 instructions, but checksumming would help in these cases. Also make sure you don't compile your binary in thumb, cause the compiler will fail due to limited availability of registers in thumb mode.