Differences between version 4 and predecessor to the previous major change of jdb(1).
Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History
Newer page: | version 4 | Last edited on Sunday, August 10, 2003 5:11:26 pm | by CraigBox | Revert |
Older page: | version 3 | Last edited on Sunday, August 10, 2003 4:49:55 pm | by PerryLorier | Revert |
@@ -8,241 +8,130 @@
;options: Command-line options.
;class:Name of the class to begin debugging.
-;arguments:Arguments passed to the main() method of
-
class.
+;arguments:Arguments passed to the main() method of class.
!!!DESCRIPTION
-;:
The Java debugger, jdb, is a simple command-line debugger
-
for Java classes. It is a demonstration of the Java Platform Debugger Architecture that provides inspection and
+
+
The Java debugger, jdb, is a simple command-line debugger for Java classes. It is a demonstration of the Java Platform Debugger Architecture that provides inspection and
debugging of a local or remote Java Virtual Machine.
-;
Starting a jdb Session:
-
There are many ways to start a jdb session. The most frequently used way is to have jdb launch a new Java Virtual
-
Machine (VM) with the main class of the application to be
-
debugged. This is done by substituting the command jdb
-
for java(1) in the command line. For example, if your
-
application's main class is !MyClass, you use the following
-
command to debug it under jdb:
-%%%
-example% jdb !MyClass
-%%%
-When started this way, jdb invokes a second Java VM with
-any specified parameters, loads the specified class, and
-stops the VM before executing that class's first instruc
-tion.
+Starting a jdb Session: There are many ways to start a jdb session. The most frequently used way is to have jdb launch a new Java Virtual Machine (VM) with the main class of the application to be debugged. This is done by substituting the command jdb for java(1) in the command line. For example, if your application's main class is !MyClass, you use the following command to debug it under jdb:
+
+ example% jdb !MyClass
+When started this way, jdb invokes a second Java VM with any specified parameters, loads the specified class, and stops the VM before executing that class's first instruction.
-;:
Another way to use jdb is by attaching it to a Java VM
-
that is already running. A VM that is to be debugged with
-
jdb must be started with the following options:
+Another way to use jdb is by attaching it to a Java VM that is already running. A VM that is to be debugged with jdb must be started with the following options:
-|option
|purpose
+|Option
|Purpose
|-Xdebug| Enables debugging support in the VM.
|-Xrunjdwp:transport=dt_socket,server=y,suspend=n|Loads in-process debugging libraries and specifies the kind of connection to be made.
-%%%
-For example, the following command will run the !MyClass
-application and allow jdb to connect to it at a later
-time:
-example%
jdb -Xdebug \
+For
example, the following command will run the !MyClass application and allow
jdb to connect to it at a later time:
--Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
+ example% jdb -Xdebug
-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
You can then attach jdb to the VM with the following commmand:
-example% jdb -attach 8000
+
example% jdb -attach 8000
-;:
Note that !MyClass is not specified in the jdb command line
-
in this case because jdb is connecting to an existing VM
-
instead of launching a new one.
+Note that !MyClass is not specified in the jdb command line in this case because jdb is connecting to an existing VM instead of launching a new one.
-;:
There are many other ways to connect the debugger to a VM,
-
and all of them are supported by jdb. The Java Platform
-
Debugger Architecture has additional documentation on
+There are many other ways to connect the debugger to a VM, and all of them are supported by jdb. The Java Platform Debugger Architecture has additional documentation on
these connection options.
-;
Basic jdb Commands:
-The following is a list of the basic jdb commands.The
-Java debugger supports other commands listed with the help
-command.
+!
Basic jdb Commands:
-Notice that to display local (stack) variables,
the class
-must have been compiled
with the javac -g option
.
+The following is a list of
the basic
jdb commands. The Java debugger supports other commands listed
with the help command
.
-;cont:Continues
execution of
the debugged application after a breakpoint, exception, or step
.
+Notice that to display local (stack) variables, the
class must have been compiled with
the javac -g option
.
-;dump:For primitive values, this command is identical to print. For objects, it prints the current value of each field defined in the object. Static and instance fields are included.
+;__cont__:Continues execution of the debugged application after a breakpoint, exception, or step.
+;__
dump__
:For primitive values, this command is identical to print. For objects, it prints the current value of each field defined in the object. Static and instance fields are included. %%% The dump command supports the same set of expressions as the print command.
+;__help, or ?__: As the most important jdb command, help displays the list of recognized commands with a brief description.
+;__print__:Displays Java objects and primitive values. For variables or fields of primitive types, the actual value is printed. For objects, a short description is printed. See the dump command for getting more information about an object
.
- The
dump
command supports the same set of
- expressions as the print command
.
+print supports many simple Java expressions including those
with
method
invocations
. For example:
-;help, or ?
: As the most
important
jdb
command,
help
- displays
the
list
of recognized commands
- with
a brief description
.
+ print !MyClass.myStaticField
+ print myObj.myInstanceField
+ print i + j + k
+
;:where i, j, and k
are
primitives
and
either
fields
or
local variables.
+ print
myObj.myMethod()
+;:if myMethod returns
a non-null.
+ print new java.lang.String("Hello")
.length()
-;print
:Displays Java objects and primitive values
.
- For variables or fields
of primitive types,
-
the actual value is printed
. For
objects,
- a
short
description
is printed
. See
the
- dump command for getting
more
information
- about
an object
.
+;__thread__
: Selects a thread to be the current thread
. Many jdb commands are based on the setting
of the current thread
. The thread is specified with the thread
index
described
in
the threads command
.
+;__threads__: Lists
the threads that are currently running.
For each thread, its name and current status are printed, as well as
an index that can be used for other commands
. For example:
- print supports many simple Java expressions
- including those with method invocations
.
- For example:
+ 4
. (java.lang.Thread)0x1 main running
- ·
print MyClass
.myStaticField
- · print myObj
.myInstanceField
- ·
print
i
+ j + k
... where i, j
, and k
- are primitives
and either
fields or
- local variables
.
- ·
print
myObj.myMethod()
... if myMethod
- returns a non-null.
- ·
print new
- java.lang.String
("Hello"
).length()
+;: In this example, the thread index is 4, the
thread is an instance of
java
.lang
.Thread,
the
thread
name
is main
, and it is currently running
+;__run__:
After starting jdb,
and setting any
necessary breakpoints, use this command to start the execution of the debugged
application
. This
command
is
available only when jdb launches
the debugged application
(as opposed to attaching to an existing VM
).
-;thread
: Selects
a thread to be
the current thread.
- Many jdb commands are based on
the setting
-
of the current thread. The
thread is spec
- ified with
the thread index
described
in
-
the threads
command.
+;__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 threadindex dumps the stack of the specified
thread. If
the current
thread is
suspended (either through an event such
as a
breakpoint or through
the suspend
command), local variables and fields can be displayed with the print and dump commands. The up and down commands select which stack frame is current
.
-;threads: Lists the threads that are currently run
- ning. For each thread, its name and cur
- rent status are printed, as well as an
- index that can be used for other commands.
- For example:
+!Breakpoint Commands
-4
. (java.lang.Thread)0x1 main running
+Breakpoints are set in jdb at line numbers or at the first instruction of a method
. For example:
- In this example, the thread index is 4, the
- thread is an instance of
java.lang.Thread,
-
the thread
name
is
main, and it is cur
- rently running
+ stop at !MyClass:22
+Sets a breakpoint at
the first instruction
for
line
22 of the source file containing !MyClass.
-;run:
After starting jdb, and setting any
neces
- sary breakpoints, use this command to start
-
the execution
of the debugged application
.
- This command is available only when jdb
- launches the debuggedapplication(as
- opposed to attaching to an existing VM)
.
+ stop in java.lang.String.length
+Sets a breakpoint at
the beginning
of the method java.lang
.String.length
.
-*whereThe
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 threadindex dumps
the stack of the
- specified thread. If the current thread is
- suspended (either through an event such as
- a breakpoint or through the suspend com
- mand), local variables and fields can be
- displayed with the print and dump commands.
- The up and down commands select which stack
- frame is current
.
+ stop
in !MyClass
.init
+init identifies
the !MyClass
constructor
.
-;Breakpoint Commands:
-;:Breakpoints are set
in jdb at line numbers or at the first
-instruction of a method
. For example:
+ stop
in !MyClass.clinit
+clinit identifies the static initialization code for !MyClass
.
-stop at MyClass:22Sets
a breakpoint at
the first
- instruction
for line 22 of the
- source file containing MyClass.
+If
a method is overloaded, you must also specify its argument types so that
the proper method can be selected
for breakpoint.
For example,
-stop in java.lang.String.length
- Sets a breakpoint at
the begin
- ningofthemethod
- java.lang.String.length.
-
-stop in MyClass.init init identifies the MyClass con
- structor.
-
-stop in MyClass.clinitclinit identifies the static ini
- tialization code for MyClass.
-
-;:If a method is overloaded, you must also specify its argument types so that the proper method can be selected for a
-breakpoint. For example,
-
-
MyClass.myMethod(int,java.lang.String)
+ !
MyClass.myMethod(int,java.lang.String)
or
- MyClass.myMethod()
+ !
MyClass.myMethod()
-;:
The clear command removes breakpoints using a syntax as in
-
clearMyClass:45. Using the clear command with no argument
-
displays a list of all breakpoints currently set.The
+The clear command removes breakpoints using a syntax as in clearMyClass:45. Using the clear command with no argument displays a list of all breakpoints currently set.The
cont command continues execution.
-;
Stepping Commands:
-The step command advances execution to the next line,
-
whether it is in the current stack frame or a called
-
method.The next command advances execution to the next
+!
Stepping Commands:
+
+The step command advances execution to the next line, whether it is in the current stack frame or a called method.The next command advances execution to the next
line in the current stack frame.
-;
Exception Commands:
-When an exception occurs for which there is no catch
-statement anywhere in the throwing thread's call stack,
-the VM normally prints an exception trace and exits. When
-running under jdb, however, control returns to jdb at the
-offending throw. Use jdb to determine the cause of the
-exception.
+!
Exception Commands
-;
catch:Causes
the debugged application
to stop
at
- other thrown exceptions
. For example:
+When an exception occurs for which there is no
catch statement anywhere in
the throwing thread's call stack, the VM normally prints an exception trace and exits. When
+running under jdb, however, control returns
to jdb
at the offending throw
. Use jdb to determine the cause of the exception.
-catch java
.io.FileNotFoundException
+;__
catch__:Causes the debugged application to stop at other thrown exceptions
. For example:
- or
+ catch java.io.!FileNotFoundException
+;:
or
+ catch mypackage.!BigTroubleException
-catch mypackage
.!BigTroubleException
+;: Any exception which is an instance of the specified class (or of a subclass) will stop the application at the point where it is thrown
.
- Any exception which is an instance
of the
- specified
class
(or
of
a subclass) will
- stop
the application at the point where it
- is thrown
.
+;__ignore__:
Negates the effect
of a previous catch command.
Notice that
the ignore command
does not
cause
the
debugged VM to ignore specific exceptions, only
the debugger
.
-;ignore: Negates the effect of a previous catch command. Notice that the ignore command does
- not cause the debugged VM to ignore spe
- cific exceptions, only the debugger.
+!!OPTIONS
-!!!OPTIONS
-;:
When using jdb in place of the Java application launcher
-
on the command line, jdb accepts many of the same options
-
as the java(1) command, including -D, -classpath, and
-
-Xoption.
+When using jdb in place of the Java application launcher on the command line, jdb accepts many of the same options as the java(1) command, including -D, -classpath, and -Xoption.
The following additional options are accepted by jdb:
--sourcepath dir1:dir2:...
-
Uses the given path in searching for source
-
files in the specified path.If this
-
option is not specified, the default path
-
of "." is used.
-
-;-attach address:Attaches the debugger to previously runningVM using the default connection mechanism.
-
-;-launch:Launches the debugged application immediately upon startup of jdb. This option
-
removes the need for using the run command.
-
The debuged application is launched and
-
then stopped just before the initial application class is loaded. At that point, you can set any necessary breakpoints and use
-
the __cont__ command to continue execution.
-
-;-J option: Pass option to the Java virtual machine,
-
where option is oneoftheoptions
-
described on the man page for the java
-
application launcher, java(1). For example,
-
-J-Xms48m sets the startup memory to 48
-
megabytes. It is a common convention for -J
-
to pass options to the underlying virtual
-
machine.
-
+;__
-sourcepath dir1:dir2:...__:
Uses the given path in searching for source
files in the specified path.If this option is not specified, the default path
of "." is used.
+;__
-attach address__
:Attaches the debugger to previously runningVM using the default connection mechanism.
+;__
-launch__
:Launches the debugged application immediately upon startup of jdb. This option
removes the need for using the run command. The debuged application is launched and
then stopped just before the initial application class is loaded. At that point, you can set any necessary breakpoints and use the __cont__ command to continue execution.
+;__
-J option__
: Pass option to the Java virtual machine,
where option is oneoftheoptions
described on the man page for the java application launcher, java(1). For example,
-J-Xms48m sets the startup memory to 48
megabytes. It is a common convention for -J
to pass options to the underlying virtual
machine.
-;:
Other options are supported for alternate mechanisms for
-
connecting the debugger and the VM it is to debug. The
-
Java Platform Debugger Architecture has additional docu
+Other options are supported for alternate mechanisms for connecting the debugger and the VM it is to debug. The Java Platform Debugger Architecture has additional docu
mentation on these connection alternatives.
-!
!!SEE ALSO
+!!SEE ALSO
java(1), javac(1), javadoc(1), javah(1), javap(1)