如何在Mac OSX El Capitan中安装gdb(调试器)? [英] How to install gdb (debugger) in Mac OSX El Capitan?

查看:100
本文介绍了如何在Mac OSX El Capitan中安装gdb(调试器)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Mac OSX El Capitan中安装gdb(调试器)?我曾尝试安装gdb,但几次都失败。



我正在关注这个网址:

任何人都可以在这方面帮助我。 是这个问题的两个解决方案,他们都在这个问题的其他答案中提到,并且如何让gdb在OSX 10.11 El Capitan下使用macports?,但是为了清除这里的一些混淆是我的总结(作为一个答案,因为它有点长的评论):

哪种方法更安全?我猜可以归结为1)信任自签名证书和2)给用户更多权限。
$ b

备选1:对二进制文件进行签名

如果使用签名替代方法,禁用SIP添加<-c $ c> taskgated 的-p选项不是必需的。



不过,请注意这个替代方案,调试只允许 em> _developer group



使用codesign使用名为 gdb-cert

codesign -s gdb-cert / opt / local / bin / ggdb



(使用MacPorts标准路径,必要时采用)

代码签名配方(包括创建证书),请参阅:
https://gcc.gnu.org/onlinedocs/gcc-4.8.1/gnat_ugn_unw/Codesigning-the-Debugger.html
https://sourceware.org/gdb/wiki/BuildingOnDarwin



请注意,您需要重新启动钥匙串应用程序和任务门户服务(最简单的方法是重新启动)。



方案2:使用传统选项进行任务处理



根据@ user14241的回答,dis abling SIP并将-p选项添加到 taskgated 是一个选项。请注意,如果使用此选项,则不需要签名二进制文件,并且它还绕过用于进行身份验证的对话框,以便作为开发人员工具组的成员进行身份验证( _developer

在添加-p选项(允许组procmod和procview)到taskgated之后,您还需要添加应允许使用的用户gdb到procmod组

配方是:


  1. 在恢复模式下重启,打开终端并运行 csrutil disable


  2. 重启机器并编辑 / System / Library / LaunchDaemons / com.apple.taskgated.plist ,添加
    -p opion:

     < array> 
    < string> / usr / libexec / taskgated< / string>
    < string> -sp< / string>
    < / array>


  3. 以恢复模式重新启用SIP( csrutil enable < code $)

  4. 重新启动机器并将用户 USERNAME 添加到组中 procmod



    sudo dseditgroup -o编辑-a USERNAME -t用户procmod



    另一个不涉及将用户添加到组的方法是将可执行文件setgid procmod ,因为这也使得 procmod 执行setgid二进制文件的任何用户的有效组标识符(在

      sudo chgrp procmod / path / to / gdb 
    sudo chmod g + s / path / to / gdb



How to install gdb (debugger) in Mac OSX El Capitan ? I have tried installing gdb but failed couple of time.

I was following this URL : http://ntraft.com/installing-gdb-on-os-x-mavericks/ , MAC doesnot allow to install MacPorts.

Could anyone please help me in this regard.

解决方案

There are two solutions to the problem, and they are both mentioned in other answers to this question and to How to get gdb to work using macports under OSX 10.11 El Capitan?, but to clear up some confusion here is my summary (as an answer since it got a bit long for a comment):

Which alternative is more secure I guess boils down to the choice between 1) trusting self-signed certificates and 2) giving users more privileges.

Alternative 1: signing the binary

If the signature alternative is used, disabling SIP to add the -p option to taskgated is not required.

However, note that with this alternative, debugging is only allowed for users in the _developer group.

Using codesign to sign using a cert named gdb-cert:

codesign -s gdb-cert /opt/local/bin/ggdb

(using the MacPorts standard path, adopt as necessary)

For detailed code-signing recipes (incl cert creation), see : https://gcc.gnu.org/onlinedocs/gcc-4.8.1/gnat_ugn_unw/Codesigning-the-Debugger.html or https://sourceware.org/gdb/wiki/BuildingOnDarwin

Note that you need to restart the keychain application and the taskgated service during and after the process (the easiest way is to reboot).

Alternative 2: use the legacy option for taskgated

As per the answer by @user14241, disabling SIP and adding the -p option to taskgated is an option. Note that if using this option, signing the binary is not needed, and it also bypasses the dialog for authenticating as a member of the Developer Tools group (_developer).

After adding the -p option (allow groups procmod and procview) to taskgated you also need to add the users that should be allowed to use gdb to the procmod group.

The recipe is:

  1. restart in recovery mode, open a terminal and run csrutil disable

  2. restart machine and edit /System/Library/LaunchDaemons/com.apple.taskgated.plist, adding the -p opion:

    <array>
        <string>/usr/libexec/taskgated</string>
        <string>-sp</string>
    </array>
    

  3. restart in recovery mode to reenable SIP (csrutil enable)

  4. restart machine and add user USERNAME to the group procmod:

    sudo dseditgroup -o edit -a USERNAME -t user procmod

    An alternative that does not involve adding users to groups is to make the executable setgid procmod, as that also makes procmod the effective group id of any user executing the setgid binary (suggested in https://apple.stackexchange.com/a/112132)

    sudo chgrp procmod /path/to/gdb
    sudo chmod g+s /path/to/gdb 
    

这篇关于如何在Mac OSX El Capitan中安装gdb(调试器)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