mac下配置gdb调试golang

原文链接
https://sourceware.org/gdb/wiki/BuildingOnDarwin

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.

You also need to be in the Unix group _developer.

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 Continueuntil 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).

xcode自带的gdb是6,golang需要的gdb是7,因此,homebrew之

brew install https://raw.github.com/Homebrew/homebrew-dupes/master/gdb.rb

添加证书

钥匙串访问,证书助理,选第二个,证书助理,创建证书,名字为gdb-cert,勾选覆盖默认值,有效期可以改的长一点,一步步下去,注意一定要选择代码签名,安装一定要到系统里面。

配置证书,全部改成信任模式,和goagent的配置方式一样

签名

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

liteide里面配置gdb为新的路径即可

调试的时候提示输入密码,貌似输入一次以后,只要不重启,永久有效,不错

mac下配置gdb调试golang的更多相关文章

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

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

  2. 为DEV C++/CodeBlock配置gdb调试遇到的问题

    DEV C++和CodeBlock都只是一个IDE,不能编译调试,需要自己配置MINGW和gdb调试 1.MINGW 在这下载mingw-get-setup.exe安装即可. https://sour ...

  3. 在Mac下配置php开发环境:Apache+php+MySql

    /private/etc/apache2/httpd.conf 一.启动Apache sudo apachectl start sudo apachectl -v   可以查看到Apache的版本信息 ...

  4. iOS开发MAC下配置svn

    版本控制对于团队合作显得尤为重要,那么如何在iOS开发中进行版本控制呢?在今天的博客中将会介绍如何在MAC下配置SVN服务器,如何导入我们的工程,如何在Xcode中进行工程的checkOut和Comm ...

  5. mac下配置openfire

    下载 在浏览器中打开如下网址http://www.igniterealtime.org/downloads/index.jsp,根据你的操作系统选择对应的版本进行下载,这里我是在mac下配置的,所以选 ...

  6. Mac下配置idk

    Mac下配置java #以下进入啰嗦模式演示添加jdk7 #下载jdk7的mac版 #官网下载地址http://www.oracle.com/technetwork/java/javase/downl ...

  7. CAS (1) —— Mac下配置CAS到Tomcat(服务端)(转)

    tomcat版本: tomcat-8.0.29 jdk版本: jdk1.8.0_65 cas版本: cas4.1.2cas-client-3.4.1 参考来源: CAS实现单点登录(SSO)经典完整教 ...

  8. Mac下配置Maven环境变量

    Mac下配置Maven环境变量 1.先到Apache官网下载maven压缩包.下载地址:http://maven.apache.org/download.cgi 2.Maven是用Java开发的,所以 ...

  9. 如何在Mac下配置Github和Bitbucket的SSH

    --- title: 如何在Mac下配置Github和Bitbucket的SSH date: 2017-12-23 21:10:30 tags: - Mac - Git - Github catego ...

随机推荐

  1. DB2使用存储过程插入数据

    要求:插入一张表(TESTMV)中三个字段(ID, GROUPID[组id], USERID[用户id]),为了产生多个组,每个组多个人的数据,进行统计每个组多少人数据用 代码如下: delete t ...

  2. python手记(11)

    <form method="POST" action="http://host.com/cgi-bin/test.py"> <p>You ...

  3. Hybrid App(一)App开发选型

    1.几种app开发模式概述 Native App 即传统的原生APP开发模式,Android基于Java语言,底层调用Google的 API;iOS基于OC或者Swift语言,底层调用App官方提供的 ...

  4. Node.js(初识)

    之前有了解过一点Node.js,只是一直停留在文字描述,没有真正使用过Node.js,如今因为工作的原因,开始真正接触到Node.js,也开始深入学习. Node.js具体是用来做什么的,我想一开始接 ...

  5. 【NOIP2013】Day2不完全题解+代码

    T1 直接递归区间,从1-n开始,找到这个区间中的最小值然后将区间里的所有值都减去这个最小值 以被减去最小值之后的零点为分段分别递归处理即可. #include <algorithm> # ...

  6. Linux 复习重点目录

    Linux安全复习 一.Linux基本命令 1.文件管理命令 lvm 2.用户管理命令 3.网络管理命令 4.权限管理 普通权限和特殊权限 权限命令修改 5.服务命令 6.软件安装管理命令 yum安装 ...

  7. IPython与notebook 安装

    基于 python2.7.13 32-bit版本安装 1.安装pyreadline https://pypi.python.org/pypi/pyreadline 下载对应的32位版本 2.用pip安 ...

  8. 【IE6的疯狂之八】链接伪类(:hover)CSS背景图片有闪动BUG

    IE6下链接伪类(:hover)CSS背景图片有闪动BUG,主要原因ie会再一次请求这张图片,或者说图片没被缓存. 例如: CSS代码 a:hover{background:url(imagepath ...

  9. Linux 操作命令列表记录

    Linux 操作命令列表记录 SSH登录 登录 ## 范式 ssh [username]@[host] ## 例 ssh -p 1222 root@10.0.0.1 使用非默认端口(ssh默认端口22 ...

  10. R语言数据结构

    5. 数据结构 5.1 数据结构简介 (1)向量 一个向量的所有元素必须有相同的类型(模式) (2)列表 列表可以非同质的 列表可按位置索引:lst[[2]] 抽取子列表:lst[c(2,5)] 列表 ...