Jdb-the Java Debugger

Source: Internet
Author: User

JDB is a simple command-line debugger that can debug a local or remote Java Virtual machine.

jdb [Options] [class] [Arguments]options command-line arguments class-debug Classes name arguments main function parameters
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 when you start executing the instruction, and the other is to connect to a running JVM. Here's how.
(1) c:\> jdb MyClass (2) c:\> java-agentlib:jdwp=transport=dt_shmem,address=jdbconn,server=y,suspend=n MyClass C :\> Jdb-attach Jdbconn
2. JDB Basic Operation command
Help, or? Display Help information run [class [args]] executes the main method threads lists running threads thread <thread id> setting default thread where dump thread stack print display Java object (short description) or raw data type value, to display local variables at compile time you need to add the-G parameter to print support for simple Java expressions, as follows: Print Myclass.mystaticfield print Myobj.myinstancefield PR int i + j + k (I, J, K is primities and either fields or local variables) print Myobj.mymethod () (If MyMethod returns A non-null) print new java.lang.String ("Hello"). Length () Dump original type print value, object prints the current value of each field (static and instance), with print also supports expression locals output current stack frame local Variable classes lists the currently known classes Class <class id> display Class details methods <class id> List class methods fields <class id> List class field stop in &  Lt;class id>.<method>[(Argument_type,...)] Set a breakpoint in the method stop at <class id>:<line> set a breakpoint on a line stop at myclass:22 (set a breakpoint on the MyClass line 22nd) stop in java.lang.String. Length (set breakpoint in String.Length method) stop in Myclass.<init> (MyClass constructor) stop in Myclass.<clinit> (MyClass static block initial  Method of Initiation) Clear <class id>.<method>[(Argument_type,...)] Clears the breakpoint of a method clear &Lt;class Id>:<line> Clears a line breakpoint clear lists all breakpoints step execution to the next line next executes the current stack frame next line cont Continue execution exit from the breakpoint 
3. Debug Hello World

For more information, please refer to: jdb

Jdb-the Java Debugger

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.