且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 MacOS 10.13.3 (High Sierra) 上安装 GDB

更新时间:2023-02-23 15:33:55

经过几个小时的搜索,我终于找到了一个 晦涩的要点 确定问题并详细说明解决方案.

After hours and hours of searching, I finally found an obscure gist identifying the issue and detailing the solution.

TL;DR GNU 调试器需要一个补丁才能在 MacOS 上运行.gdb v8.0.1 是已知的最后一个适用于 MacOS 的 GDB 良好版本.

TL;DR The GNU Debugger requires a patch before it can work with MacOS. gdb v8.0.1 is the last known good version of GDB for MacOS.

  1. 卸载最新版本的gdb(即v8.1)

brew uninstall --force gdb

  • 强制 Homebrew 安装带有 MacOS 补丁的 gdb 版本.

    brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/c3128a5c335bd2fa75ffba9d721e9910134e4644/Formula/gdb.rb
    

  • 使用现有证书对 gdb

    codesign -f -s  "<GNU GDB Certificate>" $(which gdb)
    

  • 现在,gdb 可以正常工作了!

    Now, gdb works as expected!

    特别感谢 https://github.com/marcoparentehttps://github.com/lokoum 了解他们的要点评论!

    Special thanks to https://github.com/marcoparente and https://github.com/lokoum for their gist comments!