在.vscode文件夹下建立launch.json
例子1:调试python
来自
https://github.com/chunleili/tiPBD/tree/amg
{
"version": "0.2.0",
"configurations": [
{
"name": "hpbd 5 5",
"type": "python",
"request": "launch",
"program": "engine/volumetric/arap_multigrid.py",
"console": "integratedTerminal",
"args": ["--fine_iterations", "5",
"--coarse_iterations", "5",
"--solver_type", "Jacobian",
"--multigrid_type", "HPBD"
]
},
]
}
逐行解释:
name是显示在侧边栏的名字,例如
program是要调试的程序
console是console打开的类型,分为内部(vscode内)和外部(额外弹出个终端模拟器)
args是调试传入参数,注意对应于命令行的每个空格都要单独分一个词。
例子2:调试c++
参考
https://github.com/chunleili/fast_mass_spring
{
"version": "0.2.0",
"configurations": [
{
"name": "(msvc) Launch",
"type": "cppvsdbg",
"request": "launch",
// Resolved by CMake Tools:
"program": "${workspaceFolder}/fast_mass_spring/main.exe",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}/fast_mass_spring",
"environment": [
{
"name": "PATH",
"value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}"
}
],
"console": "externalTerminal"
}
]
}
这里额外增加了几个
cwd是设定当前目录
stopAtEntry是是否在程序第一句暂停
environment是设定环境变量,这里将${command:cmake.getLaunchTargetDirectory}追加到PATH最后
GUI的使用
如图,
手动指定exe文件
假如生成的exe不在Build文件夹下,比如有一些shader或者txt文件的路径是硬编码的,就需要我们手动指定exe文件的路径。
以这个项目为例: https://github.com/chunleili/fast_mass_spring
创建.vscode/launch.json文章来源:https://www.toymoban.com/news/detail-589290.html
{
"version": "0.2.0",
"configurations": [
{
"name": "(msvc) Launch",
"type": "cppvsdbg",
"request": "launch",
// Resolved by CMake Tools:
"program": "${workspaceFolder}/fast_mass_spring/main.exe",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}/fast_mass_spring",
"environment": [
{
"name": "PATH",
"value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}"
}
],
"console": "externalTerminal"
}
]
}
其中更改了cwd和program。
点击VS code左侧边栏(运行和调试)
(注意不是下侧)的调试按钮,然后点击(msvc) Launch即可。文章来源地址https://www.toymoban.com/news/detail-589290.html
到了这里,关于vscode debug的方式的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!