$ file app
app: Mach-O universal binary with 2 architectures
app (for architecture i386): Mach-O executable i386
app (for architecture x86_64): Mach-O 64-bit executable x86_64
$ gdb app
GNU gdb (GDB) 7.6
Copyright (C) 2013 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-darwin13.0.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
"app": not in executable format: File format not recognized
$ file test
test: Mach-O 64-bit executable x86_64
$ gdb test
GNU gdb (GDB) 7.6
Copyright (C) 2013 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-darwin13.0.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /Users/dmulder/test...Reading symbols from /Users/dmulder/test.dSYM/Contents/Resources/DWARF/test...done.
done.
Run Code Online (Sandbox Code Playgroud)
为什么64位二进制文件会成功,但64 + 32二进制文件会失败?
los*_*ebo 15
不幸的是,非Apple版本的GNU gdb目前无法调试通用(或"胖")二进制文件(包含32位和64位可执行文件的二进制文件).
一种选择是用于lipo提取单个体系结构并在其上运行gdb:
lipo -thin x86_64 -output app-x86_64 ./app
Run Code Online (Sandbox Code Playgroud)
要么
lipo -thin i386 -output app-i386 ./app
Run Code Online (Sandbox Code Playgroud)
如果您更喜欢调试组合的可执行文件,可以尝试使用LLDB或Apple版本的gdb.
正如OP评论的那样,使用苹果的gdb将解决这个问题。
以下是在 OS 10.9 上从源代码构建 Apple gdb 6.3.50.20050815-cvs 的说明:
注意:您需要安装 Xcode 并设置构建环境。如果您安装了Homebrew,请运行brew doctor以查看是否“您的系统已准备好进行酿造”。
从以下位置下载 gdb-1822 源 tarball:http://opensource.apple.com/tarballs/gdb/gdb-1822.tar.gz
将其提取到临时目录中。打开终端并cd进入gdb-1822/src.
运行configure脚本:
./configure --prefix="$HOME/.local/stow/gdb-1822" --disable-debug --disable-dependency-tracking --with-system-readline
(最后三个配置参数来自 homebrew-dupes 公式:https://github.com/Homebrew/homebrew-dupes/blob/master/gdb.rb)
运行使:
制作 进行安装
按照https://sourceware.org/gdb/wiki/BuildingOnDarwin#Creating_a_certificate中的说明创建 gdb-cert 代码签名证书。
cd进入$HOME/.local/stow/gdb-1822/bin并签署gdb可执行文件:
codesign -s gdb-cert gdb
cd进入$HOME/.local/stow并存放文件gdb-1822夹:
存放gdb-1822
添加$HOME/.local/bin到您的PATH并重新启动终端或清除 Bash 的缓存到以下位置gdb:
哈希-d gdb
| 归档时间: |
|
| 查看次数: |
8833 次 |
| 最近记录: |