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 ≪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