我在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/