如何配置.vimspector.json使C++调试自动执行-enable-pretty-printing
解决方案
你之前将-enable-pretty-printing加入args不生效,是因为args字段传递的是被调试程序的启动参数,而非GDB调试器的执行命令。
正确修改方式是在配置的configuration块中新增setupCommands字段,该字段专门用于定义调试器启动完成后自动执行的预置命令,修改后的完整配置如下:
{ "configurations": { "Vim - run a test": { "adapter": "vscode-cpptools", "configuration": { "type": "cppdbg", "request": "launch", "program": "${workspaceRoot}/main", "args": [], "cwd": "${workspaceRoot}", "environment": [ { "name": "VIMRUNTIME", "value": "${workspaceRoot}" } ], "externalConsole": true, "stopAtEntry": true, "MIMode": "gdb", "logging": { "engineLogging": false }, "setupCommands": [ { "text": "-enable-pretty-printing", "description": "Enable GDB pretty printing for STL structures", "ignoreFailures": false } ] } } } }
修改后重启调试即可自动启用STL类型的格式化打印,无需每次手动输入命令。
内容的提问来源于stack exchange,提问作者user5668024
相关产品推荐
相关产品推荐

