[英]How do I get VS Code on WSL to debug my C++ code?
我已经在我的 Windows 10 系统上安装了 Ubuntu 20.04。 在我第一次从 Ubuntu 中运行 VS Code 之前,VS Code 在 Windows 中运行良好。 现在,我可以在那里构建我的 C++ 应用程序,但无法调试它。 我收到一个警告框,提示“在 PATH 上找不到运行时 'node'。是否安装了 'node'?”
每当我启动 VS Code 时,一个名为“node”的后台进程也会启动,所以我假设 VS Code 会启动它。 我的 Ubuntu 安装在 ~/.vscode-server 的各个子目录中有大约八个版本的 node.js。
这是我的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": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/gametest",
"skipFiles": [
"<node_internals>/**"
]
},
]
}
我尝试安装最新的nodejs。 我不再收到带有未找到消息的警报框,但 VS Code 中的调试控制台现在显示:
/usr/bin/node /home/jon/projects/KSolve/gametest
Debugger listening on ws://127..... (can't copy from debug console window)
For help, ...
/home/jon/projects/KSolve/gametest:1
ELF(three squares)
^
SyntaxError: Invalid or unexpected token
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
...
...
Process exited with code 1
前段时间对我来说,在 WSL Ubuntu 下的 VS Code 上运行调试器也很棘手。 经过大量尝试,我得到了下一个.vscode/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": "test tree",
"type": "cppdbg",
"request": "launch",
"program": "enter program name, for example ${workspaceFolder}/tests/ttree",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/tests",
"environment": [],
"externalConsole": false,
"targetArchitecture": "x86_64",
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.