liveBook · Manning

Debugger

As explained in Troubleshooting Java, Second Edition

A debugger is a software tool that pauses program execution and allows code to be run step by step while observing state changes.

A debugger pauses program execution at a chosen instruction, lets you run code step by step, and exposes how values change. It reduces the cognitive effort of following non-linear logic and helps investigate behavior, not only bugs. section 1.1 section 2.2

Use a debugger when you know which logic to investigate and need to connect instructions with runtime data.

  • Place a breakpoint on the first unclear instruction, run the application under the debugger, and inspect variables in scope and the execution stack. section 2.2
  • Step over to continue within the current method, step into a called method when its behavior is unclear, and step out to return to the previous investigation plan. section 2.2.2
  • Avoid relying on it alone when the output source is unknown, performance is poor, the application has crashed, execution is multithreaded, or timing affects behavior; use profiling, logging, stubs, or thread dumps as appropriate. section 2.3

Tracing a decoder

Given a Java Decoder.decode method that extracts digits from each input string and sums them, set a breakpoint at the first unclear extraction line. Step over it to inspect digits and the running total; step into extractDigits() only if the resulting value remains unexplained. Use step out to return without manually traversing every instruction. section 2.2 section 2.2.2

Figure 1.4 Using a debugger, you can pause the execution before a particular instruction and then observe how the app’s logic changes the data by manually running the instructions step by step.

Shows the debugger pausing before an instruction and revealing data changes through manual, step-by-step execution. section 1.2.1

How Troubleshooting Java, Second Edition covers it

How deep it goes
Explains breakpoints, state inspection, expression evaluation, and navigation, but defers unknown execution sources and unsuitable runtime conditions.
Examples
Uses a Java Decoder method, partial database insertion, breakpoints, variable values, stack traces, and step-navigation operations.
What it assumes
Assumes language fundamentals and a known logic area, while requiring other techniques when the relevant code location is unknown.
What you can do after
Diagnose known logic and output problems by controlling execution, observing state, evaluating expressions, and narrowing unclear instructions.
How it connects
Connects debugging with code investigation, breakpoints, profilers, logging, stubs, thread dumps, and AI assistants.

Also explained in

Compare how 6 books explain debugger →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Troubleshooting Java, Second Edition. The section links point to the parts of the book it draws on.