Mac(os x)下使用gdb的问题

先说问题: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乱找一气,应该沉下心来仔细观察应有的报错和已知提示,从中找到解决问题的办法,往往是最有效的!
~

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
This combination reference and tutorial provides a comprehensive yet concise look at UNIX for users of Mac OS X. The book is fully up-to-date with the 10.4 (Tiger) release of OS X which is built on top of a UNIX system. Building upon Mark Sobell's A Practical Guide to the UNIX System, this book provides step-by-step tutorials for OS X users eager to get the most from the underlying UNIX system. Peter Seebach and Mark Sobell offer clear, straightforward coverage of hundreds of UNIX and Mac OS X UNIX specific commands and utilities, including Sobell's user-friendly 236-page command reference section that alone is worth the price of the book. Using a practical approach, this book provides hands-on examples and detailed explanations to demystify the UNIX environment. Designed for the novice to intermediate user, it covers basic user-level commands, shell programming, as well as more advanced utilities. Features: A quick introduction to 30+ useful utilities An introduction to the UNIX filesystem and its features One chapter on vim and one chapter on emacs A chapter on programming tools including sections on gcc, make, gdb, and CVS Detailed coverage of more than 80 UNIX utilities with many examples (Part VI) An introductory chapter on using the shells A chapter on using bash (the Bourne Again Shell) interactively (from the command line) A chapter covering bash as a programming language (to write shell scripts) A chapter about how to use tcsh (the TC Shell) interactively (from the command line) and as a programming language A chapter on the awk pattern processing language An appendix on regular expressions A glossary with over 500 entries

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值