Using conditional breakpoints
tl;dr:
Tip how to simplify debugging process by 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.
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