jdk/src/linux/doc/man/jdb.1
changeset 9573 c02ff5a7c67b
parent 5865 47da38a8c0f0
child 21743 3d979da7bdf0
equal deleted inserted replaced
9572:6f64c69a7574 9573:c02ff5a7c67b
     1 ." Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
     1 ." Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
     2 ." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2 ." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3 ."
     3 ."
     4 ." This code is free software; you can redistribute it and/or modify it
     4 ." This code is free software; you can redistribute it and/or modify it
     5 ." under the terms of the GNU General Public License version 2 only, as
     5 ." under the terms of the GNU General Public License version 2 only, as
     6 ." published by the Free Software Foundation.
     6 ." published by the Free Software Foundation.
    17 ."
    17 ."
    18 ." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    18 ." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    19 ." or visit www.oracle.com if you need additional information or have any
    19 ." or visit www.oracle.com if you need additional information or have any
    20 ." questions.
    20 ." questions.
    21 ."
    21 ."
    22 .TH jdb 1 "02 Jun 2010"
    22 .TH jdb 1 "10 May 2011"
    23 
    23 
    24 .LP
    24 .LP
    25 .SH "Name"
    25 .SH "Name"
    26 jdb \- The Java Debugger
    26 jdb \- The Java Debugger
    27 .LP
    27 .LP
    28 .RS 3
       
    29 
       
    30 .LP
       
    31 .LP
    28 .LP
    32 \f3jdb\fP helps you find and fix bugs in Java language programs.
    29 \f3jdb\fP helps you find and fix bugs in Java language programs.
    33 .LP
    30 .LP
    34 .RE
       
    35 .SH "SYNOPSIS"
    31 .SH "SYNOPSIS"
    36 .LP
    32 .LP
    37 
       
    38 .LP
       
    39 .nf
    33 .nf
    40 \f3
    34 \f3
    41 .fl
    35 .fl
    42 \fP\f3jdb\fP [ options ] [ class ] [ arguments ] 
    36 \fP\f3jdb\fP [ options ] [ class ] [ arguments ] 
    43 .fl
    37 .fl
    44 .fi
    38 .fi
    45 
       
    46 .LP
       
    47 .RS 3
       
    48 
    39 
    49 .LP
    40 .LP
    50 .RS 3
    41 .RS 3
    51 .TP 3
    42 .TP 3
    52 options 
    43 options 
    58 arguments 
    49 arguments 
    59 Arguments passed to the \f2main()\fP method of \f2class\fP. 
    50 Arguments passed to the \f2main()\fP method of \f2class\fP. 
    60 .RE
    51 .RE
    61 
    52 
    62 .LP
    53 .LP
    63 .RE
       
    64 .SH "DESCRIPTION"
    54 .SH "DESCRIPTION"
    65 .LP
       
    66 
       
    67 .LP
    55 .LP
    68 .LP
    56 .LP
    69 The Java Debugger, \f3jdb\fP, is a simple command\-line debugger for Java classes. It is a demonstration of the 
    57 The Java Debugger, \f3jdb\fP, is a simple command\-line debugger for Java classes. It is a demonstration of the 
    70 .na
    58 .na
    71 \f2Java Platform Debugger Architecture\fP @
    59 \f2Java Platform Debugger Architecture\fP @
    72 .fi
    60 .fi
    73 http://java.sun.com/javase/6/docs/technotes/guides/jpda/index.html that provides inspection and debugging of a local or remote Java Virtual Machine.
    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.
    74 .LP
    62 .LP
    75 .SS 
    63 .SS 
    76 Starting a jdb Session
    64 Starting a jdb Session
    77 .LP
       
    78 .RS 3
       
    79 
       
    80 .LP
    65 .LP
    81 .LP
    66 .LP
    82 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:
    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:
    83 .LP
    68 .LP
    84 .nf
    69 .nf
   135 .LP
   120 .LP
   136 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 
   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 
   137 .na
   122 .na
   138 \f2documentation\fP @
   123 \f2documentation\fP @
   139 .fi
   124 .fi
   140 http://java.sun.com/javase/6/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 
   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 
   141 .na
   126 .na
   142 \f21.4.2 documentation\fP @
   127 \f21.4.2 documentation\fP @
   143 .fi
   128 .fi
   144 http://java.sun.com/j2se/1.4.2/docs/guide/jpda/conninv.html
   129 http://java.sun.com/j2se/1.4.2/docs/guide/jpda/conninv.html
   145 .LP
   130 .LP
   148 .LP
   133 .LP
   149 .LP
   134 .LP
   150 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.
   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.
   151 .LP
   136 .LP
   152 .RS 3
   137 .RS 3
   153 
       
   154 .LP
       
   155 .RS 3
       
   156 .TP 3
   138 .TP 3
   157 help, or ? 
   139 help, or ? 
   158 The most important \f3jdb\fP command, \f2help\fP displays the list of recognized commands with a brief description. 
   140 The most important \f3jdb\fP command, \f2help\fP displays the list of recognized commands with a brief description. 
   159 .TP 3
   141 .TP 3
   160 run 
   142 run 
   162 .TP 3
   144 .TP 3
   163 cont 
   145 cont 
   164 Continues execution of the debugged application after a breakpoint, exception, or step. 
   146 Continues execution of the debugged application after a breakpoint, exception, or step. 
   165 .TP 3
   147 .TP 3
   166 print 
   148 print 
   167 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. 
   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.
   168 .LP
   150 .br
   169 \f2NOTE: To display local variables, the containing class must have been compiled with the \fP\f2javac(1)\fP\f2 \fP\f2\-g\fP option. 
   151 .br
   170 .LP
   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
   171 \f2print\fP supports many simple Java expressions including those with method invocations, for example: 
   155 \f2print\fP supports many simple Java expressions including those with method invocations, for example: 
   172 .RS 3
   156 .RS 3
   173 .TP 2
   157 .TP 2
   174 o
   158 o
   175 \f2print MyClass.myStaticField\fP 
   159 \f2print MyClass.myStaticField\fP 
   186 o
   170 o
   187 \f2print new java.lang.String("Hello").length()\fP 
   171 \f2print new java.lang.String("Hello").length()\fP 
   188 .RE
   172 .RE
   189 .TP 3
   173 .TP 3
   190 dump 
   174 dump 
   191 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. 
   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.
   192 .LP
   176 .br
   193 The \f2dump\fP command supports the same set of expressions as the \f2print\fP command.  
   177 .br
       
   178 The \f2dump\fP command supports the same set of expressions as the \f2print\fP command. 
   194 .TP 3
   179 .TP 3
   195 threads 
   180 threads 
   196 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: 
   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: 
   197 .RS 3
       
   198 
       
   199 .LP
       
   200 .nf
   182 .nf
   201 \f3
   183 \f3
   202 .fl
   184 .fl
   203 4. (java.lang.Thread)0x1 main      running
   185 4. (java.lang.Thread)0x1 main      running
   204 .fl
   186 .fl
   205 \fP
   187 \fP
   206 .fi
   188 .fi
   207 .RE
       
   208 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, 
   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, 
   209 .TP 3
   190 .TP 3
   210 thread 
   191 thread 
   211 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. 
   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. 
   212 .TP 3
   193 .TP 3
   213 where 
   194 where 
   214 \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. 
   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.
   215 .LP
   196 .br
   216 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.  
   197 .br
   217 .RE
   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. 
   218 
   199 .RE
   219 .LP
   200 
   220 .RE
   201 .LP
   221 .SS 
   202 .SS 
   222 Breakpoints
   203 Breakpoints
   223 .LP
   204 .LP
   224 .RS 3
       
   225 
       
   226 .LP
       
   227 .LP
   205 .LP
   228 Breakpoints can be set in \f3jdb\fP at line numbers or at the first instruction of a method, for example:
   206 Breakpoints can be set in \f3jdb\fP at line numbers or at the first instruction of a method, for example:
   229 .LP
   207 .LP
   230 .RS 3
   208 .RS 3
   231 .TP 2
   209 .TP 2
   247 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".
   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".
   248 .LP
   226 .LP
   249 .LP
   227 .LP
   250 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.
   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.
   251 .LP
   229 .LP
   252 .RE
       
   253 .SS 
   230 .SS 
   254 Stepping
   231 Stepping
   255 .LP
   232 .LP
   256 .RS 3
       
   257 
       
   258 .LP
       
   259 .LP
   233 .LP
   260 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.
   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.
   261 .LP
   235 .LP
   262 .RE
       
   263 .SS 
   236 .SS 
   264 Exceptions
   237 Exceptions
   265 .LP
   238 .LP
   266 .RS 3
       
   267 
       
   268 .LP
       
   269 .LP
   239 .LP
   270 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.
   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.
   271 .LP
   241 .LP
   272 .LP
   242 .LP
   273 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.
   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.
   276 The \f2ignore\fP command negates the effect of a previous \f2catch\fP command.
   246 The \f2ignore\fP command negates the effect of a previous \f2catch\fP command.
   277 .LP
   247 .LP
   278 .LP
   248 .LP
   279 \f2NOTE: The \fP\f2ignore\fP command does not cause the debugged VM to ignore specific exceptions, only the debugger.
   249 \f2NOTE: The \fP\f2ignore\fP command does not cause the debugged VM to ignore specific exceptions, only the debugger.
   280 .LP
   250 .LP
   281 .RE
       
   282 .RE
       
   283 .SH "Command Line Options"
   251 .SH "Command Line Options"
   284 .LP
       
   285 
       
   286 .LP
   252 .LP
   287 .LP
   253 .LP
   288 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.
   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.
   289 .LP
   255 .LP
   290 .LP
   256 .LP
   333 .LP
   299 .LP
   334 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 
   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 
   335 .na
   301 .na
   336 \f2documentation\fP @
   302 \f2documentation\fP @
   337 .fi
   303 .fi
   338 http://java.sun.com/javase/6/docs/technotes/guides/jpda/conninv.html on these connection alternatives.
   304 http://download.oracle.com/javase/7/docs/technotes/guides/jpda/conninv.html on these connection alternatives.
   339 .LP
   305 .LP
   340 .SS 
   306 .SS 
   341 Options Forwarded to Debuggee Process
   307 Options Forwarded to Debuggee Process
   342 .LP
   308 .LP
   343 .RS 3
   309 .RS 3
   356 .RE
   322 .RE
   357 
   323 
   358 .LP
   324 .LP
   359 .SH "SEE ALSO"
   325 .SH "SEE ALSO"
   360 .LP
   326 .LP
   361 
       
   362 .LP
       
   363 .LP
   327 .LP
   364 javac(1), java(1), javah(1), javap(1), javadoc(1).
   328 javac(1), java(1), javah(1), javap(1), javadoc(1).
   365 .LP
   329 .LP
   366  
   330