JDB is a tool that supports Java code-level debugging, which is provided by the Java JDK and exists under Xxx\java\jdk1.6.0_21\bin
With DDMS debugging, the main opportunity to open another network port, viewed in the DDMS, is typically 8700.
Start DDMS, then the program should have a red bug, click on the Start Debugging button above. This step is not necessary, the work of this step is actually equivalent to a manual knock:
$ adb-d forward tcp:8700 jdwp: $PID
Where $pid is the process number to tune the program.
Debug steps by Attach:
Show all user processes available for debugging:
ADB jdwp
Connect to the terminal's given process using the local port number:
ADB forward tcp:xxx jdwp:<pid>
Direct use of native bound communication ports, no process specified
Jdb-connect com.sun.jdi.socketattach:hostname=localhost,port=xxx
JDWP Protocol Introduction
&NBSP;JDWP full write: Java Debug wire Protocol: The Java Debugger Wireless protocol, which defines the debugger (Debugger) and the Java Virtual machine being debugged (target VM) Communication protocols between the. Here, I would like to explain the following: Debugger and Target Vm,target VMS running the program that we want to debug, it is not the same as the Java Virtual machine generally running, just loaded the agent jdwp at startup to have debugging capabilities. And debugger is our familiar debugger, which sends commands to the running target VM to get the status of the target VM runtime and control the execution of the Java program. The Debugger and Target VMs run separately in their own process, and the communication protocol between them is JDWP. Unlike many other protocols, JDWP only defines the format of the data transfer, but does not specify a specific transmission mode. This means that a JDWP implementation can work in different modes of transmission without having to make any modifications (in detail in the JDWP transport interface). JDWP is language-independent. Theoretically, we can use any language to implement JDWP. We note, however, that at both ends of the jdwp are target VMS and debugger. Target VM side, the JDWP module must be loaded in the form of the agent library when the Java Virtual machine is started, and it must implement various debug functions through the JVMTI interface provided by the Java Virtual machine, so it must be written in C + + language. And the debugger end there is no such restrictions, can be written in any language, as long as compliance with the JDWP specification. JDI (Java Debug Interface) contains a Java JDWP debugger implementation, and the Debug tool jdb in the JDK also uses JDI to complete its debugging functions.