I have set a super simple C program and compiled it with GCC (with the
-g flag). I've tried running it with
gdb a.out, set a breakpoint on
main and run it, but GDB ignored my breakpoint and simply ran the entire program nonstop.
On my questions in SO they told me to run it with
grep for failed calls to ptrace. I did so and got:
5765 ptrace(PTRACE_TRACEME, 0, 0, 0) = -1 EPERM (Operation not permitted)
When I'm trying to run
sudo it works fine, so it's definitely a permissions problem. I've also tried reinstalling GDB, hoping it'll re-set the permissions, but it didn't help. Here are the groups and permissions for GDB and for the executable I'm trying to debug:
-rwxr-xr-x 1 idanarye users 7797 Dec 28 04:52 ./a.out -rwxr-xr-x 1 root root 5206304 Aug 31 07:10 /usr/bin/gdb
I tried googling for this problem, but all I could find is another problem where GDB fails to attach to running processes due a to a new security rule that prevents ptracing another process unless it's a child process. This is not the problem here, since I let GDB start the process I want to debug. I've tried the suggested solution(changing
/proc/sys/kernel/yama/ptrace_scope) anyways and it didn't work.
What am I missing here? What permissions do I need to give and to what?
I'm running a 64bit ArchLinux.
No idea how or why, but it works now. Probably a system update fixed it...