gdb不能使用mac
先说问题:1、gdb不能使用,重新用homebrew install 了gdb
2、brew装的gdb可以用了,但是等start调试的时候报这些错误:
dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib
gdb Reason: image not found
或者:
Unable to find Mach task port for process-id 15634: (os/kern) failure (0x5).
During startup program terminated with signal ?, Unknown signal.
经google研究,说没有code-sign的原因,然后一通stackoverflow乱搜,遂,卒。
总之是怎么整都不行,然后brew info gdb查看发现当初安装好gdb homebrew有这么几句提示:
==> Caveats
gdb requires special privileges to access Mach ports.
You will need to codesign the binary. For instructions, see:
https://sourceware.org/gdb/wiki/BuildingOnDarwin
On 10.12 (Sierra) or later with SIP, you need to run this:
echo "set startup-with-shell off" >> ~/.gdbinit
遂按照上面的提示最后一行 echo "set startup-with-shell off" >> ~/.gdbinit结果发现,也不行。
确定了是没有codesign引起的原因,又google,查到一遍文章apple专门关于codesign的:https://opensource.apple.com/source/lldb/lldb-69/docs/code-signing.txt
大概看了下意思,发现要手动Create a Certificate...,觉得好麻烦啊,肯定没这么麻烦,还不死心,继续google。。。结果你懂的
无奈,只能返回去看brew info gdb,发现上面这句链接:
https://sourceware.org/gdb/wiki/BuildingOnDarwin
发现还是需要手动Create a Certificate,罢了,这个写的排版和Troubleshooting都不错,耐着心看下去吧,
跟着尝试了一遍,证书也创好了,taskgated也kill掉了,结果还是不行。。。
再Troubleshooting,
发现没有“Ensure that the certificate is marked as Always Trust”
把证书打开,显示简介,发现里面有调整的选项,换成Always Trust
重新kill了taskgated
新开一个terminal
gdb
start
弹出了一框:输入用户名和密码,老老实实照办,最终:
[New Thread 0x1403 of process 17715]
warning: unhandled dyld version (15)
Thread 2 hit Temporary breakpoint 1, main () at int.c:4
4 int a = 0;
(gdb)
真是不容易啊!
这件事说明:碰到问题不要动不动就google乱找一气,应该沉下心来仔细观察应有的报错和已知提示,从中找到解决问题的办法,往往是最有效的!
本文来自博客园,作者:易先讯,转载请注明原文链接:https://www.cnblogs.com/gongxianjin/p/10528343.html