Conditional Breakpoints

Adding a simple breakpoint at a line will stop the running programming whenever that line of code is hit. But this might not be the requirement every time. Suppose we want to add a kind of breakpoint on a line that will get hit only when a condition is met, not always.

Let’s understand by example. Check the code below,

Now suppose we want to set the breakpoint at line 8 and we want to get it hit when val is 50. To do that we need to add breakpoint with following command,


For Example,

After this breakpoint when application runs, line number 8 will be hit many times before value of va is 50. But breakpoint will be hit on this line only when value of val is 50.


If you check the current list of breakpoints, it will explain the stuff too i.e.


Watchpoints is a kind of breakpoint but it is set on a variable instead of any line. Suppose you set the watchpoint on a variable val i.e.

Then whenever value of val will change watchpoint will be hit and it will display the old and new values. For example,

Disable and Enabling Breakpoints or watchpoints

A watchpoint can be enbaled and disabled by using enable and disable command i.e.

Python Recommendations:

C++ & C++11 Recommendations:

If you didn't find what you were looking, then do suggest us in the comments below. We will be more than happy to add that.

Subscribe with us to join 1500+ Python & C++ developers, to get more Tips &  Tutorials like this.