macos - 在OSX上的gdb中转储核心(没有 "gcore"或 "generate-core-file")

标签 macos gdb coredump

我在OSX上使用gdb,它似乎既没有gcore也没有generate-core-file命令:

$ gdb
GNU gdb 6.3.50-20050815 (Apple version gdb-1705) (Fri Jul  1 10:50:06 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".
(gdb) gcore
Undefined command: "gcore".  Try "help".
(gdb) generate-core-file
Undefined command: "generate-core-file".  Try "help".
(gdb)

鉴于此,我该如何通过GDB生成核心转储或近似的核心转储?

(我怀疑我可以使用dump memory,但是这需要一个地址范围,而我正在努力寻找正确的info调用以获取正确的内存范围...)

最佳答案

运行lldb --attach-pid,然后使用process save-core命令保存内核。请注意,该过程会在您附加到该过程后立即暂停,因此请注意它是否很重要。

$ lldb --attach-pid <pid>
(lldb) process attach --pid 76669
Process 76669 stopped
Executable module set to "/bin/bash".
Architecture set to: x86_64h-apple-macosx.
(lldb) process save-core "core"
mach_header: 0xfeedfacf 0x01000007 0x00000008 0x00000004 0x00000030 0x00000e08 0x00000000 0x00000000
...
Saving data for segment at 0x7fd455200000
...

关于macos - 在OSX上的gdb中转储核心(没有 "gcore"或 "generate-core-file"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10386921/

相关文章:

c - segmentation fault和segmentation fault core dumped的区别

macos - 如何防止 Python 应用程序的传入连接出现 OSX 弹出窗口?

objective-c - 如何在 Cocoa Objective-c 中创建 UI 标签?

xml - 下载多个文件会将相同的数据写入所有文件

c - gdb 错误 "Program exited normally"

c - GDB MI机制来调试自执行程序

c++ - 段错误(核心转储)C++,因为我使用了大量内存

C/多线程/段错误/(可能是)线程队列问题

linux - Dwarfdump OSX 和 Linux 之间的差异(以及如何避免它们)

linux - 如何在linux上将安装的gdb添加到系统路径