What Is an HTML Debugger?

JDB is a text- and command-line-based debugging tool (such as Sun JDB); although there are some good debugging tools available today, the Java Debugger (JDB) provides some advantages. Most importantly, JDB is freely available and platform independent. The disadvantage is that it only has a command-line format, which some developers find primitive and difficult to use. Some IDEs have built GUI interfaces into JDB debugging APIs (such as Jikes). JDB is part of the JDK installation. It has been enhanced in the Java 2 platform.

jdb

(JAVA debugger)

Right!
JDB is text and command line based
1. ** Command List **
Connectors-lists the connectors and transmitters available in this VM
4.
17. args = instance of java.lang.String [0] (id = 323) 18. Local variables: 19. a = 2 20. b = 3
21. main [1] next 22.>
23. Completed steps: "thread = main", jvm.init.Example5.main (), line = 8 bci = 10 24.
25. main [1]
First we write the simplest applet, but it contains some of the most basic object-oriented elements. class test {
int a; int b;
test (int aa, int bb) {
a = aa; b = bb;}
int add ()
{return a + b;}}
public class hehe
{
public static void main (String args []) {
int a = 2; int b = 3; int c = a + b;
System.out.println (c); test kk = new test (1,2); System.out.println (kk.add ());}}
After saving as hehe.java, compile with javac -g hehe.java. The parameter g is used to generate various debugging information, and debugging cannot be used without it. If you encounter problems here, please refer to the Helloworld guide. The above program can be passed,
Can run directly with java hehe. The following uses this example to talk about the use of JDB.
First type jdb hehe. If the following message appears, the system did not find the debugging class. At this point you can use the java -classpath. Hehe command. C: \ javasource> jdb hehe Initializing jdb ... hehe not found>
If a message appears, it indicates that debugging has started and everything is normal. If you are debugging an applet, use the appletviewer -debug hehe.html command to debug C: \ javasource> jdb -classpath. Hehe Initializing jdb ... 0xb0: class (hehe)>
Recall that debugging in VC should be setting breakpoints and then tracking.
The same is true in Java. Use the stop command to set the breakpoint. Then use the run command to start debugging, run the program to the breakpoint, where the breakpoint is set in the main main function. > stop at hehe: 18
Breakpoint set at hehe: 18> run run hehe
running ... main [1]
Breakpoint hit: hehe.main (hehe: 18) main [1]
At this time, you can use the locals command to view the variables, use the step command to enter the next command, or use a separate stop command to view the breakpoint setting. Note that b has not yet been assigned at this time. main [1] locals Method arguments: Local variables: args = a = 2 main [1] step
main [1]
Breakpoint hit: hehe.main (hehe: 19) main [1]
When running to the System.out.println () function, the following prompt will appear: main [1] step main [1]
Breakpoint hit: java.lang.ClassLoader.loadClass (ClassLoader: 247)
This is because we tracked the println method. We generally do not need to do this. At this time, we can use next to skip this method and proceed to the next sentence. The meaning of step is to enter the function trace, and next is to go to the next statement for execution. We can always type the locals and list commands to see the variable values and the currently running code. The down arrow points to where the current program is running. main [1] next main [1]
Breakpoint hit: hehe.main (hehe: 20) main [1] list
16 {
17 int a = 2; 18 int b = 3; 19 int c = a + b;
20 => System.out.println (c); 21 test kk = new test (1,2); 22
System.out.println (kk.add ());
twenty three
24} main [1]
The next question is naturally how to view objects. When the program reaches the new command, type locals, you can see main [1] step main [1]
Breakpoint hit: test. (Test: 5) main [1] list
1 class test 2 {
3 int a; 4 int b;
5 => test (int aa, int bb) 6 {
7 a = aa; 8 b = bb;
9} main [1] locals
Method arguments: Local variables:
this = test @ 64fd6722 aa = 1 bb = 2 main [1]
You can see that the variable value displayed at this time is the variable value in the constructor in the class test. The this object is the currently constructed object. You can view it with the dump command. main [1] dump this this = (test) 0x11a {int b = 0 int a = 0}
You can also use the dump kk and print commands in the main function to view the object main [1] dump kk kk = (test) 0x11a {int b = 2 int a = 1}
main [1] print kk kk = test @ 64fd6722 main [1] print kk.a kk.a = 1
main [1] print kk.b kk.b = 2
Finally, type the cont command. If there are no other breakpoints, the program will run directly and exit. Commissioning is complete. main [1] cont 3
> Current thread "main" died. Execution continuing ...>
hehe exited
The breakpoints in the above operations are set in the main function. If you want to set the class method in the call, you need to use the stop in yourclassname.functionname command to set it, for example:> stop in test.add Breakpoint set in test.add> run run hehe running ... main [1] 5
Breakpoint hit: test.add (test: 11) main [1] list
7 a = aa; 8 b = bb; 9} 10 int add () 11 => {return a + b;} 12}
13 public class hehe 14 {
15 public static void main (String args []) main [1]
In this way, we can already set breakpoints and track variables in almost all places where we need them in the program.
JDB also has many debugging methods. In addition to the most commonly used ones above, other important ones are clear to clear breakpoints, use to set the source program path, memory to display the current memory usage, gc to force memory reclamation, and repeat the above Commands, thread to set the current thread, quit and exit to exit jdb, etc., as well as remote debugging, etc. are very useful

IN OTHER LANGUAGES

Was this article helpful? Thanks for the feedback Thanks for the feedback

How can we help? How can we help?