liveBook · Manning

Conditional breakpoint

As explained in Troubleshooting Java: Read, debug, and optimize JVM applications

A debugger breakpoint configured to evaluate a condition or perform an action, such as logging, without necessarily pausing program execution.

A conditional breakpoint pauses execution at a chosen line only when its Boolean condition is true. It filters out cases that do not matter to your investigation, so you can focus on relevant values without stepping through every execution. section 3.1

Use a conditional breakpoint to:

  • Pause only when a variable has the value you want to investigate, such as when sum is zero. section 3.1
  • Log selected values or a stack trace without suspending execution or adding log instructions to the code. section 3.2

Investigating a zero sum

In a method that sums digits extracted from strings, set a breakpoint on the line handling sum and make its condition sum == 0. The debugger skips other cases and pauses when the value matches. section 3.1

Figure 3.1 Using a conditional breakpoint to pause the execution just for specific cases. In this figure, we want to pause the execution on line 14 only if sum is zero. We can apply a condition on the breakpoint that instructs the debugger to consider that breakpoint only if the given state is true. This helps you more quickly get to a scenario you want to investigate.

See how a condition limits pauses to the cases relevant to an investigation. section 3.1

How Troubleshooting Java: Read, debug, and optimize JVM applications covers it

How deep it goes
Defines Boolean-triggered pauses and demonstrates filtering and non-pausing logs, without detailing debugger internals.
Examples
Uses a Java digit-summing method, a zero-value condition, and logs showing an empty list and stack trace.
What it assumes
Assumes familiarity with basic debugger navigation while defining conditional breakpoints directly.
What you can do after
Diagnose specific execution cases by pausing on matching values or logging details without suspending execution.
How it connects
Connects debugger navigation with logging as complementary ways to investigate program execution.

Also explained in

Compare how 2 books explain conditional breakpoint →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Troubleshooting Java: Read, debug, and optimize JVM applications. The section links point to the parts of the book it draws on.