In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
What is the principle of Debug implementation? in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
The following will describe the composition of JPDA, the implementation principle of Debugger and so on.
There's something wrong with the program!
The result returned is incorrect!
It's normal with me.
Every time we encounter such an abnormal situation, when we have to deal with the problem, we must think of
Give me a moment to Debug and solve it in minutes.
And if it's an online problem, we're sure to think
It would be nice if I could debug.
When we talk about Debug, we usually add breakpoints to the code in IDE and track them step by step. Then observe the value of the variable, observe the output, and so on.
This is provided in Debug tools, many IDE, such as Eclipse, IDEA,NetBeans, and even we can directly use the jdb tool that comes with JDK for height. These tools support both local and remote debugging.
So how is it realized behind a series of actions such as add point, debug, single-step debugging and so on?
When it comes to this, we have to mention JPDA (Java Platform Debugger Architecture). Every time we use the debug function, we rely on the support of JPDA.
What is JPDA?
This is what the official document says:
The Java Platform Debugger Architecture (JPDA) consists of three interfaces designed for use by debuggers in development environments for desktop systems.
As we can see, JPDA consists of three parts:
JVMTI (Java Virtual Machine Tool Interface)
JDWP (Java Debugger Wire Protocol)
JDI (Java Debug Interface)
Friends who are familiar with JVM may have heard of JVMPI and JVMDI, which are replaced by JVMTI in JDK1.5.
JVMTI
In previous articles, we mentioned Class's hotSwap, which is to implement class's redefine and retransform through Instrument.
In essence, JVMTI is a programming interface, which is mainly used in development and monitoring. And it provides an interface to inspect the status of the application and control the execution of the application. Through the interface provided by the tool, the following functions can be implemented:
Profiling
Debuging
Monitoring
Thread analysis
Coverage analysis
As you can see, the debug we use is just one of the crowd-following capabilities provided by JVMTI.
JDWP
Students who have observed the Java debug process may have the impression that the JVM process started in debug looks like this:
-agentlib:jdwp=transport=dt_socket,address=127.0.0.1:63971,server=y,suspend=n
In addition to the process name, agentlib:jdwp is included in the startup parameters. This is the JDWP we are going to introduce now.
What is JDWP?
Java Debug Wire Protocol is the communication protocol between debugger and the JVM it wants to debug. More details of the agreement will not be introduced here. Students who are interested can check it here:
Http://docs.oracle.com/javase/6/docs/technotes/guides/jpda/jdwp-spec.html
Note that this is only a protocol format, and the specific transport implementation is not implemented by JDWP. The operation performed by our debugger is sent to the implementation of JDWP and then transferred to JVMTI for specific control.
JDI
JDI is the highest-level interface of the three modules. Through JDI,debugger, it is more convenient to write data in accordance with JDWP format for debugging data transmission. The introduction of JDI improves the efficiency of developing debugger.
So, on the whole, we can think of JPDA as two programs that communicate with each other, so we can easily debug another program running on JVM anywhere.
Every time we debug the code in IDE, we essentially perform the GUI operation through the debugger interface in IDE, then send the data to JDWP through JDI, and finally achieve the height of the program through JVMTI.
Every time we open IDE to debug a Java application, or remotely attach a Java process, don't forget the figure behind this IDE-JPDA.
The PS:Tomcat startup script also directly includes the debug startup function, which is typed on the command line.
Catalina jpda start, Tomcat is started in debug mode.
For students who want to know the source code but do not want to run the source code as a project, you can use this method, and then use remote debugging to connect the source code project with the attach.
This is the answer to the question about what is the principle of Debug implementation. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.