92

While debugging is there anyway to see a complete stack trace, list of methods called in main thread. Or any way to print them on command window.

Popeye
  • 11,839
  • 9
  • 58
  • 91
NaXir
  • 2,373
  • 2
  • 24
  • 31
  • 1
    possible duplicate of [Objective C - getting line number or full stack trace from debugger error?](http://stackoverflow.com/questions/10501358/objective-c-getting-line-number-or-full-stack-trace-from-debugger-error) – Mike Weller Apr 11 '13 at 10:40
  • Programmatically, you can use callStackSymbols as Mihir describes. But of course you can also stop in Xcode, at a breakpoint (or just pressing "pause") and examine the stack in the left-hand column. (Always enable an exception breakpoint.) – Hot Licks Apr 11 '13 at 10:47
  • 1
    (+1 for realizing that examining the stack is important. Far too few folks starting out on Xcode appreciate this.) – Hot Licks Apr 11 '13 at 10:49
  • I am doing same, but in stack trace I can see just 5 or 6 method calls and after that on 25 its UIApplicationMain and on 26 its main. I can't see the methods between 6 and 25. I want to see complete stack trace. – NaXir Apr 11 '13 at 11:00
  • 1
    I got it via nslog. thanks guys – NaXir Apr 11 '13 at 11:05

5 Answers5

164

Use the bt command in (lldb).

Once paused or after a crash, just type bt into the debug console.
It will print the full stack trace.

sample output of bt command

Pang
  • 9,564
  • 146
  • 81
  • 122
Alex Iceman
  • 1,679
  • 1
  • 11
  • 6
88

You can print the stack trace in the NSLog by

NSLog(@"Stack trace : %@",[NSThread callStackSymbols]);

Upon a crash, next to the word (lldb), you can type:

po [NSThread callStackSymbols]

Edit:

For better output on console on Swift you can use following line instead:

Thread.callStackSymbols.forEach{print($0)}
jvarela
  • 3,744
  • 1
  • 22
  • 43
Mihir Mehta
  • 13,743
  • 3
  • 64
  • 88
72

In Xcode 6 you can click the button at the bottom left corner of the pane which shows the full stack trace. Xcode 6 show full stack trace

Gong Pengjun
  • 971
  • 7
  • 14
17

In Xcode 5 you can move the slider at the bottom of the pane which shows the stack trace. It controls how much of the struck trace is shown.

Slider controlling the stack trace

4

You can add breakpoint before exception is thrown. First go to Breakpoint Navigator (cmd + 6). In the bottom left corner mouse click plus button. OR You can use Instruments (/Developer/Applications/Instruments) to help detect usage of zombie objects. Reference

And When you add breakpoint review the picture will create by Xcode.

enter image description here

You can expand the stack trace using the slider at bottom use step over and over for line by line logs.

thanks hope this will help you

Buntylm
  • 7,345
  • 1
  • 31
  • 51