gpt4 book ai didi

macos - 为什么我的 mac lldb 生成 lldb 本身无法识别的核心文件?

转载 作者:行者123 更新时间:2023-12-05 07:44:53 29 4
gpt4 key购买 nike

$cat testleak01.cpp
#include<iostream>
int main()
{
int*p=new int[3];
return 0;
}

用调试信息编译它

$g++ testleak01.cpp -g

然后用lldb启动

(lldb) b main
Breakpoint 1: where = a.out`main + 22 at testleak01.cpp:4, address = 0x0000000100000f86
(lldb) r
Process 87960 launched: '/Users/x/Documents/learn/a.out' (x86_64)
Process 87960 stopped
* thread #1: tid = 0x60b7ec, 0x0000000100000f86 a.out`main + 22 at testleak01.cpp:4, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100000f86 a.out`main + 22 at testleak01.cpp:4
1 #include<iostream>
2 int main()
3 {
-> 4 int*p=new int[3];
5 return 0;
6 }
(lldb) process save-core mycore
... a lot of stuff

然后半分钟后我得到了一个巨大的核心文件(500M+),所有者是root

-rw-------   1 root  staff  589529088  2 25 21:06 mycore

然后我尝试加载它

$lldb -c mycore
(lldb) target create --core "mycore"
error: Unable to find process plug-in for core file '/Users/x/Documents/learn/mycore'

为什么不能识别自己生成的核心文件?我期望使用 lldb 加载 a.out 和 mycore 以检查转储文件作为进程镜像。

最佳答案

在我的例子中,这是一个错误生成的核心文件。同一个应用程序的多个并行实例几乎同时崩溃,我得到了 3 个核心文件。对于其中 2 个,lldb 工作正常,但对于其中一个,我得到“无法找到核心文件的进程插件”。

ls -la /cores/core*
-r-------- 1 build admin 1605496832 Jun 24 09:53 core.83754
-r-------- 1 build admin 1615982592 Jun 24 09:53 core.83773
-r-------- 1 build admin 1605496832 Jun 24 09:53 core.83797

当我用"file"命令测试核心文件时,我发现它确实不可读:

file /cores/core*
/cores/core.83754: Mach-O 64-bit core x86_64
/cores/core.83773: Mach-O 64-bit core x86_64
/cores/core.83797: data

我假设这是一个 MacOS 错误,它有时无法正确写入 coredump。

关于macos - 为什么我的 mac lldb 生成 lldb 本身无法识别的核心文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42456545/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com