英文:
How to load coredumps in mac osx?
问题
我正在尝试学习如何使用gdb(教程链接:https://www.cse.unsw.edu.au/~learn/debugging/modules/gdb_coredumps/)。我使用的是macOS X 10.14 Mojave。
以下是一个复现的示例:
ulimit -c
unlimited
gcc -g -o broken_linked_list broken_linked_list.c
./broken_linked_list
[1] 10585 分段错误 ./broken_linked_list
gdb broken_linked_list /cores/core.14192
错误信息:
要获取帮助,请键入“help”。
键入“apropos word”以搜索与“word”相关的命令...
正在读取broken_linked_list中的符号...
正在读取/Users/me/foo/broken_linked_list.dSYM/Contents/Resources/DWARF/broken_linked_list中的符号...
“/cores/core.14192”:没有核心文件处理程序可以识别的格式
英文:
I'm trying to learn how to use gdb (tutorial: https://www.cse.unsw.edu.au/~learn/debugging/modules/gdb_coredumps/). I'm on mac os x, 10.14, mojave.
Here's a repro:
ulimit -c
unlimited
gcc -g -o broken_linked_list broken_linked_list.c
./broken_linked_list
[1] 10585 segmentation fault ./broken_linked_list
gdb broken_linked_list /cores/core.14192
Error
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from broken_linked_list...
Reading symbols from /Users/me/foo/broken_linked_list.dSYM/Contents/Resources/DWARF/broken_linked_list...
"/cores/core.14192": no core file handler recognizes format
答案1
得分: 1
gdb
不理解 macOS MachO 二进制文件。请使用 lldb
:
> gdb -c /cores/core.782 a.out
...
"/cores/core.782": 不支持的核心文件格式
(gdb) 退出
> lldb -c /cores/core.782 a.out
(lldb) target create "a.out" --core "/cores/core.782"
核心文件 'core.782' (x86_64) 已加载。
(lldb) bt
* 线程 #1,停止原因 = 信号 SIGSTOP
* 帧 #0: 0x0000000100019062 a.out`main + 258
帧 #1: 0x00007fff2059ff3d libdyld.dylib`start + 1
帧 #2: 0x00007fff2059ff3d libdyld.dylib`start + 1
英文:
gdb
doesn't understand macOS MachO binaries. Use lldb
:
> gdb -c /cores/core.782 a.out
...
"/cores/core.782": Core file format not supported
(gdb) quit
> lldb -c /cores/core.782 a.out
(lldb) target create "a.out" --core "/cores/core.782"
Core file '/cores/core.782' (x86_64) was loaded.
(lldb) bt
* thread #1, stop reason = signal SIGSTOP
* frame #0: 0x0000000100019062 a.out`main + 258
frame #1: 0x00007fff2059ff3d libdyld.dylib`start + 1
frame #2: 0x00007fff2059ff3d libdyld.dylib`start + 1
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论