mac+gdb调试环境的那些坑——brew安装、gdb证书认证

一开始要安装gdb的时候,发现brew版本过低了,想要update结果慢的要死,一气之下就卸载重装了,结果踩了第一个坑……

brew安装

官方给的Homebrew安装方法 https://brew.sh/:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

 

安装巨慢,下载到百分之十几就会报错,尝试了网上能搜到的一票方法,包括修改git缓存大小、获取install文件修改镜像(install文件已经被重写,官方指路上图了)等都不成功,最后https://zhuanlan.zhihu.com/p/111014448 完美高速解决

 

gdb安装和配置

安装好brew后,brew install gdb快速搞定,但是file可执行文件之后,显示

(gdb) file study/C/C_Primer_plus/pre/gdb-sample 
Reading symbols from study/C/C_Primer_plus/pre/gdb-sample...
Reading symbols from /Users/joy/study/C/C_Primer_plus/pre/gdb-sample.dSYM/Contents/Resources/DWARF/gdb-sample...
BFD: /usr/lib/dyld(i386:x86-64): unknown load command 0x34
BFD: /usr/lib/dyld(i386:x86-64): unknown load command 0x34
BFD: /usr/lib/dyld(i386:x86-64): unknown load command 0x34

run之后

(gdb) run
Starting program: /Users/joy/study/C/C_Primer_plus/pre/gdb-sample 
Unable to find Mach task port for process-id 60383: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))

需要创建证书对gdb签名,运行时加sudo

 

posted @ 2020-09-05 20:43  进击的小Y  阅读(554)  评论(0编辑  收藏  举报