在Eclipse里调试c程序, 出现: "Error while launching command: gdb -version"。需要让Eclipse知道Eclipse具体在什么地方,配置方法是: "Debug configuration"-->"Debugger"-->"GDB debugger"里的"gdb"改成gdb的绝对路径:"/usr/local/bin/gdb"
但配置之后仍然会有错误:
Unable to find Mach task port for process-id 83686: (os/kern) failure (0x5). (please check gdb is codesigned - see taskgated(8)) Unable to find Mach task port for process-id 83686: (os/kern) failure (0x5). (please check gdb is codesigned - see taskgated(8))
原因是在Mac系统(10.9)里默认不允许GNU gdb访问其他进程,需要对gdb进行签名:
? ~ which gdb /usr/local/bin/gdb --> ~ codesign -s gdb-cert /usr/local/bin/gdb
签名的命令是`codesign`,gdb-cert是自己制作的证书,后面跟上被签名的进程: `/usr/local/bin/gdb`
下面是签名的方法,参考资料来自:<BuildingOnDarwin><Installing GDB on OS X Mavericks>
钥匙串访问-->证书助理-->创建证书,在“证书助理”创建名字为gdb-cert的证书:
一路`继续`,中间有个选项要选择:
最终生成:
生成之后,用`codesign`注册,重启taskgated进程即可
? ~ ps -e | grep taskgated 69 ?? 2:06.20 /usr/libexec/taskgated -s 84711 ttys002 0:00.00 grep --color=auto taskgated --> ~ sudo kill -9 69
Mac里配置Eclipse + GDB
时间: 2024-11-09 00:42:27