0

I would like to free all running threads at some point to get callstack from UI Thread. Is there a method call for this?

Thank you

ilker Acar
  • 401
  • 1
  • 5
  • 11

1 Answers1

0

If I'm not mistaken, you could just set a breakpoint somewhere in the code and the threads will be paused. In console, you could do: po [NSThread callStackSymbols] to print a stack trace on the current thread.

ninjaneer
  • 6,951
  • 8
  • 60
  • 104
  • How do you get call stack of main thread from background thread? In my situation, when UI thread is frozen, I want to get a call stack from main thread. – ilker Acar Jul 23 '12 at 23:54
  • When your app hits a breakpoint, in Xcode's debug navigator (5th button on the top left under "Scheme"), select which thread you would like to work on and print out the callStackSymbols again in console. – ninjaneer Jul 23 '12 at 23:57
  • Actually, I want to do this programmatically. – ilker Acar Jul 24 '12 at 00:00
  • [NSThread callStackSymbols] will print out the call stack from whatever thread is calling it. So have each thread call that message. – ninjaneer Jul 24 '12 at 00:06
  • The problem is that, If UI thread is blocked for some reason, I won't be able to get what's causing the hang since [NSThread callStackSymbols] must be called on the UI thread. Once UI thread is released (finishes its long running task) I won't be able to catch the call stack that caused the hang. Therefore, I need to query this info from another thread however unfortunately, this is not supported i think in iOS – ilker Acar Jul 24 '12 at 00:09
  • This sounds like a perfect job for System Trace in Instruments. While I haven't used it much myself, the System Trace monitors all threads during the lifetime of the app and you should be able to see what methods are blocking the thread. – ninjaneer Jul 24 '12 at 17:45