简体   繁体   English

Visual Studio 2013中的调试技术c ++

[英]Debugging techniques c++ in Visual Studio 2013

I'm developing in visual studio 2013, and have a couple of questions regarding debugging: 我正在Visual Studio 2013中进行开发,并且有几个关于调试的问题:

  1. Is it possible to have a group of breakpoints that I can enable/disable all together? 是否可以有一组可以一起启用/禁用的断点? Sometimes I may be working on feature 'a' and then need to work on feature 'b'. 有时我可能正在使用功能“ a”,然后需要使用功能“ b”。 Being able to group breakpoints, and disable them all at once would be very handy! 能够对断点进行分组并立即将其全部禁用将非常方便!

  2. Is it possible to have a variable with one value for the debug build, and another for the release build? 是否可能有一个变量,其中一个值用于调试版本,而另一个值用于发行版本? Working with opencv, and when I'm in the debug mode, I like to see data on the image that isn't to be shown in the release, so I've set up one bool variable to control this that I have to keep changing when switching builds! 使用opencv,当我处于调试模式时,我希望看到映像中的数据不会在发行版中显示,因此我设置了一个bool变量来控制该变量,我必须保留该变量切换构建时改变!

1 - Yes, as of VS 2010 you can label breakpoints into groups. 1-是的,从VS 2010开始,您可以将断点标记为组。

http://msdn.microsoft.com/en-us/library/vstudio/dd293674(v=vs.100).aspx http://weblogs.asp.net/scottgu/vs-2010-debugger-improvements-breakpoints-datatips-import-export http://msdn.microsoft.com/zh-CN/library/vstudio/dd293674(v=vs.100).aspx http://weblogs.asp.net/scottgu/vs-2010-debugger-improvements-breakpoints-数据提示,进出口

Briefly, right click on a breakpoint, click Edit Labels..., then either Add a new one (Ex. parser ), or select a previous one. 简短地说,右键单击一个断点,单击“编辑标签...”,然后添加一个新的(例如解析器 )或选择一个上一个。 To toggle groups by label, go to the Breakpoints window (Debug -> Windows -> Breakpoints), and change the criteria "In Column" to Labels, and type parser into Search. 要按标签切换组,请转到“断点”窗口(“调试”->“ Windows”->“断点”),并将“在列中”条件更改为“标签”,然后在“搜索”中键入解析器 Then you can toggle the results. 然后,您可以切换结果。

2 - Use conditional compilation macros 2-使用条件编译宏

#ifdef DEBUG
int verbose = 1;
#else
int verbose = 0;
#endif

For the second questions, you can use the pre-processor conditional features: 对于第二个问题,您可以使用预处理器的条件功能:

#ifdef DEBUG
// Building debug variant
#else
// Building something else
#endif

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

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