Using JDB to debug apk

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.