2

我试图编译一个 7.x 版本的 gdb 没有任何运气。我对可执行文件进行了代码签名(http://sourceware.org/gdb/wiki/BuildingOnDarwin)。

以下版本存在这些问题。

7.5、7.4、git clone:启动 gbd 时我的应用程序和不同系统库的未知加载命令 0x2a(和其他)。例如,当尝试打印矢量时,我总是得到:找不到“main(int,char**)”的框架基础

7.3(macports 和来自 gdb-website):在启动应用程序时,它无法设置断点并继续运行。

(gdb) start
Temporary breakpoint 1 at 0x100000950: file ../src/main.cpp, line 15.
Starting program: [...]
BFD: unable to read unknown load command 0x24
BFD: unable to read unknown load command 0x2a
BFD: unable to read unknown load command 0x26
Error in re-setting breakpoint 1: Cannot access memory at address 0x100000950
[application continues]

我使用系统llvm-gcc、gcc4.7和svn-gcc4.8编译。有人在 Mountain Lion 上成功安装了 gdb 吗?

4

4 回答 4

11

我在山狮上安装了 gdb 7.5 没有问题...

  1. 这些步骤可能会对您有所帮助:./configure --prefix=/usr/local --enable-targets=x86_64-apple-darwin10 --enable-64-bit-bfd --disable-werror --build=x86_64-apple- darwin10 --host=x86_64-apple-darwin10 --target=x86_64-apple-darwin10

  2. 然后安装 gdb。

  3. 创建您自己的证书,如此处所述并签署 gdb http://sourceware.org/gdb/wiki/BuildingOnDarwin

  4. 在签署 gdb 之前,您必须明确声明: codesign -s gdb-cert /usr/local/gdb 确保您已将证书设置为受信任。在签署 gdb 之前还要关闭钥匙串。

希望这也适用于你

于 2012-09-11T14:28:43.307 回答
5

我按照此处尝试的步骤解决了这个问题:http: //coding.derkeiler.com/Archive/Ada/comp.lang.ada/2012-09/msg00305.html

脚步

  1. sudo chgrp procmod /usr/local/bin/gdb
  2. sudo chmod g+s /usr/local/bin/gdb
  3. 编辑 /System/Library/LaunchDaemons/com.apple.taskgated.plist 并将 +p 参数添加到 taskgated 进程
  4. 强制终止任务门控进程(它将重新启动)
  5. 再试一次

其他链接:

  1. https://blogs.oracle.com/dns/entry/understanding_the_authorization_framework_on
于 2012-12-01T01:07:08.233 回答
2

OP的问题有两个问题。关于签署可执行文件或修改 taskgated 和使用 setgid procmod 的内容已涵盖。第二个问题是关于未知加载命令的警告。我也遇到了这个问题,经过大量搜索后发现了以下补丁,修复了它:

https://gist.github.com/davidbalbert/4197567

于 2013-02-05T17:45:10.507 回答
2

它似乎对我不起作用......与默认自制设置相同的问题

v1:src zeph$ brew install gdb
==> Downloading http://ftpmirror.gnu.org/gdb/gdb-7.5.tar.bz2
Already downloaded: /Library/Caches/Homebrew/gdb-7.5.tar.bz2
==> ./configure --prefix=/usr/local/Cellar/gdb/7.5 --with-python=/usr --with-system-readline --enable-targets=x86_64-apple-darwin10 --enable-64-bit-bfd --disable-werror --build=x86_64-apple-darwin10 --hos
==> make
==> make install
==> Caveats
gdb requires special privileges to access Mach ports.
You will need to codesign the binary. For instructions, see:

  http://sourceware.org/gdb/wiki/BuildingOnDarwin
==> Summary
/usr/local/Cellar/gdb/7.5: 62 files, 9.3M, built in 119 seconds
v1:src zeph$ codesign -s gdb-cert /usr/local/Cellar/gdb/7.5/bin/gdb 
v1:src zeph$ /usr/local/Cellar/gdb/7.5/bin/gdb --args /Users/zeph/tmp/CouchBase/src/install/bin/memcached -d -u root -P /tmp/0libmemcached_memc.pid -t 1 -p 11221 -U 11221 -m 128
GNU gdb (GDB) 7.5
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin10".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
BFD: /Users/zeph/tmp/CouchBase/src/install/bin/memcached: unknown load command 0x29
BFD: /Users/zeph/tmp/CouchBase/src/install/bin/memcached: unknown load command 0x29
Reading symbols from /Users/zeph/tmp/CouchBase/src/install/bin/memcached...done.
(gdb) run
Starting program: /Users/zeph/tmp/CouchBase/src/install/bin/memcached -d -u root -P /tmp/0libmemcached_memc.pid -t 1 -p 11221 -U 11221 -m 128
Unable to find Mach task port for process-id 28755: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))
(gdb) 

k,我必须在全面信任证书后重新签名

codesign -fs gdb-cert /usr/local/Cellar/gdb/7.5/bin/gdb

于 2012-11-15T18:05:13.397 回答