title: gdb can not debug "hello world" in mac os x
body: <p>I have the following smal C++ program</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main(void) {
      puts("!!!Hello World!!!");
      return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>I compile in Mac OS X Leopard last release using:</p>
  
  <pre><code>g++ -g hello.cpp -o hello.exe
  </code></pre>
  
  <p>being g++:</p>
  
  <pre><code>host:bin macbook$ g++ --ver
  Using built-in specs.
  Target: i686-apple-darwin9
  Configured with: /var/tmp/gcc/gcc-5493~1/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib --build=i686-apple-darwin9 --with-arch=apple --with-tune=generic --host=i686-apple-darwin9 --target=i686-apple-darwin9
  Thread model: posix
  gcc version 4.0.1 (Apple Inc. build 5493)
  </code></pre>
  
  <p>then I try to debug this program using fsf-gdb 7.1:</p>
  
  <pre><code>fsf-gdb hello.exe
  </code></pre>
  
  <p>put a breakpoint in main:</p>
  
  <pre><code>(gdb) b main
  Breakpoint 1 at 0x1f8f: file hello.cpp, line 5.
  </code></pre>
  
  <p>run the program:</p>
  
  <pre><code>(gdb) r
  Starting program: /Users/horacio/work/software/gdb/gdb-7.2-inst/bin/hello.exe 
  
  Breakpoint 1, main () at hello.cpp:5
  5       puts("!!!Hello World!!!");
  </code></pre>
  
  <p>and try to step, and this happens:</p>
  
  <pre><code>(gdb) n
  0x00003045 in ?? ()
  </code></pre>
  
  <p>This is the output if I do the same under Ubuntu Linux:</p>
  
  <pre><code>(gdb) n
  !!!Hello World!!!
  6       return EXIT_SUCCESS;
  </code></pre>
  
  <p>where gdb=7.1 and g++=4.3.4</p>
  
  <p>What is the problem ???? I honestly do not understand why this does not work in mac os x.</p>
  
  <p>Maybe the problem is the gdb version used in mac or the gcc version in mac. Which other alternatives exist for gdb in mac? </p>
  
  <p>Thanks in advance</p>
  
  <p>PS: Apple Leopard's gdb does not produce this error. But I want to use Eclipse CDT, and it can not work with Apple's gdb, that is why I am trying to use a non-Apple gdb version. </p>