Nid*_*nna 16 gdb visual-studio visual-studio-code windows-subsystem-for-linux
我最近开始研究 vscode。我想调试我的 C 代码。但是当我启动调试器时出现错误:无法开始调试。miDebuggerPath 的值无效。
我在 wsl 上安装了我的 gdb 。它的路径是/usr/bin/gdb。我已将相同的路径复制到 miDebuggerPath 中的 launch.json。
这是我的 launch.json :
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/main",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
Run Code Online (Sandbox Code Playgroud)
}
它不应该抛出错误,我应该能够启动我的调试器。
Ash*_*cob 21
所以这在 WSL-Ubuntu 上发生在我身上。在我的情况下,由于未满足的依赖关系,gdb 被破坏了。花了一段时间来修复,但是一旦我在 WSL-Ubuntu 中正确地重新安装了 gdb,我终于让它工作了。
安装 gdb 可以在 shell 上完成
sudo apt-get install gdb
Run Code Online (Sandbox Code Playgroud)
它最终可能会损坏可能有多种原因,但是一旦修复了 gdb,vscode-debugging 应该会运行。至少,您不会看到该错误弹出。
小智 8
我有同样的问题,我的解决方案是:
1. 更改launch.json中的此部分
"miDebuggerPath": "/usr/bin/gdb",
Run Code Online (Sandbox Code Playgroud)
为了:
"miDebuggerPath": "C:/MinGW/bin/gdb.exe",
Run Code Online (Sandbox Code Playgroud)
2.你的PC上是否需要安装MinGW,这是链接:
https://osdn.net/projects/mingw/downloads/68260/mingw-get-setup.exe/
3. 接下来,打开 MinGW,然后在 URL“C:/MinGW/bin”中安装 gdb(选择)
mingw32-gdb-bin
Run Code Online (Sandbox Code Playgroud)
4. 享受 VS-Code
归档时间: |
|
查看次数: |
17706 次 |
最近记录: |