本文介绍了gcc 4.7.3和gdb 7.6在Mac - 奇怪的步进问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近通过MacPorts在我的OS X 10.7系统上安装了 GCC 4.7.3 GDB 7.6 ,可以编译C ++ 11代码。我不能使用苹果的自制铛++和gdb因为它不会让我正确(如果我取消引用列表迭代器,程序崩溃为例)调试标准模板库中的代码。

I recently installed GCC 4.7.3 and GDB 7.6 on my OS X 10.7 system via MacPorts to be able to compile C++11 code. I cannot use Apple's selfmade clang++ and gdb since it doesn't allow me to debug standard template library code properly (for example, if I dereference a list iterator, the program crashes).

现在,使用新的GCC / GDB组合,我有一些奇怪的问题,步入函数。以这个最小示例:

Now, with the new GCC / GDB combination I have some weird problems with stepping into functions. Take this minimal example:

#include <stdio.h>

class A {
public:
    virtual void testMethod() {
        printf("test in A\n");
    }
};

void test(A &a) {
    printf("asdf\n");
    a.testMethod(); // here, stepping works with -std=c++11
}

int main() {
    A a;
    a.testMethod();
    test(a);
    a.testMethod();
    return 0;
}



如果我使用 g ++ -O0编译代码, ggdb test.cpp ,GDB不会进入 A :: testMethod 。我可以,而不是通过指定的方法名( B A :: TestMethod的指定内部 A :: TestMethod的代码行设置一个断点() )。

If I compile the code with g++ -O0 -ggdb test.cpp, GDB does not step into A::testMethod at all. I can set a breakpoint by specifying the code line inside A::testMethod, but not by specifying the method name (b A::testMethod()).

更奇怪的是,如果我编译 G ++ -O0 -ggdb -std = C ++ 11的测试.cpp ,如果从 void test()调用,GDB将进入testMethod。从主,步进仍然不工作。然而,现在,我可以通过只指定方法名来设置断点。

More strangely, if I compile with g++ -O0 -ggdb -std=c++11 test.cpp, GDB steps into testMethod if called from void test(). From the main, stepping still doesn't work. However, now, I can set a breakpoint by specifying just the method name.

此外,一旦我在GDB中启动程序,我得到GDB警告,在相关问题。无论是否指定 -std = c ++ 11 ,这些警告都会出现。

Further, as soon as I start the program in GDB, I get GDB warnings, as described in related questions. These warnings appear regardless of whether I specify -std=c++11 or not.

warning: Could not open OSO archive file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_gcc49/libstdcxx-devel/work/build/./gcc/libgcc_eh.a"
warning: Could not open OSO archive file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_gcc49/libstdcxx-devel/work/build/x86_64-apple-darwin11/libstdc++-v3/src/../libsupc++/.libs/libsupc++convenience.a"
warning: Could not open OSO archive file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_gcc49/libstdcxx-devel/work/build/x86_64-apple-darwin11/libstdc++-v3/src/../src/c++11/.libs/libc++11convenience.a"
warning: Could not open OSO archive file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_gcc49/libstdcxx-devel/work/build/x86_64-apple-darwin11/libstdc++-v3/src/../src/c++98/.libs/libc++98convenience.a"
warning: `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_gcc49/libstdcxx-devel/work/build/x86_64-apple-darwin11/libstdc++-v3/src/.libs/compatibility-atomic-c++0x.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_gcc49/libstdcxx-devel/work/build/x86_64-apple-darwin11/libstdc++-v3/src/.libs/compatibility-c++0x.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_gcc49/libstdcxx-devel/work/build/x86_64-apple-darwin11/libstdc++-v3/src/.libs/compatibility-debug_list-2.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_gcc49/libstdcxx-devel/work/build/x86_64-apple-darwin11/libstdc++-v3/src/.libs/compatibility-debug_list.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_gcc49/libstdcxx-devel/work/build/x86_64-apple-darwin11/libstdc++-v3/src/.libs/compatibility-thread-c++0x.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_gcc49/libstdcxx-devel/work/build/x86_64-apple-darwin11/libstdc++-v3/src/.libs/compatibility.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/_muldi3_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/addtf3_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/darwin-64_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/divtf3_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/emutls_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/enable-execute-stack_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/eqtf2_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/extenddftf2_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/extendsftf2_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/extendxftf2_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/fixtfdi_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/fixtfsi_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/fixtfti_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/fixunstfdi_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/fixunstfsi_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/fixunstfti_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/floatditf_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/floatsitf_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/floattitf_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/floatunditf_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/floatunsitf_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/floatuntitf_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/getf2_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/letf2_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/multf3_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/negtf2_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/subtf3_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/trunctfdf2_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/trunctfsf2_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/trunctfxf2_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/unordtf2_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/unwind-c_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/unwind-dw2-fde-darwin_s.o': can't open to read symbols: No such file or directory.
warning: `/opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libgcc/unwind-dw2_s.o': can't open to read symbols: No such file or directory.

我知道以下问题:



失败,
但他们没有帮助我。指定 -gdwarf-2 -gstrict-dwarf 也没有帮助。

I am aware of the following questions: Debugging Problems, Weird GDB messages, GDB error message, GDB fails on Mountain Lion,yet they didn't help me. Specifying -gdwarf-2 -gstrict-dwarf does not help either.

-EDIT-
nm 的输出在两种情况下是相同的:

-EDIT-The output of nm is the same in both cases:

0000000100001068 s GCC_except_table0
00000001000010c0 S _NXArgc
00000001000010c8 S _NXArgv
                 U __Unwind_Resume
0000000100000e34 T __Z4testR1A
0000000100000eae T __ZN1A10testMethodEv
00000001000010b0 S __ZTI1A
0000000100000f1d S __ZTS1A
0000000100001090 S __ZTV1A
                 U __ZTVN10__cxxabiv117__class_type_infoE
                 U ___gxx_personality_v0
00000001000010d8 S ___progname
0000000100000000 T __mh_execute_header
00000001000010d0 S _environ
                 U _exit
0000000100000e61 T _main
                 U _puts
0000000100001000 s _pvars
                 U dyld_stub_binder
0000000100000df8 T start


b $ b

有谁设法获得GCC 4.7和一些适当的调试器在OS X Lion上工作?

Has anyone managed to get GCC 4.7 and some appropriate debugger working on OS X Lion?

推荐答案

编译这样....它工作正常....
你能只尝试用-g选项吗?

I tried compiling like this....It is working fine....Could you just try with -g option alone?

例如:g ++ -g test .cpp -o test

E.g: g++ -g test.cpp -o test

这篇关于gcc 4.7.3和gdb 7.6在Mac - 奇怪的步进问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 04:05