JPDA with easy debugging Java code

Author:Anonymous    Updated:2008-3-20 12:24:55
Can not be accessed in the running instance, a Java debugging process can be quite troublesome when the application environment in the long-distance running, and are not in the console log files or export any results, debugging more difficult. If you need a Java application in the operation of comprehensive debugging procedures, Sun's Java Platform Debugger Architecture (JPDA) to help you.


JPDA API set is a group designed to help you debug Java code. 1.2.2 version of J2SE since starting JPDA tool sets, and 1.3. X version of it directly included in the J2SE package.


JPDA is not an application or debugging tools, but a group of well-designed interface with the agreement, understanding of this very important point. Sun designed the purpose of this standard is to provide an infrastructure for third-party tools and can be adjusted for efficient use of it. There are many JPDA use of the excellent debugger and IDE, including some widely recognized tools such as Borland JBuilder, Oracle JDeveloper, IntelliJ IDEA, Sun NetBeans, IBM Eclipse, and so on. However, the Sun in its traditional command-line debugger jdb-provide a reference examples. Java 1.3 rewrite the jdb to support the JPDA. In this article, I will discuss the JPDA technology and some of its practical applications.


Principle


JPDA posed by the three interfaces, these interfaces for the desktop development environment and design. Java Virtual Machine Tool Interface (JVMTI) definition of virtual machine (VM) for debugging must provide services. (In Java 5.0, JVMTI alternative has been deleted Java virtual machine debugging interface). Java debugging Line Protocol (JDWP) defined in the debugging process and debugger front-end transmission between information and the format of the request. The implementation of its Java debugging interface (JDI). JDI user-defined code-level information and requests.


JPDA concept of debugging process is divided into two parts: the debugging process (the debugging - debuggee) and JDI. JDI is generally a debugging application's user interface (or part of the Java IDE). Debugging was in the back-end applications running on the front end and JDI operation. In the front-end and back-end of a communication channel between the operating JDWP agreement, therefore, was debugging procedures and debugger can be in the same system, can be located in different systems.


From the perspective of developers, a debug applications may enter any JPDA level. JDI is at the highest level since, and the most easy-to-use, we recommend the use of this interface. JDI a hypothetical company with the development of a debugger. Companies can use it for reference examples, it will automatically and VM support of the platform and Sun work together, most IDE providers to adopt this approach. This can be, for example, front-end reference examples in the operation, the debugger to run another company JDWP implementation (it may run or neglect JVMTI) VM.


Some debugger possible in the lower level above, such as JDWP (for example, if Java produced no front-end) or JVMTI (for the needs of low-level functions for debugging).


Debugger for the back-end charge to the front from the debugger to debug VM transfer requests, such as "Tell me the value of variables X"; It is also responsible for the front-end transmission of these requests (such as breakpoint at the expected events) response. JDWP use of the back-end and front-end through a communication channel for communication. Debugging with the back-end to the use JVMTI VM communication.


Communication links between the debugger front-end and back-end. That it can be installed by two components: a transmitter and a connector. JDI connector is a target, it set up on the front end and back-end connectivity; there might be three types of connector:


Listen to type: from the front-end access to a back-end link to listen.

Dependent: a front-end attachment to the back-end, has been in operation.

Published types: front-end operations was issued to debug code and the Java back-end process.


