Hands-off triggering of Xcode 'Pause'?

I have an app that sometimes hangs when the left mouse button is pressed, and resumes when the button is released. The code base is large with complex input handling, and I have no idea where the hang is coming from.

I'm in desperate need of a stack trace and a way to inspect state when this happens, but I can't find a way to suspend the app like this. How can I trigger a Pause operation in the debugger without releasing the mouse or changing app focus? The Metal debugger has a feature to 'Capture in X seconds' - is there something similar for general debugging?

I have an app that sometimes hangs when the left mouse button is pressed

This is on the Mac, right?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

To expand on this, it's a local Mac application running from Xcode. So, the question is really about how to trigger a pause in the debugger without disturbing the application state.

On the Mac you can do this:

  1. Run your app from Xcode

  2. In Terminal, run this command:

    % sleep 5 ; kill -STOP PPP
    

    where PPP is the process ID of your app.

  3. Now get the app into the state that’s causing the problem.

After 5 seconds Terminal will send a SIGSTOP to your app and that’ll get you into the debugger.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Hands-off triggering of Xcode 'Pause'?
 
 
Q