VSCode调试
目录
- C/C++远程本地调试
- 插件
- 配置
- 参考
C/C++远程本地调试
测试源码:https://github.com/jrhee17/ssl-study
插件
Remote - SSH
C/C++
配置
.vscode/launch.json
{"version": "0.2.0","configurations": [{"name": "after/ch02", // 配置名称,将会在启动配置的下拉菜单中显示"type": "cppdbg","request": "launch", // 请求配置类型,可以为launch(启动)或attach(附加)"program": "${workspaceFolder}/after/ch02/rc4", // 将要进行调试的程序的路径,与 makefile 中的 main 一致"args": ["-e", "abcdef" , "abcdefghijklmnop"]"stopAtEntry": true, // 设为true时程序将暂停在程序入口处"cwd": "${workspaceFolder}","environment": [],"externalConsole": false, // 调试时是否显示控制台窗口,必须为true显示控制台,才能输入,交互"MIMode": "gdb", // 指定连接的调试器,可以为gdb或lldb。"preLaunchTask": "ch02", // 调试会话开始前执行的任务,一般为编译程序。与 tasks.json 的 label 一致"miDebuggerPath": "/usr/local/bin/gdb" }]
}
.vscode/tasks.json
{"tasks": [{"type": "cppbuild","label": "C/C++: gcc build active file","command": "/usr/bin/gcc","args": ["-fdiagnostics-color=always","-g","${file}","-o","${fileDirname}/${fileBasenameNoExtension}"],"options": {"cwd": "${fileDirname}"},"problemMatcher": ["$gcc"],"group": {"kind": "build","isDefault": true},"detail": "Task generated by Debugger."},{"type": "shell","label": "ch02","command": "/usr/bin/make","options": {"cwd": "${workspaceFolder}/after/ch02"}}],"version": "2.0.0"
}
不重新编译gdb,前面已经编译过,arg复杂参数要注意转义
{"version": "0.2.0","configurations": [{"name": "(gdb) Launch","type": "cppdbg","request": "launch","program": "${workspaceFolder}/curl-8.11.1/src/.libs/curl","args": [],"cwd": "${workspaceFolder}","environment": [],"externalConsole": false,"MIMode": "gdb","setupCommands": [{"description": "为 gdb 启用整齐打印","text": "-enable-pretty-printing","ignoreFailures": true}],// "miDebuggerPath": "/usr/local/bin/gdb"}]
}
参考
https://www.cnblogs.com/lidabo/p/16355947.html