如何在Mac OS X中加载核心转储文件?

huangapple go评论104阅读模式
英文:

How to load coredumps in mac osx?

问题

我正在尝试学习如何使用gdb(教程链接:https://www.cse.unsw.edu.au/~learn/debugging/modules/gdb_coredumps/)。我使用的是macOS X 10.14 Mojave。

以下是一个复现的示例:

  1. ulimit -c
  2. unlimited
  1. gcc -g -o broken_linked_list broken_linked_list.c
  1. ./broken_linked_list
  2. [1] 10585 分段错误 ./broken_linked_list
  1. gdb broken_linked_list /cores/core.14192

错误信息:

  1. 要获取帮助,请键入“help”。
  2. 键入“apropos word”以搜索与“word”相关的命令...
  3. 正在读取broken_linked_list中的符号...
  4. 正在读取/Users/me/foo/broken_linked_list.dSYM/Contents/Resources/DWARF/broken_linked_list中的符号...
  5. “/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:

  1. ulimit -c
  2. unlimited
  1. gcc -g -o broken_linked_list broken_linked_list.c
  1. ./broken_linked_list
  2. [1] 10585 segmentation fault ./broken_linked_list
  1. gdb broken_linked_list /cores/core.14192

Error

  1. For help, type "help".
  2. Type "apropos word" to search for commands related to "word"...
  3. Reading symbols from broken_linked_list...
  4. Reading symbols from /Users/me/foo/broken_linked_list.dSYM/Contents/Resources/DWARF/broken_linked_list...
  5. "/cores/core.14192": no core file handler recognizes format

答案1

得分: 1

gdb 不理解 macOS MachO 二进制文件。请使用 lldb

  1. > gdb -c /cores/core.782 a.out
  2. ...
  3. "/cores/core.782": 不支持的核心文件格式
  4. (gdb) 退出
  5. > lldb -c /cores/core.782 a.out
  6. (lldb) target create "a.out" --core "/cores/core.782"
  7. 核心文件 'core.782' (x86_64) 已加载。
  8. (lldb) bt
  9. * 线程 #1,停止原因 = 信号 SIGSTOP
  10. * #0: 0x0000000100019062 a.out`main + 258
  11. #1: 0x00007fff2059ff3d libdyld.dylib`start + 1
  12. #2: 0x00007fff2059ff3d libdyld.dylib`start + 1
英文:

gdb doesn't understand macOS MachO binaries. Use lldb:

  1. > gdb -c /cores/core.782 a.out
  2. ...
  3. "/cores/core.782": Core file format not supported
  4. (gdb) quit
  5. > lldb -c /cores/core.782 a.out
  6. (lldb) target create "a.out" --core "/cores/core.782"
  7. Core file '/cores/core.782' (x86_64) was loaded.
  8. (lldb) bt
  9. * thread #1, stop reason = signal SIGSTOP
  10. * frame #0: 0x0000000100019062 a.out`main + 258
  11. frame #1: 0x00007fff2059ff3d libdyld.dylib`start + 1
  12. frame #2: 0x00007fff2059ff3d libdyld.dylib`start + 1

huangapple
  • 本文由 发表于 2023年6月25日 22:42:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/76550952.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定