Jdb, jiadobao

Source: Internet
Author: User

Jdb, jiadobao

Jdb is a simple command line debugger that can debug local or remote Java Virtual Machine.

Jdb [options] [class] [arguments] options command line parameters of the class name arguments main function debugged by class
1. Start debugging
There are two ways to start debugging: one is to start a new JVM to load the specified class and then stop executing the command; the other is to connect to a running JVM. The specific method is as follows.
(1) C:\> jdb MyClass(2) C:\> java -agentlib:jdwp=transport=dt_shmem,address=jdbconn,server=y,suspend=n MyClass  C:\> jdb -attach jdbconn
2. Basic jdb operation commands
Help, or? Display help information run [class [args] execute main method threads to list running thread <thread id> set default thread where dump thread stack print display Java object (brief description) or the original data type value. To display local variables, you must add the-g parameter print to support simple Java expressions during compilation, as shown below: print MyClass. myStaticField print myObj. myInstanceField print I + j + k (I, j, k are primities and either fields or local variables) print myObj. myMethod () (if myMethod returns a non-null) print new java. lang. string ("Hello "). length () dump the print value of the original type. The object prints the current value of each field (static and instance, the same as print supports expressions locals to output the current stack frame local variable classes to list currently known classes class <class id> display class details methods <class id> List class methods fields <class id> lists the class fields stop in <class id>. <method> [(argument_type,...)] in the method, set the breakpoint stop at <class id>: <line> in a line, set the breakpoint stop at MyClass: 22 (set the breakpoint in MyClass 22nd) stop in java. lang. string. length (in String. the length method sets the breakpoint) stop in MyClass. <init> (MyClass constructor) stop in MyClass. <clinit> (MyClass static block initialization method) clear <class id>. <method> [(argument_type,...)] clear the breakpoint clear <class id> of a method: <line> clear a line of breakpoint clear list all breakpoint step execute to next line execute current stack frame next line cont from breakpoint continue execute exit
3. command line options
# Jdb also recognizes many java command options, such as-D,-classpath,-X <option> (non-standard VM options).-help displays help information-sourcepath <dir1: dir2:...> search for the source file in the specified path. By default, the file is in the current directory-connect <connector-name >:< name1 >=< value1> ,... attached parameters connect to the target JVM-tclient Java HotSpot VM (Client)-tserver Java HotSpot VM (Server)-Joption to pass options to JVM to run jdb, such as-J-Xms48m to set heap size
4. debug Hello World

For more information, see jdb



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.