vscode cpp debug
使用vscode 直接debug程序代码,不仅利于阅读,也便于调试程序
cpp debug
主要插件:
可便于调试cpp程序,attach或者run均可;
- 如run ut,并支持单步执行
- gdb 版本配置
{ // 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。 // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "(gdb) 启动", "type": "cppdbg", "request": "launch", "program": "/root/rocksdb/build/plain_table_db_test", "args": [], "stopAtEntry": false, "cwd": "${fileDirname}", "environment": [], "externalConsole": false, "MIMode": "gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true }, { "description": "将反汇编风格设置为 Intel", "text": "-gdb-set disassembly-flavor intel", "ignoreFailures": true } ] } ] }
- clang 版本配置
{ // 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。 // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "C/C++: clang++ build and debug active file", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/src/app/problem_set", "args": [], "stopAtEntry": false, "cwd": "${fileDirname}", "environment": [], "externalConsole": false, "MIMode": "lldb", "preLaunchTask": "C/C++: clang++ build active file", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true }, { "description": "将反汇编风格设置为 Intel", "text": "-gdb-set disassembly-flavor intel", "ignoreFailures": true } ] } ] }
- 当然也支持传递args参数,如上
// "args": [
// "--flagfile",
// "xx.conf",
// "--port",
// "10021"
// ],
参考
Using Clang in Visual Studio Code
文档信息
- 本文作者:Miko Song
- 本文链接:https://sinomiko.github.io/2023/10/09/vscode-cpp-debug/
- 版权声明:自由转载-非商用-非衍生-保持署名(创意共享3.0许可证)