简体   繁体   English

如何在 Visual Studio 2022 中为 c/c++ 指定多个调试命令?

[英]How to specify multiple debugging commands in visual studio 2022 for c/c++?

In vs you can edit your debugging command in Configuration Properties -> Debugging .在 vs 中,您可以在Configuration Properties -> Debugging中编辑调试命令。 But when you have multiple debugging scenarios to review, it is very cumbersome to be constantly adjusting the Command Arguments entry.但是当您有多个调试场景要查看时,不断调整Command Arguments条目非常麻烦。

I was hoping one can do similar to a cmake project in vscode, where you can edit a launch.json file that will have multiple debugging commands ready for you to select and run, each with their own arguments, for example:我希望可以做类似于 vscode 中的 cmake 项目,您可以在其中编辑launch.json文件,该文件将准备好多个调试命令供您选择和运行,每个命令都有自己的参数,例如:

{
    "name": "(Windows) Launch",
    "type": "cppvsdbg",
    "request": "launch",
    "program": "enter program name, for example ${workspaceFolder}/a.exe",
    "args": [],
    "stopAtEntry": false,
    "cwd": "${fileDirname}",
    "environment": [],
    "console": "externalTerminal"
},

Note: Answers to VS2019 are also welcomed.注意:也欢迎对 VS2019 的回答。

(See also New SDK project missing "Start External Command" in visual studio . ) (另请参阅Visual Studio 中缺少“启动外部命令”的新 SDK 项目。)

There's a new "launch profiles" dialog.有一个新的“启动配置文件”对话框。 You find it either by clicking there:您可以通过单击此处找到它: 要么在这里 or on the small down arrow next to the "Start project" element in the toolbar (and then choose the last element in the menu):或在工具栏中“开始项目”元素旁边的小向下箭头上(然后选择菜单中的最后一个元素): 在此处输入图像描述

In this new dialog, you can create an arbitrary number of startup configurations with different startup parameters.在这个新对话框中,您可以使用不同的启动参数创建任意数量的启动配置。 Very helpful for debugging console applications.对调试控制台应用程序非常有帮助。 To add a new configuration, click the "New project configuration" icon in the top left corner.要添加新配置,请单击左上角的“新建项目配置”图标。 Each entry can have different command line options.每个条目可以有不同的命令行选项。 To choose which one to start, tick it in the drop-down menu of the start button.要选择启动哪一个,请在开始按钮的下拉菜单中勾选它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM