Reputation: 102245
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
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:
- Launch gdb or lldb as
sudo
(which ignores the codesign req to run executables)- 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:
Launch /Applications/Utilities/Keychain Access.app
Select the Keychain Access -> Certificate Assistant -> Create a Certificate...
Choose a name for the new certificate (for example lldb-cert
or gdb-cert
)
Set Identity Type
to Self Signed Root
Set Certificate Type
to Code Signing
Select the Let me override defaults
option
Continue
until the "Specify a Location For The Certificate
" screen appears
Set Keychain
to System
and Continue
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:
codesign -f -s "gdb-cert" /path/to/gdb (or) "lldb-cert" /path/to/lldb
There are more concise instructions here for gdb and here for lldb on the codesigning process.
Upvotes: 2