title: How to get a line-numbered stack trace for a memory leak on Mac OS X?
body: <p>I've managed to get the Xcode <code>leaks</code> tool to report leaks in my command-line GCC Ada program (by adding <code>delay 11.0;</code> at the end to let <code>leaks</code> make its checks) and then</p>
  
  <pre><code>$ export MallocStackLogging=1
  $ (./foobar &amp;)  &amp;&amp; leaks foobar
  </code></pre>
  
  <p>which leads to (excerpted)</p>
  
  <pre><code>Process 52027: 18 nodes malloced for 2053 KB
  Process 52027: 2 leaks for 32 total leaked bytes.
  Leak: 0x1002000c0  size=16  zone: DefaultMallocZone_0x100175000 string '*'
          Call stack: [thread 0x7fff70bbcca0]: | start | main | _ada_foobar | __gnat_malloc | malloc | malloc_zone_malloc 
  Leak: 0x1002000d0  size=16  zone: DefaultMallocZone_0x100175000 string 'T'
          Call stack: [thread 0x7fff70bbcca0]: | start | main | _ada_foobar | __gnat_malloc | malloc | malloc_zone_malloc 
  </code></pre>
  
  <p>which is a great deal better than nothing, but would be considerably improved with line numbers.</p>
  
  <p>Are there any build options I should have used? Would it work better if the Ada compiler (FSF GCC 4.6.0, not from Apple) was integrated with Xcode?</p>
  
  <p>This is an x86_64 build on 10.6.7, Xcode 3.2.6. Using -g makes no difference.</p>
  
  <p>In the call stack, <code>main</code> is the <code>main()</code> generated by <code>gnatmake</code>, <code>_ada_foobar</code> is the Ada program in which the leak actually occurs. The other frames are from the run time system.</p>