mac下配置gdb调试golang

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为新的路径即可

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

时间: 2024-09-30 18:32:46

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

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

DEV C++和CodeBlock都只是一个IDE,不能编译调试,需要自己配置MINGW和gdb调试 1.MINGW 在这下载mingw-get-setup.exe安装即可. https://sourceforge.net/projects/mingw/files/MinGW/ 配置MINGW很简单,安装包就好了,可以只安装gcc和g++的. 选中前面的方块,然后installation->ApplyChanges即可.这个安装过程...很慢,也可能是我的网不好,他慢慢的安装了快一个小时. 2.

mac 下真机调试 android 手机

第一步: 查看usb设备信息 在 终端输入:system_profiler SPUSBDataType     可以查看连接的usb设备的信息 比如我的usb信息如下(部分内容): Spreadtrum phone: Product ID: 0x5d04 Vendor ID: 0x1782 Version:  2.29 Serial Number: 19761202 Speed: Up to 480 Mb/sec Manufacturer: Spreadtrum Location ID: 0xf

zend server mac 下配置

Post Installation on Mac OS X If you intend to use PHP and other tools provided by Zend Server (pear and pecl) from the command line (PHP CLI), it is recommended that you add the <install_path>/bin directory to your $PATH environment variable. This

mac下配置cocos2d-x3.0

今天看到3.0的正式版公布了,就马上荡下来试试3.0,以下记录下环境变量配置过程 打开用户文件夹下.bash_profile文件,配置环境 1.首先配置下android sdk,我的是在opt文件夹下 #sdk export ANDROID_SDK_ROOT=/opt/android-sdk-macosx export PATH=$PATH:$ANDROID_SDK_ROOT export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools 2.ndk #nd

Mac下配置Apache,PHP

注:如果觉得终端下编辑太麻烦,也可以直接将文件拖出来手动编辑后在放回原文件夹替换即可 1.启用Apache: 在Mac下打开终端,输入“sudo apachectl start”(不包含引号,下同) 回车后输入自己的电脑密码即可启动Apache 2.检测Apache: 在终端中输入“sudo apachectl -v”,即可看到Apache的版本号 或在浏览器中输入“localhost”可以看到“It Works!”字样 这是检测Apache是否成功启用的两种方法 3.启用PHP: 一.修改ht

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

/private/etc/apache2/httpd.conf 一.启动Apache sudo apachectl start sudo apachectl -v   可以查看到Apache的版本信息 此时在浏览器中输入http://localhost,会出现It works!的页面 sudo apachectl restart 重启Apache 二.运行PHP 1.找到Apache的配置文件,在目录/etc/apache2/下,打开Finder,选择"前往"-"前往文件夹&

[Linux]在Mac下配置Linux服务器并安装Nginx+PHP

Linux 安装Debian系统 我安装的是Debian7.5的系统,Debian的软件包管理和升级十分方便,而且系统也很稳定.安装盘可以去华中科技大学镜像.网易开源镜像站或者中国科技大学镜像下载,和官网一样,一般下载的时候会提供DVD-1.DVD-2和DVD-3的下载,后面二者均是一些不太流行的软件,只需要下载安装DVD-1即可. 修改sources.list 装好系统之后的第一件事情就是修改Debian的源,因为默认的配置会访问镜像介质,修改源可以直接联网通过apt-get获取并安装软件包,

mac下配置openfire

下载 在浏览器中打开如下网址http://www.igniterealtime.org/downloads/index.jsp,根据你的操作系统选择对应的版本进行下载,这里我是在mac下配置的,所以选择Mac版本的安装包,下载完成后在Finder中找到下载好的openfire_3_8_2.dmg文件. 安装 双击下载完的openfire_3_8_2.dmg文件,然后验证过后,双击如下的pkg程序包: 启动服务 在系统偏好设置中找到openfire的服务,如下图所示: 点击Openfire,启动服

mac下配置Node.js开发环境、express安装、创建项目

mac下配置Node.js开发环境.express安装.创建项目 一.node.js的安装 去官网下载对应的平台版本就可以了,https://nodejs.org 二.express安装 sudo npm install -g express 进行全局安装. 这时有可能会安装不成功,用下面的命令即可 sudo npm install express-generator -g 三.创建项目 终端输入 express -e 你的项目名称 -e 为使用ejs框架 express默认为jade,为了 学