gpt4 book ai didi

linux - 如何使用 VSCode 调试 Linux 核心转储?

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:02:53 26 4
gpt4 key购买 nike

我有意从我使用 VSCode 编写的 C++ 应用程序生成核心转储。我不知道如何调试核心转储。是否有人愿意分享这方面的经验?

***** 更新 *****我相信我现在已经开始工作了。我为核心文件创建了第二个调试配置。我需要添加指向生成的转储文件的“coreDumpPath”选项。我还需要删除始终构建新可执行文件的 preLaunchTask 选项。


最佳答案

来自VScode docs

Memory dump debugging

The C/C++ extension for VS Code also has the ability to debug memory dumps. To debug a memory dump, open your launch.json file and add the coreDumpPath (for GDB or LLDB) or dumpPath (for the Visual Studio Windows Debugger) property to the C++ Launch configuration, set its value to be a string containing the path to the memory dump. This will even work for x86 programs being debugged on an x64 machine.

附言提问者已经用解决方案更新了问题。但是添加这个答案是为了帮助那些直接跳到答案部分的人 ;)


更新:用于 C/C++ 扩展的示例 launch.json 没有硬编码核心文件名

{
"version": "0.2.0",
"configurations": [
{
"type": "cppdbg",
"request": "launch",
"name": "Open a core dump(c/c++)",
"program": "<Path to the program here>",
"coreDumpPath": "${input:coreFileName}",
"cwd": "${workspaceFolder}",
"MIMode": "lldb" // or gdb, if you are using gdb
}
],
"inputs": [
{
"id": "coreFileName",
"type": "promptString",
"description": "Enter core file path"
}
]
}

示例 launch.json 用于没有硬编码核心文件名的 CodeLLDB 扩展

{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "custom",
"name": "Open a core dump",
"initCommands": [
"target create -c ${input:coreFileName}"
]
}
],
"inputs": [
{
"id": "coreFileName",
"type": "promptString",
"description": "Enter core file path"
}
]
}

关于linux - 如何使用 VSCode 调试 Linux 核心转储?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55736235/

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