转载自:http://blog.plotcup.com/a/129

最近一直用go写一个项目,本想在mac上用gdb调试一下,但xcode4.6带的gdb版 本还是太低了,不支持go,只好自己安装一个。本以为直接brew install gdb就 完事了,后来发现不是那么回事,还要给gdb制作证书签名。下面是操作步骤:

安装gdb

brew install gdb

程序编译完成后在/usr/local/bin/下面建立一个gdb的软链,并且将/usr/bin/ 下面的gdb改名。

制作证书

  1. 打开钥匙串访问
  2. 创建证书

  1. 输入名称,并选择类型

  1. 输入有效期,一般默认365就好,也就是一年

  1. 然后一直直接继续,直到创建画面,选择系统,并创建

  1. 选择刚刚生成的gdb-cert证书,并双击

  1. 在证书简介中打开信任,并将使用此证书时选择为总是信任

对gdb签名

有了刚刚制作的证书后,打开shell,然后执行如下代码:

codesign -s gdb-cert /usr/local/bin/gdb

Tip

执行这个之前可能要重启计算机

完成以上工作后gdb就可以调试go了,但是每次使用的时候都会提示输入管理员 密码。

使普通用户也可使用gdb

由于之前制作的证书是在系统下面的,所以每次执行gdb都会提示管理员密码,解 决方法也很简单,打开钥匙串访问将系统下面的gdb-cert复制一份放到登录下面 就行。

参考资料

Building GDB for Darwin

Creating the binary for Darwin isn't very difficult. Download a release snapshot or get the current source via git/CVS/FTP, then configure and make as usual.

Building the 7.0 release unfortunately results in many "warning: format not a string literal and no format arguments" warnings. This problem has been fixed in CVS. To avoid such warnings building 7.0, configure with --disable-intl.

Giving gdb permission to control other processes

If you try to use your freshly built gdb, you will get an error message such as:

Starting program: /x/y/foo
Unable to find Mach task port for process-id 28885: (os/kern) failure (0x5).
(please check gdb is codesigned - see taskgated(8))

This is because the Darwin kernel will refuse to allow gdb to debug another process if you don't have special rights, since debugging a process means having full control over that process, and that isn't allowed by default since it would be exploitable by malware. (The kernel won't refuse if you are root, but of course you don't want to be root to debug.)

The most up to date method to allow gdb to control another process is to sign it with any system-trusted code signing authority. This is an easy process once you have a certificate (see the section below). If the certificate is known as gdb-cert, just use:

$ codesign -s gdb-cert gdb

Old notes: In Tiger, the kernel would accept processes whose primary effective group is procmod or procview. That means that making gdb setgid procmod should work. Later versions of Darwin should accept this convention provided that taskgated (the daemon that control the access) is invoked with option '-p'. This daemon is configured by/System/Library/LaunchDaemons/com.apple.taskgated.plist. I was able to use this rule provided that I am also a member of the procmod group.

Creating a certificate

Start Keychain Access application (/Applications/Utilities/Keychain Access.app)

Open menu /Keychain Access/Certificate Assistant/Create a Certificate...

Choose a name (gdb-cert in the example), set Identity Type to Self Signed Root, set Certificate Type to Code Signing and select the Let me override defaults. Click several times on Continue until you get to the Specify a Location For The Certificate screen, then set Keychain to System.

If you can't store the certificate in the System keychain, create it in the login keychain, then exported it. You can then imported it into the System keychain.

Finally, using the contextual menu for the certificate, select Get Info, open the Trust item, and set Code Signing to Always Trust.

You must quit Keychain Access application in order to use the certificate and restart taskgated service by killing the current running taskgated process (so before using gdb).

本文出自:http://blog.plotcup.com, 原文地址:http://blog.plotcup.com/a/129, 感谢原作者分享。
 

