10上打开核心文件

10上打开核心文件

本文介绍了Homebrew GDB无法在Yosemite 10.10上打开核心文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我打开一个由GCC编译生成的核心文件( gcc -4.9 -g xxx.c -o xxx )程序,它报告:

 →gdb。 / list_test /cores/core.1176 
GNU gdb(GDB)7.8.1
版权所有(C)2014自由软件基金会,Inc.
许可证GPLv3 +:GNU GPL版本3或更新版本< http://gnu.org/licenses/gpl.html>
这是免费软件:您可以自由更改和重新分配它。
在法律允许的范围内,不存在任何担保。有关详细信息,请键入显示复制
和显示保修。
这个GDB被配置为x86_64-apple-darwin14.0.0。
输入显示配置以获取配置详细信息。
有关错误报告的说明,请参阅:
< http://www.gnu.org/software/gdb/bugs/> ;.
在线查找GDB手册和其他文档资源:
< http://www.gnu.org/software/gdb/documentation/> ;.
如需帮助,请输入help。
输入apropos word以搜索与word相关的命令...
读取./list_test中的符号...
警告:`/ var / folders / r1 / 3sx4x5k1557g_v5by83k4hg00000gn / T // cchuMtAU.o':无法读取符号:无此文件或目录。
(找不到调试符号)...完成。
/cores/core.1176:没有核心文件处理程序识别格式

并发现有人建议使用LLDB而不是GDB。



是否可以使用GDB来调试核心文件?这是因为GDB不支持Yosemite的二进制格式吗? 解决方案

基于,似乎苹果公司并没有将他们的修改合并回官方的GNU主线,而是选择了在他们自己的网站上发布修改后的源代码。因此,自制GDB安装(使用库存GDB源代码)无法加载OS X核心文件。



此时,我看到三个选择:


  1. 投入并学习LLDB。


  2. 从MacPorts安装Apple的自定义GDB 我已经很久没有MacPorts了,所以我无法测试它,但是如果您安装了MacPorts,请尝试以下操作:

      $ sudo port install gdb-apple 
    $ codesign -s< your_GDB_cert_id> / opt / local / bin / gdb-apple
    $ / opt / local / bin / gdb-apple ./list_test /cores/core.1176


  3. 翻译MacPorts的GDB补丁并将规范构建为自制公式。理论上可行,但我没有时间做它本人。


就我个人而言,我选择了学习LLDB。 Apple已经永久移动到LLVM,所以在旧的补丁GDB停止使用最新最好的Xcode工具之前,这可能只是一个时间问题。


I installed GDB 7.8.1 and GCC 4.9 through Homebrew.

When I open a core file generated by a GCC-compiled (gcc-4.9 -g xxx.c -o xxx) program, it reports:

→  gdb ./list_test /cores/core.1176
GNU gdb (GDB) 7.8.1
Copyright (C) 2014 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-darwin14.0.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./list_test...
warning: `/var/folders/r1/3sx4x5k1557g_v5by83k4hg00000gn/T//cchuMtAU.o': can't open to read symbols: No such file or directory.
(no debugging symbols found)...done.
"/cores/core.1176": no core file handler recognizes format

I googled and found someone suggested to use LLDB instead of GDB.

Is is possible to use GDB to debug the core file? And is it because GDB does not support the binary format on Yosemite?

解决方案

Based on the long GDB developers' discussion thread on this issue, it seems Apple did not merge their changes back to the official GNU mainline, and instead chose to publish the modified source code on their own site. As a result, the Homebrew GDB install (which uses the stock GDB sources) can't load OS X core files.

At this point, I see three choices:

  1. Give in and learn LLDB. There's a GDB to LLDB cheat sheet to help.

  2. Install Apple's custom GDB from MacPorts. I've long forsaken MacPorts, so I can't test it, but if you have MacPorts installed, try the following:

    $ sudo port install gdb-apple
    $ codesign -s <your_GDB_cert_id> /opt/local/bin/gdb-apple
    $ /opt/local/bin/gdb-apple ./list_test /cores/core.1176
    

  3. Translate MacPorts' GDB patches and build spec into a Homebrew formula. It's theoretically possible, but I don't have the time to do it myself.

Personally, I've opted to just learn LLDB. Apple has moved permanently to LLVM, so it's probably just a matter of time before the old patched GDB stops working with the latest-and-greatest Xcode tools.

这篇关于Homebrew GDB无法在Yosemite 10.10上打开核心文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 18:52