vimspector安装
vim配置文件加入一下内容
1 2 | Plug 'puremourning/vimspector' let g:vimspector_enable_mappings = 'HUMAN' |
上面的HUMAN是插件配置的一套快捷命令。具体如下
| Key | Function | API |
|---|---|---|
| When debugging, continue. Otherwise start debugging. | ||
| Stop debugging. | ||
| Restart debugging with the same configuration. | ||
| Pause debugee. | ||
| Toggle line breakpoint on the current line. | ||
| Toggle conditional line breakpoint on the current line. | ||
| Add a function breakpoint for the expression under cursor | ||
| Step Over | ||
| Step Into | ||
| Step out of current function scope |
vimspector配置
| Language | Status | Switch | Adapter | Dependencies |
|---|---|---|---|---|
| C, C++, etc. | Tested | vscode-cpptools | mono-core | |
| Python | Tested | debugpy | Python 2.7 or Python 3 | |
| Go | Tested | vscode-go | Go, [Delve][] | |
| TCL | Supported | tclpro | TCL 8.5 | |
| Bourne Shell | Supported | vscode-bash-debug | Bash v?? | |
| Node.js | Supported | vscode-node-debug2 | 6 | |
| Javascript | Supported | debugger-for-chrome | Chrome | |
| Java | Supported | vscode-java-debug | Compatible LSP plugin (see later) | |
| C# (dotnet core) | Experimental | netcoredbg | DotNet core | |
| C# (mono) | Experimental | vscode-mono-debug | Mono | |
| Python.legacy | Legacy | vscode-python | Node 10, Python 2.7 or Python3 |
在vimspector目录运行 以上按照你本所需调试语言的命令即可。这里我只需调试C++代码。在我本地
1 | ./install.py --enable-c |
这里会去下载一个
在
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | { "adapters": { "vscode-cpptools": { "attach": { "pidProperty": "processId", "pidSelect": "ask" }, "command": [ "${gadgetDir}/vscode-cpptools/debugAdapters/OpenDebugAD7" ], "name": "cppdbg" } } } |
新建文件夹
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | { "adapters": { "lldb-vscode": { "variables": { "LLVM": { "shell": "brew --prefix llvm" } }, "attach": { "pidProperty": "pid", "pidSelect": "ask" }, "command": [ "${LLVM}/bin/lldb-vscode" ], "env": { "LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY": "YES" }, "name":"lldb" } } } |
项目配置
在项目下添加
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | { "configurations": { "cpp:launch": { "adapter": "vscode-cpptools", "configuration": { "name": "cpp", "type": "cppdbg", "request": "launch", "program": "${fileDirname}/a.out", "args": ["*${ProgramArgs}"], "cwd": "${workspaceRoot}", "environment": [], "externalConsole": false, "stopAtEntry": true, "MIMode": "lldb", "logging": { "engineLogging": true } } } } } |
其中
编辑
1 2 3 4 5 6 7 8 | #include<stdio.h> int main(){ int a = 1; int b = 2; int c = a + b; printf("%d", c); return 0; } |
vim打开