NAME
jdb - Java debugger
SYNOPSIS
jdb [ -host hostname ] [ -password password ] [ classname ]
DESCRIPTION
The Java debugger, jdb, is a dbx-like command-line debugger
for Java classes. It uses the Java debugger API to provide
inspection and debugging of a local or remote Java inter-
preter.
Starting a jdb Session
Like dbx, there are two ways jdb can be used for debugging.
The most frequently used way is to have jdb start java(1)
with the class to be debugged. This is done by substituting
the command jdb for java(1) in the command line. For exam-
ple, to start appletviewer(1) under jdb, use the following:
example% jdb sun.applet.AppletViewer
or
example% jdb -classpath $INSTALL_DIR/classes
sun.applet.AppletViewer
When started this way, jdb invokes a second Java interpreter
with any specified parameters, loads the specified class,
and stops the interpreter before executing the first
instruction of that class.
The second way to use jdb is by attaching it to a running
Java. For security reasons, Java interpreters can only be
debugged if started with the -debug option. When started
with the -debug option, the Java interpreter displays out a
password for the Java debugger to use.
To attach jdb to a running Java interpreter (once the ses-
sion password is known), invoke it as follows:
example% jdb -host hostname -password <password>
Basic jdb Commands
The following is a list of the basic jdb commands. The Java
debugger supports other commands listed with the help com-
mand.
Please note that to browse local (stack) variables, the
class must have been compiled with the -g option.
dump Dumps an object's instance variables. Objects
are specified by their object ID (a hexade-
cimal integer).
Classes are specified by either their object
ID or by name. If a class is already loaded,
a substring can be used, such as Thread for
java.lang.Thread. If a class isn't loaded,
its full name must be specified, and the
class is loaded as a side effect. This is
needed to set breakpoints in referenced
classes before an applet runs.
The dump command supports Java expressions
such as dump 0x12345678.myCache[3].foo.
Method invocation is not currently supported.
help, or ? The most important jdb command, help displays
the list of recognized commands with a brief
description.
print Browses Java objects. The print command calls
the toString() method of the object, so it
will be formatted differently depending on
its class.
Classes are specified by either their object
ID or by name. If a class is already loaded,
a substring can be used, such as Thread for
java.lang.Thread.
The print subcommand supports Java expres-
sions, such as print MyClass.clsVar. Method
invocation is not currently supported.
threads Lists the current threads. This lists all
threads, organized by thread group. Threads
are referenced by their object ID, or if they
are in the current thread group, with the
form t@index, such as t@3.
where The where subcommand with no arguments dumps
the stack of the current thread (which is set
with the thread command). Using where all
dumps the stack of all threads in the current
thread group. Using where threadid dumps the
stack of the specified thread. The threadid
subcommand takes the form of t@index, such as
t@3. If a requested thread is suspended
(either because it's at a breakpoint or via
the suspend command), local (stack) and
instance variables can be browsed with the
print and dump commands. The up and down com-
mands select which stack frame is current.
Breakpoint Commands
Breakpoints are set in jdb in classes as follows:
clear at class:line
Removes breakpoints using a syntax similar to
stop.
cont Continues execution.
step Single step line execution.
stop at class:line
The source file line number must be speci-
fied, or the name of the method (the break-
point will then be set at the first instruc-
tion of that method).
stop at MyClass:45
Exception Commands
When an exception occurs for which there is no catch state-
ment anywhere up a Java program's stack, the Java runtime
normally dumps an exception trace and exits. When running
under jdb, however, that exception is treated as a non-
recoverable breakpoint, and jdb stops at the offending
instruction. If that class was compiled with the -g option,
instance and local variables can be printed to determine the
cause of the exception.
catch Breaks for specific exception.
Specific exceptions may be caught with the
catch command, for example:
catch FileNotFoundException
or
catch mypackage.BigTroubleException
The Java debugging facility keeps a list of
these exceptions, and when one is thrown, it
is treated as if a breakpoint had been on the
instruction that caused the exception.
ignore Removes exception classes from this list.
Please note that the ignore command does not
cause the Java interpreter to ignore specific
exceptions, only the debugger.
OPTIONS
When using jdb in place of the Java interpreter on the
command line, jdb accepts the same options as the java(1)
command.
When using jdb to attach to a running Java interpreter ses-
sion, jdb accepts these options:
-host hostname Sets the name of the host machine on which
the interpreter session is to attach when
running.
-password password
Logs in to the active interpreter session.
This is the password printed by the Java
interpreter when invoked with the -debug
option.
ENVIRONMENT VARIABLES
CLASSPATH Used to provide the system a path to user-
defined classes. Directories are separated
by colons, for example,
.:/home/avh/classes:/usr/local/java/classes
ATTRIBUTES
See attributes(5) for a description of the following attri-
butes:
__________________________________
| ATTRIBUTE TYPE| ATTRIBUTE VALUE|
|_______________|__________________|_
| Availability | SUNWjvdev |
|_______________|_________________|
SEE ALSO
java(1), javac(1), javadoc(1), javah(1), javap(1)
http://java.sun.com/
|
Закладки на сайте Проследить за страницей |
Created 1996-2025 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |