简体   繁体   English

在Mac上使用gdb在eclipse中调试-无法执行MI命令:-exec-run

[英]debugging in eclipse using gdb on mac - Failed to execute MI command: -exec-run

I have my Eclipse Kepler and my simple HelloWorld C-program, where I wanted to learn how to debug a C-program. 我有我的Eclipse Kepler和我简单的HelloWorld C程序,我想在这里学习如何调试C程序。 When clicking on the debug-button, I get the following error message: 当单击调试按钮时,出现以下错误信息:

Error in final launch sequence Failed to execute MI command: -exec-run Error message from debugger back end: Unable to find Mach task port for process-id 359: (os/kern) failure (0x5). 最终启动序列中的错误无法执行MI命令:-exec-run来自调试器后端的错误消息:找不到进程ID 359的Mach任务端口:(os / kern)故障(0x5)。 Unable to find Mach task port for process-id 359: (os/kern) failure (0x5). 找不到进程ID 359的Mach任务端口:(os / kern)故障(0x5)。

I searched the whole day and didn't find any solution. 我整天都在搜索,没有找到任何解决方案。 I already did all of the recommended things in this post Eclipse GDB MacOSX Mavericks and still get this error. 我已经在Eclipse GDB MacOSX Mavericks中完成了所有推荐的操作,但仍然出现此错误。

It would be really great, if somebody could help me out setting up the debugger in Eclipse. 如果有人可以帮助我在Eclipse中设置调试器,那就太好了。

Oh and I downloaded and installed gdb-apple via macports and I had to use the "-f" option with the codesign command as it didn't work without. 哦,我通过macports下载并安装了gdb-apple,我不得不在codesign命令中使用“ -f”选项,因为如果没有它,它就无法工作。 Maybe these are important information. 也许这些是重要的信息。

This may happen if you signed 'gdb' before making all changes to 'gdb-cert'. 如果在对“ gdb-cert”进行所有更改之前对“ gdb”进行了签名,则可能会发生这种情况。 Then you can restart 'taskgated' and then re-sign the 'gdb' executable. 然后,您可以重新启动“ taskgated”,然后重新签署“ gdb”可执行文件。

  1. ps -e | ps -e | grep taskgated grep taskgated
  2. sudo kill -9 <pid of taskgated> sudo kill -9 <任务的pid>
  3. codesign -f -s gdb-cert $(which gdb) codesign -f -s gdb-cert $(其中gdb)

This worked for me. 这对我有用。

Keep using gdb (not gdb-apple) and just do the following steps: 继续使用gdb(而非gdb-apple),只需执行以下步骤:

1- Create a certificate: 1-创建证书:

  • Start Keychain Access application (/Applications/Utilities/Keychain Access.app) 启动钥匙串访问应用程序(/ Applications / Utilities / Keychain Access.app)
  • Open menu /Keychain Access/Certificate Assistant/Create a Certificate... 打开菜单/钥匙串访问/证书助手/创建证书...
  • Choose a name (gdb-cert in the example), set Identity Type to "Self Signed Root", set Certificate Type to "Code Signing" and select the "Let me override defaults". 选择一个名称(在示例中为gdb-cert),将“身份类型”设置为“自签名根”,将“证书类型”设置为“代码签名”,然后选择“让我覆盖默认值”。
  • Click several times on Continue until you get to the Specify a Location For The Certificate screen, then set Keychain to System. 在“继续”上单击几次,直到进入“指定证书的位置”屏幕,然后将“钥匙串”设置为“系统”。
  • Using the contextual menu for the certificate, select "Get Info", open the Trust item, and set Code Signing to "Always Trust". 使用证书的上下文菜单,选择“获取信息”,打开“信任”项,并将“代码签名”设置为“始终信任”。

2- You must quit Keychain Access application (named "taskgated",from activity monitor) and open it again in order to use the certificate. 2-您必须退出“钥匙串访问”应用程序(从活动监视器中命名为“ taskgated”),然后再次打开它才能使用证书。

3- Assign the certificate to gdb: 3-将证书分配给gdb:

  • using the following command: $ codesign -s gdb-cert gdb 使用以下命令: $ codesign -s gdb-cert gdb

For more details, check this link: http://sourceware.org/gdb/wiki/BuildingOnDarwin 有关更多详细信息,请检查此链接: http : //sourceware.org/gdb/wiki/BuildingOnDarwin

if any of these steps are not clear, feel free to ask. 如果这些步骤中的任何一个不清楚,请随时提出。

If you get this below error, don't forget to add sudo in front of the command: 如果出现以下错误,请不要忘记在sudo前添加sudo

sudo codesign -s gdb-cert $(which gdb-apple)

codesign -s gdb-cert $(which gdb-apple)

error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate: can't create output file: /opt/local/bin/gdb-apple.cstemp (Permission denied)
/opt/local/bin/gdb-apple: the codesign_allocate helper tool cannot be found or used

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM