jdk/src/linux/doc/man/jdb.1
changeset 21743 3d979da7bdf0
parent 9573 c02ff5a7c67b
child 31876 91b22707521a
equal deleted inserted replaced
21741:8cd632761233 21743:3d979da7bdf0
     1 ." Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
     1 '\" t
     2 ." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2 .\"  Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
     3 ."
     3 .\"
     4 ." This code is free software; you can redistribute it and/or modify it
     4 .\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5 ." under the terms of the GNU General Public License version 2 only, as
     5 .\"
     6 ." published by the Free Software Foundation.
     6 .\" This code is free software; you can redistribute it and/or modify it
     7 ."
     7 .\" under the terms of the GNU General Public License version 2 only, as
     8 ." This code is distributed in the hope that it will be useful, but WITHOUT
     8 .\" published by the Free Software Foundation.
     9 ." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     9 .\"
    10 ." FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    10 .\" This code is distributed in the hope that it will be useful, but WITHOUT
    11 ." version 2 for more details (a copy is included in the LICENSE file that
    11 .\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    12 ." accompanied this code).
    12 .\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
    13 ."
    13 .\" version 2 for more details (a copy is included in the LICENSE file that
    14 ." You should have received a copy of the GNU General Public License version
    14 .\" accompanied this code).
    15 ." 2 along with this work; if not, write to the Free Software Foundation,
    15 .\"
    16 ." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    16 .\" You should have received a copy of the GNU General Public License version
    17 ."
    17 .\" 2 along with this work; if not, write to the Free Software Foundation,
    18 ." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    18 .\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    19 ." or visit www.oracle.com if you need additional information or have any
    19 .\"
    20 ." questions.
    20 .\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    21 ."
    21 .\" or visit www.oracle.com if you need additional information or have any
    22 .TH jdb 1 "10 May 2011"
    22 .\" questions.
    23 
    23 .\"
    24 .LP
    24 .\"     Arch: generic
    25 .SH "Name"
    25 .\"     Software: JDK 8
    26 jdb \- The Java Debugger
    26 .\"     Date: 21 November 2013
    27 .LP
    27 .\"     SectDesc: Basic Tools
    28 .LP
    28 .\"     Title: jdb.1
    29 \f3jdb\fP helps you find and fix bugs in Java language programs.
    29 .\"
    30 .LP
    30 .if n .pl 99999
    31 .SH "SYNOPSIS"
    31 .TH jdb 1 "21 November 2013" "JDK 8" "Basic Tools"
    32 .LP
    32 .\" -----------------------------------------------------------------
    33 .nf
    33 .\" * Define some portability stuff
    34 \f3
    34 .\" -----------------------------------------------------------------
    35 .fl
    35 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    36 \fP\f3jdb\fP [ options ] [ class ] [ arguments ] 
    36 .\" http://bugs.debian.org/507673
    37 .fl
    37 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
    38 .fi
    38 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    39 
    39 .ie \n(.g .ds Aq \(aq
    40 .LP
    40 .el       .ds Aq '
    41 .RS 3
    41 .\" -----------------------------------------------------------------
    42 .TP 3
    42 .\" * set default formatting
    43 options 
    43 .\" -----------------------------------------------------------------
    44 Command\-line options, as specified below. 
    44 .\" disable hyphenation
    45 .TP 3
    45 .nh
    46 class 
    46 .\" disable justification (adjust text to left margin only)
    47 Name of the class to begin debugging. 
    47 .ad l
    48 .TP 3
    48 .\" -----------------------------------------------------------------
    49 arguments 
    49 .\" * MAIN CONTENT STARTS HERE *
    50 Arguments passed to the \f2main()\fP method of \f2class\fP. 
    50 .\" -----------------------------------------------------------------
       
    51 
       
    52 .SH NAME    
       
    53 jdb \- Finds and fixes bugs in Java platform programs\&.
       
    54 .SH SYNOPSIS    
       
    55 .sp     
       
    56 .nf     
       
    57 
       
    58 \fBjdb\fR [\fIoptions\fR] [\fIclassname\fR]  [\fIarguments\fR]
       
    59 .fi     
       
    60 .sp     
       
    61 .TP     
       
    62 \fIoptions\fR
       
    63 Command-line options\&. See Options\&.
       
    64 .TP     
       
    65 \fIclass\fRname
       
    66 Name of the main class to debug\&.
       
    67 .TP     
       
    68 \fIarguments\fR
       
    69 Arguments passed to the \f3main()\fR method of the class\&.
       
    70 .SH DESCRIPTION    
       
    71 The Java Debugger (JDB) is a simple command-line debugger for Java classes\&. The \f3jdb\fR command and its options call the JDB\&. The \f3jdb\fR command demonstrates the Java Platform Debugger Architecture (JDBA) and provides inspection and debugging of a local or remote Java Virtual Machine (JVM)\&. See Java Platform Debugger Architecture (JDBA) at http://docs\&.oracle\&.com/javase/8/docs/technotes/guides/jpda/index\&.html
       
    72 .SS START\ A\ JDB\ SESSION    
       
    73 There are many ways to start a JDB session\&. The most frequently used way is to have JDB launch a new JVM with the main class of the application to be debugged\&. Do this by substituting the \f3jdb\fR command for the \f3java\fR command in the command line\&. For example, if your application\&'s main class is \f3MyClass\fR, then use the following command to debug it under JDB:
       
    74 .sp     
       
    75 .nf     
       
    76 \f3jdb MyClass\fP
       
    77 .fi     
       
    78 .nf     
       
    79 \f3\fP
       
    80 .fi     
       
    81 .sp     
       
    82 When started this way, the \f3jdb\fR command calls a second JVM with the specified parameters, loads the specified class, and stops the JVM before executing that class\&'s first instruction\&.
       
    83 .PP
       
    84 Another way to use the \f3jdb\fR command is by attaching it to a JVM that is already running\&. Syntax for starting a JVM to which the \f3jdb\fR 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\&.
       
    85 .sp     
       
    86 .nf     
       
    87 \f3java \-agentlib:jdwp=transport=dt_socket,server=y,suspend=n MyClass\fP
       
    88 .fi     
       
    89 .nf     
       
    90 \f3\fP
       
    91 .fi     
       
    92 .sp     
       
    93 You can then attach the \f3jdb\fR command to the JVM with the following command:
       
    94 .sp     
       
    95 .nf     
       
    96 \f3jdb \-attach 8000\fP
       
    97 .fi     
       
    98 .nf     
       
    99 \f3\fP
       
   100 .fi     
       
   101 .sp     
       
   102 The \f3MyClass\fR argument is not specified in the \f3jdb\fR command line in this case because the \f3jdb\fR command is connecting to an existing JVM instead of launching a new JVM\&.
       
   103 .PP
       
   104 There are many other ways to connect the debugger to a JVM, and all of them are supported by the \f3jdb\fR command\&. The Java Platform Debugger Architecture has additional documentation on these connection options\&.
       
   105 .SS BASIC\ JDB\ COMMANDS    
       
   106 The following is a list of the basic \f3jdb\fR commands\&. The JDB supports other commands that you can list with the \f3-help\fR option\&.
       
   107 .TP     
       
   108 help or ?
       
   109 The \f3help\fR or \f3?\fR commands display the list of recognized commands with a brief description\&.
       
   110 .TP     
       
   111 run
       
   112 After you start JDB and set breakpoints, you can use the \f3run\fR command to execute the debugged application\&. The \f3run\fR command is available only when the \f3jdb\fR command starts the debugged application as opposed to attaching to an existing JVM\&.
       
   113 .TP     
       
   114 cont
       
   115 Continues execution of the debugged application after a breakpoint, exception, or step\&.
       
   116 .TP     
       
   117 print
       
   118 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\&.
       
   119 
       
   120 \fINote:\fR To display local variables, the containing class must have been compiled with the \f3javac -g\fR option\&.
       
   121 
       
   122 The \f3print\fR command supports many simple Java expressions including those with method invocations, for example:
       
   123 .sp     
       
   124 .nf     
       
   125 \f3print MyClass\&.myStaticField\fP
       
   126 .fi     
       
   127 .nf     
       
   128 \f3print myObj\&.myInstanceField\fP
       
   129 .fi     
       
   130 .nf     
       
   131 \f3print i + j + k (i, j, k are primities and either fields or local variables)\fP
       
   132 .fi     
       
   133 .nf     
       
   134 \f3print myObj\&.myMethod() (if myMethod returns a non\-null)\fP
       
   135 .fi     
       
   136 .nf     
       
   137 \f3print new java\&.lang\&.String("Hello")\&.length()\fP
       
   138 .fi     
       
   139 .nf     
       
   140 \f3\fP
       
   141 .fi     
       
   142 .sp     
       
   143 
       
   144 .TP     
       
   145 dump
       
   146 For primitive values, the \f3dump\fR command is identical to the \f3print\fR command\&. For objects, the \f3dump\fR command prints the current value of each field defined in the object\&. Static and instance fields are included\&. The \f3dump\fR command supports the same set of expressions as the \f3print\fR command\&.
       
   147 .TP     
       
   148 threads
       
   149 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\fR, the thread name is \f3main\fR, and it is currently running\&.
       
   150 .sp     
       
   151 .nf     
       
   152 \f34\&. (java\&.lang\&.Thread)0x1 main      running\fP
       
   153 .fi     
       
   154 .nf     
       
   155 \f3\fP
       
   156 .fi     
       
   157 .sp     
       
   158 
       
   159 .TP     
       
   160 thread
       
   161 Select a thread to be the current thread\&. Many \f3jdb\fR commands are based on the setting of the current thread\&. The thread is specified with the thread index described in the threads command\&.
       
   162 .TP     
       
   163 where
       
   164 The \f3where\fR command with no arguments dumps the stack of the current thread\&. The \f3where\fR\f3all\fR command dumps the stack of all threads in the current thread group\&. The \f3where\fR\f3threadindex\fR command dumps the stack of the specified thread\&.
       
   165 
       
   166 If the current thread is suspended either through an event such as a breakpoint or through the \f3suspend\fR command, then local variables and fields can be displayed with the \f3print\fR and \f3dump\fR commands\&. The \f3up\fR and \f3down\fR commands select which stack frame is the current stack frame\&.
       
   167 .SS BREAKPOINTS    
       
   168 Breakpoints can be set in JDB at line numbers or at the first instruction of a method, for example:
       
   169 .TP 0.2i    
       
   170 \(bu
       
   171 The command \f3stop at MyClass:22\fR sets a breakpoint at the first instruction for line 22 of the source file containing \f3MyClass\fR\&.
       
   172 .TP 0.2i    
       
   173 \(bu
       
   174 The command \f3stop in java\&.lang\&.String\&.length\fR sets a breakpoint at the beginning of the method \f3java\&.lang\&.String\&.length\fR\&.
       
   175 .TP 0.2i    
       
   176 \(bu
       
   177 The command \f3stop in MyClass\&.<clinit>\fR uses \f3<clinit>\fR to identify the static initialization code for \f3MyClass\fR\&.
       
   178 .PP
       
   179 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)\fR or \f3MyClass\&.myMethod()\fR\&.
       
   180 .PP
       
   181 The \f3clear\fR command removes breakpoints using the following syntax: \f3clear MyClass:45\fR\&. Using the \f3clear\fR or \f3stop\fR command with no argument displays a list of all breakpoints currently set\&. The \f3cont\fR command continues execution\&.
       
   182 .SS STEPPING    
       
   183 The \f3step\fR command advances execution to the next line whether it is in the current stack frame or a called method\&. The \f3next\fR command advances execution to the next line in the current stack frame\&.
       
   184 .SS EXCEPTIONS    
       
   185 When an exception occurs for which there is not a \f3catch\fR statement anywhere in the throwing thread\&'s call stack, the JVM typically prints an exception trace and exits\&. When running under JDB, however, control returns to JDB at the offending throw\&. You can then use the \f3jdb\fR command to diagnose the cause of the exception\&.
       
   186 .PP
       
   187 Use the \f3catch\fR command to cause the debugged application to stop at other thrown exceptions, for example: \f3catch java\&.io\&.FileNotFoundException\fR or \f3catch\fR\f3mypackage\&.BigTroubleException\fR\&. Any exception that is an instance of the specified class or subclass stops the application at the point where it is thrown\&.
       
   188 .PP
       
   189 The \f3ignore\fR command negates the effect of an earlier \f3catch\fR command\&. The \f3ignore\fR command does not cause the debugged JVM to ignore specific exceptions, but only to ignore the debugger\&.
       
   190 .SH OPTIONS    
       
   191 When you use the \f3jdb\fR command instead of the \f3java\fR command on the command line, the \f3jdb\fR command accepts many of the same options as the \f3java\fR command, including \f3-D\fR, \f3-classpath\fR, and \f3-X\fR options\&. The following list contains additional options that are accepted by the \f3jdb\fR command\&.
       
   192 .PP
       
   193 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
       
   194 .TP
       
   195 -help
       
   196 .br
       
   197 Displays a help message\&.
       
   198 .TP
       
   199 -sourcepath \fIdir1:dir2: \&. \&. \&.\fR
       
   200 .br
       
   201 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 (\&.)\&.
       
   202 .TP
       
   203 -attach \fIaddress\fR
       
   204 .br
       
   205 Attaches the debugger to a running JVM with the default connection mechanism\&.
       
   206 .TP
       
   207 -listen \fIaddress\fR
       
   208 .br
       
   209 Waits for a running JVM to connect to the specified address with a standard connector\&.
       
   210 .TP
       
   211 -launch
       
   212 .br
       
   213 Starts the debugged application immediately upon startup of JDB\&. The \f3-launch\fR option removes the need for the \f3run\fR 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\fR command to continue execution\&.
       
   214 .TP
       
   215 -listconnectors
       
   216 .br
       
   217 List the connectors available in this JVM\&.
       
   218 .TP
       
   219 -connect connector-name:\fIname1=value1\fR
       
   220 .br
       
   221 Connects to the target JVM with the named connector and listed argument values\&.
       
   222 .TP
       
   223 -dbgtrace [\fIflags\fR]
       
   224 .br
       
   225 Prints information for debugging the \f3jdb\fR command\&.
       
   226 .TP
       
   227 -tclient
       
   228 .br
       
   229 Runs the application in the Java HotSpot VM client\&.
       
   230 .TP
       
   231 -tserver
       
   232 .br
       
   233 Runs the application in the Java HotSpot VM server\&.
       
   234 .TP
       
   235 -J\fIoption\fR
       
   236 .br
       
   237 Passes \f3option\fR 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\fR sets the startup memory to 48 MB\&. See java(1)\&.
       
   238 .SH OPTIONS\ FORWARDED\ TO\ THE\ DEBUGGER\ PROCESS    
       
   239 .TP
       
   240 -v -verbose[:\fIclass\fR|gc|jni]
       
   241 .br
       
   242 Turns on verbose mode\&.
       
   243 .TP
       
   244 -D\fIname\fR=\fIvalue\fR
       
   245 .br
       
   246 Sets a system property\&.
       
   247 .TP
       
   248 -classpath \fIdir\fR
       
   249 .br
       
   250 Lists directories separated by colons in which to look for classes\&.
       
   251 .TP
       
   252 -X\fIoption\fR
       
   253 .br
       
   254 Nonstandard target JVM option\&.
       
   255 .SH SEE\ ALSO    
       
   256 .TP 0.2i    
       
   257 \(bu
       
   258 javac(1)
       
   259 .TP 0.2i    
       
   260 \(bu
       
   261 java(1)
       
   262 .TP 0.2i    
       
   263 \(bu
       
   264 javah(1)
       
   265 .TP 0.2i    
       
   266 \(bu
       
   267 javap(1)
    51 .RE
   268 .RE
    52 
   269 .br
    53 .LP
   270 'pl 8.5i
    54 .SH "DESCRIPTION"
   271 'bp
    55 .LP
       
    56 .LP
       
    57 The Java Debugger, \f3jdb\fP, is a simple command\-line debugger for Java classes. It is a demonstration of the 
       
    58 .na
       
    59 \f2Java Platform Debugger Architecture\fP @
       
    60 .fi
       
    61 http://download.oracle.com/javase/7/docs/technotes/guides/jpda/index.html that provides inspection and debugging of a local or remote Java Virtual Machine.
       
    62 .LP
       
    63 .SS 
       
    64 Starting a jdb Session
       
    65 .LP
       
    66 .LP
       
    67 There are many ways to start a jdb session. The most frequently used way is to have \f3jdb\fP launch a new Java Virtual Machine (VM) with the main class of the application to be debugged. This is done by substituting the command \f3jdb\fP for \f3java\fP in the command line. For example, if your application's main class is MyClass, you use the following command to debug it under JDB:
       
    68 .LP
       
    69 .nf
       
    70 \f3
       
    71 .fl
       
    72  % jdb MyClass 
       
    73 .fl
       
    74 \fP
       
    75 .fi
       
    76 
       
    77 .LP
       
    78 .LP
       
    79 When started this way, \f3jdb\fP invokes a second Java VM with any specified parameters, loads the specified class, and stops the VM before executing that class's first instruction.
       
    80 .LP
       
    81 .LP
       
    82 Another way to use \f3jdb\fP is by attaching it to a Java VM that is already running. Syntax for Starting a VM to which jdb will attach when the VM is running is as follows. This loads in\-process debugging libraries and specifies the kind of connection to be made.
       
    83 .LP
       
    84 .nf
       
    85 \f3
       
    86 .fl
       
    87 \-agentlib:jdwp=transport=dt_socket,server=y,suspend=n
       
    88 .fl
       
    89 \fP
       
    90 .fi
       
    91 
       
    92 .LP
       
    93 .LP
       
    94 For example, the following command will run the MyClass application, and allow \f3jdb\fP to connect to it at a later time.
       
    95 .LP
       
    96 .nf
       
    97 \f3
       
    98 .fl
       
    99  % java \-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n MyClass
       
   100 .fl
       
   101 \fP
       
   102 .fi
       
   103 
       
   104 .LP
       
   105 .LP
       
   106 You can then attach \f3jdb\fP to the VM with the following commmand:
       
   107 .LP
       
   108 .nf
       
   109 \f3
       
   110 .fl
       
   111  % jdb \-attach 8000 
       
   112 .fl
       
   113 \fP
       
   114 .fi
       
   115 
       
   116 .LP
       
   117 .LP
       
   118 Note that "MyClass" is not specified in the \f3jdb\fP command line in this case because \f3jdb\fP is connecting to an existing VM instead of launching a new one.
       
   119 .LP
       
   120 .LP
       
   121 There are many other ways to connect the debugger to a VM, and all of them are supported by \f3jdb\fP. The Java Platform Debugger Architecture has additional 
       
   122 .na
       
   123 \f2documentation\fP @
       
   124 .fi
       
   125 http://download.oracle.com/javase/7/docs/technotes/guides/jpda/conninv.html on these connection options. For information on starting a J2SE 1.4.2 or early VM for use with \f3jdb\fP see the 
       
   126 .na
       
   127 \f21.4.2 documentation\fP @
       
   128 .fi
       
   129 http://java.sun.com/j2se/1.4.2/docs/guide/jpda/conninv.html
       
   130 .LP
       
   131 .SS 
       
   132 Basic jdb Commands
       
   133 .LP
       
   134 .LP
       
   135 The following is a list of the basic \f3jdb\fP commands. The Java debugger supports other commands which you can list using \f3jdb\fP's \f2help\fP command.
       
   136 .LP
       
   137 .RS 3
       
   138 .TP 3
       
   139 help, or ? 
       
   140 The most important \f3jdb\fP command, \f2help\fP displays the list of recognized commands with a brief description. 
       
   141 .TP 3
       
   142 run 
       
   143 After starting \f3jdb\fP, and setting any necessary breakpoints, you can use this command to start the execution the debugged application. This command is available only when \f3jdb\fP launches the debugged application (as opposed to attaching to an existing VM). 
       
   144 .TP 3
       
   145 cont 
       
   146 Continues execution of the debugged application after a breakpoint, exception, or step. 
       
   147 .TP 3
       
   148 print 
       
   149 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 \f2dump\fP command below for getting more information about an object.
       
   150 .br
       
   151 .br
       
   152 \f2NOTE: To display local variables, the containing class must have been compiled with the \fP\f2javac(1)\fP\f2 \fP\f2\-g\fP option.
       
   153 .br
       
   154 .br
       
   155 \f2print\fP supports many simple Java expressions including those with method invocations, for example: 
       
   156 .RS 3
       
   157 .TP 2
       
   158 o
       
   159 \f2print MyClass.myStaticField\fP 
       
   160 .TP 2
       
   161 o
       
   162 \f2print myObj.myInstanceField\fP 
       
   163 .TP 2
       
   164 o
       
   165 \f2print i + j + k\fP \f2(i, j, k are primities and either fields or local variables)\fP 
       
   166 .TP 2
       
   167 o
       
   168 \f2print myObj.myMethod()\fP \f2(if myMethod returns a non\-null)\fP 
       
   169 .TP 2
       
   170 o
       
   171 \f2print new java.lang.String("Hello").length()\fP 
       
   172 .RE
       
   173 .TP 3
       
   174 dump 
       
   175 For primitive values, this command is identical to \f2print\fP. For objects, it prints the current value of each field defined in the object. Static and instance fields are included.
       
   176 .br
       
   177 .br
       
   178 The \f2dump\fP command supports the same set of expressions as the \f2print\fP command. 
       
   179 .TP 3
       
   180 threads 
       
   181 List 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: 
       
   182 .nf
       
   183 \f3
       
   184 .fl
       
   185 4. (java.lang.Thread)0x1 main      running
       
   186 .fl
       
   187 \fP
       
   188 .fi
       
   189 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, 
       
   190 .TP 3
       
   191 thread 
       
   192 Select a thread to be the current thread. Many \f3jdb\fP commands are based on the setting of the current thread. The thread is specified with the thread index described in the \f2threads\fP command above. 
       
   193 .TP 3
       
   194 where 
       
   195 \f2where\fP with no arguments dumps the stack of the current thread. \f2where all\fP dumps the stack of all threads in the current thread group. \f2where\fP \f2threadindex\fP dumps the stack of the specified thread.
       
   196 .br
       
   197 .br
       
   198 If the current thread is suspended (either through an event such as a breakpoint or through the \f2suspend\fP command), local variables and fields can be displayed with the \f2print\fP and \f2dump\fP commands. The \f2up\fP and \f2down\fP commands select which stack frame is current. 
       
   199 .RE
       
   200 
       
   201 .LP
       
   202 .SS 
       
   203 Breakpoints
       
   204 .LP
       
   205 .LP
       
   206 Breakpoints can be set in \f3jdb\fP at line numbers or at the first instruction of a method, for example:
       
   207 .LP
       
   208 .RS 3
       
   209 .TP 2
       
   210 o
       
   211 \f2stop at MyClass:22\fP \f2(sets a breakpoint at the first instruction for line 22 of the source file containing MyClass)\fP 
       
   212 .TP 2
       
   213 o
       
   214 \f2stop in java.lang.String.length\fP \f2(sets a breakpoint at the beginnig of the method \fP\f2java.lang.String.length\fP) 
       
   215 .TP 2
       
   216 o
       
   217 \f2stop in MyClass.<init>\fP \f2(<init> identifies the MyClass constructor)\fP 
       
   218 .TP 2
       
   219 o
       
   220 \f2stop in MyClass.<clinit>\fP \f2(<clinit> identifies the static initialization code for MyClass)\fP 
       
   221 .RE
       
   222 
       
   223 .LP
       
   224 .LP
       
   225 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, "\f2MyClass.myMethod(int,java.lang.String)\fP", or "\f2MyClass.myMethod()\fP".
       
   226 .LP
       
   227 .LP
       
   228 The \f2clear\fP command removes breakpoints using a syntax as in "\f2clear\ MyClass:45\fP". Using the \f2clear\fP or command with no argument displays a list of all breakpoints currently set. The \f2cont\fP command continues execution.
       
   229 .LP
       
   230 .SS 
       
   231 Stepping
       
   232 .LP
       
   233 .LP
       
   234 The \f2step\fP commands advances execution to the next line whether it is in the current stack frame or a called method. The \f2next\fP command advances execution to the next line in the current stack frame.
       
   235 .LP
       
   236 .SS 
       
   237 Exceptions
       
   238 .LP
       
   239 .LP
       
   240 When an exception occurs for which there isn't a catch statement anywhere in the throwing thread's call stack, the VM normally prints an exception trace and exits. When running under \f3jdb\fP, however, control returns to \f3jdb\fP at the offending throw. You can then use \f3jdb\fP to diagnose the cause of the exception.
       
   241 .LP
       
   242 .LP
       
   243 Use the \f2catch\fP command to cause the debugged application to stop at other thrown exceptions, for example: "\f2catch java.io.FileNotFoundException\fP" or "\f2catch mypackage.BigTroubleException\fP. Any exception which is an instance of the specifield class (or of a subclass) will stop the application at the point where it is thrown.
       
   244 .LP
       
   245 .LP
       
   246 The \f2ignore\fP command negates the effect of a previous \f2catch\fP command.
       
   247 .LP
       
   248 .LP
       
   249 \f2NOTE: The \fP\f2ignore\fP command does not cause the debugged VM to ignore specific exceptions, only the debugger.
       
   250 .LP
       
   251 .SH "Command Line Options"
       
   252 .LP
       
   253 .LP
       
   254 When you use \f3jdb\fP in place of the Java application launcher on the command line, \f3jdb\fP accepts many of the same options as the java command, including \f2\-D\fP, \f2\-classpath\fP, and \f2\-X<option>\fP.
       
   255 .LP
       
   256 .LP
       
   257 The following additional options are accepted by \f3jdb\fP:
       
   258 .LP
       
   259 .RS 3
       
   260 .TP 3
       
   261 \-help 
       
   262 Displays a help message. 
       
   263 .TP 3
       
   264 \-sourcepath <dir1:dir2:...> 
       
   265 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. 
       
   266 .TP 3
       
   267 \-attach <address> 
       
   268 Attaches the debugger to previously running VM using the default connection mechanism. 
       
   269 .TP 3
       
   270 \-listen <address> 
       
   271 Waits for a running VM to connect at the specified address using standard connector. 
       
   272 .TP 3
       
   273 \-listenany 
       
   274 Waits for a running VM to connect at any available address using standard connector. 
       
   275 .TP 3
       
   276 \-launch 
       
   277 Launches the debugged application immediately upon startup of jdb. This option removes the need for using the \f2run\fP 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 \f2cont\fP to continue execution. 
       
   278 .TP 3
       
   279 \-listconnectors 
       
   280 List the connectors available in this VM 
       
   281 .TP 3
       
   282 \-connect <connector\-name>:<name1>=<value1>,... 
       
   283 Connects to target VM using named connector with listed argument values. 
       
   284 .TP 3
       
   285 \-dbgtrace [flags] 
       
   286 Prints info for debugging jdb. 
       
   287 .TP 3
       
   288 \-tclient 
       
   289 Runs the application in the Java HotSpot(tm) VM (Client). 
       
   290 .TP 3
       
   291 \-tserver 
       
   292 Runs the application in the Java HotSpot(tm) VM (Server). 
       
   293 .TP 3
       
   294 \-Joption 
       
   295 Pass \f2option\fP to the Java virtual machine used to run jdb. (Options for the application Java virtual machine are passed to the \f3run\fP command.) For example, \f3\-J\-Xms48m\fP sets the startup memory to 48 megabytes. 
       
   296 .RE
       
   297 
       
   298 .LP
       
   299 .LP
       
   300 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 
       
   301 .na
       
   302 \f2documentation\fP @
       
   303 .fi
       
   304 http://download.oracle.com/javase/7/docs/technotes/guides/jpda/conninv.html on these connection alternatives.
       
   305 .LP
       
   306 .SS 
       
   307 Options Forwarded to Debuggee Process
       
   308 .LP
       
   309 .RS 3
       
   310 .TP 3
       
   311 \-v \-verbose[:class|gc|jni] 
       
   312 Turns on verbose mode. 
       
   313 .TP 3
       
   314 \-D<name>=<value> 
       
   315 Sets a system property. 
       
   316 .TP 3
       
   317 \-classpath <directories separated by ":"> 
       
   318 Lists directories in which to look for classes. 
       
   319 .TP 3
       
   320 \-X<option> 
       
   321 Non\-standard target VM option 
       
   322 .RE
       
   323 
       
   324 .LP
       
   325 .SH "SEE ALSO"
       
   326 .LP
       
   327 .LP
       
   328 javac(1), java(1), javah(1), javap(1), javadoc(1).
       
   329 .LP
       
   330