问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

如何在Mac系统中安装gdb调试器

发布网友 发布时间:2022-04-22 23:54

我来回答

2个回答

懂视网 时间:2022-04-30 00:01

  • For the remainder of the tutorial, use /opt/local/bin/gdb-apple as the GDB executable
  • Remember if you want breakpoints in template functions to work, you‘ll need to change your compiler to g++-apple-4.2 instead of g++! This can be done in your Makefiles or in your IDE settings.
  • Install with Homebrew

    1. Install Xcode and Homebrew, if not already installed.
    2. Now install GDB from Homebrew: $ brew tap homebrew/dupes
      $ brew install gdb
    3. For the remainder of the tutorial, use /usr/local/bin/gdb as the GDB executable

    If that worked, then lucky you! Getting it compiled is where many people seem to have trouble. Now you just need to sign it to give it permission to control OS X processes.

    Certifying GDB

    Open up the Keychain Access application (/Applications/Utilities/Keychain Access.app). Navigate via the menu to Keychain Access > Certificate Assistant > Create Certificate...

    技术分享

    Enter a name for the certificate. For this how-to, I‘ll call it "gdb-cert". Set the fields exactly as shown below.

    技术分享

    The maximum validity period is 999 days. I don‘t really want to deal with this again, so I‘m going to max it out.

    技术分享

    Keep clicking the "Continue" button until you are asked for a location. Set it to "System".3

    技术分享

    Success!

    技术分享

    Now make sure the cert is always trusted. Right-click the new certificate and select Get Info. Under the Trust section, set Code Signing to Always Trust.

    技术分享

    技术分享

    Now that we have a certificate, we need to use it to sign GDB. First, we‘ll restart the taskgatedprocess to make sure it picks up the new certificate. Quit Keychain Access (you must quit Keychain Access!) and return to the Terminal for these final commands.

    Find the taskgated process.

    $ ps -e | grep taskgated
    56822 ??         0:03.11 /usr/libexec/taskgated -s
    60944 ttys002    0:00.00 grep --color=auto taskgated

    The first number in the above output is the PID. Use this to kill the process (it will immediately restart itself).

    $ sudo kill -9 56822

    Now you can finally code sign GDB.

    # MacPorts version
    $ codesign -s gdb-cert $(which gdb-apple)
    # Homebrew version
    $ codesign -s gdb-cert $(which gdb)

    Now you should be all set! The OS X Keychain may ask for your password the first time you attempt to debug a program, but it should work!

    Getting it to Work with Eclipse

    There‘s one more step for Eclipse users. You need to specify where Eclipse can find the new GDB. Specify the path to GDB in Preferences > C/C++ > Debug > GDB:

    技术分享

    If you already have some debug configurations, you may need to edit them individually to point to the correct place (under Run > Debug Configurations...):

    技术分享


      1. The CDT developers are planning to support LLDB, but they will have to write a whole new interface, and I think most of them only work on Eclipse in their spare time, so it will likely be at least some months before LLDB support is there.
      2. The procedure is derived from this StackOverflow post and this GDB Wiki page.
      3. If you are unable to save it to the System keychain, then save it to the login keychain. You can later export the cert, and then import it into the System keychain. I didn‘t have to do this, so comment if you have any problem.

    mac上eclipse用gdb调试(转)

    标签:

    热心网友 时间:2022-04-29 21:09

    一、安装GDB1在进行gdb安装前应首先配置好homebrew安装管理工具,由于先前写过Homebrew的详细安装过程(可以参考本人先前经验)2安装好homebrew后,输入如下命令查看homebrew中是否有gdb安装包,可以看到现在的版本中并没有gdb安装包。3输入命令brew update来更新homebrew的软件库,更新完成后再次查询即可看到已经有gdb安装包喽。4输入命令brew install gdb 即可以进行gdb调试器的安装了,安装过程如下所求5安装完成后可以通过输入gdb测试gdb版本及是否正确安装。6此外,建议大家通过如上安装方式来安装CGDB或者DDD调试工具,它们也都是基于GDB的,但是它们有着便捷的界面调试优势。7可能会发现安装完成后还是不能利用GDB来进行代码调试,会出现如下错误:Unable to find Mach task port for process-id 6603: (os/kern) failure (0x5). (please check gdb is codesigned - see taskgated(8))接下来。。。还需要对GDB进行证书签名方可正常使用。END二、给GDB创建证书1在mac中打开keychain access工具,并创建一个证书2证书的信息可能参考如下所示的图3此后一直点击继续按钮直到下图时,更改为相应设置为System,最终便生成了如下所示的证书。4按照下面步骤更改证书的权限为“Always trust"END三、对证书进行签名打开终端,输入如下命令codesign -s yc_GDB_cert /usr/local/bin/gdb打开任务管理器,在CPU选项卡中关闭进程taskgated接下来就可以通过GDB来进行代码调试了
    声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
    化学速率的理解问题 标准平衡常数Kθ公式「科普」 沼泽过滤用沙子还是石子 艾利和U10VP(1GB)主要功能 艾利和U10VP(512MB)重要参数 艾利和U10(1GB)重要参数 艾利和U10(1GB)艾利和U10(1GB)详细参数 艾利和U10(512MB)艾利和U10(512MB)详细参数 电信手机查详单能不能把上网的历史记录查出来 电信流量超支怎么查询 linux gdb如何安装 深度linux V20如何安装gdb,如何用gdb调试程序、用gdb设置断点删除断点... linux gdb如何安装? 喝乳清蛋白粉增肌,建议做什么运动比较适宜? 没坐过成都地铁,是怎么买票? 有什么好的蛋白棒推荐? 成都地铁app哪个好 健身喝的蛋白质粉的功效与作用 蛋白棒和蛋白粉有哪些区别? 乳清蛋白除了可以增长肌肉,还有什么作用?具体点。 星咔乳清蛋白棒的原理是什么 怎么关win10飞行模式,总是关不了,导致一直重启电脑 乳清蛋白有什么作用 请问各位健身大神,乳清蛋白质对健身有啥好处? win10的飞行模式如何关闭? 蛋白棒的作用是什么? 什么是亚克力? win10怎么关闭飞行模式? 亚克力是什么塑料 笔记本win10一直处于飞行模式关 无法登录 如何在虚拟机(linux)中安装gdb软件包? 成都地铁和公交是一个APP? 怎样在linux系统中安装gdb调试工具? 健身吃乳清蛋白粉哪个牌子比较好? 如何在centos7上安装最新的gdb 成都地铁站可以刷云闪付坐地铁吗?或者什么卡支付? 哪位大神知道mac下gdb如何安装? 同一手机号注册了天府通乘车二维码和成都地铁app、坐车使用成都地铁app扣费会? 如何查看linux是否安装了gdb 成都地铁不购票,使用二维码支付,那这二维码指的是什么软件上的二维码... 如何查看系统中gdb是否已安装及gdb的版本 我的linux操作系统没有gdb命令,请问怎么安装gdb命令呢?​ 成都地铁app无法注册怎么做? linux下make,gcc,gdb安装问题 刷脸乘车记录在哪看 win10内嵌子系统unbuntu18.04中怎么装gdb,用了 sudo apt-get install build-essential,但没有安装上gdb 电脑右下角的小喇叭不见了,怎么设置? ubuntu中怎么用命令安装gdb 请问如何才能让电脑桌面右下角的声音和音频设备显示出来? visual box lubuntu 怎么安装gdb