背景
筆者在終端想用gdb進行調(diào)試, 運行g(shù)db命令時, 突然終端向我拋出一個 gdb: command not found, 頓時一頭霧水, 簡單百度查了下, 原來是因為mac并沒有自帶的gdb調(diào)試工具, 所以需要自己手動安裝, 筆者簡單記錄了下安裝的步驟, 以備以后不時之需.
流程
在進行g(shù)db安裝前應首先配置好homebrew安裝管理工具
- 打開終端復制下面語句回車即可
ruby -e"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
會自動進行更新的
-
輸入命令
brew search gdb查看homebrew中是否有g(shù)db安裝包, 可以看到我現(xiàn)在的版本中并沒有g(shù)db安裝包
Snip20170425_16.png 執(zhí)行命令
brew install gdb進行安裝, 注意這里不要執(zhí)行sudo brew install gdb, 如果執(zhí)行此命令, 中端會向你拋出下面這些問題
Error: Running Homebrew as root is extremely dangerous and no longer supported. As Homebrew does not drop privileges on installation you would be giving all build scripts full access to your system.Error: Running Homebrew as root is extremely dangerous and no longer supported. As Homebrew does not drop privileges on installation you would be giving all build scripts full access to your system.-
在進行安裝的過程中我們來配置我們的證書吧
- 打開鑰匙串, 添加證書

-
填寫信息, 必須一樣
-
然后一直繼續(xù)下去,直到看到這個界面,剛出現(xiàn)這個界面的時候是“登陸”,我們需要把它改為“系統(tǒng)”
-
在鑰匙串的系統(tǒng)選項中查看到剛剛創(chuàng)建的gdb-cert證書,然后雙擊,點擊信任,全部選擇始終信任,至此證書就創(chuàng)建好了
5 打開終端, 執(zhí)行命令sudo codesign -s gdb-cert /usr/local/bin/gdb 到這里就完成了



