Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/162.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ OS X上MacPorts GCC的调试问题_C++_Macos_Gcc_Gdb - Fatal编程技术网

C++ OS X上MacPorts GCC的调试问题

C++ OS X上MacPorts GCC的调试问题,c++,macos,gcc,gdb,C++,Macos,Gcc,Gdb,对于使用GCC4.7MacPorts构建编译的程序,我似乎无法获得可读的调试输出 我已经尝试过GDB6.3和GDB7.3,它们都有各自的问题 尝试使用GDB7.3(MacPorts) 使用GDB 7.3,我在启动时获得以下输出: $ ggdb ./test GNU gdb (GDB) 7.3 Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http:/

对于使用GCC4.7MacPorts构建编译的程序,我似乎无法获得可读的调试输出

我已经尝试过GDB6.3和GDB7.3,它们都有各自的问题

尝试使用GDB7.3(MacPorts) 使用GDB 7.3,我在启动时获得以下输出:

$ ggdb ./test
GNU gdb (GDB) 7.3
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin11.4.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
BFD: unable to read unknown load command 0x24
BFD: unable to read unknown load command 0x26
BFD: unable to read unknown load command 0x24
BFD: unable to read unknown load command 0x26
Reading symbols from /Users/StackedCrooked/programming/projects/stacked-crooked/Playground/LockOrderChecker/test...Reading symbols from /Users/StackedCrooked/programming/projects/stacked-crooked/Playground/LockOrderChecker/test.dSYM/Contents/Resources/DWARF/test...done.
done.
尝试使用GDB6.3(内置) 据我所知,我应该使用GDB6.3。然而,这导致了一系列不同的问题。在启动过程中,我会遇到一系列错误:

GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Thu Nov  3 21:59:02 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries .
warning: Could not find object file "/Volumes/work/macports/var/macports/build/_Volumes_work_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libstdc++-v3/src/.libs/compatibility.o" - no debug information available for "../../../../gcc-4.7.1/libstdc++-v3/src/c++98/compatibility.cc".


warning: Could not find object file "/Volumes/work/macports/var/macports/build/_Volumes_work_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libstdc++-v3/src/.libs/compatibility-debug_list.o" - no debug information available for "../../../../gcc-4.7.1/libstdc++-v3/src/c++98/compatibility-debug_list.cc".

warning: Could not find object file "/Volumes/work/macports/var/macports/build/_Volumes_work_mports_dports_lang_gcc47/gcc47/work/build/x86_64-apple-darwin11/libstdc++-v3/src/.libs/compatibility-debug_list-2.o" - no debug information available for "../../../../gcc-4.7.1/libstdc++-v3/src/c++98/compatibility-debug_list-2.cc".
这就是我在触发断言并尝试获取回溯跟踪时看到的情况:

Assertion failed: (false), function lock, file main.cpp, line 168.

Program received signal SIGABRT, Aborted.
0x00007fff8ede282a in __kill ()
(gdb) bt
#0  0x00007fff8ede282a in __kill ()
#1  0x00007fff9a273a9c in abort ()
#2  0x00007fff9a2a65de in __assert_rtn ()
Die: DW_TAG_unspecified_type (abbrev = 19, offset = 423)
    has children: FALSE
    attributes:
        DW_AT_name (DW_FORM_strp) string: "decltype(nullptr)"
Die: DW_TAG_unspecified_type (abbrev = 19, offset = 423)
    has children: FALSE
    attributes:
        DW_AT_name (DW_FORM_strp) string: "decltype(nullptr)"
Dwarf Error: Cannot find type of die [in module /Users/StackedCrooked/programming/projects/stacked-crooked/Playground/LockOrderChecker/test.dSYM/Contents/Resources/DWARF/test]
根据(引用GCC 4.5手册)我应该使用
-gdwarf-2-gstrict dwarf
选项

我听从了这个建议。我的生成命令如下所示:

g++ -o run-test -std=c++0x -Wall -Wextra -Werror -gdwarf-2 -gstrict-dwarf -g2 -O0 -I/opt/local/include main.cpp
但是,它不能解决上述任何问题

记录在案:我在OSX Lion上


有人知道如何解决这个问题吗?

根据g++手册页,您应该使用-ggdb为gdb生成调试符号。顺便说一句,根据我的经验(在linux、windows(mingw)和mac上),只要使用-g就可以为gdb生成良好的符号。

来自MacPorts gdb 7.3会话的警告用于加载命令0x24(LC_VERSION_MIN_MACOSX)和0x26(LC_FUNCTION_启动)。这些是新的加载命令,但不是调试所必需的-警告是无害的。会话缺少任何符号信息的事实可能是因为ASLR?自从它被引入系统进行用户端调试以来已经有好几年了,但是如果调试器不知道运行时内存中的所有内容都在滑动,那么调试器的输出就是这样的


你试过使用lldb吗?Xcode 4.5中提供的版本非常好。这是苹果公司目前正在积极支持和开发的调试器,它应该能够正确地使用较新编译器的DWARF输出。命令语法与gdb稍有不同(尽管提供了许多命令快捷方式,让gdb用户熟悉),但在上提供了一个gdb/lldb命令等效表。试试看,你可能会喜欢。

@Walter我想gdb是gcc的调试器?是的,我正在使用MacPorts提供的命令行工具g++和gdb。我试图建议放弃使用调试器的想法。或者你可以在调试器中运行调试器。我在StackOverflow上读到了关于web和其他主题的文章,有人认为这是gdb 7.3的一个错误,并且已经解决了升级到gdb 7.4的问题。我不知道这个主题是否能帮到你:你为什么使用MacPorts的GCC/gdb而不是XCode工具?
g++ -o run-test -std=c++0x -Wall -Wextra -Werror -gdwarf-2 -gstrict-dwarf -g2 -O0 -I/opt/local/include main.cpp