jww
jww

Reputation: 102245

error: initial process state wasn't stopped: exited

I'm having a problem debugging a command line program on OS X. I've used this same source file with the same g++ command line hundreds of times to test things with the Crypto++ library.

Under GDB, I get the following after loading the 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).

Under LLDB, I get the following:

$ lldb ./cryptopp-test.exe
Current executable set to './cryptopp-test.exe' (x86_64).
(lldb) r
error: initial process state wasn't stopped: exited

I've recompiled the program a few times, and I can't get it to run under a debugger. I'm getting a segfault when trying to run outside the debugger too, so that may be a symptom here also.

OS X is 10.8.5, and Xcode is 5.1.1 (5B1008). Everything is fully patched. The only thing to change recently is signing up for a developer account, which is broken thanks to Apple's DRM crap. I can't seem to get any of it to work with Xcode or the command line even though Roots and Certificates are in my Keychain. But this program does not use code signing.

What is causing the initial process state wasn't stopped: exited error, and how do I fix it?

Upvotes: 1

Views: 520

Answers (1)

l'L'l
l'L'l

Reputation: 47169

The errors that you have received are usually a direct correlation of a codesigning issue, not with your executable, but with gdb and lldb themselves.

You have a couple of options:

  1. Launch gdb or lldb as sudo (which ignores the codesign req to run executables)
  2. Create a codesigning certificate for gdb or lldb in Keychain.app

Obviously the first option is quickest, but probably should be avoided as it opens up the possibility of bad things happening with elevated permissions.

With option #2 you can likely get gdb or lldb properly working by doing this:

  1. Launch /Applications/Utilities/Keychain Access.app

  2. Select the Keychain Access -> Certificate Assistant -> Create a Certificate...

  3. Choose a name for the new certificate (for example lldb-cert or gdb-cert)

  4. Set Identity Type to Self Signed Root

  5. Set Certificate Type to Code Signing

  6. Select the Let me override defaults option

  7. Continue until the "Specify a Location For The Certificate" screen appears

  8. Set Keychain to System and Continue

  9. In the view showing your certificates, double-click on the one just created and then set "When using this certificate" to "Always Trust"

In Terminal:

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

    • You might have to restart for this to effectively take hold.

There are more concise instructions here for gdb and here for lldb on the codesigning process.

Upvotes: 2

Related Questions