mac安装gdb调试(转载)的更多相关文章

  1. centos7 安装gdb (调试nginx)

    首先卸载原有的gdb,sudo yum remove gdb 从gnu官网下载最新的gdb源文件,wget http://mirrors.ustc.edu.cn/gnu/gdb/gdb-7.9.1.t ...

  2. Mac os系统gdb调试器的安装与使用

    Mac os系统gdb调试器的安装与使用 1.简介 Mac os下的Terminal 终端中默认情况下并没有安装gdb调试器,但是可以通过gcc编译器进行代码编译,如果出错了就需要通过gdb调试器进行 ...

  3. 用gdb调试python多线程代码-记一次死锁的发现

    | 版权:本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接.如有问题,可以邮件:wangxu198709@gmail.com 前言 相信很多人都有 ...

  4. 一文入门Linux下gdb调试(一)

    作者:良知犹存 转载授权以及围观:欢迎添加微信号:Conscience_Remains 总述 在window下我们习惯了IDE的各种调试按钮,说实话确实挺方便的,但到了Linux下,没有那么多的IDE ...

  5. 在 Python 中使用 GDB 来调试 转载

    2013/11/01 | Comments 大约一年前,我接触了 Java 中的 Btrace 能够不停机查看线上 JVM 运行情况的特性让我艳羡不已. 另外还有强悍的 jStack 和 jConso ...

  6. 如何在mac os中安装gdb及为gdb进行代码签名

    1. 安装gdb GDB作为一个强大的c/c++调试工具,一直是程序猿们的良好伴侣,但转到Mac os才发现竟然没有默认安装,所幸还有强大的homebrew工具: brew install homeb ...

  7. mac下配置gdb调试golang

    mac下配置gdb调试golang 原文链接 https://sourceware.org/gdb/wiki/BuildingOnDarwin Building GDB for Darwin Crea ...

  8. mac上eclipse用gdb调试(转)

    mac上eclipse用gdb调试 With its new OS release, Apple has discontinued the use of GDB in OS X. Since 2005 ...

  9. GDB调试,转载一位大牛的东西

    http://www.wuzesheng.com/?p=1327 手把手教你玩转GDB(一)——牛刀小试:启动GDB开始调试 写在最前面:GDB是unix相关操作系统中C/C++程序开发必不可少的工具 ...

随机推荐

  1. JetBrains全家桶激活地址

    全家桶地址:https://www.jetbrains.com/products.html?fromMenu JetBrains 授权服务器(License Server URL):http://id ...

  2. 矩阵乘法np.dot()及np.multiply()以及*

    转载自 https://blog.csdn.net/u012609509/article/details/70230204 Python中的几种矩阵乘法 1. 同线性代数中矩阵乘法的定义: np.do ...

  3. 在MS Test中如何测试private方法

    前言: 在博客开始之前,我们先讨论一下是否应该对private方法做测试,通常有两种观点: private方法应该被测试: private方法不应该被测试: 我们以下面的代码为例子来进行说明: pub ...

  4. HRBUST1213 单词接龙 2017-03-06 15:53 67人阅读 评论(0) 收藏

    单词接龙  单词接龙是一个与我们经常玩的成语接龙相类似的游戏,现在我们已知一组单词,且给定一个开头的字母,要求出以这个字母开头的最长的"龙"(每个单词都最多在"龙&quo ...

  5. Zend_Controller_Front 研究

    如果你裸写php,一个项目就会出现很多的页面控制器(Page Controller),如果项目很大,重复代码就很多,越来越变得很难维护.有了问题,自然就有解决方案!于是前端设计模式  闪亮登场! 前端 ...

  6. 怎样运用servlet

    制作登陆界面 login.html <!DOCTYPE html> <html> <head> <title>login.html</title& ...

  7. Cacti部署

    1>监控概述   通常运维人员在一个企业当中所需要管理一台或者多台服务器,或者甚至更多,特别是BAT公司或者门户级别的公司,一个人管理的服务器可能上百甚至上千台                  ...

  8. [SAP]编辑表

    SAP中,不能直接修改表的内容,可以用SE16N进行调试打开编辑选项,进行修改. (注:直接修改数据有风险,首先要确认修改数据的关系或做好必要的备份) 1:运行SE16N ,填好表名,参数等. 2:在 ...

  9. lucene学习笔记(四)lucene分词详解

    分词器的核心类 Analyzer SimpleAnalyzer StopAnalyzer WhitespaceAnalyzer StandardAnalyzer TokenStream 分词器做好处理 ...

  10. [转发]RTH试用手记之“外场应用”

    年初,罗德与施瓦茨公司(Rohde & Schwarz)推出了第一款的手持示波器,从指标上看,该示波器打破了传统手持器功能简单.指标水平低.结构粗糙的印象,取而代之达到了主流台式数字示波器的性 ...