Java Tool Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 5.00

'jdb' - The Java Debugger

This chapter provides tutorial notes on the Java debugger 'jdb'. Topics include starting 'jdb' to debug an application, running 'jdb' separately from the application, debugging remote application, debugging multi-thread application, listing and switching execution threads.

'jdb' - Java Debugger Command and Options

Starting a Debugging Session with 'jdb'

Debugging Applications with Separate 'jdb' Sessions

Debugging Java Applications Remotely

Listing Debugging Commands with 'help' Command

PrimeNumberSeeker.java - Multi-Thread Sample Program

Starting Debugging Session on a Multi-Thread Application

Stepping through Statements of the Child Thread

Checking Variable Values in a Debugging Session

Debugging the Main Thread of a Multi-Thread Application

Switching Execution Threads in a Debugging Session

Suspending Main Thread to Debug Child Thread

Conclusions:

  • "jdb" is a nice debugging tool. But it only offers a command line interface, not so easy to use. It is much more efficient to use graphical interface debugger.
  • JPDA is well designed, allowing us to debug Java applications remotely.
  • Debugging multi-thread application is tricky. The following "jdb" notes may help you.
  • Whenever one thread reaches a break point, all other threads are stopped also.
  • The command prompt tells what is the current thread.
  • "where all" tells where the execution are currently in all threads.
  • "threads" lists all the threads with thread indexes as Hex numbers.

Dr. Herong Yang, updated in 2008
'jdb' - The Java Debugger