使用OS X上的MacPorts GCC调试问题 [英] Debugging problems with MacPorts GCC on OS X

查看:115
本文介绍了使用OS X上的MacPorts GCC调试问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法获得使用GCC 4.7 MacPorts构建编译的程序的可读调试输出。



我试过GDB 6.3和GDB 7.3以及每个有自己的问题。

尝试使用GDB 7.3(MacPorts)



使用GDB 7.3,我得到以下输出在启动时:

  $ ggdb ./test 
GNU gdb(GDB)7.3
版权所有(C) 2011 Free Software Foundation,Inc.
许可证GPLv3 +:GNU GPL版本3或更高版本< http://gnu.org/licenses/gpl.html>
这是免费软件:您可以自由更改和重新分配它。
在法律允许的范围内,不存在任何担保。有关详细信息,请键入显示复制
和显示保修。
此GDB被配置为x86_64-apple-darwin11.4.0。
有关错误报告的说明,请参阅:
< http://www.gnu.org/software/gdb/bugs/> ...
BFD:无法读取未知的负载命令0x24
BFD:无法读取未知的加载命令0x26
BFD:无法读取未知的加载命令0x24
BFD:无法读取未知的加载命令0x26
从/ Users /StackedCrooked/programming/projects/stacked-crooked/Playground/LockOrderChecker/test...Readers symbols from /Users/StackedCrooked/programming/projects/stacked-crooked/Playground/LockOrderChecker/test.dSYM/Contents/Resources/DWARF/test ...完成。
完成。

运行并触发断言会导致无法读取的堆栈跟踪:

 (gdb)r 
启动程序:/ Users / StackedCrooked / programming / projects / stacked-crooked / Playground / LockOrderChecker / test
BFD:无法读取未知的加载命令0x24
BFD:无法读取未知的加载命令0x26
main
断言失败:(false),函数锁定,文件main.cpp,第168行。

编程接收到的信号SIGABRT,中止。
0x00007fff8ede282a在?? ()

(gdb)bt
#0 0x00007fff8ede282a in ?? ()
#1 0x00007fff9a273a9c in ?? ()
#2 0x00007fff6af00690 in ?? ()
#3 0x0000003000000030 in ?? ()
#4 0x00007fffffffffdf在? ()
#5 0x000000010b305840 in ?? ()
#6 0x00007fff6af006d0在? ()
#7 0x00007fff9a2a65de在?? ()
#8 0x0000000000000000 in ?? ()



尝试使用GDB 6.3(内置)



根据这个答案,我应该使用GDB 6.3。然而,这导致了一系列不同的问题。在启动过程中,我收到了一堆错误:

  GNU gdb 6.3.50-20050815(Apple版本gdb-1708)(Thu Nov 3 2011年2月21日21:59:02)
版权所有2004自由软件基金会,Inc.
GDB是GNU通用公共许可证涵盖的免费软件,您可以随时更改它并获得
的欢迎/或在特定条件下分发它的副本。
输入show copying查看条件。
GDB绝对没有担保。输入显示保修以获取详细信息。
这个GDB被配置为x86_64-apple-darwin...阅读共享库的符号。
警告:无法找到目标文件/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 - 没有可用于../../../../gcc-4.7.1/libstdc++-v3/src/c++98/compatibility.cc的调试信息。


警告:无法找到目标文件/ 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 - 没有调试信息可用于../../../../gcc-4.7.1/libstdc++-v3/src/c++98/compatibility- debug_list.cc。

警告:无法找到目标文件/ 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 - 没有调试信息可用于../../../../gcc-4.7.1/libstdc++-v3/src/c++98/compatibility-debug_list- 2.cc。

这是我看到的是,如果断言被触发,我尝试获得回溯:

 断言失败:(false),函数锁定,文件main.cpp,行168. 

编程接收信号SIGABRT,中止。 ()
(gdb)bt
#0 0x00007fff8ede282a in __kill()
#1 0x00007fff9e273a9c在abort()中
#2 0x00007fff9a2a65de在__assert_rtn()中
0x00007fff8ede282a
Die:DW_TAG_unspecified_type(abbrev = 19,offset = 423)
有孩子:FALSE
属性:
DW_AT_name(DW_FORM_strp)字符串:decltype(nullptr)
Die:DW_TAG_unspecified_type(abbrev = 19,offset = 423)
有孩子:FALSE
属性:
DW_AT_name(DW_FORM_strp)字符串:decltype(nullptr)
Dwarf错误:Can not找到死亡类型[在模块/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 



<但是,它并没有解决任何上述问题。



记录:我在OS X Lion上。



有人知道如何解决这个问题吗?根据你应该使用的g ++手册页 -

ggdb为gdb生成调试符号。顺便说一句,只是使用-g总是为我的经验(在linux,windows(mingw)和mac)上生成gdb的好符号。


I can't seem to get readable debugging output for programs compiled with GCC 4.7 MacPorts build.

I've tried with both GDB 6.3 and GDB 7.3 and each have their own problems.

Try with GDB 7.3 (MacPorts)

With GDB 7.3 I get the following output on startup:

$ 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.

Running and triggering an assertion results in an unreadable stack trace:

(gdb) r
Starting program: /Users/StackedCrooked/programming/projects/stacked-crooked/Playground/LockOrderChecker/test 
BFD: unable to read unknown load command 0x24
BFD: unable to read unknown load command 0x26
main
Assertion failed: (false), function lock, file main.cpp, line 168.

Program received signal SIGABRT, Aborted.
0x00007fff8ede282a in ?? ()

(gdb) bt
#0  0x00007fff8ede282a in ?? ()
#1  0x00007fff9a273a9c in ?? ()
#2  0x00007fff6af00690 in ?? ()
#3  0x0000003000000030 in ?? ()
#4  0x00007fffffffffdf in ?? ()
#5  0x000000010b305840 in ?? ()
#6  0x00007fff6af006d0 in ?? ()
#7  0x00007fff9a2a65de in ?? ()
#8  0x0000000000000000 in ?? ()

Try with GDB 6.3 (built-in)

According to this answer I should use GDB 6.3. However that leads to a different set of problems. During startup I get a bunch of errors:

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".

This is what I see if an assertion is triggered and I try to get a backtrace:

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]

According to this answer (which quotes the GCC 4.5 manual) I should use the -gdwarf-2 -gstrict-dwarf options.

I followed this advice. My build command looks like this:

g++ -o run-test -std=c++0x -Wall -Wextra -Werror -gdwarf-2 -gstrict-dwarf -g2 -O0 -I/opt/local/include main.cpp

However, it doesn't fix any of the aforementioned problems.

For the record: I'm on OS X Lion.

Does anyone know how to fix this?

解决方案

According to the g++ man pages you should use -ggdb to generate debug symbols for gdb. BTW, just using -g always generated good symbols for gdb in my experience (on linux, windows (mingw) and mac).

这篇关于使用OS X上的MacPorts GCC调试问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