我有以下SMaL公司的C++程序GDB在Mac无法调试的 “Hello World” OS X
#include <stdio.h>
#include <stdlib.h>
int main(void) {
puts("!!!Hello World!!!");
return EXIT_SUCCESS;
}
我在Mac OS X Leopard的最后一个版本使用编译:
g++ -g hello.cpp -o hello.exe
是G ++:
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)
然后我尝试使用调试这个程序FSF-gdb的7.1:
fsf-gdb hello.exe
将断点在主:
(gdb) b main
Breakpoint 1 at 0x1f8f: file hello.cpp, line 5.
运行程序:
(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!!!");
,并尝试一步,出现这种情况:
(gdb) n
0x00003045 in ??()
这是输出,如果我在Ubuntu Linux下也是这样做的:
(gdb) n
!!!Hello World!!!
6 return EXIT_SUCCESS;
其中GDB = 7.1和g ++ = 4.3.4
什么问题????我真的不明白为什么这在mac os x中不起作用。
也许问题是mac中使用的gdb版本或mac中的gcc版本。 mac中有哪些其他替代方法可用于gdb?
在此先感谢
PS:苹果Leopard的GDB不会产生这个错误。但是我想使用Eclipse CDT,并且它不能与Apple的gdb一起工作,这就是为什么我想要使用非Apple gdb版本。
这不是C++。这就是C. – delnan 2011-03-08 15:44:20
现在修复 – flow 2011-03-08 15:55:48
为什么不直接使用随Xcode一起安装的Apple gcc和gdb? – 2011-03-08 16:37:58