使用Dalvik调试侦听服务(DDMS)

DDMS是Android SDK中的一个调试工具,提供端口转发、屏幕捕获、线程及堆信息查看等功能。它作为IDE与设备上运行的应用之间的中介,帮助开发者实现远程调试。本文介绍DDMS的工作原理及其主要功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

Using Dalvik Debug Monitor Service (DDMS)

使用Dalvik调试侦听服务(DDMS

Android ships with a debugging tool called the Dalvik Debug Monitor Service (DDMS), which provides port-forwarding services, screen capture on the device, thread and heap information on the device, logcat, process, and radio state information, incoming call and SMS spoofing, location data spoofing, and more. This page provides a modest discussion of DDMS features; it is not an exhaustive exploration of all the features and capabilities.

Android配备了调试工具:Dalvik调试监听服务(DDMS)。它提供了端口转发服务、设备屏幕截取、设备上的线程和堆信息、logcat,进程和广播状态信息、来电和短信模拟,地理位置数据模拟等。

 

DDMS ships in the tools/ directory of the SDK. Enter this directory from a terminal/console and type ddms (or ./ddms on Mac/Linux) to run it. DDMS will work with both the emulator and a connected device. If both are connected and running simultaneously, DDMS defaults to the emulator.

DDMS包含在SDK的“tools/”目录中。在终端/控制台中进入tools目录,输入ddms(或者Mac/Linux下输入./ddms)运行它。DDMS工作在模拟器和连接设备(这里指真机)上。如果两周都连接且同时运行,DDMS默认工作在模拟器上。

 

How DDMS works

DDMS是如何工作的。

DDMS acts as a middleman to connect the IDE to the applications running on the device. On Android, every application runs in its own process, each of which hosts its own virtual machine (VM). And each process listens for a debugger on a different port.

DDMS担当了连接IDE和运行在设备上的应用程序的中间人的角色。在Android上,每个应用运行在它自己的进程中,且都拥有自己的虚拟机(VM)。而且每个进程从不同的端口侦听调试器。

 

When it starts, DDMS connects to adb and starts a device monitoring service between the two, which will notify DDMS when a device is connected or disconnected. When a device is connected, a VM monitoring service is created between adb and DDMS, which will notify DDMS when a VM on the device is started or terminated. Once a VM is running, DDMS retrieves the the VM's process ID (pid), via adb, and opens a connection to the VM's debugger, through the adb daemon (adbd) on the device. DDMS can now talk to the VM using a custom wire protocol.

DDMS启动的时候,它连接到adb,在两者(adbDDMS)之间启动设备监视服务,它将通知DDMS设备何时被连接、断开。当设备连接时,在adbDDMS之间创建了虚拟机监听服务,它将通知DDMS“设备上的虚拟机何时开始、终止”。一旦虚拟机运行,DDMS通过adb取得虚拟机进程的ID,并且通过adb deamon(adbd)开启一个到虚拟机调试器的连接。DDMS可以通过自定义的无线协议和虚拟机通信。

 

For each VM on the device, DDMS opens a port upon which it will listen for a debugger. For the first VM, DDMS listens for a debugger on port 8600, the next on 8601, and so on. When a debugger connects to one of these ports, all traffic is forwarded between the debugger and the associated VM. Debugging can then process like any remote debugging session.

对设备上的每个虚拟机,DDMS开启了一个端口来侦听调试器。对第一个VMDDMS侦听端口8600,下一个是8601,以此类推。当调试器连接到那些端口的其中一个,所有的通信可以进一步的在调试器和对应的虚拟机之间进行。调试像任何远程调试会话一样进行。

 

DDMS also opens another local port, the DDMS "base port" (8700, by default), upon which it also listens for a debugger. When a debugger connects to this base port, all traffic is forwarded to the VM currently selected in DDMS, so this is typically where you debugger should connect.

DDMS也开启另一个本地端口:DDMS“基本端口”(默认是8700),同样在此端口上侦听调试器。当调试器连接到“基本端口”,所有的连接会被转移到DDMS中当前选择的虚拟机上,因此这通常是你的调试器应该连接的端口。

 

For more information on port-forwarding with DDMS, read Configuring your IDE to attach to port 8700 for debugging.

要获取DDMS的端口转移的更多信息,参考“配置您的IDE,链接到8700端口进行调试”。

 

Tip: You can set a number of DDMS preferences in File > Preferences. Preferences are saved to "$HOME/.ddmsrc".

提示:你可以通过菜单File > Preferences设置DDMS参数。参数保存在"$HOME/.ddmsrc"中。

 

 

原文地址:

http://developer.android.com/guide/developing/tools/ddms.html

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值