gdb fails with "Unable to find Mach task port for process-id" error

S B picture S B · Jul 16, 2012 · Viewed 112.1k times · Source

My app runs fine but gdb fails to debug it with the following error

(gdb) run
Starting program: /path/to/app 
Unable to find Mach task port for process-id 83767: (os/kern) failure (0x5).

I am on OS X Lion. GDB version is

$ gdb --version
GNU gdb 6.3.50-20050815 (Apple version gdb-1752) (Sat Jan 28 03:02:46 UTC 2012)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".

Answer

Mengyuan picture Mengyuan · Jan 12, 2014

It works when I change to sudo gdb executableFileName! :)