Nicolas Holthaus Nicolas Holthaus - 1 month ago 8
C++ Question

break when watched expression becomes true

I'm using

visual studio code
with the
c++
extension and
gnu
debugger on ubuntu 14.04.

I'm setting a watch expression in my program, which works as expected, but I'd like to trigger the debugger to break when that condition becomes true. How can you do that with
visual studio code
? The documentation is pretty thin on this subject.

Answer

Why don't you add a block that you can break at?

For example, make a condition:

while(true)
{
    //stuff is happening
    if(condition_happened)
    {
        std::cout<<"things happened"<<std::endl; //break here
    }
}
Comments