DEV Community

Andrzej Karaś
Andrzej Karaś

Posted on • Originally published at karas.codes on

Using conditional breakpoints

This post would cover another tip that could make debugging process way easier. Imagine that we have registered a listener for some browser API, and we want to test how it works. Sometimes our normal break point won’t stop the code execution. That’s why we could use conditional breakpoints.

What’s conditional breakpoint?

It’s just line of code marked as normal breakpoint, but with additional condition applied. Thanks to that approach our code will stop there only if condition would be fulfilled. Take a look at example shown below.

Scenario 1: Across columns

Also in multithreaded languages e.g. like Java we could decide whether stop all threads or only one that is executing code for given class.

When we should use it?

We could use conditional breakpoints when:

  • we want to filter out breakpoints we don’t want to observe that time
  • we want to stop the code only in some specific cases
  • to make sure that breakpoint for event listener would stop the code execution

Top comments (0)