JDB Tutorial
- Start jdb. After loading, a ">" prompt will be displayed,
indicating that there is currently no default thread.
- Type "help" to show the list of commands available in jdb.
- Type "threadgroups" to show the list of threadgroups running.
The "system" and "main" threadgroups should be present.
- Try printing the "system" threadgroup, by typing "print" and
the object_id. The object_id is the eight digit hexadecimal
number following the class name, java.lang.ThreadGroup. The print
command displays the object using its toString() method.
- List the threads in the current threadgroup ("main") by typing
"threads". Only one thread is currently running in this threadgroup.
("threads system" will show all the threads we don't want you to
play with ;-)
- Try dumping the "main" thread, using the dump command and
either the thread's object_id, or the shorthand notation for threads:
t@<thread_number> (in this case, t@1).
- Object variables can be printed as well. Try printing the main
threadgroup with "print t@1.group". To see how many threads that
threadgroup supports, use "print t@1.group.nthreads".
- List the classes which are currently loaded with the "classes"
command. (It's amazing how many classes are loaded for an empty application.)
- Try printing or dumping a class to see its class variables and
constants, such as "dump Thread". Technically, that class name is
really java.lang.Thread, but jdb will make its best guess if you
specify a partial name.
- Dump the main thread's stack by specifying "where t@1". Each
line is a separate stack frame whose display varies slightly depending
on how that file was compiled. Every line displays the full method
name and signature. The first line then shows a stack frame where the
class was optimized and has no line number information, while the next
line shows one with line numbers.
- You are finished! Type "quit" to exit jdb.
Copyright © 1995, Sun Microsystems, Inc.
Last updated September 5, 1995.