Transmitter in the front-end and back-end transmission of the basic device information. In the JPDA norms do not specify the use of the transmitter must be installed. The device may include: the socket, serial lines and shared memory. However, JDWP designated through the channel of the bit stream for the format and semantics. Many IDE and debugger support for the two types of conveyor (Sun's reference example is the case): shared memory (if debugging and debugger in the same system) and socket (the debugging and debugger can be located anywhere, including the same system).


J2SE 5.0 from the start, including service providers JPDA interface that allows the connector and Transmitter examples development and configuration. These service providers for services interface allows debugger and other tools suppliers to the development of new connector example, in addition to Sun and to provide the socket and shared memory devices other than the transmitter.


And the debugger to debug communications between the connecting as a guide. Therefore, the party must, as a server, a link to listen; other as a client to the server. JPDA permit applications and debugging target VM servers.


JPDA practical application


If you need to use socket Transmitter, in the corresponding JVM dt_socket to determine the name of the variable's type. If the debugger and debugger in the same machine, and running the Windows system, you can use the shared memory called dt_schmem connector. If you wish to use a debugger JPDA compatible debug applications, you should be running in debug mode debugger, and the other parameters, such as conveyor types, host name, port number, and other information. JPDA and debug all parameters must be activated when the application submitted as independent variables.


To debugging, you must debug JDWP agents loaded into the application's JVM. Java 5.0 from the beginning, you can use - agentlib: jdwp options to complete loading. Previous versions were used 5.0 - Xdebug and - Xrunjdwp options (5.0 support - Xdebug and - Xrunjdwp option, but the new - agentlib: jdwp more useful options. JDWP because the agent 5.0 JVMTI use interface connector VM, instead of the old JVMDI interface). You should - agentlib: jdwp (Java 5.0) or - Xrunjdwp (Java previous version 5.0) parameters of options; two possible options of the same.


Designated in the following manner of options:


- Agentlib: jdwp =[=],[=]...


Or


- Xrunjdwp :[=],[=]...


You can use these options:


Help: Print the application of its simple message and withdraw from VM.

Server: (a "y" or no "n"): As the "server = y" and receive an attachment to debug applications; such as "server = n", the attachment to the designated address debugging applications.

Address: Address transmission link. If the server = n, the attachment to this address to debug applications; such as server = y, received the address connected.

Timeout: If the server = y, it milliseconds to wait for the units designated for dependent debugging time as server = n, it has millisecond units designated for attachment to the debugger, the time spent.

Suspend: If "Yes", JVM stay of execution until the debugger and the debugging JVM establish a connection.

Following is the command-line examples:


Agentlib: jdwp = = dt_socket transport, server = y, address = 8000


Listen to port 8000 in a socket connection. In the main category before loading delay the VM (default suspend = y). Once connected debugging applications, it sends a JDWP restore order VM.


Agentlib: jdwp = = dt_shmem transport, server = y, n = suspend


Choose an effective shared memory address transmission and print it out. In that address listen to a shared memory connections. Debugging applications in the attachment before allowing VM begun to be implemented.


Agentlib: jdwp = = dt_socket transport, address = myhost: 8000


Myhost host ports 8000 through socket attachment to a running debugging applications. In the main category of this delay before loading VM



Can not be accessed in the running instance, a Java debugging process can be quite troublesome when the application environment in the long-distance running, and are not in the console log files or export any results, debugging more difficult. If you need a Java application in the operation of comprehensive debugging procedures, Sun's Java Platform Debugger Architecture (JPDA) to help you.


JPDA API set is a group designed to help you debug Java code. 1.2.2 version of J2SE since starting JPDA tool sets, and 1.3. X version of it directly included in the J2SE package.


JPDA is not an application or debugging tools, but a group of well-designed interface with the agreement, understanding of this very important point. Sun designed the purpose of this standard is to provide an infrastructure for third-party tools and can be adjusted for efficient use of it. There are many JPDA use of the excellent debugger and IDE, including some widely recognized tools such as Borland JBuilder, Oracle JDeveloper, IntelliJ IDEA, Sun NetBeans, IBM Eclipse, and so on. However, the Sun in its traditional command-line debugger jdb-provide a reference examples. Java 1.3 rewrite the jdb to support the JPDA. In this article, I will discuss the JPDA technology and some of its practical applications.


Principle


JPDA posed by the three interfaces, these interfaces for the desktop development environment and design. Java Virtual Machine Tool Interface (JVMTI) definition of virtual machine (VM) for debugging must provide services. (In Java 5.0, JVMTI alternative has been deleted Java virtual machine debugging interface). Java debugging Line Protocol (JDWP) defined in the debugging process and debugger front-end transmission between information and the format of the request. The implementation of its Java debugging interface (JDI). JDI user-defined code-level information and requests.


JPDA concept of debugging process is divided into two parts: the debugging process (the debugging - debuggee) and JDI. JDI is generally a debugging application's user interface (or part of the Java IDE). Debugging was in the back-end applications running on the front end and JDI operation. In the front-end and back-end of a communication channel between the operating JDWP agreement, therefore, was debugging procedures and debugger can be in the same system, can be located in different systems.


From the perspective of developers, a debug applications may enter any JPDA level. JDI is at the highest level since, and the most easy-to-use, we recommend the use of this interface. JDI a hypothetical company with the development of a debugger. Companies can use it for reference examples, it will automatically and VM support of the platform and Sun work together, most IDE providers to adopt this approach. This can be, for example, front-end reference examples in the operation, the debugger to run another company JDWP implementation (it may run or neglect JVMTI) VM.


Some debugger possible in the lower level above, such as JDWP (for example, if Java produced no front-end) or JVMTI (for the needs of low-level functions for debugging).


Debugger for the back-end charge to the front from the debugger to debug VM transfer requests, such as "Tell me the value of variables X"; It is also responsible for the front-end transmission of these requests (such as breakpoint at the expected events) response. JDWP use of the back-end and front-end through a communication channel for communication. Debugging with the back-end to the use JVMTI VM communication.


Communication links between the debugger front-end and back-end. That it can be installed by two components: a transmitter and a connector. JDI connector is a target, it set up on the front end and back-end connectivity; there might be three types of connector:


Listen to type: from the front-end access to a back-end link to listen.

Dependent: a front-end attachment to the back-end, has been in operation.

Published types: front-end operations was issued to debug code and the Java back-end process.


Transmitter in the front-end and back-end transmission of the basic device information. In the JPDA norms do not specify the use of the transmitter must be installed. The device may include: the socket, serial lines and shared memory. However, JDWP designated through the channel of the bit stream for the format and semantics. Many IDE and debugger support for the two types of conveyor (Sun's reference example is the case): shared memory (if debugging and debugger in the same system) and socket (the debugging and debugger can be located anywhere, including the same system).


J2SE 5.0 from the start, including service providers JPDA interface that allows the connector and Transmitter examples development and configuration. These service providers for services interface allows debugger and other tools suppliers to the development of new connector example, in addition to Sun and to provide the socket and shared memory devices other than the transmitter.


And the debugger to debug communications between the connecting as a guide. Therefore, the party must, as a server, a link to listen; other as a client to the server. JPDA permit applications and debugging target VM servers.


JPDA practical application


If you need to use socket Transmitter, in the corresponding JVM dt_socket to determine the name of the variable's type. If the debugger and debugger in the same machine, and running the Windows system, you can use the shared memory called dt_schmem connector. If you wish to use a debugger JPDA compatible debug applications, you should be running in debug mode debugger, and the other parameters, such as conveyor types, host name, port number, and other information. JPDA and debug all parameters must be activated when the application submitted as independent variables.


To debugging, you must debug JDWP agents loaded into the application's JVM. Java 5.0 from the beginning, you can use - agentlib: jdwp options to complete loading. Previous versions were used 5.0 - Xdebug and - Xrunjdwp options (5.0 support - Xdebug and - Xrunjdwp option, but the new - agentlib: jdwp more useful options. JDWP because the agent 5.0 JVMTI use interface connector VM, instead of the old JVMDI interface). You should - agentlib: jdwp (Java 5.0) or - Xrunjdwp (Java previous version 5.0) parameters of options; two possible options of the same.


Designated in the following manner of options:


- Agentlib: jdwp =[=],[=]...


Or


- Xrunjdwp :[=],[=]...


You can use these options:


Help: Print the application of its simple message and withdraw from VM.

Server: (a "y" or no "n"): As the "server = y" and receive an attachment to debug applications; such as "server = n", the attachment to the designated address debugging applications.

Address: Address transmission link. If the server = n, the attachment to this address to debug applications; such as server = y, received the address connected.

Timeout: If the server = y, it milliseconds to wait for the units designated for dependent debugging time as server = n, it has millisecond units designated for attachment to the debugger, the time spent.

Suspend: If "Yes", JVM stay of execution until the debugger and the debugging JVM establish a connection.

Following is the command-line examples:


Agentlib: jdwp = = dt_socket transport, server = y, address = 8000


Listen to port 8000 in a socket connection. In the main category before loading delay the VM (default suspend = y). Once connected debugging applications, it sends a JDWP restore order VM.


Agentlib: jdwp = = dt_shmem transport, server = y, n = suspend


Choose an effective shared memory address transmission and print it out. In that address listen to a shared memory connections. Debugging applications in the attachment before allowing VM begun to be implemented.


Agentlib: jdwp = = dt_socket transport, address = myhost: 8000


Myhost host ports 8000 through socket attachment to a running debugging applications. In the main category of this delay before loading VM
Previous:Java generic equivalent of the understanding and realization
Next:Java Web site to the request sent POST
User Reviews
Site Search
Related Articles
Recommended article
AD