Detailed explanation of the use of Android debugging tool DDMS

Specific visible http://developer.android.com/tools/debugging/ddms.html 。 DDMS provides a bridge between IDE and emultor, real Android devices. Through DDMS, developers can see the process / ready-made status running on the target machine, the Android screen to the development machine, the heap information of the process, the logcat information, the memory allocation of the process, sending text messages and making phone calls like the target machine, and sending geographic location information like Android development. You can attach a process to debug like GDB. The full version of DDMS is provided in the SDK Tools Directory. You can run it directly. Next, take the DDMS perspective of eclipse as an example to briefly introduce the functions of DDMS.

Like debug and Java perspective, there will be a DDMS perspective after ADT is installed. Open it.

The open window is,

The device window lists all the processes in the simulator. The buttons in the upper right corner are: debug a process, update a process, update the process stack information, stop a process, and grab the current screen of Android when the last picture button.

When you select a process and press the debug process button, if there is code for this process in eclipse, you can debug at the source code level. A bit like GDB attach. The picture capture button can capture the current Android display desktop on your machine, which is also very useful.

In the right window, there are threads, heap and file explorer tabs. Thread statistics, stack information, and Android file system are displayed respectively.

File explorer is very useful. It can upload files to Android phones, download them from mobile phones, or delete them. After selecting the file explorer tab, press the following three buttons to upload, download and delete the file system of Android mobile phone.

Emulator control is also very important. It can send text messages, make calls and update the location information of the mobile phone.

Summary:

The DDMS function currently provided by eclipse ADT is only a small part of the real DDMS. You can directly use the DDMS under tools to use all functions. There is a function to view the process memory allocation, which is more useful.

Full name of DDMS: Dalvik debug monitor service I. The role of DDMS is to provide screenshots, View Thread and heap information, logcat, process, broadcast status information, simulate incoming calls and SMS, virtual geographic coordinates, etc. 2、 How DDMS works 1. Every Android application runs in a Dalvik virtual machine instance, and each virtual machine instance is an independent process space. The threading mechanism of virtual machine, memory allocation and management, mutex and so on are all implemented by relying on the underlying operating system. All Android application threads correspond to a Linux thread, so the virtual machine can rely more on the thread scheduling and management mechanism of the operating system. 2. DDMS acts as an intermediary between IDE and device or simulator. 3. When DDMS is started, a device monitoring service will be established with ADB to monitor the device. When the device is disconnected or linked, this service will notify DDMS. 4. When a device is linked, a VM monitoring service will be established between ddsm and ADB to monitor the virtual machines on the device. 5. Establish a link with the debugger of the virtual machine on the device through ADB Deamon, so that DDMS can start a dialogue with the virtual machine. 3、 Port 1. DDMS will open a listening port for the debugger of each virtual machine on the device. Ports start at 8600. 28700 port 4, panel 1 on the left. The left displays the list of all simulators or devices that can be found and the list of virtual machines that are currently running for each device. Virtual machines are displayed according to the package life of the program. 2. Through these lists, you can find the virtual machine running the activity you want to debug. Next to each virtual machine is the "debugger pass through" port. Linking to one of the ports will link to the corresponding virtual machine on the device. In any case, when using DDMS, you only need to link to port 8700, because ddsm forwards all communication to the currently selected virtual machine. In this way, you don't have to reconfigure the debugger port every time you switch the virtual machine. 3. When a running program calls the waitfordebugger() function, a red icon will be displayed next to the client name. When the debugger is connected to the corresponding virtual machine, the debugger will turn green. 4. If you see a cross icon, it means that DDMS cannot open the port of the virtual machine and cannot establish a debugger to establish a connection with the virtual machine. If you see that all virtual machines are like this, it is likely that there is another ddsm instance running. 5、 On the right panel 1, info, general information about the selected VM is displayed, including process ID, package name, and virtual machine version. 2. The threads view lists all threads of this process. ID: the unique thread ID assigned by the virtual machine. In Dalvik, they are odd numbers starting from 3. TID: thread ID of Linux, for the main thread in a process, this will match the process ID. stauts: thread status, running: executing program code, sleeping: executing thread. Sleep() monitor: waiting to accept a listening lock. Wait: object. Wait() native: executing native code vmwait: waiting for virtual machine Zombie: thread is dying process init: thread is initializing (we can't see) starting: thread is starting (we can't see) utime: cumulative time of executing user code stime: cumulative time of executing system code name: thread name 4, VM heap shows the status of some heaps, which are updated during garbage collection. When a virtual machine is selected, the VM heap view cannot display data. You can click the green "show heap updates" button on the right, and then click "cause GC" to implement garbage collection and update the heap status. 6. Allocation tracker in this view, we can track the memory allocation of each selected virtual machine. Click " Click "get allocations" after "start tracking" "You can see. 7. Emulator control can simulate some device states and behaviors here. Telephony status: change the state of telephone voice and data schemes to simulate different network speeds. Telephony actions: send simulated telephone calls and SMS to the emulator. Location controls: send virtual positioning data to the simulator, and we can execute Line positioning and other operations. You can enter the longitude and latitude in the manual after work and send it to the simulator, or you can use GPX and KML files. 6. Others 1. File explorer opens file explorer through device > file explorer. Here you can browse files, upload and delete files. Of course, this has corresponding permission restrictions. 2. Screen capture uses device > Screen ca Pture can take a screenshot. 3. Exploring processes uses device > show process status. The information here is output through the shell command "PS - X". 4. Examine radio state detect the broadcast state through device > dump radio. 5. Stop a virtual machine. Stop a virtual machine through actions > halt VM.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>