Chapter 3: Finding problem root causes using advanced debugging techniques
This introduction previews advanced debugger approaches for investigating code more efficiently.
After this chapter you will be able to
- Conditional breakpoint investigation. Explain how conditional breakpoints help investigate code that behaves unexpectedly for specific values.
- Boolean condition configuration. Describe how to configure the example conditional breakpoint in IntelliJ IDEA and explain what happens when sum is zero.
- Non-suspending breakpoint logging. Explain how a breakpoint can log investigation details without pausing execution, using the section’s example.
- Choosing an investigation approach. Distinguish when to use conditional breakpoints versus changing variable values during debugging, including the trade-off as changes become extensive.
- Changing paused variable values. Describe how to change an in-scope variable in IntelliJ IDEA and trace the effect when execution continues.
- Frame dropping and stepping out. Distinguish dropping an execution frame from stepping out, and explain why replaying a call can aid an investigation.
- External changes during replay. Explain why dropping a frame cannot reliably replay code that has changed external data, using the file-creation example.
What it builds on
- Navigating code with the debugger (chapter 2) · Navigating execution with the debugger
- What is the execution stack trace, and how do I use it? (chapter 2) · Execution stack traces
Section by section
Introduction
This introduction previews advanced debugger approaches for investigating code more efficiently.
3.1 Minimizing investigation time with conditional breakpoints
This section explains how conditional breakpoints focus debugging on specific cases, how to configure them, and their performance and IDE-related limitations.
- Conditional breakpoint investigation: Explain how conditional breakpoints help investigate code that behaves unexpectedly for specific values.
Why it matters: This lets you focus on a rare or unpredictable case without manually stepping until it appears. - Boolean condition configuration: Describe how to configure the example conditional breakpoint in IntelliJ IDEA and explain what happens when sum is zero.
Why it matters: A correctly configured condition gets the debugger to stop at the case you want to inspect. - Conditional breakpoint performance cost: Explain why conditional breakpoints can slow execution and how the section recommends limiting that cost.
Why it matters: Limiting conditional breakpoints helps keep the investigation from slowing the app unnecessarily. - Conditional breakpoint logging support: Describe the conditional logging use of breakpoints and the IDE limitation noted in the section.
Why it matters: Knowing that logging support differs by IDE helps you choose an available investigation approach.
Key terms: conditional breakpoint, step over, Boolean expression, sum == 0, IntelliJ IDEA, conditional breakpoints, breakpoint conditions, expression values, stack traces
3.2 Using breakpoints that don’t pause the execution
This section explains how to use a non-suspending breakpoint to log execution details for later investigation.
- Non-suspending breakpoint logging: Explain how a breakpoint can log investigation details without pausing execution, using the section’s example.
Why it matters: This lets you collect clues about execution without stopping the app or adding log instructions.
Key terms: conditional breakpoint, suspend, execution stack trace, digits variable
3.3 Dynamically altering the investigation scenario
This section shows how to change variables during debugging and when that approach is useful compared with conditional breakpoints.
- Choosing an investigation approach: Distinguish when to use conditional breakpoints versus changing variable values during debugging, including the trade-off as changes become extensive.
Why it matters: Choosing the right approach can save investigation time without making the scenario unnecessarily complex. - Changing paused variable values: Describe how to change an in-scope variable in IntelliJ IDEA and trace the effect when execution continues.
Why it matters: Changing a value while paused lets you observe how the app behaves under a different condition. - Stack trace representations: Explain how visual and textual stack traces convey the execution path and why the textual form is useful.
Why it matters: A textual stack trace can preserve the execution path for investigation outside the debugger’s visual display.
Key terms: conditional breakpoints, changing data on the fly, variables’ values, variables in scope, debugger, step over, extractDigits(), execution stack trace, visual representation, text representation
3.4 Rewinding the investigation case
This section explains how to replay a method call by dropping a debugger frame, how that differs from stepping out, and why external changes make replay risky.
- Frame dropping and stepping out: Distinguish dropping an execution frame from stepping out, and explain why replaying a call can aid an investigation.
Why it matters: The distinction lets you replay a confusing call rather than simply finish it. - IntelliJ drop frame operation: Describe how to drop the current execution frame in IntelliJ IDEA.
Why it matters: This gives you a practical way to replay a call during a debugging session. - External changes during replay: Explain why dropping a frame cannot reliably replay code that has changed external data, using the file-creation example.
Why it matters: A replay can mislead you or repeat an external action because rewinding execution does not rewind the outside world.
Key terms: dropping an execution frame, execution stack trace, stepping out, investigation plan, Drop Frame, dropping the frame, external changes, filesystem, Files.createFile()
3.5 Summary
Where this is used later
- What is remote debugging? (chapter 4) · Conditional breakpoints as a debugging technique.
Concepts explained in this chapter
- drop frameA debugger operation that removes one or more active call-stack frames, allowing execution to return to an earlier call and replay it.
- conditional breakpointA debugger breakpoint configured to evaluate a condition or perform an action, such as logging, without necessarily pausing program execution.
- runtime variable modificationRuntime variable modification is changing a program variable’s value while the program is paused during debugging.
- external changeA change to state outside an application's internal memory that cannot be undone merely by rewinding its debugger execution.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
