错误:初始进程状态未停止:退出

时间:2015-02-16 05:36:57

标签: c++ macos osx-mountain-lion lldb

我在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错误的原因是什么,我该如何解决?

1 个答案:

答案 0 :(得分:2)

您收到的错误通常与代码签名问题直接相关,而与您的可执行文件无关,但与gdblldb本身有关。

您有几个选择:

  
      
  1. 将gdb或lldb作为sudo启动(忽略了要运行可执行文件的codesign req)
  2.   
  3. 在Keychain.app
  4. 中为gdb或lldb创建代码签名证书   

显然第一个选项是最快的,但可能应该避免,因为它开启了使用提升权限发生不良事件的可能性。

使用选项#2,您可以通过以下方式正常工作gdblldb

  1. 启动/Applications/Utilities/Keychain Access.app

  2. 选择Keychain Access -> Certificate Assistant -> Create a Certificate...

  3. 选择新证书的名称(例如lldb-certgdb-cert

  4. Identity Type设为Self Signed Root

  5. Certificate Type设为Code Signing

  6. 选择Let me override defaults选项

  7. Continue直到出现“Specify a Location For The Certificate”屏幕

  8. Keychain设为System并继续

  9. 在显示证书的视图中,双击刚刚创建的证书,然后将“When using this certificate”设置为“Always Trust

  10. 在终点站:

    1. codesign -f -s "gdb-cert" /path/to/gdb (or) "lldb-cert" /path/to/lldb

      • 您可能需要重新启动才能有效占用。
    2. 在代码签名过程中有更简洁的说明here for gdbhere for lldb