简体   繁体   中英

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++) ?

I was trying using the '&&' but it didn't worked. I also couldn't find an answer on MSDN.

the breakpoint that i wanna set is inside the WindowProc, the condition that i wanna set is - 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. 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. 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). If you however want to be reminded to remove the debugging clause, option C is probably the way you wanna go. As this will generate a variable breakpoint is declared but never used warning. As kindly suggested by borisbn.

If you are using this statement a lot it's probably most useful to wrap it into a precompiler macro.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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