title: How to print a usable stack trace in Cocoa app?
body: <p>I'm using <code>[NSThread callStackSymbols]</code> to log a stack trace when my app encounters an <code>NSError</code>, to help me troubleshoot and debug behavior my users see. It produces output like this:</p>
  
  <pre><code>(
      0   MyApp                               0x00000001067b02fc MyApp + 451324
      1   AppKit                              0x00007fff89e922c2 -[NSApplication finishLaunching] + 354
      2   AppKit                              0x00007fff89e91e05 -[NSApplication run] + 231
      3   AppKit                              0x00007fff89e14520 NSApplicationMain + 1176
      4   libdyld.dylib                       0x00007fff9bae25ad start + 1
  )
  </code></pre>
  
  <p>How do I print in that same log statement the address into which <code>MyApp</code> has been loaded, so I can manually symbolicate the stack frame (in this case, finding out what method resides at <code>451324</code>)?</p>
  
  <p>When looking at a crash report, for example, there is a section labeled "Binary Images" that lists the address of each binary. I'm looking for a way to get that for my own process, at runtime.</p>
  
  <p>I found <a href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Exceptions/Tasks/ControllingAppResponse.html#//apple_ref/doc/uid/20000473-DontLinkElementID_3" rel="nofollow">this Apple documentation page</a>, which shows how to symbolicate by shelling out to <code>atos</code>, but I'd prefer a Cocoa API call.</p>