简体   繁体   English

是否可以在Visual Studio 2013中设置多个条件断点?

[英]Is it possible to set a multiple conditions Breakpoint in Visual Studio 2013?

does anyone knows if its possible to set a multiple condition breakpoint on a specific line in Visual Studio 2013 (C++) ? 有谁知道它是否可以在Visual Studio 2013(C ++)中的特定行上设置多条件断点?

I was trying using the '&&' but it didn't worked. 我正在尝试使用'&&',但它没有用。 I also couldn't find an answer on MSDN. 我也无法在MSDN上找到答案。

the breakpoint that i wanna set is inside the WindowProc, the condition that i wanna set is - message = WM_MOUSEMOVE, WPARAM = MK_LBUTTON 我想设置的断点是在WindowProc中,我想设置的条件是 - message = WM_MOUSEMOVE,WPARAM = MK_LBUTTON

thanks in advace, Igor. 感谢先生,伊戈尔。

WM_MOUSEMOVE is a macrodefinition and gets replaced in the source code by the compiler during compilation. WM_MOUSEMOVE是一个宏定义,在编译期间由编译器在源代码中替换。 It is unknown to the debugger, so you can't use it in a breakpoint condition expression; 调试器是未知的,因此您不能在断点条件表达式中使用它; use explicit number constant instead. 使用显式数字常量。

BTW, are you aware you used operator ' = ', which is not the same as ' == '...? 顺便说一句,你知道你使用了运算符' = ',这与' == ' 一样......?

Using && is allowed and should work. 使用&&是允许的,应该可行。 What's more, a lot of common C++ expressions are allowed. 更重要的是,允许使用许多常见的C ++表达式。 This page lists what is and what isn't allowed. 页面列出了什么是不允许的和什么是不允许的。

Note that using this kind of breakpoint will considerably slow down your application. 请注意,使用这种断点会大大降低应用程序的速度。 To the point where debugging is no longer feasible. 到调试不​​再可行的程度。 This might be what has led you to believe && isn't allowed. 这可能是让你相信&&不被允许的原因。 To overcome this particular problem you might want to use a construct like this: 要克服这个特殊问题,您可能需要使用如下构造:

//untested code
#ifdef _DEBUG
if(condition a && condition b)
{
    //either output something (option A)
    std::cout << "condition a and b are true"
    //or create a nop statement (option B)
    __nop(); //and set a breakpoint
    //or create a 'nop statement' with compiler warning (option C)
    int breakpoint = 0;
}
#endif

This will yield much better performance. 这将产生更好的性能。

Since this code is only compiled in when you are compiling in debug, you can leave this bit of code in (and option B would therefore be the best). 由于此代码仅在您在调试中编译时编译,因此可以保留此代码(因此选项B将是最佳的)。 If you however want to be reminded to remove the debugging clause, option C is probably the way you wanna go. 如果您想要提醒您删除调试子句,则选项C可能是您想要的方式。 As this will generate a variable breakpoint is declared but never used warning. 因为这将生成一个variable breakpoint is declared but never used警告。 As kindly suggested by borisbn. 正如borisbn所说的那样。

If you are using this statement a lot it's probably most useful to wrap it into a precompiler macro. 如果你正在使用这个语句,将它包装到预编译器宏中可能是最有用的。

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

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