You can only debug a setuid or setgid program if the debugger is running as root. The kernel won't let you call
ptrace on a program running with extra privileges. If it did, you would be able to make the program execute anything, which would effectively mean you could e.g. run a root shell by calling a debugger on
If you run Gdb as root, you'll be able to run your program, but you'll only be observing its behavior when run by root.
If you need to debug the program when it's not started by root, start the program outside Gdb, make it pause in some fashion before getting to the troublesome part, and
attach the process inside Gdb (
at 1234 where 1234 is the process ID).