4

I am using XCode 4.2 on MacOS Lion. When debugging an iPhone/iPad app in Simulator, I am using "Stop" button on XCode toolbar (Product | Stop) to exit the app. Very often after this, XCode opens main.m file, puts the execution pointer on UIApplicationMain call and says "Program received SIGKILL". In about a second after that it breaks off debug mode, so I can not debug this error. My app involves lots of threads, so, my guess is it can be related to resources being pulled out when threads are still working, or something like that. This may even be normal, and I do not care very much about this problem, because the app is being terminated anyway. But seeing this SIGKILL after every debug is really annoying. How can I debug it? Alternatively, is there a way to disable it?

EDIT: there's nothing in the console except the usual activity log (no crash details like with regular exceptions).

Nick Frolov
  • 1,835
  • 18
  • 14
  • 1
    Debugger kills the app by sending it SIGKILL. That's how you end processes in Unix. What is the problem? – hamstergene Oct 26 '11 at 10:11
  • The problem is: XCode shows this SIGKILL in debugger, in a same way it would show a breakpoint, then quits debugger after a second. – Nick Frolov Oct 26 '11 at 10:13
  • 4
    It _is_ annoying if it switches the code window in Xcode to the main.m, away from whatever you were looking at. – jrturton Oct 26 '11 at 10:14

5 Answers5

7

SIGKILL is what you are sending to the process when you stop the debugger. There isn't anything wrong, but sometimes it does show up and switch you to the main.m file which is useless and annoying.

To get around it, don't bother stopping the executable from Xcode. Just leave it running, and when you want to run again, just re-launch with the "Play" button and the previous task will be terminated anyway.

jrturton
  • 118,105
  • 32
  • 252
  • 268
  • 1
    So what you saying this is basically the same thing as http://stackoverflow.com/questions/6703185/getting-exception-sigkill-when-relaunching-app , and both of them are just the XCode way to handle things. Well I don't like it, but it seems to be correct. Thanks. – Nick Frolov Oct 26 '11 at 11:29
  • I don't like it either. I think it is a mistake to interpret the SIGKILL as something that needs highlighting in the debugger. – jrturton Oct 26 '11 at 11:33
1

It seems to me that jrturton's solution doesn't really get around the problem. I'm specifically stopping the app so I can test saving data using NSUserDefaults.

My suggestion is to hit STOP right after running so that the debugger is no longer monitoring the app. Then you are free to close the app and reopen it as you wish. Doing this I was able to check that NSUserDefaults were being saved correctly without having to step through the debugger every time I killed and reopened the app.

Kyle Clegg
  • 38,547
  • 26
  • 130
  • 141
0

To prevent Xcode 4 from shortly halting and switching to the main.m, you can turn off debug mode(?) by clicking the Breakpoints button before pressing the Stop button.

Sebastian
  • 2,109
  • 1
  • 20
  • 15
0

If you prefer to stop your app while editing code, you can try my answer given here:

Xcode 4.2 jumps to main.m every time after stopping simulator

Community
  • 1
  • 1
0

If you use a trackpad, one workaround is to "swipe left" in the editor area. This will move main.c away, and open the previously edited file.

michaelmichael
  • 13,755
  • 7
  • 54
  • 60
Bart van Kuik
  • 4,704
  • 1
  • 33
  • 57