Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License version 2 only, as
published by the Free Software Foundation.
This code is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
version 2 for more details (a copy is included in the LICENSE file that
accompanied this code).
You should have received a copy of the GNU General Public License version
2 along with this work; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
or visit www.oracle.com if you need additional information or have any
questions.
Arch: generic
Software: JDK 8
Date: 21 November 2013
SectDesc: Basic Tools
Title: jdb.1
* Define some portability stuff
-----------------------------------------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://bugs.debian.org/507673
http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-----------------------------------------------------------------
* set default formatting
-----------------------------------------------------------------
disable hyphenation
disable justification (adjust text to left margin only)
-----------------------------------------------------------------
* MAIN CONTENT STARTS HERE *
-----------------------------------------------------------------
jdb [options] [classname] [arguments]
options Command-line options. See Options.
classname Name of the main class to debug.
arguments Arguments passed to the \f3main() method of the class.
\f3jdb MyClass
\f3When started this way, the \f3jdb command calls a second JVM with the specified parameters, loads the specified class, and stops the JVM before executing that class's first instruction.
Another way to use the \f3jdb command is by attaching it to a JVM that is already running. Syntax for starting a JVM to which the \f3jdb command attaches when the JVM is running is as follows. This loads in-process debugging libraries and specifies the kind of connection to be made.
\f3java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n MyClass
\f3You can then attach the \f3jdb command to the JVM with the following command:
\f3jdb -attach 8000
\f3The \f3MyClass argument is not specified in the \f3jdb command line in this case because the \f3jdb command is connecting to an existing JVM instead of launching a new JVM.
There are many other ways to connect the debugger to a JVM, and all of them are supported by the \f3jdb command. The Java Platform Debugger Architecture has additional documentation on these connection options.
help or ? The \f3help or \f3? commands display the list of recognized commands with a brief description.
run After you start JDB and set breakpoints, you can use the \f3run command to execute the debugged application. The \f3run command is available only when the \f3jdb command starts the debugged application as opposed to attaching to an existing JVM.
cont Continues execution of the debugged application after a breakpoint, exception, or step.
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 to find out how to get more information about an object. Note: To display local variables, the containing class must have been compiled with the \f3javac -g option. The \f3print command supports many simple Java expressions including those with method invocations, for example:
\f3print MyClass.myStaticField
\f3print myObj.myInstanceField
\f3print i + j + k (i, j, k are primities and either fields or local variables)
\f3print myObj.myMethod() (if myMethod returns a non-null)
\f3print new java.lang.String("Hello").length()
\f3
dump For primitive values, the \f3dump command is identical to the \f3print command. For objects, the \f3dump command prints the current value of each field defined in the object. Static and instance fields are included. The \f3dump command supports the same set of expressions as the \f3print command.
threads List the threads that are currently running. For each thread, its name and current status are printed and an index that can be used in other commands. In this example, the thread index is 4, the thread is an instance of \f3java.lang.Thread, the thread name is \f3main, and it is currently running.
\f34. (java.lang.Thread)0x1 main running
\f3
thread Select a thread to be the current thread. Many \f3jdb commands are based on the setting of the current thread. The thread is specified with the thread index described in the threads command.
where The \f3where command with no arguments dumps the stack of the current thread. The \f3where\f3all command dumps the stack of all threads in the current thread group. The \f3where\f3threadindex command dumps the stack of the specified thread. If the current thread is suspended either through an event such as a breakpoint or through the \f3suspend command, then local variables and fields can be displayed with the \f3print and \f3dump commands. The \f3up and \f3down commands select which stack frame is the current stack frame.
0.2i The command \f3stop at MyClass:22 sets a breakpoint at the first instruction for line 22 of the source file containing \f3MyClass.
0.2i The command \f3stop in java.lang.String.length sets a breakpoint at the beginning of the method \f3java.lang.String.length.
0.2i The command \f3stop in MyClass.<clinit> uses \f3<clinit> to identify the static initialization code for \f3MyClass.
When a method is overloaded, you must also specify its argument types so that the proper method can be selected for a breakpoint. For example, \f3MyClass.myMethod(int,java.lang.String) or \f3MyClass.myMethod().
The \f3clear command removes breakpoints using the following syntax: \f3clear MyClass:45. Using the \f3clear or \f3stop command with no argument displays a list of all breakpoints currently set. The \f3cont command continues execution.
Use the \f3catch command to cause the debugged application to stop at other thrown exceptions, for example: \f3catch java.io.FileNotFoundException or \f3catch\f3mypackage.BigTroubleException. Any exception that is an instance of the specified class or subclass stops the application at the point where it is thrown.
The \f3ignore command negates the effect of an earlier \f3catch command. The \f3ignore command does not cause the debugged JVM to ignore specific exceptions, but only to ignore the debugger.
Other options are supported to provide alternate mechanisms for connecting the debugger to the JVM it is to debug. For additional documentation about these connection alternatives, see Java Platform Debugger Architecture (JPDA) at http://docs.oracle.com/javase/8/docs/technotes/guides/jpda/index.html
-help
Displays a help message.
-sourcepath dir1:dir2: . . .
Uses the specified path to search for source files in the specified path. If this option is not specified, then use the default path of dot (.).
-attach address
Attaches the debugger to a running JVM with the default connection mechanism.
-listen address
Waits for a running JVM to connect to the specified address with a standard connector.
-launch
Starts the debugged application immediately upon startup of JDB. The \f3-launch option removes the need for the \f3run command. The debugged 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 \f3cont command to continue execution.
-listconnectors
List the connectors available in this JVM.
-connect connector-name:name1=value1
Connects to the target JVM with the named connector and listed argument values.
-dbgtrace [flags]
Prints information for debugging the \f3jdb command.
-tclient
Runs the application in the Java HotSpot VM client.
-tserver
Runs the application in the Java HotSpot VM server.
-Joption
Passes \f3option to the JVM, where option is one of the options described on the reference page for the Java application launcher. For example, \f3-J-Xms48m sets the startup memory to 48 MB. See java(1).
-v -verbose[:class|gc|jni]
Turns on verbose mode.
-Dname=value
Sets a system property.
-classpath dir
Lists directories separated by colons in which to look for classes.
-Xoption
Nonstandard target JVM option.
0.2i javac(1)
0.2i java(1)
0.2i javah(1)
0.2i javap(1)
'pl 8.5i 'bp