Mac配置Eclipse CDT的Debug出现的问题

这篇博客详细介绍了在Mac环境下,使用Eclipse CDT进行C++开发时遇到的四个关于gdb调试器的问题,包括gdb未安装、gdb签名问题、mac osx版本问题以及gdb版本导致的调试问题。针对每个问题,博主提供了详细的解决步骤,包括安装gdb、配置Eclipse调试器路径、处理gdb签名问题以及降级gdb版本等解决方案。

问题1:出现 Could not determine GDB version using command: gdb --version

原因:

mac上没有安装gdb或者gdb位置配置有问题

解决方法:

1 安装gdb,

2 如果确定已经安装了gdb,需要配置Eclipse中Debuger的路径:项目右键-》Debug As-》Debug Configurations-》左侧C++ Application找到当前项目-》右侧标签页选择Debuger-》修改gdb的路径和.gdbinit文件路径



问题2:出现 Could not determine GDB version using command: gdb --version

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 99177: (os/kern) failure (0x5).  
 (please check gdb is codesigned - see taskgated(8))  
Unable to find Mach task port for process-id 99177: (os/kern) failure (0x5).  
 (please check gdb is codesigned - see taskgated(8))  

原因:

gdb没有签名

解决方法:

1 具体步骤参考:https://segmentfault.com/q/1010000004136334

2 如果出现系统证书创建失败的问题参照:http://blog.youkuaiyun.com/lllkey/article/details/79423596


问题3:出现 Could not determine GDB version using command: gdb --version

Error in final launch sequence
Failed to execute MI command:
-exec-run
Error message from debugger back end:
During startup program terminated with signal ?, Unknown signal.
During startup program terminated with signal ?, Unknown signal.

原因:

mac osx某个版本之后会出现的问题,修改.gdbinit文件的配置可以解决

解决方法:

1 参考:https://stackoverflow.com/questions/40052171/gdb-terminated-with-signal-unknown-signal

在home目录或者gdb的目录下创建文件:.gdbinit (我的gdb的路径为:/usr/local/Cellar/gdb/8.1/bin),只要之后再Eclipse中配置相应路径即可
echo "set startup-with-shell off" >> ~/.gdbinit
重新开一个terminal 或者 在Eclipse下再debug即可


问题4:出现 Could not determine GDB version using command: gdb --version

Error in final launch sequence
Failed to execute MI command:
-exec-run
Error message from debugger back end:
During startup program terminated with signal SIGTRAP, Trace/breakpoint trap.
During startup program terminated with signal SIGTRAP, Trace/breakpoint trap.

原因:

gdb8.1版本的某些问题,需要降到某版本,我现在尝试gdb8.0.1是可以调试的

解决方法:

1 参考:https://www.jianshu.com/p/b546a47b6b75 

从这个文章来看gdb8.1并不适配现在的os,所以需要回退到gdb8.0.1
使用brew更换版本失败,由于其中需要用到
brew versions gdb
但是返回:
Error: Unknown command: versions
2 8.0.1下载地址: https://ftp.gnu.org/gnu/gdb/gdb-8.0.1.tar.xz
开始编译安装gdb:
解压:
tar -Jxvf /Users/lsq/Movies/thunder/gdb-8.0.1.tar.xz 
编译安装:
./configure --prefix=/usr/local
make
make -C gdb install
签名gdb:
codesign -fs gdb_codesign $(which gdb)
配置:
echo "set startup-with-shell off" >> ~/.gdbinit
如果使用Eclipse调试:修改Debuger中gdb和.gdbinit的位置(参考问题1)









评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值