c-gdb用于macOS上的Python



我想使用gdb来调试我编写的C扩展。

我按照这里的所有步骤对gdb的brew install gdb版本进行了代码签名:https://sourceware.org/gdb/wiki/PermissionsDarwin

然而,security dump-trust-settings -d显示

SecTrustSettingsCopyCertificates: No Trust Settings were found.

即使我选择了";始终信任";用于在Keychain Access中进行代码签名。不管怎样,我继续按照指示进行。

gdb仍然有和我第一次尝试时相同的错误:

% gdb -ex r --args zsh python crash.py
GNU gdb (GDB) 10.1
Copyright (C) 2020 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-darwin20.2.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
"0x7ffee8d454b0s": not in executable format: file format not recognized
Starting program:  python crash.py
No executable file specified.
Use the "file" or "exec-file" command.
(gdb) 

gdb对Mac OS X上所谓的"fat"二进制文件的支持在近十年的时间里一直是断断续续的(目前已经中断了两年多(。您需要使用苹果Xcode命令行工具中的lipo实用程序,只提取您感兴趣的架构,例如

lipo -thin x86_64 -output ls-x86_64 /bin/ls

之后,您应该能够对其进行gdb,例如

▶gdb/ls-x86_64GNU gdb(gdb(10.1版权所有(C(2020自由软件基金会,股份有限公司。[…]正在从中读取符号/ls-x86_64。。。(在./ls-x86_64中找不到调试符号((gdb(在shell关闭的情况下设置启动(gdb(运行gdb-authority.xml[劣1(过程7566(正常退出](gdb(

在撰写本文时,您需要构建并使用修补版本。

最新更新