Setting Breakpoint on exit() - Xcode 8.x

For some reason my app is exiting right after it shows the launch image. There's nothing in the console output and when I look at the device logs (I'm running on a real device) I see that the app just exits voluntarily...


<FBApplicationProcessExitContext: 0x17742a7a0; exitReason: voluntary; terminationReason: (none)>


I have several third party libraries that may be doing something they aren't supposed to (or I've just set them up incorrectly). Is there anyway to set a breakpoint on a call to exit() using xCode 8? That's my only guess as to what's happening here and I'm hoping to be able to track down which one might be doing it?

Replies

What platform, what kind of app? Note that Mac app store apps will exit immediately if they don't have a valid receipt.

Sorry, this is for iOS. I'm testing on an iPad.


Also, I just made another discovery by fluke. I decided to run it in the Profiler using Allocations. When I did that the app loaded up fine. I then shutdown the profiler and then just tapped the app on my iPad to run it without the debugger or any hook into xCode and the app worked there as well. Very very odd. Either there's some weird race condition going on or one of these libraries are being naughty.


However my question still stands. I'd like to be able to set a breakpoint on any call to the exit() function.

After the app ran standalone, did it then run when launched from Xcode? There are some cases where the device loses track of the fact that it has granted your app permission to debug it.


I don't there's an exit() function at all in iOS (many unix-y system functions are disabled), so I doubt that you can set a breakpoint. Still, you can try — add a "symbolic" breakpoint in Xcode, and enter "exit" for the symbol (leaving the library blank). Xcode will try to resolve the symbol, and if it succeeds, you should see your breakpoint get a disclosure triangle, that when expanded shows you the resolved symbol breakpoint.


But my guess is that iOS just terminates your app with a big hammer.


The other thing that's worth trying is create a new app from one of the iOS templates in Xcode, and try building and running. That should tell you whether the problem is all apps, or just your app. You can also try running your app on the simulator and see what happens.

Unfortunately no, it didn't run from xCode afterwards.


There is an exit(); function in iOS. exit(0); will just terminate the app with an error code of 0.


I tried putting in exit as a symbolic breakpoint and it looks like it's added it as [NSThread exit]. Unfortunately it didn't capture anything on the next run from xCode. Same result. I think you are right Quincey, iOS is just taking a hammer and shutting this app down. But according to the log it seems like the app shut down on it's on. ie. "voluntary" as mention in my original post. So perhaps iOS isn't killing it?


One thing that is very odd is that I'm getting an error during App Installation every now and then.. "App installation failed" "No code signature found."


However after doing a Project/Clean and then run again it works just fine. So I'm not sure if that is causing an issue or not. I have an odd setup and not one that I've created as I'm picking this project up from a departed developer. It involves some fairly intense encryption libraries that need some custom run scripts added into the build phases. My guess is that it's this library but we are struggling to figure out the cause even when talking to these guys. Fingers are still pointing at other libraries the project is using. Hence why I'm trying to figure out where this is occuring.


Welcome any further thoughts or suggestions. Thanks for all the comments so far.