我在OS X上调试命令行程序时遇到问题。我已经使用相同的g ++命令行使用相同的源文件数百次来使用Crypto ++库进行测试。
在GDB下,我在加载EXE后得到以下内容:
$ gdb ./cryptopp-test.exe
...
(gdb) r
Starting program: /Users/jwalton/cryptopp-test.exe
Unable to find Mach task port for process-id 42811: (os/kern) failure (0x5).
在LLDB下,我得到以下内容:
$ lldb ./cryptopp-test.exe
Current executable set to './cryptopp-test.exe' (x86_64).
(lldb) r
error: initial process state wasn't stopped: exited
我已经重新编译了几次程序,但我无法在调试器下运行它。我试图在调试器外部运行时遇到段错误,所以这也可能是一个症状。
OS X为10.8.5,Xcode为5.1.1(5B1008)。一切都完全修补。最近唯一要改变的是注册一个开发者帐户,由于Apple的DRM废话,该帐户已经破产。即使Roots和Certificates在我的Keychain中,我似乎无法使用Xcode或命令行。但是这个程序不使用代码签名。
导致initial process state wasn't stopped: exited
错误的原因是什么,我该如何解决?
答案 0 :(得分:2)
您收到的错误通常与代码签名问题直接相关,而与您的可执行文件无关,但与gdb
和lldb
本身有关。
您有几个选择:
- 将gdb或lldb作为
sudo
启动(忽略了要运行可执行文件的codesign req)- 在Keychain.app
中为gdb或lldb创建代码签名证书 醇>
显然第一个选项是最快的,但可能应该避免,因为它开启了使用提升权限发生不良事件的可能性。
使用选项#2,您可以通过以下方式正常工作gdb
或lldb
:
启动/Applications/Utilities/Keychain Access.app
选择Keychain Access -> Certificate Assistant -> Create a Certificate...
选择新证书的名称(例如lldb-cert
或gdb-cert
)
将Identity Type
设为Self Signed Root
将Certificate Type
设为Code Signing
选择Let me override defaults
选项
Continue
直到出现“Specify a Location For The Certificate
”屏幕
将Keychain
设为System
并继续
在显示证书的视图中,双击刚刚创建的证书,然后将“When using this certificate
”设置为“Always Trust
”
在终点站:
codesign -f -s "gdb-cert" /path/to/gdb (or) "lldb-cert" /path/to/lldb
在代码签名过程中有更简洁的说明here for gdb和here for lldb。