How can I display all threads for my program when debugging in Xcode

How can I display all threads for my program when debugging in Xcode? I use eclipse to debug java, it can display all current threads in the program and I can pause each of them and show their current stack trace. Can I do the same in Xcode?

Thanks.

+5
source share
3 answers

You can see stack traces for each active thread in the debugger view. (Movable> Debugger). In the upper left pane, you can see the stack trace for the current thread. It should say something like "Thread-1" at the top, click on it, and you can select any of the other threads and view their individual stack traces.

+4
source

After starting the application, the debug area automatically opens. If this is not the case, most likely because the visibility of the debug area is disabled. To turn it on. Switch the first control in the upper right of the xcode window, and the debug area appears.

enter image description here

Once you do this, an area similar to the one shown in the image below will appear. enter image description here

Click the show debug navigator button, which is the third last in the show debug navigator controls. There are two buttons in the line immediately after the name of your project, click the second

enter image description here

and select the stream view process. enter image description here

For threads to appear, your application must be paused. This can be done by adding a breakpoint to a specific point in the code or manually by clicking the pause button on the debug panel under the original editor. After a pause, streams appear automatically, as shown below. enter image description here

+3
source

You can use the bt command to find the stream number and other useful information (backstack)

 bt 

The output looks like

 * thread #1: tid = 0x3cccc1, 0x00003076 MyStuff'-[BNRMasterViewController viewDidLoad](self=0x08988fa0, _cmd=0x009bad27) + 102 at BNRMasterViewController.m:35, queue = 'com.apple.main-thread, stop reason = breakpoint 1.1 frame #0: 0x00003076 MyStuff'-[BNRMasterViewController viewDidLoad](self=0x08988fa0, _cmd=0x009bad27) + 102 at BNRMasterViewController.m:35 frame #1: 0x003409a8 UIKit'-[UIViewController loadViewIfRequired] + 696 frame #2: 0x00340c44 UIKit'-[UIViewController view] + 35 frame #3: 0x0036b339 UIKit'-[UINavigationController rotatingSnapshotViewForWindow:] + 52 frame #4: 0x00694910 UIKit'-[UIClientRotationContext initWithClient:toOrientation:duration:andWindow:] + 420 frame #5: 0x00270ea2 UIKit'-[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 1495 frame #6: 0x002708c6 UIKit'-[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 82 frame #7: 0x00270798 UIKit'-[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 117 frame #8: 0x00270820 UIKit'-[UIWindow _setRotatableViewOrientation:duration:force:] + 67 frame #9: 0x0026f8ba UIKit'__57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 120 

You can also print information about the current topic using

Objective-C Command:

 po [NSThread currentThread] 

Swift team:

 po Thread.currentThread 

Please read more here

+1
source

All Articles